babylon.module.d.ts 5.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079
  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. readonly 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 readonly 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 LogLevels: 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 readonly 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. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. /**
  486. * Returns client's state
  487. */
  488. readonly readyState: number;
  489. /**
  490. * Returns client's status
  491. */
  492. readonly status: number;
  493. /**
  494. * Returns client's status as a text
  495. */
  496. readonly statusText: string;
  497. /**
  498. * Returns client's response
  499. */
  500. readonly response: any;
  501. /**
  502. * Returns client's response url
  503. */
  504. readonly responseURL: string;
  505. /**
  506. * Returns client's response as text
  507. */
  508. readonly responseText: string;
  509. /**
  510. * Gets or sets the expected response type
  511. */
  512. responseType: XMLHttpRequestResponseType;
  513. /** @hidden */
  514. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  515. /** @hidden */
  516. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  517. /**
  518. * Cancels any network activity
  519. */
  520. abort(): void;
  521. /**
  522. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  523. * @param body defines an optional request body
  524. */
  525. send(body?: Document | BodyInit | null): void;
  526. /**
  527. * Sets the request method, request URL
  528. * @param method defines the method to use (GET, POST, etc..)
  529. * @param url defines the url to connect with
  530. */
  531. open(method: string, url: string): void;
  532. /**
  533. * Sets the value of a request header.
  534. * @param name The name of the header whose value is to be set
  535. * @param value The value to set as the body of the header
  536. */
  537. setRequestHeader(name: string, value: string): void;
  538. /**
  539. * Get the string containing the text of a particular header's value.
  540. * @param name The name of the header
  541. * @returns The string containing the text of the given header name
  542. */
  543. getResponseHeader(name: string): Nullable<string>;
  544. }
  545. }
  546. declare module "babylonjs/Misc/fileRequest" {
  547. import { Observable } from "babylonjs/Misc/observable";
  548. /**
  549. * File request interface
  550. */
  551. export interface IFileRequest {
  552. /**
  553. * Raised when the request is complete (success or error).
  554. */
  555. onCompleteObservable: Observable<IFileRequest>;
  556. /**
  557. * Aborts the request for a file.
  558. */
  559. abort: () => void;
  560. }
  561. }
  562. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  563. /**
  564. * Define options used to create a render target texture
  565. */
  566. export class RenderTargetCreationOptions {
  567. /**
  568. * Specifies is mipmaps must be generated
  569. */
  570. generateMipMaps?: boolean;
  571. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  572. generateDepthBuffer?: boolean;
  573. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  574. generateStencilBuffer?: boolean;
  575. /** Defines texture type (int by default) */
  576. type?: number;
  577. /** Defines sampling mode (trilinear by default) */
  578. samplingMode?: number;
  579. /** Defines format (RGBA by default) */
  580. format?: number;
  581. }
  582. }
  583. declare module "babylonjs/Instrumentation/timeToken" {
  584. import { Nullable } from "babylonjs/types";
  585. /**
  586. * @hidden
  587. **/
  588. export class _TimeToken {
  589. _startTimeQuery: Nullable<WebGLQuery>;
  590. _endTimeQuery: Nullable<WebGLQuery>;
  591. _timeElapsedQuery: Nullable<WebGLQuery>;
  592. _timeElapsedQueryEnded: boolean;
  593. }
  594. }
  595. declare module "babylonjs/Engines/constants" {
  596. /** Defines the cross module used constants to avoid circular dependncies */
  597. export class Constants {
  598. /** Defines that alpha blending is disabled */
  599. static readonly ALPHA_DISABLE: number;
  600. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  601. static readonly ALPHA_ADD: number;
  602. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_COMBINE: number;
  604. /** Defines that alpha blending to DEST - SRC * DEST */
  605. static readonly ALPHA_SUBTRACT: number;
  606. /** Defines that alpha blending to SRC * DEST */
  607. static readonly ALPHA_MULTIPLY: number;
  608. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  609. static readonly ALPHA_MAXIMIZED: number;
  610. /** Defines that alpha blending to SRC + DEST */
  611. static readonly ALPHA_ONEONE: number;
  612. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  613. static readonly ALPHA_PREMULTIPLIED: number;
  614. /**
  615. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  616. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  619. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  620. static readonly ALPHA_INTERPOLATE: number;
  621. /**
  622. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  623. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  624. */
  625. static readonly ALPHA_SCREENMODE: number;
  626. /**
  627. * Defines that alpha blending to SRC + DST
  628. * Alpha will be set to SRC ALPHA + DST ALPHA
  629. */
  630. static readonly ALPHA_ONEONE_ONEONE: number;
  631. /**
  632. * Defines that alpha blending to SRC * DST ALPHA + DST
  633. * Alpha will be set to 0
  634. */
  635. static readonly ALPHA_ALPHATOCOLOR: number;
  636. /**
  637. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  638. */
  639. static readonly ALPHA_REVERSEONEMINUS: number;
  640. /**
  641. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  642. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  643. */
  644. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  645. /**
  646. * Defines that alpha blending to SRC + DST
  647. * Alpha will be set to SRC ALPHA
  648. */
  649. static readonly ALPHA_ONEONE_ONEZERO: number;
  650. /** Defines that alpha blending equation a SUM */
  651. static readonly ALPHA_EQUATION_ADD: number;
  652. /** Defines that alpha blending equation a SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  654. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  656. /** Defines that alpha blending equation a MAX operation */
  657. static readonly ALPHA_EQUATION_MAX: number;
  658. /** Defines that alpha blending equation a MIN operation */
  659. static readonly ALPHA_EQUATION_MIN: number;
  660. /**
  661. * Defines that alpha blending equation a DARKEN operation:
  662. * It takes the min of the src and sums the alpha channels.
  663. */
  664. static readonly ALPHA_EQUATION_DARKEN: number;
  665. /** Defines that the ressource is not delayed*/
  666. static readonly DELAYLOADSTATE_NONE: number;
  667. /** Defines that the ressource was successfully delay loaded */
  668. static readonly DELAYLOADSTATE_LOADED: number;
  669. /** Defines that the ressource is currently delay loading */
  670. static readonly DELAYLOADSTATE_LOADING: number;
  671. /** Defines that the ressource is delayed and has not started loading */
  672. static readonly DELAYLOADSTATE_NOTLOADED: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  674. static readonly NEVER: number;
  675. /** 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 */
  676. static readonly ALWAYS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  678. static readonly LESS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  680. static readonly EQUAL: number;
  681. /** 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 */
  682. static readonly LEQUAL: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  684. static readonly GREATER: number;
  685. /** 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 */
  686. static readonly GEQUAL: number;
  687. /** 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 */
  688. static readonly NOTEQUAL: number;
  689. /** Passed to stencilOperation to specify that stencil value must be kept */
  690. static readonly KEEP: number;
  691. /** Passed to stencilOperation to specify that stencil value must be replaced */
  692. static readonly REPLACE: number;
  693. /** Passed to stencilOperation to specify that stencil value must be incremented */
  694. static readonly INCR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be decremented */
  696. static readonly DECR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be inverted */
  698. static readonly INVERT: number;
  699. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  700. static readonly INCR_WRAP: number;
  701. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  702. static readonly DECR_WRAP: number;
  703. /** Texture is not repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  705. /** Texture is repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  707. /** Texture is repeating and mirrored */
  708. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  709. /** ALPHA */
  710. static readonly TEXTUREFORMAT_ALPHA: number;
  711. /** LUMINANCE */
  712. static readonly TEXTUREFORMAT_LUMINANCE: number;
  713. /** LUMINANCE_ALPHA */
  714. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  715. /** RGB */
  716. static readonly TEXTUREFORMAT_RGB: number;
  717. /** RGBA */
  718. static readonly TEXTUREFORMAT_RGBA: number;
  719. /** RED */
  720. static readonly TEXTUREFORMAT_RED: number;
  721. /** RED (2nd reference) */
  722. static readonly TEXTUREFORMAT_R: number;
  723. /** RG */
  724. static readonly TEXTUREFORMAT_RG: number;
  725. /** RED_INTEGER */
  726. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  727. /** RED_INTEGER (2nd reference) */
  728. static readonly TEXTUREFORMAT_R_INTEGER: number;
  729. /** RG_INTEGER */
  730. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  731. /** RGB_INTEGER */
  732. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  733. /** RGBA_INTEGER */
  734. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  735. /** UNSIGNED_BYTE */
  736. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  737. /** UNSIGNED_BYTE (2nd reference) */
  738. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  739. /** FLOAT */
  740. static readonly TEXTURETYPE_FLOAT: number;
  741. /** HALF_FLOAT */
  742. static readonly TEXTURETYPE_HALF_FLOAT: number;
  743. /** BYTE */
  744. static readonly TEXTURETYPE_BYTE: number;
  745. /** SHORT */
  746. static readonly TEXTURETYPE_SHORT: number;
  747. /** UNSIGNED_SHORT */
  748. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  749. /** INT */
  750. static readonly TEXTURETYPE_INT: number;
  751. /** UNSIGNED_INT */
  752. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  753. /** UNSIGNED_SHORT_4_4_4_4 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  755. /** UNSIGNED_SHORT_5_5_5_1 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  757. /** UNSIGNED_SHORT_5_6_5 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  759. /** UNSIGNED_INT_2_10_10_10_REV */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  761. /** UNSIGNED_INT_24_8 */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  763. /** UNSIGNED_INT_10F_11F_11F_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  765. /** UNSIGNED_INT_5_9_9_9_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  767. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  768. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  769. /** nearest is mag = nearest and min = nearest and mip = linear */
  770. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  771. /** Bilinear is mag = linear and min = linear and mip = nearest */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** Trilinear is mag = linear and min = linear and mip = linear */
  774. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  775. /** nearest is mag = nearest and min = nearest and mip = linear */
  776. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  777. /** Bilinear is mag = linear and min = linear and mip = nearest */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  781. /** mag = nearest and min = nearest and mip = nearest */
  782. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = nearest */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = linear */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  787. /** mag = nearest and min = linear and mip = none */
  788. static readonly TEXTURE_NEAREST_LINEAR: number;
  789. /** mag = nearest and min = nearest and mip = none */
  790. static readonly TEXTURE_NEAREST_NEAREST: number;
  791. /** mag = linear and min = nearest and mip = nearest */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  793. /** mag = linear and min = nearest and mip = linear */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  795. /** mag = linear and min = linear and mip = none */
  796. static readonly TEXTURE_LINEAR_LINEAR: number;
  797. /** mag = linear and min = nearest and mip = none */
  798. static readonly TEXTURE_LINEAR_NEAREST: number;
  799. /** Explicit coordinates mode */
  800. static readonly TEXTURE_EXPLICIT_MODE: number;
  801. /** Spherical coordinates mode */
  802. static readonly TEXTURE_SPHERICAL_MODE: number;
  803. /** Planar coordinates mode */
  804. static readonly TEXTURE_PLANAR_MODE: number;
  805. /** Cubic coordinates mode */
  806. static readonly TEXTURE_CUBIC_MODE: number;
  807. /** Projection coordinates mode */
  808. static readonly TEXTURE_PROJECTION_MODE: number;
  809. /** Skybox coordinates mode */
  810. static readonly TEXTURE_SKYBOX_MODE: number;
  811. /** Inverse Cubic coordinates mode */
  812. static readonly TEXTURE_INVCUBIC_MODE: number;
  813. /** Equirectangular coordinates mode */
  814. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed Mirrored coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  819. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  820. static readonly SCALEMODE_FLOOR: number;
  821. /** Defines that texture rescaling will look for the nearest power of 2 size */
  822. static readonly SCALEMODE_NEAREST: number;
  823. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  824. static readonly SCALEMODE_CEILING: number;
  825. /**
  826. * The dirty texture flag value
  827. */
  828. static readonly MATERIAL_TextureDirtyFlag: number;
  829. /**
  830. * The dirty light flag value
  831. */
  832. static readonly MATERIAL_LightDirtyFlag: number;
  833. /**
  834. * The dirty fresnel flag value
  835. */
  836. static readonly MATERIAL_FresnelDirtyFlag: number;
  837. /**
  838. * The dirty attribute flag value
  839. */
  840. static readonly MATERIAL_AttributesDirtyFlag: number;
  841. /**
  842. * The dirty misc flag value
  843. */
  844. static readonly MATERIAL_MiscDirtyFlag: number;
  845. /**
  846. * The all dirty flag value
  847. */
  848. static readonly MATERIAL_AllDirtyFlag: number;
  849. /**
  850. * Returns the triangle fill mode
  851. */
  852. static readonly MATERIAL_TriangleFillMode: number;
  853. /**
  854. * Returns the wireframe mode
  855. */
  856. static readonly MATERIAL_WireFrameFillMode: number;
  857. /**
  858. * Returns the point fill mode
  859. */
  860. static readonly MATERIAL_PointFillMode: number;
  861. /**
  862. * Returns the point list draw mode
  863. */
  864. static readonly MATERIAL_PointListDrawMode: number;
  865. /**
  866. * Returns the line list draw mode
  867. */
  868. static readonly MATERIAL_LineListDrawMode: number;
  869. /**
  870. * Returns the line loop draw mode
  871. */
  872. static readonly MATERIAL_LineLoopDrawMode: number;
  873. /**
  874. * Returns the line strip draw mode
  875. */
  876. static readonly MATERIAL_LineStripDrawMode: number;
  877. /**
  878. * Returns the triangle strip draw mode
  879. */
  880. static readonly MATERIAL_TriangleStripDrawMode: number;
  881. /**
  882. * Returns the triangle fan draw mode
  883. */
  884. static readonly MATERIAL_TriangleFanDrawMode: number;
  885. /**
  886. * Stores the clock-wise side orientation
  887. */
  888. static readonly MATERIAL_ClockWiseSideOrientation: number;
  889. /**
  890. * Stores the counter clock-wise side orientation
  891. */
  892. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  893. /**
  894. * Nothing
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_NothingTrigger: number;
  898. /**
  899. * On pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPickTrigger: number;
  903. /**
  904. * On left pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnLeftPickTrigger: number;
  908. /**
  909. * On right pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnRightPickTrigger: number;
  913. /**
  914. * On center pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnCenterPickTrigger: number;
  918. /**
  919. * On pick down
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnPickDownTrigger: number;
  923. /**
  924. * On double pick
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnDoublePickTrigger: number;
  928. /**
  929. * On pick up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnPickUpTrigger: number;
  933. /**
  934. * On pick out.
  935. * This trigger will only be raised if you also declared a OnPickDown
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnPickOutTrigger: number;
  939. /**
  940. * On long press
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnLongPressTrigger: number;
  944. /**
  945. * On pointer over
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOverTrigger: number;
  949. /**
  950. * On pointer out
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPointerOutTrigger: number;
  954. /**
  955. * On every frame
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnEveryFrameTrigger: number;
  959. /**
  960. * On intersection enter
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionEnterTrigger: number;
  964. /**
  965. * On intersection exit
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnIntersectionExitTrigger: number;
  969. /**
  970. * On key down
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyDownTrigger: number;
  974. /**
  975. * On key up
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnKeyUpTrigger: number;
  979. /**
  980. * Billboard mode will only apply to Y axis
  981. */
  982. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  983. /**
  984. * Billboard mode will apply to all axes
  985. */
  986. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  987. /**
  988. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  989. */
  990. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  991. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  992. * Test order :
  993. * Is the bounding sphere outside the frustum ?
  994. * If not, are the bounding box vertices outside the frustum ?
  995. * It not, then the cullable object is in the frustum.
  996. */
  997. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  998. /** Culling strategy : Bounding Sphere Only.
  999. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1000. * It's also less accurate than the standard because some not visible objects can still be selected.
  1001. * Test : is the bounding sphere outside the frustum ?
  1002. * If not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1005. /** Culling strategy : Optimistic Inclusion.
  1006. * This in an inclusion test first, then the standard exclusion test.
  1007. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1008. * 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.
  1009. * Anyway, it's as accurate as the standard strategy.
  1010. * Test :
  1011. * Is the cullable object bounding sphere center in the frustum ?
  1012. * If not, apply the default culling strategy.
  1013. */
  1014. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1015. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1016. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1017. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1018. * 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.
  1019. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1020. * Test :
  1021. * Is the cullable object bounding sphere center in the frustum ?
  1022. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1023. */
  1024. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1025. /**
  1026. * No logging while loading
  1027. */
  1028. static readonly SCENELOADER_NO_LOGGING: number;
  1029. /**
  1030. * Minimal logging while loading
  1031. */
  1032. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1033. /**
  1034. * Summary logging while loading
  1035. */
  1036. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1037. /**
  1038. * Detailled logging while loading
  1039. */
  1040. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1041. }
  1042. }
  1043. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1044. import { Nullable } from "babylonjs/types";
  1045. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1046. /**
  1047. * This represents the required contract to create a new type of texture loader.
  1048. */
  1049. export interface IInternalTextureLoader {
  1050. /**
  1051. * Defines wether the loader supports cascade loading the different faces.
  1052. */
  1053. supportCascades: boolean;
  1054. /**
  1055. * This returns if the loader support the current file information.
  1056. * @param extension defines the file extension of the file being loaded
  1057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1058. * @param fallback defines the fallback internal texture if any
  1059. * @param isBase64 defines whether the texture is encoded as a base64
  1060. * @param isBuffer defines whether the texture data are stored as a buffer
  1061. * @returns true if the loader can load the specified file
  1062. */
  1063. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1064. /**
  1065. * Transform the url before loading if required.
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the transformed texture
  1069. */
  1070. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1071. /**
  1072. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the fallback texture
  1076. */
  1077. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1078. /**
  1079. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param createPolynomials will be true if polynomials have been requested
  1083. * @param onLoad defines the callback to trigger once the texture is ready
  1084. * @param onError defines the callback to trigger in case of error
  1085. */
  1086. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1087. /**
  1088. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1089. * @param data contains the texture data
  1090. * @param texture defines the BabylonJS internal texture
  1091. * @param callback defines the method to call once ready to upload
  1092. */
  1093. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1094. }
  1095. }
  1096. declare module "babylonjs/Engines/IPipelineContext" {
  1097. /**
  1098. * Class used to store and describe the pipeline context associated with an effect
  1099. */
  1100. export interface IPipelineContext {
  1101. /**
  1102. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1103. */
  1104. isAsync: boolean;
  1105. /**
  1106. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1107. */
  1108. isReady: boolean;
  1109. /** @hidden */
  1110. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1111. }
  1112. }
  1113. declare module "babylonjs/Meshes/dataBuffer" {
  1114. /**
  1115. * Class used to store gfx data (like WebGLBuffer)
  1116. */
  1117. export class DataBuffer {
  1118. /**
  1119. * Gets or sets the number of objects referencing this buffer
  1120. */
  1121. references: number;
  1122. /** Gets or sets the size of the underlying buffer */
  1123. capacity: number;
  1124. /**
  1125. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1126. */
  1127. is32Bits: boolean;
  1128. /**
  1129. * Gets the underlying buffer
  1130. */
  1131. readonly underlyingResource: any;
  1132. }
  1133. }
  1134. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1135. /** @hidden */
  1136. export interface IShaderProcessor {
  1137. attributeProcessor?: (attribute: string) => string;
  1138. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1139. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1140. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1141. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1142. lineProcessor?: (line: string, isFragment: boolean) => string;
  1143. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1144. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. }
  1146. }
  1147. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1148. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1149. /** @hidden */
  1150. export interface ProcessingOptions {
  1151. defines: string[];
  1152. indexParameters: any;
  1153. isFragment: boolean;
  1154. shouldUseHighPrecisionShader: boolean;
  1155. supportsUniformBuffers: boolean;
  1156. shadersRepository: string;
  1157. includesShadersStore: {
  1158. [key: string]: string;
  1159. };
  1160. processor?: IShaderProcessor;
  1161. version: string;
  1162. platformName: string;
  1163. lookForClosingBracketForUniformBuffer?: boolean;
  1164. }
  1165. }
  1166. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1167. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1168. /** @hidden */
  1169. export class ShaderCodeNode {
  1170. line: string;
  1171. children: ShaderCodeNode[];
  1172. additionalDefineKey?: string;
  1173. additionalDefineValue?: string;
  1174. isValid(preprocessors: {
  1175. [key: string]: string;
  1176. }): boolean;
  1177. process(preprocessors: {
  1178. [key: string]: string;
  1179. }, options: ProcessingOptions): string;
  1180. }
  1181. }
  1182. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1183. /** @hidden */
  1184. export class ShaderCodeCursor {
  1185. private _lines;
  1186. lineIndex: number;
  1187. readonly currentLine: string;
  1188. readonly canRead: boolean;
  1189. lines: string[];
  1190. }
  1191. }
  1192. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1193. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1194. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1195. /** @hidden */
  1196. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1197. process(preprocessors: {
  1198. [key: string]: string;
  1199. }, options: ProcessingOptions): string;
  1200. }
  1201. }
  1202. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1203. /** @hidden */
  1204. export class ShaderDefineExpression {
  1205. isTrue(preprocessors: {
  1206. [key: string]: string;
  1207. }): boolean;
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1213. /** @hidden */
  1214. export class ShaderCodeTestNode extends ShaderCodeNode {
  1215. testExpression: ShaderDefineExpression;
  1216. isValid(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1225. define: string;
  1226. not: boolean;
  1227. constructor(define: string, not?: boolean);
  1228. isTrue(preprocessors: {
  1229. [key: string]: string;
  1230. }): boolean;
  1231. }
  1232. }
  1233. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1237. leftOperand: ShaderDefineExpression;
  1238. rightOperand: ShaderDefineExpression;
  1239. isTrue(preprocessors: {
  1240. [key: string]: string;
  1241. }): boolean;
  1242. }
  1243. }
  1244. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1245. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1246. /** @hidden */
  1247. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1248. leftOperand: ShaderDefineExpression;
  1249. rightOperand: ShaderDefineExpression;
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1259. define: string;
  1260. operand: string;
  1261. testValue: string;
  1262. constructor(define: string, operand: string, testValue: string);
  1263. isTrue(preprocessors: {
  1264. [key: string]: string;
  1265. }): boolean;
  1266. }
  1267. }
  1268. declare module "babylonjs/Offline/IOfflineProvider" {
  1269. /**
  1270. * Class used to enable access to offline support
  1271. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1272. */
  1273. export interface IOfflineProvider {
  1274. /**
  1275. * Gets a boolean indicating if scene must be saved in the database
  1276. */
  1277. enableSceneOffline: boolean;
  1278. /**
  1279. * Gets a boolean indicating if textures must be saved in the database
  1280. */
  1281. enableTexturesOffline: boolean;
  1282. /**
  1283. * Open the offline support and make it available
  1284. * @param successCallback defines the callback to call on success
  1285. * @param errorCallback defines the callback to call on error
  1286. */
  1287. open(successCallback: () => void, errorCallback: () => void): void;
  1288. /**
  1289. * Loads an image from the offline support
  1290. * @param url defines the url to load from
  1291. * @param image defines the target DOM image
  1292. */
  1293. loadImage(url: string, image: HTMLImageElement): void;
  1294. /**
  1295. * Loads a file from offline support
  1296. * @param url defines the URL to load from
  1297. * @param sceneLoaded defines a callback to call on success
  1298. * @param progressCallBack defines a callback to call when progress changed
  1299. * @param errorCallback defines a callback to call on error
  1300. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1301. */
  1302. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/filesInputStore" {
  1306. /**
  1307. * Class used to help managing file picking and drag'n'drop
  1308. * File Storage
  1309. */
  1310. export class FilesInputStore {
  1311. /**
  1312. * List of files ready to be loaded
  1313. */
  1314. static FilesToLoad: {
  1315. [key: string]: File;
  1316. };
  1317. }
  1318. }
  1319. declare module "babylonjs/Misc/retryStrategy" {
  1320. import { WebRequest } from "babylonjs/Misc/webRequest";
  1321. /**
  1322. * Class used to define a retry strategy when error happens while loading assets
  1323. */
  1324. export class RetryStrategy {
  1325. /**
  1326. * Function used to defines an exponential back off strategy
  1327. * @param maxRetries defines the maximum number of retries (3 by default)
  1328. * @param baseInterval defines the interval between retries
  1329. * @returns the strategy function to use
  1330. */
  1331. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1332. }
  1333. }
  1334. declare module "babylonjs/Misc/baseError" {
  1335. /**
  1336. * @ignore
  1337. * Application error to support additional information when loading a file
  1338. */
  1339. export abstract class BaseError extends Error {
  1340. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1341. }
  1342. }
  1343. declare module "babylonjs/Misc/fileTools" {
  1344. import { WebRequest } from "babylonjs/Misc/webRequest";
  1345. import { Nullable } from "babylonjs/types";
  1346. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1347. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1348. import { BaseError } from "babylonjs/Misc/baseError";
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. 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>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. 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;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. 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;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1467. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1468. /** @hidden */
  1469. export class ShaderProcessor {
  1470. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1471. private static _ProcessPrecision;
  1472. private static _ExtractOperation;
  1473. private static _BuildSubExpression;
  1474. private static _BuildExpression;
  1475. private static _MoveCursorWithinIf;
  1476. private static _MoveCursor;
  1477. private static _EvaluatePreProcessors;
  1478. private static _PreparePreProcessors;
  1479. private static _ProcessShaderConversion;
  1480. private static _ProcessIncludes;
  1481. }
  1482. }
  1483. declare module "babylonjs/Maths/math.like" {
  1484. import { float, int, DeepImmutable } from "babylonjs/types";
  1485. /**
  1486. * @hidden
  1487. */
  1488. export interface IColor4Like {
  1489. r: float;
  1490. g: float;
  1491. b: float;
  1492. a: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IColor3Like {
  1498. r: float;
  1499. g: float;
  1500. b: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IVector4Like {
  1506. x: float;
  1507. y: float;
  1508. z: float;
  1509. w: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IVector3Like {
  1515. x: float;
  1516. y: float;
  1517. z: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IVector2Like {
  1523. x: float;
  1524. y: float;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IMatrixLike {
  1530. toArray(): DeepImmutable<Float32Array>;
  1531. updateFlag: int;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IViewportLike {
  1537. x: float;
  1538. y: float;
  1539. width: float;
  1540. height: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IPlaneLike {
  1546. normal: IVector3Like;
  1547. d: float;
  1548. normalize(): void;
  1549. }
  1550. }
  1551. declare module "babylonjs/Materials/iEffectFallbacks" {
  1552. import { Effect } from "babylonjs/Materials/effect";
  1553. /**
  1554. * Interface used to define common properties for effect fallbacks
  1555. */
  1556. export interface IEffectFallbacks {
  1557. /**
  1558. * Removes the defines that should be removed when falling back.
  1559. * @param currentDefines defines the current define statements for the shader.
  1560. * @param effect defines the current effect we try to compile
  1561. * @returns The resulting defines with defines of the current rank removed.
  1562. */
  1563. reduce(currentDefines: string, effect: Effect): string;
  1564. /**
  1565. * Removes the fallback from the bound mesh.
  1566. */
  1567. unBindMesh(): void;
  1568. /**
  1569. * Checks to see if more fallbacks are still availible.
  1570. */
  1571. hasMoreFallbacks: boolean;
  1572. }
  1573. }
  1574. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1575. /**
  1576. * Class used to evalaute queries containing `and` and `or` operators
  1577. */
  1578. export class AndOrNotEvaluator {
  1579. /**
  1580. * Evaluate a query
  1581. * @param query defines the query to evaluate
  1582. * @param evaluateCallback defines the callback used to filter result
  1583. * @returns true if the query matches
  1584. */
  1585. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1586. private static _HandleParenthesisContent;
  1587. private static _SimplifyNegation;
  1588. }
  1589. }
  1590. declare module "babylonjs/Misc/tags" {
  1591. /**
  1592. * Class used to store custom tags
  1593. */
  1594. export class Tags {
  1595. /**
  1596. * Adds support for tags on the given object
  1597. * @param obj defines the object to use
  1598. */
  1599. static EnableFor(obj: any): void;
  1600. /**
  1601. * Removes tags support
  1602. * @param obj defines the object to use
  1603. */
  1604. static DisableFor(obj: any): void;
  1605. /**
  1606. * Gets a boolean indicating if the given object has tags
  1607. * @param obj defines the object to use
  1608. * @returns a boolean
  1609. */
  1610. static HasTags(obj: any): boolean;
  1611. /**
  1612. * Gets the tags available on a given object
  1613. * @param obj defines the object to use
  1614. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1615. * @returns the tags
  1616. */
  1617. static GetTags(obj: any, asString?: boolean): any;
  1618. /**
  1619. * Adds tags to an object
  1620. * @param obj defines the object to use
  1621. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1622. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1623. */
  1624. static AddTagsTo(obj: any, tagsString: string): void;
  1625. /**
  1626. * @hidden
  1627. */
  1628. static _AddTagTo(obj: any, tag: string): void;
  1629. /**
  1630. * Removes specific tags from a specific object
  1631. * @param obj defines the object to use
  1632. * @param tagsString defines the tags to remove
  1633. */
  1634. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1635. /**
  1636. * @hidden
  1637. */
  1638. static _RemoveTagFrom(obj: any, tag: string): void;
  1639. /**
  1640. * Defines if tags hosted on an object match a given query
  1641. * @param obj defines the object to use
  1642. * @param tagsQuery defines the tag query
  1643. * @returns a boolean
  1644. */
  1645. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1646. }
  1647. }
  1648. declare module "babylonjs/Maths/math.scalar" {
  1649. /**
  1650. * Scalar computation library
  1651. */
  1652. export class Scalar {
  1653. /**
  1654. * Two pi constants convenient for computation.
  1655. */
  1656. static TwoPi: number;
  1657. /**
  1658. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1659. * @param a number
  1660. * @param b number
  1661. * @param epsilon (default = 1.401298E-45)
  1662. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1663. */
  1664. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1665. /**
  1666. * Returns a string : the upper case translation of the number i to hexadecimal.
  1667. * @param i number
  1668. * @returns the upper case translation of the number i to hexadecimal.
  1669. */
  1670. static ToHex(i: number): string;
  1671. /**
  1672. * Returns -1 if value is negative and +1 is value is positive.
  1673. * @param value the value
  1674. * @returns the value itself if it's equal to zero.
  1675. */
  1676. static Sign(value: number): number;
  1677. /**
  1678. * Returns the value itself if it's between min and max.
  1679. * Returns min if the value is lower than min.
  1680. * Returns max if the value is greater than max.
  1681. * @param value the value to clmap
  1682. * @param min the min value to clamp to (default: 0)
  1683. * @param max the max value to clamp to (default: 1)
  1684. * @returns the clamped value
  1685. */
  1686. static Clamp(value: number, min?: number, max?: number): number;
  1687. /**
  1688. * the log2 of value.
  1689. * @param value the value to compute log2 of
  1690. * @returns the log2 of value.
  1691. */
  1692. static Log2(value: number): number;
  1693. /**
  1694. * Loops the value, so that it is never larger than length and never smaller than 0.
  1695. *
  1696. * This is similar to the modulo operator but it works with floating point numbers.
  1697. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1698. * With t = 5 and length = 2.5, the result would be 0.0.
  1699. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1700. * @param value the value
  1701. * @param length the length
  1702. * @returns the looped value
  1703. */
  1704. static Repeat(value: number, length: number): number;
  1705. /**
  1706. * Normalize the value between 0.0 and 1.0 using min and max values
  1707. * @param value value to normalize
  1708. * @param min max to normalize between
  1709. * @param max min to normalize between
  1710. * @returns the normalized value
  1711. */
  1712. static Normalize(value: number, min: number, max: number): number;
  1713. /**
  1714. * Denormalize the value from 0.0 and 1.0 using min and max values
  1715. * @param normalized value to denormalize
  1716. * @param min max to denormalize between
  1717. * @param max min to denormalize between
  1718. * @returns the denormalized value
  1719. */
  1720. static Denormalize(normalized: number, min: number, max: number): number;
  1721. /**
  1722. * Calculates the shortest difference between two given angles given in degrees.
  1723. * @param current current angle in degrees
  1724. * @param target target angle in degrees
  1725. * @returns the delta
  1726. */
  1727. static DeltaAngle(current: number, target: number): number;
  1728. /**
  1729. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1730. * @param tx value
  1731. * @param length length
  1732. * @returns The returned value will move back and forth between 0 and length
  1733. */
  1734. static PingPong(tx: number, length: number): number;
  1735. /**
  1736. * Interpolates between min and max with smoothing at the limits.
  1737. *
  1738. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1739. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1740. * @param from from
  1741. * @param to to
  1742. * @param tx value
  1743. * @returns the smooth stepped value
  1744. */
  1745. static SmoothStep(from: number, to: number, tx: number): number;
  1746. /**
  1747. * Moves a value current towards target.
  1748. *
  1749. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1750. * Negative values of maxDelta pushes the value away from target.
  1751. * @param current current value
  1752. * @param target target value
  1753. * @param maxDelta max distance to move
  1754. * @returns resulting value
  1755. */
  1756. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1757. /**
  1758. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1759. *
  1760. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1761. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1762. * @param current current value
  1763. * @param target target value
  1764. * @param maxDelta max distance to move
  1765. * @returns resulting angle
  1766. */
  1767. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1768. /**
  1769. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1770. * @param start start value
  1771. * @param end target value
  1772. * @param amount amount to lerp between
  1773. * @returns the lerped value
  1774. */
  1775. static Lerp(start: number, end: number, amount: number): number;
  1776. /**
  1777. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1778. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static LerpAngle(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1787. * @param a start value
  1788. * @param b target value
  1789. * @param value value between a and b
  1790. * @returns the inverseLerp value
  1791. */
  1792. static InverseLerp(a: number, b: number, value: number): number;
  1793. /**
  1794. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1795. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1796. * @param value1 spline value
  1797. * @param tangent1 spline value
  1798. * @param value2 spline value
  1799. * @param tangent2 spline value
  1800. * @param amount input value
  1801. * @returns hermite result
  1802. */
  1803. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1804. /**
  1805. * Returns a random float number between and min and max values
  1806. * @param min min value of random
  1807. * @param max max value of random
  1808. * @returns random value
  1809. */
  1810. static RandomRange(min: number, max: number): number;
  1811. /**
  1812. * This function returns percentage of a number in a given range.
  1813. *
  1814. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1815. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1816. * @param number to convert to percentage
  1817. * @param min min range
  1818. * @param max max range
  1819. * @returns the percentage
  1820. */
  1821. static RangeToPercent(number: number, min: number, max: number): number;
  1822. /**
  1823. * This function returns number that corresponds to the percentage in a given range.
  1824. *
  1825. * PercentToRange(0.34,0,100) will return 34.
  1826. * @param percent to convert to number
  1827. * @param min min range
  1828. * @param max max range
  1829. * @returns the number
  1830. */
  1831. static PercentToRange(percent: number, min: number, max: number): number;
  1832. /**
  1833. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1834. * @param angle The angle to normalize in radian.
  1835. * @return The converted angle.
  1836. */
  1837. static NormalizeRadians(angle: number): number;
  1838. }
  1839. }
  1840. declare module "babylonjs/Maths/math.constants" {
  1841. /**
  1842. * Constant used to convert a value to gamma space
  1843. * @ignorenaming
  1844. */
  1845. export const ToGammaSpace: number;
  1846. /**
  1847. * Constant used to convert a value to linear space
  1848. * @ignorenaming
  1849. */
  1850. export const ToLinearSpace = 2.2;
  1851. /**
  1852. * Constant used to define the minimal number value in Babylon.js
  1853. * @ignorenaming
  1854. */
  1855. let Epsilon: number;
  1856. export { Epsilon };
  1857. }
  1858. declare module "babylonjs/Maths/math.viewport" {
  1859. /**
  1860. * Class used to represent a viewport on screen
  1861. */
  1862. export class Viewport {
  1863. /** viewport left coordinate */
  1864. x: number;
  1865. /** viewport top coordinate */
  1866. y: number;
  1867. /**viewport width */
  1868. width: number;
  1869. /** viewport height */
  1870. height: number;
  1871. /**
  1872. * Creates a Viewport object located at (x, y) and sized (width, height)
  1873. * @param x defines viewport left coordinate
  1874. * @param y defines viewport top coordinate
  1875. * @param width defines the viewport width
  1876. * @param height defines the viewport height
  1877. */
  1878. constructor(
  1879. /** viewport left coordinate */
  1880. x: number,
  1881. /** viewport top coordinate */
  1882. y: number,
  1883. /**viewport width */
  1884. width: number,
  1885. /** viewport height */
  1886. height: number);
  1887. /**
  1888. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1889. * @param renderWidth defines the rendering width
  1890. * @param renderHeight defines the rendering height
  1891. * @returns a new Viewport
  1892. */
  1893. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1894. /**
  1895. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1896. * @param renderWidth defines the rendering width
  1897. * @param renderHeight defines the rendering height
  1898. * @param ref defines the target viewport
  1899. * @returns the current viewport
  1900. */
  1901. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1902. /**
  1903. * Returns a new Viewport copied from the current one
  1904. * @returns a new Viewport
  1905. */
  1906. clone(): Viewport;
  1907. }
  1908. }
  1909. declare module "babylonjs/Misc/arrayTools" {
  1910. /**
  1911. * Class containing a set of static utilities functions for arrays.
  1912. */
  1913. export class ArrayTools {
  1914. /**
  1915. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1916. * @param size the number of element to construct and put in the array
  1917. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1918. * @returns a new array filled with new objects
  1919. */
  1920. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1921. }
  1922. }
  1923. declare module "babylonjs/Maths/math.vector" {
  1924. import { Viewport } from "babylonjs/Maths/math.viewport";
  1925. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1926. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1927. /**
  1928. * Class representing a vector containing 2 coordinates
  1929. */
  1930. export class Vector2 {
  1931. /** defines the first coordinate */
  1932. x: number;
  1933. /** defines the second coordinate */
  1934. y: number;
  1935. /**
  1936. * Creates a new Vector2 from the given x and y coordinates
  1937. * @param x defines the first coordinate
  1938. * @param y defines the second coordinate
  1939. */
  1940. constructor(
  1941. /** defines the first coordinate */
  1942. x?: number,
  1943. /** defines the second coordinate */
  1944. y?: number);
  1945. /**
  1946. * Gets a string with the Vector2 coordinates
  1947. * @returns a string with the Vector2 coordinates
  1948. */
  1949. toString(): string;
  1950. /**
  1951. * Gets class name
  1952. * @returns the string "Vector2"
  1953. */
  1954. getClassName(): string;
  1955. /**
  1956. * Gets current vector hash code
  1957. * @returns the Vector2 hash code as a number
  1958. */
  1959. getHashCode(): number;
  1960. /**
  1961. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1962. * @param array defines the source array
  1963. * @param index defines the offset in source array
  1964. * @returns the current Vector2
  1965. */
  1966. toArray(array: FloatArray, index?: number): Vector2;
  1967. /**
  1968. * Copy the current vector to an array
  1969. * @returns a new array with 2 elements: the Vector2 coordinates.
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1974. * @param source defines the source Vector2
  1975. * @returns the current updated Vector2
  1976. */
  1977. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the Vector2 coordinates with the given floats
  1980. * @param x defines the first coordinate
  1981. * @param y defines the second coordinate
  1982. * @returns the current updated Vector2
  1983. */
  1984. copyFromFloats(x: number, y: number): Vector2;
  1985. /**
  1986. * Sets the Vector2 coordinates with the given floats
  1987. * @param x defines the first coordinate
  1988. * @param y defines the second coordinate
  1989. * @returns the current updated Vector2
  1990. */
  1991. set(x: number, y: number): Vector2;
  1992. /**
  1993. * Add another vector with the current one
  1994. * @param otherVector defines the other vector
  1995. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1996. */
  1997. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1998. /**
  1999. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2000. * @param otherVector defines the other vector
  2001. * @param result defines the target vector
  2002. * @returns the unmodified current Vector2
  2003. */
  2004. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2005. /**
  2006. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2007. * @param otherVector defines the other vector
  2008. * @returns the current updated Vector2
  2009. */
  2010. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2013. * @param otherVector defines the other vector
  2014. * @returns a new Vector2
  2015. */
  2016. addVector3(otherVector: Vector3): Vector2;
  2017. /**
  2018. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2019. * @param otherVector defines the other vector
  2020. * @returns a new Vector2
  2021. */
  2022. subtract(otherVector: Vector2): Vector2;
  2023. /**
  2024. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2025. * @param otherVector defines the other vector
  2026. * @param result defines the target vector
  2027. * @returns the unmodified current Vector2
  2028. */
  2029. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2030. /**
  2031. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2032. * @param otherVector defines the other vector
  2033. * @returns the current updated Vector2
  2034. */
  2035. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2036. /**
  2037. * Multiplies in place the current Vector2 coordinates by the given ones
  2038. * @param otherVector defines the other vector
  2039. * @returns the current updated Vector2
  2040. */
  2041. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2048. /**
  2049. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2057. * @param x defines the first coordinate
  2058. * @param y defines the second coordinate
  2059. * @returns a new Vector2
  2060. */
  2061. multiplyByFloats(x: number, y: number): Vector2;
  2062. /**
  2063. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2064. * @param otherVector defines the other vector
  2065. * @returns a new Vector2
  2066. */
  2067. divide(otherVector: Vector2): Vector2;
  2068. /**
  2069. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2070. * @param otherVector defines the other vector
  2071. * @param result defines the target vector
  2072. * @returns the unmodified current Vector2
  2073. */
  2074. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2075. /**
  2076. * Divides the current Vector2 coordinates by the given ones
  2077. * @param otherVector defines the other vector
  2078. * @returns the current updated Vector2
  2079. */
  2080. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2081. /**
  2082. * Gets a new Vector2 with current Vector2 negated coordinates
  2083. * @returns a new Vector2
  2084. */
  2085. negate(): Vector2;
  2086. /**
  2087. * Multiply the Vector2 coordinates by scale
  2088. * @param scale defines the scaling factor
  2089. * @returns the current updated Vector2
  2090. */
  2091. scaleInPlace(scale: number): Vector2;
  2092. /**
  2093. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2094. * @param scale defines the scaling factor
  2095. * @returns a new Vector2
  2096. */
  2097. scale(scale: number): Vector2;
  2098. /**
  2099. * Scale the current Vector2 values by a factor to a given Vector2
  2100. * @param scale defines the scale factor
  2101. * @param result defines the Vector2 object where to store the result
  2102. * @returns the unmodified current Vector2
  2103. */
  2104. scaleToRef(scale: number, result: Vector2): Vector2;
  2105. /**
  2106. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2107. * @param scale defines the scale factor
  2108. * @param result defines the Vector2 object where to store the result
  2109. * @returns the unmodified current Vector2
  2110. */
  2111. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2112. /**
  2113. * Gets a boolean if two vectors are equals
  2114. * @param otherVector defines the other vector
  2115. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2116. */
  2117. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2118. /**
  2119. * Gets a boolean if two vectors are equals (using an epsilon value)
  2120. * @param otherVector defines the other vector
  2121. * @param epsilon defines the minimal distance to consider equality
  2122. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2123. */
  2124. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2125. /**
  2126. * Gets a new Vector2 from current Vector2 floored values
  2127. * @returns a new Vector2
  2128. */
  2129. floor(): Vector2;
  2130. /**
  2131. * Gets a new Vector2 from current Vector2 floored values
  2132. * @returns a new Vector2
  2133. */
  2134. fract(): Vector2;
  2135. /**
  2136. * Gets the length of the vector
  2137. * @returns the vector length (float)
  2138. */
  2139. length(): number;
  2140. /**
  2141. * Gets the vector squared length
  2142. * @returns the vector squared length (float)
  2143. */
  2144. lengthSquared(): number;
  2145. /**
  2146. * Normalize the vector
  2147. * @returns the current updated Vector2
  2148. */
  2149. normalize(): Vector2;
  2150. /**
  2151. * Gets a new Vector2 copied from the Vector2
  2152. * @returns a new Vector2
  2153. */
  2154. clone(): Vector2;
  2155. /**
  2156. * Gets a new Vector2(0, 0)
  2157. * @returns a new Vector2
  2158. */
  2159. static Zero(): Vector2;
  2160. /**
  2161. * Gets a new Vector2(1, 1)
  2162. * @returns a new Vector2
  2163. */
  2164. static One(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 set from the given index element of the given array
  2167. * @param array defines the data source
  2168. * @param offset defines the offset in the data source
  2169. * @returns a new Vector2
  2170. */
  2171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2172. /**
  2173. * Sets "result" from the given index element of the given array
  2174. * @param array defines the data source
  2175. * @param offset defines the offset in the data source
  2176. * @param result defines the target vector
  2177. */
  2178. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2179. /**
  2180. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2181. * @param value1 defines 1st point of control
  2182. * @param value2 defines 2nd point of control
  2183. * @param value3 defines 3rd point of control
  2184. * @param value4 defines 4th point of control
  2185. * @param amount defines the interpolation factor
  2186. * @returns a new Vector2
  2187. */
  2188. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2189. /**
  2190. * 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".
  2191. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2192. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2193. * @param value defines the value to clamp
  2194. * @param min defines the lower limit
  2195. * @param max defines the upper limit
  2196. * @returns a new Vector2
  2197. */
  2198. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2199. /**
  2200. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2201. * @param value1 defines the 1st control point
  2202. * @param tangent1 defines the outgoing tangent
  2203. * @param value2 defines the 2nd control point
  2204. * @param tangent2 defines the incoming tangent
  2205. * @param amount defines the interpolation factor
  2206. * @returns a new Vector2
  2207. */
  2208. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2209. /**
  2210. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2211. * @param start defines the start vector
  2212. * @param end defines the end vector
  2213. * @param amount defines the interpolation factor
  2214. * @returns a new Vector2
  2215. */
  2216. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2217. /**
  2218. * Gets the dot product of the vector "left" and the vector "right"
  2219. * @param left defines first vector
  2220. * @param right defines second vector
  2221. * @returns the dot product (float)
  2222. */
  2223. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2224. /**
  2225. * Returns a new Vector2 equal to the normalized given vector
  2226. * @param vector defines the vector to normalize
  2227. * @returns a new Vector2
  2228. */
  2229. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2232. * @param left defines 1st vector
  2233. * @param right defines 2nd vector
  2234. * @returns a new Vector2
  2235. */
  2236. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2237. /**
  2238. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2239. * @param left defines 1st vector
  2240. * @param right defines 2nd vector
  2241. * @returns a new Vector2
  2242. */
  2243. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2246. * @param vector defines the vector to transform
  2247. * @param transformation defines the matrix to apply
  2248. * @returns a new Vector2
  2249. */
  2250. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2251. /**
  2252. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2253. * @param vector defines the vector to transform
  2254. * @param transformation defines the matrix to apply
  2255. * @param result defines the target vector
  2256. */
  2257. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2258. /**
  2259. * Determines if a given vector is included in a triangle
  2260. * @param p defines the vector to test
  2261. * @param p0 defines 1st triangle point
  2262. * @param p1 defines 2nd triangle point
  2263. * @param p2 defines 3rd triangle point
  2264. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2265. */
  2266. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2267. /**
  2268. * Gets the distance between the vectors "value1" and "value2"
  2269. * @param value1 defines first vector
  2270. * @param value2 defines second vector
  2271. * @returns the distance between vectors
  2272. */
  2273. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2274. /**
  2275. * Returns the squared distance between the vectors "value1" and "value2"
  2276. * @param value1 defines first vector
  2277. * @param value2 defines second vector
  2278. * @returns the squared distance between vectors
  2279. */
  2280. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2281. /**
  2282. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2283. * @param value1 defines first vector
  2284. * @param value2 defines second vector
  2285. * @returns a new Vector2
  2286. */
  2287. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2288. /**
  2289. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2290. * @param p defines the middle point
  2291. * @param segA defines one point of the segment
  2292. * @param segB defines the other point of the segment
  2293. * @returns the shortest distance
  2294. */
  2295. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2296. }
  2297. /**
  2298. * Classed used to store (x,y,z) vector representation
  2299. * A Vector3 is the main object used in 3D geometry
  2300. * It can represent etiher the coordinates of a point the space, either a direction
  2301. * Reminder: js uses a left handed forward facing system
  2302. */
  2303. export class Vector3 {
  2304. /**
  2305. * Defines the first coordinates (on X axis)
  2306. */
  2307. x: number;
  2308. /**
  2309. * Defines the second coordinates (on Y axis)
  2310. */
  2311. y: number;
  2312. /**
  2313. * Defines the third coordinates (on Z axis)
  2314. */
  2315. z: number;
  2316. private static _UpReadOnly;
  2317. private static _ZeroReadOnly;
  2318. /**
  2319. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2320. * @param x defines the first coordinates (on X axis)
  2321. * @param y defines the second coordinates (on Y axis)
  2322. * @param z defines the third coordinates (on Z axis)
  2323. */
  2324. constructor(
  2325. /**
  2326. * Defines the first coordinates (on X axis)
  2327. */
  2328. x?: number,
  2329. /**
  2330. * Defines the second coordinates (on Y axis)
  2331. */
  2332. y?: number,
  2333. /**
  2334. * Defines the third coordinates (on Z axis)
  2335. */
  2336. z?: number);
  2337. /**
  2338. * Creates a string representation of the Vector3
  2339. * @returns a string with the Vector3 coordinates.
  2340. */
  2341. toString(): string;
  2342. /**
  2343. * Gets the class name
  2344. * @returns the string "Vector3"
  2345. */
  2346. getClassName(): string;
  2347. /**
  2348. * Creates the Vector3 hash code
  2349. * @returns a number which tends to be unique between Vector3 instances
  2350. */
  2351. getHashCode(): number;
  2352. /**
  2353. * Creates an array containing three elements : the coordinates of the Vector3
  2354. * @returns a new array of numbers
  2355. */
  2356. asArray(): number[];
  2357. /**
  2358. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2359. * @param array defines the destination array
  2360. * @param index defines the offset in the destination array
  2361. * @returns the current Vector3
  2362. */
  2363. toArray(array: FloatArray, index?: number): Vector3;
  2364. /**
  2365. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2366. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2367. */
  2368. toQuaternion(): Quaternion;
  2369. /**
  2370. * Adds the given vector to the current Vector3
  2371. * @param otherVector defines the second operand
  2372. * @returns the current updated Vector3
  2373. */
  2374. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2375. /**
  2376. * Adds the given coordinates to the current Vector3
  2377. * @param x defines the x coordinate of the operand
  2378. * @param y defines the y coordinate of the operand
  2379. * @param z defines the z coordinate of the operand
  2380. * @returns the current updated Vector3
  2381. */
  2382. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2383. /**
  2384. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2385. * @param otherVector defines the second operand
  2386. * @returns the resulting Vector3
  2387. */
  2388. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2389. /**
  2390. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2391. * @param otherVector defines the second operand
  2392. * @param result defines the Vector3 object where to store the result
  2393. * @returns the current Vector3
  2394. */
  2395. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2396. /**
  2397. * Subtract the given vector from the current Vector3
  2398. * @param otherVector defines the second operand
  2399. * @returns the current updated Vector3
  2400. */
  2401. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2402. /**
  2403. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2404. * @param otherVector defines the second operand
  2405. * @returns the resulting Vector3
  2406. */
  2407. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2408. /**
  2409. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2410. * @param otherVector defines the second operand
  2411. * @param result defines the Vector3 object where to store the result
  2412. * @returns the current Vector3
  2413. */
  2414. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2415. /**
  2416. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2417. * @param x defines the x coordinate of the operand
  2418. * @param y defines the y coordinate of the operand
  2419. * @param z defines the z coordinate of the operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2423. /**
  2424. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2425. * @param x defines the x coordinate of the operand
  2426. * @param y defines the y coordinate of the operand
  2427. * @param z defines the z coordinate of the operand
  2428. * @param result defines the Vector3 object where to store the result
  2429. * @returns the current Vector3
  2430. */
  2431. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2432. /**
  2433. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2434. * @returns a new Vector3
  2435. */
  2436. negate(): Vector3;
  2437. /**
  2438. * Multiplies the Vector3 coordinates by the float "scale"
  2439. * @param scale defines the multiplier factor
  2440. * @returns the current updated Vector3
  2441. */
  2442. scaleInPlace(scale: number): Vector3;
  2443. /**
  2444. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2445. * @param scale defines the multiplier factor
  2446. * @returns a new Vector3
  2447. */
  2448. scale(scale: number): Vector3;
  2449. /**
  2450. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2451. * @param scale defines the multiplier factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. scaleToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2458. * @param scale defines the scale factor
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the unmodified current Vector3
  2461. */
  2462. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2463. /**
  2464. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2465. * @param otherVector defines the second operand
  2466. * @returns true if both vectors are equals
  2467. */
  2468. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2471. * @param otherVector defines the second operand
  2472. * @param epsilon defines the minimal distance to define values as equals
  2473. * @returns true if both vectors are distant less than epsilon
  2474. */
  2475. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2476. /**
  2477. * Returns true if the current Vector3 coordinates equals the given floats
  2478. * @param x defines the x coordinate of the operand
  2479. * @param y defines the y coordinate of the operand
  2480. * @param z defines the z coordinate of the operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equalsToFloats(x: number, y: number, z: number): boolean;
  2484. /**
  2485. * Multiplies the current Vector3 coordinates by the given ones
  2486. * @param otherVector defines the second operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the new Vector3
  2494. */
  2495. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2505. * @param x defines the x coordinate of the operand
  2506. * @param y defines the y coordinate of the operand
  2507. * @param z defines the z coordinate of the operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2511. /**
  2512. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2513. * @param otherVector defines the second operand
  2514. * @returns the new Vector3
  2515. */
  2516. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2519. * @param otherVector defines the second operand
  2520. * @param result defines the Vector3 object where to store the result
  2521. * @returns the current Vector3
  2522. */
  2523. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2524. /**
  2525. * Divides the current Vector3 coordinates by the given ones.
  2526. * @param otherVector defines the second operand
  2527. * @returns the current updated Vector3
  2528. */
  2529. divideInPlace(otherVector: Vector3): Vector3;
  2530. /**
  2531. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2532. * @param other defines the second operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2538. * @param other defines the second operand
  2539. * @returns the current updated Vector3
  2540. */
  2541. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2542. /**
  2543. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2544. * @param x defines the x coordinate of the operand
  2545. * @param y defines the y coordinate of the operand
  2546. * @param z defines the z coordinate of the operand
  2547. * @returns the current updated Vector3
  2548. */
  2549. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2550. /**
  2551. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2560. * Check if is non uniform within a certain amount of decimal places to account for this
  2561. * @param epsilon the amount the values can differ
  2562. * @returns if the the vector is non uniform to a certain number of decimal places
  2563. */
  2564. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2565. /**
  2566. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2567. */
  2568. readonly isNonUniform: boolean;
  2569. /**
  2570. * Gets a new Vector3 from current Vector3 floored values
  2571. * @returns a new Vector3
  2572. */
  2573. floor(): Vector3;
  2574. /**
  2575. * Gets a new Vector3 from current Vector3 floored values
  2576. * @returns a new Vector3
  2577. */
  2578. fract(): Vector3;
  2579. /**
  2580. * Gets the length of the Vector3
  2581. * @returns the length of the Vector3
  2582. */
  2583. length(): number;
  2584. /**
  2585. * Gets the squared length of the Vector3
  2586. * @returns squared length of the Vector3
  2587. */
  2588. lengthSquared(): number;
  2589. /**
  2590. * Normalize the current Vector3.
  2591. * Please note that this is an in place operation.
  2592. * @returns the current updated Vector3
  2593. */
  2594. normalize(): Vector3;
  2595. /**
  2596. * Reorders the x y z properties of the vector in place
  2597. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2598. * @returns the current updated vector
  2599. */
  2600. reorderInPlace(order: string): this;
  2601. /**
  2602. * Rotates the vector around 0,0,0 by a quaternion
  2603. * @param quaternion the rotation quaternion
  2604. * @param result vector to store the result
  2605. * @returns the resulting vector
  2606. */
  2607. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2608. /**
  2609. * Rotates a vector around a given point
  2610. * @param quaternion the rotation quaternion
  2611. * @param point the point to rotate around
  2612. * @param result vector to store the result
  2613. * @returns the resulting vector
  2614. */
  2615. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2618. * The cross product is then orthogonal to both current and "other"
  2619. * @param other defines the right operand
  2620. * @returns the cross product
  2621. */
  2622. cross(other: Vector3): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 with the given input length.
  2625. * Please note that this is an in place operation.
  2626. * @param len the length of the vector
  2627. * @returns the current updated Vector3
  2628. */
  2629. normalizeFromLength(len: number): Vector3;
  2630. /**
  2631. * Normalize the current Vector3 to a new vector
  2632. * @returns the new Vector3
  2633. */
  2634. normalizeToNew(): Vector3;
  2635. /**
  2636. * Normalize the current Vector3 to the reference
  2637. * @param reference define the Vector3 to update
  2638. * @returns the updated Vector3
  2639. */
  2640. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Creates a new Vector3 copied from the current Vector3
  2643. * @returns the new Vector3
  2644. */
  2645. clone(): Vector3;
  2646. /**
  2647. * Copies the given vector coordinates to the current Vector3 ones
  2648. * @param source defines the source Vector3
  2649. * @returns the current updated Vector3
  2650. */
  2651. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Copies the given floats to the current Vector3 coordinates
  2654. * @param x defines the x coordinate of the operand
  2655. * @param y defines the y coordinate of the operand
  2656. * @param z defines the z coordinate of the operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. copyFromFloats(x: number, y: number, z: number): Vector3;
  2660. /**
  2661. * Copies the given floats to the current Vector3 coordinates
  2662. * @param x defines the x coordinate of the operand
  2663. * @param y defines the y coordinate of the operand
  2664. * @param z defines the z coordinate of the operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. set(x: number, y: number, z: number): Vector3;
  2668. /**
  2669. * Copies the given float to the current Vector3 coordinates
  2670. * @param v defines the x, y and z coordinates of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. setAll(v: number): Vector3;
  2674. /**
  2675. * Get the clip factor between two vectors
  2676. * @param vector0 defines the first operand
  2677. * @param vector1 defines the second operand
  2678. * @param axis defines the axis to use
  2679. * @param size defines the size along the axis
  2680. * @returns the clip factor
  2681. */
  2682. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2683. /**
  2684. * Get angle between two vectors
  2685. * @param vector0 angle between vector0 and vector1
  2686. * @param vector1 angle between vector0 and vector1
  2687. * @param normal direction of the normal
  2688. * @return the angle between vector0 and vector1
  2689. */
  2690. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. */
  2697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2698. /**
  2699. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2700. * This function is deprecated. Use FromArray instead
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @returns the new Vector3
  2704. */
  2705. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. */
  2712. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2713. /**
  2714. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2715. * This function is deprecated. Use FromArrayToRef instead.
  2716. * @param array defines the source array
  2717. * @param offset defines the offset in the source array
  2718. * @param result defines the Vector3 where to store the result
  2719. */
  2720. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2721. /**
  2722. * Sets the given vector "result" with the given floats.
  2723. * @param x defines the x coordinate of the source
  2724. * @param y defines the y coordinate of the source
  2725. * @param z defines the z coordinate of the source
  2726. * @param result defines the Vector3 where to store the result
  2727. */
  2728. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2729. /**
  2730. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2731. * @returns a new empty Vector3
  2732. */
  2733. static Zero(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2736. * @returns a new unit Vector3
  2737. */
  2738. static One(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2741. * @returns a new up Vector3
  2742. */
  2743. static Up(): Vector3;
  2744. /**
  2745. * Gets a up Vector3 that must not be updated
  2746. */
  2747. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2748. /**
  2749. * Gets a zero Vector3 that must not be updated
  2750. */
  2751. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2752. /**
  2753. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2754. * @returns a new down Vector3
  2755. */
  2756. static Down(): Vector3;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2759. * @returns a new forward Vector3
  2760. */
  2761. static Forward(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2764. * @returns a new forward Vector3
  2765. */
  2766. static Backward(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2769. * @returns a new right Vector3
  2770. */
  2771. static Right(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2774. * @returns a new left Vector3
  2775. */
  2776. static Left(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2779. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2780. * @param vector defines the Vector3 to transform
  2781. * @param transformation defines the transformation matrix
  2782. * @returns the transformed Vector3
  2783. */
  2784. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2785. /**
  2786. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2787. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2788. * @param vector defines the Vector3 to transform
  2789. * @param transformation defines the transformation matrix
  2790. * @param result defines the Vector3 where to store the result
  2791. */
  2792. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2793. /**
  2794. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2795. * This method computes tranformed coordinates only, not transformed direction vectors
  2796. * @param x define the x coordinate of the source vector
  2797. * @param y define the y coordinate of the source vector
  2798. * @param z define the z coordinate of the source vector
  2799. * @param transformation defines the transformation matrix
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2805. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the new Vector3
  2809. */
  2810. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2813. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2821. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2831. * @param value1 defines the first control point
  2832. * @param value2 defines the second control point
  2833. * @param value3 defines the third control point
  2834. * @param value4 defines the fourth control point
  2835. * @param amount defines the amount on the spline to use
  2836. * @returns the new Vector3
  2837. */
  2838. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2839. /**
  2840. * 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"
  2841. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2842. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2843. * @param value defines the current value
  2844. * @param min defines the lower range value
  2845. * @param max defines the upper range value
  2846. * @returns the new Vector3
  2847. */
  2848. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2849. /**
  2850. * 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"
  2851. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2852. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2853. * @param value defines the current value
  2854. * @param min defines the lower range value
  2855. * @param max defines the upper range value
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2859. /**
  2860. * Checks if a given vector is inside a specific range
  2861. * @param v defines the vector to test
  2862. * @param min defines the minimum range
  2863. * @param max defines the maximum range
  2864. */
  2865. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2866. /**
  2867. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2868. * @param value1 defines the first control point
  2869. * @param tangent1 defines the first tangent vector
  2870. * @param value2 defines the second control point
  2871. * @param tangent2 defines the second tangent vector
  2872. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2873. * @returns the new Vector3
  2874. */
  2875. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2876. /**
  2877. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2878. * @param start defines the start value
  2879. * @param end defines the end value
  2880. * @param amount max defines amount between both (between 0 and 1)
  2881. * @returns the new Vector3
  2882. */
  2883. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2886. * @param start defines the start value
  2887. * @param end defines the end value
  2888. * @param amount max defines amount between both (between 0 and 1)
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2892. /**
  2893. * Returns the dot product (float) between the vectors "left" and "right"
  2894. * @param left defines the left operand
  2895. * @param right defines the right operand
  2896. * @returns the dot product
  2897. */
  2898. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2899. /**
  2900. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2901. * The cross product is then orthogonal to both "left" and "right"
  2902. * @param left defines the left operand
  2903. * @param right defines the right operand
  2904. * @returns the cross product
  2905. */
  2906. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2907. /**
  2908. * Sets the given vector "result" with the cross product of "left" and "right"
  2909. * The cross product is then orthogonal to both "left" and "right"
  2910. * @param left defines the left operand
  2911. * @param right defines the right operand
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2915. /**
  2916. * Returns a new Vector3 as the normalization of the given vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @returns the new Vector3
  2919. */
  2920. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2921. /**
  2922. * Sets the given vector "result" with the normalization of the given first vector
  2923. * @param vector defines the Vector3 to normalize
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2927. /**
  2928. * Project a Vector3 onto screen space
  2929. * @param vector defines the Vector3 to project
  2930. * @param world defines the world matrix to use
  2931. * @param transform defines the transform (view x projection) matrix to use
  2932. * @param viewport defines the screen viewport to use
  2933. * @returns the new Vector3
  2934. */
  2935. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2936. /** @hidden */
  2937. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2938. /**
  2939. * Unproject from screen space to object space
  2940. * @param source defines the screen space Vector3 to use
  2941. * @param viewportWidth defines the current width of the viewport
  2942. * @param viewportHeight defines the current height of the viewport
  2943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2944. * @param transform defines the transform (view x projection) matrix to use
  2945. * @returns the new Vector3
  2946. */
  2947. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2948. /**
  2949. * Unproject from screen space to object space
  2950. * @param source defines the screen space Vector3 to use
  2951. * @param viewportWidth defines the current width of the viewport
  2952. * @param viewportHeight defines the current height of the viewport
  2953. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2954. * @param view defines the view matrix to use
  2955. * @param projection defines the projection matrix to use
  2956. * @returns the new Vector3
  2957. */
  2958. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2959. /**
  2960. * Unproject from screen space to object space
  2961. * @param source defines the screen space Vector3 to use
  2962. * @param viewportWidth defines the current width of the viewport
  2963. * @param viewportHeight defines the current height of the viewport
  2964. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2965. * @param view defines the view matrix to use
  2966. * @param projection defines the projection matrix to use
  2967. * @param result defines the Vector3 where to store the result
  2968. */
  2969. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2970. /**
  2971. * Unproject from screen space to object space
  2972. * @param sourceX defines the screen space x coordinate to use
  2973. * @param sourceY defines the screen space y coordinate to use
  2974. * @param sourceZ defines the screen space z coordinate to use
  2975. * @param viewportWidth defines the current width of the viewport
  2976. * @param viewportHeight defines the current height of the viewport
  2977. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2978. * @param view defines the view matrix to use
  2979. * @param projection defines the projection matrix to use
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Gets the minimal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Gets the maximal coordinate values between two Vector3
  2992. * @param left defines the first operand
  2993. * @param right defines the second operand
  2994. * @returns the new Vector3
  2995. */
  2996. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2997. /**
  2998. * Returns the distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the distance
  3002. */
  3003. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns the squared distance between the vectors "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the squared distance
  3009. */
  3010. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3011. /**
  3012. * Returns a new Vector3 located at the center between "value1" and "value2"
  3013. * @param value1 defines the first operand
  3014. * @param value2 defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3020. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3021. * to something in order to rotate it from its local system to the given target system
  3022. * Note: axis1, axis2 and axis3 are normalized during this operation
  3023. * @param axis1 defines the first axis
  3024. * @param axis2 defines the second axis
  3025. * @param axis3 defines the third axis
  3026. * @returns a new Vector3
  3027. */
  3028. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3029. /**
  3030. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3031. * @param axis1 defines the first axis
  3032. * @param axis2 defines the second axis
  3033. * @param axis3 defines the third axis
  3034. * @param ref defines the Vector3 where to store the result
  3035. */
  3036. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3037. }
  3038. /**
  3039. * Vector4 class created for EulerAngle class conversion to Quaternion
  3040. */
  3041. export class Vector4 {
  3042. /** x value of the vector */
  3043. x: number;
  3044. /** y value of the vector */
  3045. y: number;
  3046. /** z value of the vector */
  3047. z: number;
  3048. /** w value of the vector */
  3049. w: number;
  3050. /**
  3051. * Creates a Vector4 object from the given floats.
  3052. * @param x x value of the vector
  3053. * @param y y value of the vector
  3054. * @param z z value of the vector
  3055. * @param w w value of the vector
  3056. */
  3057. constructor(
  3058. /** x value of the vector */
  3059. x: number,
  3060. /** y value of the vector */
  3061. y: number,
  3062. /** z value of the vector */
  3063. z: number,
  3064. /** w value of the vector */
  3065. w: number);
  3066. /**
  3067. * Returns the string with the Vector4 coordinates.
  3068. * @returns a string containing all the vector values
  3069. */
  3070. toString(): string;
  3071. /**
  3072. * Returns the string "Vector4".
  3073. * @returns "Vector4"
  3074. */
  3075. getClassName(): string;
  3076. /**
  3077. * Returns the Vector4 hash code.
  3078. * @returns a unique hash code
  3079. */
  3080. getHashCode(): number;
  3081. /**
  3082. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3083. * @returns the resulting array
  3084. */
  3085. asArray(): number[];
  3086. /**
  3087. * Populates the given array from the given index with the Vector4 coordinates.
  3088. * @param array array to populate
  3089. * @param index index of the array to start at (default: 0)
  3090. * @returns the Vector4.
  3091. */
  3092. toArray(array: FloatArray, index?: number): Vector4;
  3093. /**
  3094. * Adds the given vector to the current Vector4.
  3095. * @param otherVector the vector to add
  3096. * @returns the updated Vector4.
  3097. */
  3098. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @returns the resulting vector
  3103. */
  3104. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3105. /**
  3106. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3107. * @param otherVector the vector to add
  3108. * @param result the vector to store the result
  3109. * @returns the current Vector4.
  3110. */
  3111. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3112. /**
  3113. * Subtract in place the given vector from the current Vector4.
  3114. * @param otherVector the vector to subtract
  3115. * @returns the updated Vector4.
  3116. */
  3117. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to add
  3121. * @returns the new vector with the result
  3122. */
  3123. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3124. /**
  3125. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3126. * @param otherVector the vector to subtract
  3127. * @param result the vector to store the result
  3128. * @returns the current Vector4.
  3129. */
  3130. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3131. /**
  3132. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3133. */
  3134. /**
  3135. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3136. * @param x value to subtract
  3137. * @param y value to subtract
  3138. * @param z value to subtract
  3139. * @param w value to subtract
  3140. * @returns new vector containing the result
  3141. */
  3142. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3143. /**
  3144. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3145. * @param x value to subtract
  3146. * @param y value to subtract
  3147. * @param z value to subtract
  3148. * @param w value to subtract
  3149. * @param result the vector to store the result in
  3150. * @returns the current Vector4.
  3151. */
  3152. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3153. /**
  3154. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3155. * @returns a new vector with the negated values
  3156. */
  3157. negate(): Vector4;
  3158. /**
  3159. * Multiplies the current Vector4 coordinates by scale (float).
  3160. * @param scale the number to scale with
  3161. * @returns the updated Vector4.
  3162. */
  3163. scaleInPlace(scale: number): Vector4;
  3164. /**
  3165. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3166. * @param scale the number to scale with
  3167. * @returns a new vector with the result
  3168. */
  3169. scale(scale: number): Vector4;
  3170. /**
  3171. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3172. * @param scale the number to scale with
  3173. * @param result a vector to store the result in
  3174. * @returns the current Vector4.
  3175. */
  3176. scaleToRef(scale: number, result: Vector4): Vector4;
  3177. /**
  3178. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3179. * @param scale defines the scale factor
  3180. * @param result defines the Vector4 object where to store the result
  3181. * @returns the unmodified current Vector4
  3182. */
  3183. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3184. /**
  3185. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3186. * @param otherVector the vector to compare against
  3187. * @returns true if they are equal
  3188. */
  3189. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3190. /**
  3191. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3192. * @param otherVector vector to compare against
  3193. * @param epsilon (Default: very small number)
  3194. * @returns true if they are equal
  3195. */
  3196. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3197. /**
  3198. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3199. * @param x x value to compare against
  3200. * @param y y value to compare against
  3201. * @param z z value to compare against
  3202. * @param w w value to compare against
  3203. * @returns true if equal
  3204. */
  3205. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3206. /**
  3207. * Multiplies in place the current Vector4 by the given one.
  3208. * @param otherVector vector to multiple with
  3209. * @returns the updated Vector4.
  3210. */
  3211. multiplyInPlace(otherVector: Vector4): Vector4;
  3212. /**
  3213. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3214. * @param otherVector vector to multiple with
  3215. * @returns resulting new vector
  3216. */
  3217. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3218. /**
  3219. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3220. * @param otherVector vector to multiple with
  3221. * @param result vector to store the result
  3222. * @returns the current Vector4.
  3223. */
  3224. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3225. /**
  3226. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3227. * @param x x value multiply with
  3228. * @param y y value multiply with
  3229. * @param z z value multiply with
  3230. * @param w w value multiply with
  3231. * @returns resulting new vector
  3232. */
  3233. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3234. /**
  3235. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3236. * @param otherVector vector to devide with
  3237. * @returns resulting new vector
  3238. */
  3239. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3240. /**
  3241. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3242. * @param otherVector vector to devide with
  3243. * @param result vector to store the result
  3244. * @returns the current Vector4.
  3245. */
  3246. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3247. /**
  3248. * Divides the current Vector3 coordinates by the given ones.
  3249. * @param otherVector vector to devide with
  3250. * @returns the updated Vector3.
  3251. */
  3252. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3255. * @param other defines the second operand
  3256. * @returns the current updated Vector4
  3257. */
  3258. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3259. /**
  3260. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3261. * @param other defines the second operand
  3262. * @returns the current updated Vector4
  3263. */
  3264. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3265. /**
  3266. * Gets a new Vector4 from current Vector4 floored values
  3267. * @returns a new Vector4
  3268. */
  3269. floor(): Vector4;
  3270. /**
  3271. * Gets a new Vector4 from current Vector3 floored values
  3272. * @returns a new Vector4
  3273. */
  3274. fract(): Vector4;
  3275. /**
  3276. * Returns the Vector4 length (float).
  3277. * @returns the length
  3278. */
  3279. length(): number;
  3280. /**
  3281. * Returns the Vector4 squared length (float).
  3282. * @returns the length squared
  3283. */
  3284. lengthSquared(): number;
  3285. /**
  3286. * Normalizes in place the Vector4.
  3287. * @returns the updated Vector4.
  3288. */
  3289. normalize(): Vector4;
  3290. /**
  3291. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3292. * @returns this converted to a new vector3
  3293. */
  3294. toVector3(): Vector3;
  3295. /**
  3296. * Returns a new Vector4 copied from the current one.
  3297. * @returns the new cloned vector
  3298. */
  3299. clone(): Vector4;
  3300. /**
  3301. * Updates the current Vector4 with the given one coordinates.
  3302. * @param source the source vector to copy from
  3303. * @returns the updated Vector4.
  3304. */
  3305. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3306. /**
  3307. * Updates the current Vector4 coordinates with the given floats.
  3308. * @param x float to copy from
  3309. * @param y float to copy from
  3310. * @param z float to copy from
  3311. * @param w float to copy from
  3312. * @returns the updated Vector4.
  3313. */
  3314. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3315. /**
  3316. * Updates the current Vector4 coordinates with the given floats.
  3317. * @param x float to set from
  3318. * @param y float to set from
  3319. * @param z float to set from
  3320. * @param w float to set from
  3321. * @returns the updated Vector4.
  3322. */
  3323. set(x: number, y: number, z: number, w: number): Vector4;
  3324. /**
  3325. * Copies the given float to the current Vector3 coordinates
  3326. * @param v defines the x, y, z and w coordinates of the operand
  3327. * @returns the current updated Vector3
  3328. */
  3329. setAll(v: number): Vector4;
  3330. /**
  3331. * Returns a new Vector4 set from the starting index of the given array.
  3332. * @param array the array to pull values from
  3333. * @param offset the offset into the array to start at
  3334. * @returns the new vector
  3335. */
  3336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3337. /**
  3338. * Updates the given vector "result" from the starting index of the given array.
  3339. * @param array the array to pull values from
  3340. * @param offset the offset into the array to start at
  3341. * @param result the vector to store the result in
  3342. */
  3343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3344. /**
  3345. * Updates the given vector "result" from the starting index of the given Float32Array.
  3346. * @param array the array to pull values from
  3347. * @param offset the offset into the array to start at
  3348. * @param result the vector to store the result in
  3349. */
  3350. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3351. /**
  3352. * Updates the given vector "result" coordinates from the given floats.
  3353. * @param x float to set from
  3354. * @param y float to set from
  3355. * @param z float to set from
  3356. * @param w float to set from
  3357. * @param result the vector to the floats in
  3358. */
  3359. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3360. /**
  3361. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3362. * @returns the new vector
  3363. */
  3364. static Zero(): Vector4;
  3365. /**
  3366. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3367. * @returns the new vector
  3368. */
  3369. static One(): Vector4;
  3370. /**
  3371. * Returns a new normalized Vector4 from the given one.
  3372. * @param vector the vector to normalize
  3373. * @returns the vector
  3374. */
  3375. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3376. /**
  3377. * Updates the given vector "result" from the normalization of the given one.
  3378. * @param vector the vector to normalize
  3379. * @param result the vector to store the result in
  3380. */
  3381. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3382. /**
  3383. * Returns a vector with the minimum values from the left and right vectors
  3384. * @param left left vector to minimize
  3385. * @param right right vector to minimize
  3386. * @returns a new vector with the minimum of the left and right vector values
  3387. */
  3388. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Returns a vector with the maximum values from the left and right vectors
  3391. * @param left left vector to maximize
  3392. * @param right right vector to maximize
  3393. * @returns a new vector with the maximum of the left and right vector values
  3394. */
  3395. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Returns the distance (float) between the vectors "value1" and "value2".
  3398. * @param value1 value to calulate the distance between
  3399. * @param value2 value to calulate the distance between
  3400. * @return the distance between the two vectors
  3401. */
  3402. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3403. /**
  3404. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3405. * @param value1 value to calulate the distance between
  3406. * @param value2 value to calulate the distance between
  3407. * @return the distance between the two vectors squared
  3408. */
  3409. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3410. /**
  3411. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3412. * @param value1 value to calulate the center between
  3413. * @param value2 value to calulate the center between
  3414. * @return the center between the two vectors
  3415. */
  3416. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3417. /**
  3418. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3419. * This methods computes transformed normalized direction vectors only.
  3420. * @param vector the vector to transform
  3421. * @param transformation the transformation matrix to apply
  3422. * @returns the new vector
  3423. */
  3424. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3425. /**
  3426. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3427. * This methods computes transformed normalized direction vectors only.
  3428. * @param vector the vector to transform
  3429. * @param transformation the transformation matrix to apply
  3430. * @param result the vector to store the result in
  3431. */
  3432. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3433. /**
  3434. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3435. * This methods computes transformed normalized direction vectors only.
  3436. * @param x value to transform
  3437. * @param y value to transform
  3438. * @param z value to transform
  3439. * @param w value to transform
  3440. * @param transformation the transformation matrix to apply
  3441. * @param result the vector to store the results in
  3442. */
  3443. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3444. /**
  3445. * Creates a new Vector4 from a Vector3
  3446. * @param source defines the source data
  3447. * @param w defines the 4th component (default is 0)
  3448. * @returns a new Vector4
  3449. */
  3450. static FromVector3(source: Vector3, w?: number): Vector4;
  3451. }
  3452. /**
  3453. * Class used to store quaternion data
  3454. * @see https://en.wikipedia.org/wiki/Quaternion
  3455. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3456. */
  3457. export class Quaternion {
  3458. /** defines the first component (0 by default) */
  3459. x: number;
  3460. /** defines the second component (0 by default) */
  3461. y: number;
  3462. /** defines the third component (0 by default) */
  3463. z: number;
  3464. /** defines the fourth component (1.0 by default) */
  3465. w: number;
  3466. /**
  3467. * Creates a new Quaternion from the given floats
  3468. * @param x defines the first component (0 by default)
  3469. * @param y defines the second component (0 by default)
  3470. * @param z defines the third component (0 by default)
  3471. * @param w defines the fourth component (1.0 by default)
  3472. */
  3473. constructor(
  3474. /** defines the first component (0 by default) */
  3475. x?: number,
  3476. /** defines the second component (0 by default) */
  3477. y?: number,
  3478. /** defines the third component (0 by default) */
  3479. z?: number,
  3480. /** defines the fourth component (1.0 by default) */
  3481. w?: number);
  3482. /**
  3483. * Gets a string representation for the current quaternion
  3484. * @returns a string with the Quaternion coordinates
  3485. */
  3486. toString(): string;
  3487. /**
  3488. * Gets the class name of the quaternion
  3489. * @returns the string "Quaternion"
  3490. */
  3491. getClassName(): string;
  3492. /**
  3493. * Gets a hash code for this quaternion
  3494. * @returns the quaternion hash code
  3495. */
  3496. getHashCode(): number;
  3497. /**
  3498. * Copy the quaternion to an array
  3499. * @returns a new array populated with 4 elements from the quaternion coordinates
  3500. */
  3501. asArray(): number[];
  3502. /**
  3503. * Check if two quaternions are equals
  3504. * @param otherQuaternion defines the second operand
  3505. * @return true if the current quaternion and the given one coordinates are strictly equals
  3506. */
  3507. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3508. /**
  3509. * Clone the current quaternion
  3510. * @returns a new quaternion copied from the current one
  3511. */
  3512. clone(): Quaternion;
  3513. /**
  3514. * Copy a quaternion to the current one
  3515. * @param other defines the other quaternion
  3516. * @returns the updated current quaternion
  3517. */
  3518. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Updates the current quaternion with the given float coordinates
  3521. * @param x defines the x coordinate
  3522. * @param y defines the y coordinate
  3523. * @param z defines the z coordinate
  3524. * @param w defines the w coordinate
  3525. * @returns the updated current quaternion
  3526. */
  3527. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3528. /**
  3529. * Updates the current quaternion from the given float coordinates
  3530. * @param x defines the x coordinate
  3531. * @param y defines the y coordinate
  3532. * @param z defines the z coordinate
  3533. * @param w defines the w coordinate
  3534. * @returns the updated current quaternion
  3535. */
  3536. set(x: number, y: number, z: number, w: number): Quaternion;
  3537. /**
  3538. * Adds two quaternions
  3539. * @param other defines the second operand
  3540. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3541. */
  3542. add(other: DeepImmutable<Quaternion>): Quaternion;
  3543. /**
  3544. * Add a quaternion to the current one
  3545. * @param other defines the quaternion to add
  3546. * @returns the current quaternion
  3547. */
  3548. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3549. /**
  3550. * Subtract two quaternions
  3551. * @param other defines the second operand
  3552. * @returns a new quaternion as the subtraction result of the given one from the current one
  3553. */
  3554. subtract(other: Quaternion): Quaternion;
  3555. /**
  3556. * Multiplies the current quaternion by a scale factor
  3557. * @param value defines the scale factor
  3558. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3559. */
  3560. scale(value: number): Quaternion;
  3561. /**
  3562. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3563. * @param scale defines the scale factor
  3564. * @param result defines the Quaternion object where to store the result
  3565. * @returns the unmodified current quaternion
  3566. */
  3567. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3568. /**
  3569. * Multiplies in place the current quaternion by a scale factor
  3570. * @param value defines the scale factor
  3571. * @returns the current modified quaternion
  3572. */
  3573. scaleInPlace(value: number): Quaternion;
  3574. /**
  3575. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3576. * @param scale defines the scale factor
  3577. * @param result defines the Quaternion object where to store the result
  3578. * @returns the unmodified current quaternion
  3579. */
  3580. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3581. /**
  3582. * Multiplies two quaternions
  3583. * @param q1 defines the second operand
  3584. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3585. */
  3586. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3589. * @param q1 defines the second operand
  3590. * @param result defines the target quaternion
  3591. * @returns the current quaternion
  3592. */
  3593. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3594. /**
  3595. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3596. * @param q1 defines the second operand
  3597. * @returns the currentupdated quaternion
  3598. */
  3599. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3600. /**
  3601. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3602. * @param ref defines the target quaternion
  3603. * @returns the current quaternion
  3604. */
  3605. conjugateToRef(ref: Quaternion): Quaternion;
  3606. /**
  3607. * Conjugates in place (1-q) the current quaternion
  3608. * @returns the current updated quaternion
  3609. */
  3610. conjugateInPlace(): Quaternion;
  3611. /**
  3612. * Conjugates in place (1-q) the current quaternion
  3613. * @returns a new quaternion
  3614. */
  3615. conjugate(): Quaternion;
  3616. /**
  3617. * Gets length of current quaternion
  3618. * @returns the quaternion length (float)
  3619. */
  3620. length(): number;
  3621. /**
  3622. * Normalize in place the current quaternion
  3623. * @returns the current updated quaternion
  3624. */
  3625. normalize(): Quaternion;
  3626. /**
  3627. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3628. * @param order is a reserved parameter and is ignore for now
  3629. * @returns a new Vector3 containing the Euler angles
  3630. */
  3631. toEulerAngles(order?: string): Vector3;
  3632. /**
  3633. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3634. * @param result defines the vector which will be filled with the Euler angles
  3635. * @param order is a reserved parameter and is ignore for now
  3636. * @returns the current unchanged quaternion
  3637. */
  3638. toEulerAnglesToRef(result: Vector3): Quaternion;
  3639. /**
  3640. * Updates the given rotation matrix with the current quaternion values
  3641. * @param result defines the target matrix
  3642. * @returns the current unchanged quaternion
  3643. */
  3644. toRotationMatrix(result: Matrix): Quaternion;
  3645. /**
  3646. * Updates the current quaternion from the given rotation matrix values
  3647. * @param matrix defines the source matrix
  3648. * @returns the current updated quaternion
  3649. */
  3650. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3651. /**
  3652. * Creates a new quaternion from a rotation matrix
  3653. * @param matrix defines the source matrix
  3654. * @returns a new quaternion created from the given rotation matrix values
  3655. */
  3656. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3657. /**
  3658. * Updates the given quaternion with the given rotation matrix values
  3659. * @param matrix defines the source matrix
  3660. * @param result defines the target quaternion
  3661. */
  3662. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3663. /**
  3664. * Returns the dot product (float) between the quaternions "left" and "right"
  3665. * @param left defines the left operand
  3666. * @param right defines the right operand
  3667. * @returns the dot product
  3668. */
  3669. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3670. /**
  3671. * Checks if the two quaternions are close to each other
  3672. * @param quat0 defines the first quaternion to check
  3673. * @param quat1 defines the second quaternion to check
  3674. * @returns true if the two quaternions are close to each other
  3675. */
  3676. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3677. /**
  3678. * Creates an empty quaternion
  3679. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3680. */
  3681. static Zero(): Quaternion;
  3682. /**
  3683. * Inverse a given quaternion
  3684. * @param q defines the source quaternion
  3685. * @returns a new quaternion as the inverted current quaternion
  3686. */
  3687. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3688. /**
  3689. * Inverse a given quaternion
  3690. * @param q defines the source quaternion
  3691. * @param result the quaternion the result will be stored in
  3692. * @returns the result quaternion
  3693. */
  3694. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3695. /**
  3696. * Creates an identity quaternion
  3697. * @returns the identity quaternion
  3698. */
  3699. static Identity(): Quaternion;
  3700. /**
  3701. * Gets a boolean indicating if the given quaternion is identity
  3702. * @param quaternion defines the quaternion to check
  3703. * @returns true if the quaternion is identity
  3704. */
  3705. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3706. /**
  3707. * Creates a quaternion from a rotation around an axis
  3708. * @param axis defines the axis to use
  3709. * @param angle defines the angle to use
  3710. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3711. */
  3712. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3713. /**
  3714. * Creates a rotation around an axis and stores it into the given quaternion
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle to use
  3717. * @param result defines the target quaternion
  3718. * @returns the target quaternion
  3719. */
  3720. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3721. /**
  3722. * Creates a new quaternion from data stored into an array
  3723. * @param array defines the data source
  3724. * @param offset defines the offset in the source array where the data starts
  3725. * @returns a new quaternion
  3726. */
  3727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3728. /**
  3729. * Create a quaternion from Euler rotation angles
  3730. * @param x Pitch
  3731. * @param y Yaw
  3732. * @param z Roll
  3733. * @returns the new Quaternion
  3734. */
  3735. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3736. /**
  3737. * Updates a quaternion from Euler rotation angles
  3738. * @param x Pitch
  3739. * @param y Yaw
  3740. * @param z Roll
  3741. * @param result the quaternion to store the result
  3742. * @returns the updated quaternion
  3743. */
  3744. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3745. /**
  3746. * Create a quaternion from Euler rotation vector
  3747. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3748. * @returns the new Quaternion
  3749. */
  3750. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3751. /**
  3752. * Updates a quaternion from Euler rotation vector
  3753. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3754. * @param result the quaternion to store the result
  3755. * @returns the updated quaternion
  3756. */
  3757. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3758. /**
  3759. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3760. * @param yaw defines the rotation around Y axis
  3761. * @param pitch defines the rotation around X axis
  3762. * @param roll defines the rotation around Z axis
  3763. * @returns the new quaternion
  3764. */
  3765. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3766. /**
  3767. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3768. * @param yaw defines the rotation around Y axis
  3769. * @param pitch defines the rotation around X axis
  3770. * @param roll defines the rotation around Z axis
  3771. * @param result defines the target quaternion
  3772. */
  3773. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3774. /**
  3775. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3776. * @param alpha defines the rotation around first axis
  3777. * @param beta defines the rotation around second axis
  3778. * @param gamma defines the rotation around third axis
  3779. * @returns the new quaternion
  3780. */
  3781. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3782. /**
  3783. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3784. * @param alpha defines the rotation around first axis
  3785. * @param beta defines the rotation around second axis
  3786. * @param gamma defines the rotation around third axis
  3787. * @param result defines the target quaternion
  3788. */
  3789. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3790. /**
  3791. * 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)
  3792. * @param axis1 defines the first axis
  3793. * @param axis2 defines the second axis
  3794. * @param axis3 defines the third axis
  3795. * @returns the new quaternion
  3796. */
  3797. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3798. /**
  3799. * 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
  3800. * @param axis1 defines the first axis
  3801. * @param axis2 defines the second axis
  3802. * @param axis3 defines the third axis
  3803. * @param ref defines the target quaternion
  3804. */
  3805. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3806. /**
  3807. * Interpolates between two quaternions
  3808. * @param left defines first quaternion
  3809. * @param right defines second quaternion
  3810. * @param amount defines the gradient to use
  3811. * @returns the new interpolated quaternion
  3812. */
  3813. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3814. /**
  3815. * Interpolates between two quaternions and stores it into a target quaternion
  3816. * @param left defines first quaternion
  3817. * @param right defines second quaternion
  3818. * @param amount defines the gradient to use
  3819. * @param result defines the target quaternion
  3820. */
  3821. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3822. /**
  3823. * Interpolate between two quaternions using Hermite interpolation
  3824. * @param value1 defines first quaternion
  3825. * @param tangent1 defines the incoming tangent
  3826. * @param value2 defines second quaternion
  3827. * @param tangent2 defines the outgoing tangent
  3828. * @param amount defines the target quaternion
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. }
  3833. /**
  3834. * Class used to store matrix data (4x4)
  3835. */
  3836. export class Matrix {
  3837. private static _updateFlagSeed;
  3838. private static _identityReadOnly;
  3839. private _isIdentity;
  3840. private _isIdentityDirty;
  3841. private _isIdentity3x2;
  3842. private _isIdentity3x2Dirty;
  3843. /**
  3844. * Gets the update flag of the matrix which is an unique number for the matrix.
  3845. * It will be incremented every time the matrix data change.
  3846. * You can use it to speed the comparison between two versions of the same matrix.
  3847. */
  3848. updateFlag: number;
  3849. private readonly _m;
  3850. /**
  3851. * Gets the internal data of the matrix
  3852. */
  3853. readonly m: DeepImmutable<Float32Array>;
  3854. /** @hidden */
  3855. _markAsUpdated(): void;
  3856. /** @hidden */
  3857. private _updateIdentityStatus;
  3858. /**
  3859. * Creates an empty matrix (filled with zeros)
  3860. */
  3861. constructor();
  3862. /**
  3863. * Check if the current matrix is identity
  3864. * @returns true is the matrix is the identity matrix
  3865. */
  3866. isIdentity(): boolean;
  3867. /**
  3868. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3869. * @returns true is the matrix is the identity matrix
  3870. */
  3871. isIdentityAs3x2(): boolean;
  3872. /**
  3873. * Gets the determinant of the matrix
  3874. * @returns the matrix determinant
  3875. */
  3876. determinant(): number;
  3877. /**
  3878. * Returns the matrix as a Float32Array
  3879. * @returns the matrix underlying array
  3880. */
  3881. toArray(): DeepImmutable<Float32Array>;
  3882. /**
  3883. * Returns the matrix as a Float32Array
  3884. * @returns the matrix underlying array.
  3885. */
  3886. asArray(): DeepImmutable<Float32Array>;
  3887. /**
  3888. * Inverts the current matrix in place
  3889. * @returns the current inverted matrix
  3890. */
  3891. invert(): Matrix;
  3892. /**
  3893. * Sets all the matrix elements to zero
  3894. * @returns the current matrix
  3895. */
  3896. reset(): Matrix;
  3897. /**
  3898. * Adds the current matrix with a second one
  3899. * @param other defines the matrix to add
  3900. * @returns a new matrix as the addition of the current matrix and the given one
  3901. */
  3902. add(other: DeepImmutable<Matrix>): Matrix;
  3903. /**
  3904. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3905. * @param other defines the matrix to add
  3906. * @param result defines the target matrix
  3907. * @returns the current matrix
  3908. */
  3909. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3910. /**
  3911. * Adds in place the given matrix to the current matrix
  3912. * @param other defines the second operand
  3913. * @returns the current updated matrix
  3914. */
  3915. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3916. /**
  3917. * Sets the given matrix to the current inverted Matrix
  3918. * @param other defines the target matrix
  3919. * @returns the unmodified current matrix
  3920. */
  3921. invertToRef(other: Matrix): Matrix;
  3922. /**
  3923. * add a value at the specified position in the current Matrix
  3924. * @param index the index of the value within the matrix. between 0 and 15.
  3925. * @param value the value to be added
  3926. * @returns the current updated matrix
  3927. */
  3928. addAtIndex(index: number, value: number): Matrix;
  3929. /**
  3930. * mutiply the specified position in the current Matrix by a value
  3931. * @param index the index of the value within the matrix. between 0 and 15.
  3932. * @param value the value to be added
  3933. * @returns the current updated matrix
  3934. */
  3935. multiplyAtIndex(index: number, value: number): Matrix;
  3936. /**
  3937. * Inserts the translation vector (using 3 floats) in the current matrix
  3938. * @param x defines the 1st component of the translation
  3939. * @param y defines the 2nd component of the translation
  3940. * @param z defines the 3rd component of the translation
  3941. * @returns the current updated matrix
  3942. */
  3943. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3944. /**
  3945. * Adds the translation vector (using 3 floats) in the current matrix
  3946. * @param x defines the 1st component of the translation
  3947. * @param y defines the 2nd component of the translation
  3948. * @param z defines the 3rd component of the translation
  3949. * @returns the current updated matrix
  3950. */
  3951. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3952. /**
  3953. * Inserts the translation vector in the current matrix
  3954. * @param vector3 defines the translation to insert
  3955. * @returns the current updated matrix
  3956. */
  3957. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3958. /**
  3959. * Gets the translation value of the current matrix
  3960. * @returns a new Vector3 as the extracted translation from the matrix
  3961. */
  3962. getTranslation(): Vector3;
  3963. /**
  3964. * Fill a Vector3 with the extracted translation from the matrix
  3965. * @param result defines the Vector3 where to store the translation
  3966. * @returns the current matrix
  3967. */
  3968. getTranslationToRef(result: Vector3): Matrix;
  3969. /**
  3970. * Remove rotation and scaling part from the matrix
  3971. * @returns the updated matrix
  3972. */
  3973. removeRotationAndScaling(): Matrix;
  3974. /**
  3975. * Multiply two matrices
  3976. * @param other defines the second operand
  3977. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3978. */
  3979. multiply(other: DeepImmutable<Matrix>): Matrix;
  3980. /**
  3981. * Copy the current matrix from the given one
  3982. * @param other defines the source matrix
  3983. * @returns the current updated matrix
  3984. */
  3985. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3986. /**
  3987. * Populates the given array from the starting index with the current matrix values
  3988. * @param array defines the target array
  3989. * @param offset defines the offset in the target array where to start storing values
  3990. * @returns the current matrix
  3991. */
  3992. copyToArray(array: Float32Array, offset?: number): Matrix;
  3993. /**
  3994. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3995. * @param other defines the second operand
  3996. * @param result defines the matrix where to store the multiplication
  3997. * @returns the current matrix
  3998. */
  3999. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4000. /**
  4001. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4002. * @param other defines the second operand
  4003. * @param result defines the array where to store the multiplication
  4004. * @param offset defines the offset in the target array where to start storing values
  4005. * @returns the current matrix
  4006. */
  4007. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4008. /**
  4009. * Check equality between this matrix and a second one
  4010. * @param value defines the second matrix to compare
  4011. * @returns true is the current matrix and the given one values are strictly equal
  4012. */
  4013. equals(value: DeepImmutable<Matrix>): boolean;
  4014. /**
  4015. * Clone the current matrix
  4016. * @returns a new matrix from the current matrix
  4017. */
  4018. clone(): Matrix;
  4019. /**
  4020. * Returns the name of the current matrix class
  4021. * @returns the string "Matrix"
  4022. */
  4023. getClassName(): string;
  4024. /**
  4025. * Gets the hash code of the current matrix
  4026. * @returns the hash code
  4027. */
  4028. getHashCode(): number;
  4029. /**
  4030. * Decomposes the current Matrix into a translation, rotation and scaling components
  4031. * @param scale defines the scale vector3 given as a reference to update
  4032. * @param rotation defines the rotation quaternion given as a reference to update
  4033. * @param translation defines the translation vector3 given as a reference to update
  4034. * @returns true if operation was successful
  4035. */
  4036. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4037. /**
  4038. * Gets specific row of the matrix
  4039. * @param index defines the number of the row to get
  4040. * @returns the index-th row of the current matrix as a new Vector4
  4041. */
  4042. getRow(index: number): Nullable<Vector4>;
  4043. /**
  4044. * Sets the index-th row of the current matrix to the vector4 values
  4045. * @param index defines the number of the row to set
  4046. * @param row defines the target vector4
  4047. * @returns the updated current matrix
  4048. */
  4049. setRow(index: number, row: Vector4): Matrix;
  4050. /**
  4051. * Compute the transpose of the matrix
  4052. * @returns the new transposed matrix
  4053. */
  4054. transpose(): Matrix;
  4055. /**
  4056. * Compute the transpose of the matrix and store it in a given matrix
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. transposeToRef(result: Matrix): Matrix;
  4061. /**
  4062. * Sets the index-th row of the current matrix with the given 4 x float values
  4063. * @param index defines the row index
  4064. * @param x defines the x component to set
  4065. * @param y defines the y component to set
  4066. * @param z defines the z component to set
  4067. * @param w defines the w component to set
  4068. * @returns the updated current matrix
  4069. */
  4070. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4071. /**
  4072. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4073. * @param scale defines the scale factor
  4074. * @returns a new matrix
  4075. */
  4076. scale(scale: number): Matrix;
  4077. /**
  4078. * Scale the current matrix values by a factor to a given result matrix
  4079. * @param scale defines the scale factor
  4080. * @param result defines the matrix to store the result
  4081. * @returns the current matrix
  4082. */
  4083. scaleToRef(scale: number, result: Matrix): Matrix;
  4084. /**
  4085. * Scale the current matrix values by a factor and add the result to a given matrix
  4086. * @param scale defines the scale factor
  4087. * @param result defines the Matrix to store the result
  4088. * @returns the current matrix
  4089. */
  4090. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4091. /**
  4092. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4093. * @param ref matrix to store the result
  4094. */
  4095. toNormalMatrix(ref: Matrix): void;
  4096. /**
  4097. * Gets only rotation part of the current matrix
  4098. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4099. */
  4100. getRotationMatrix(): Matrix;
  4101. /**
  4102. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4103. * @param result defines the target matrix to store data to
  4104. * @returns the current matrix
  4105. */
  4106. getRotationMatrixToRef(result: Matrix): Matrix;
  4107. /**
  4108. * Toggles model matrix from being right handed to left handed in place and vice versa
  4109. */
  4110. toggleModelMatrixHandInPlace(): void;
  4111. /**
  4112. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4113. */
  4114. toggleProjectionMatrixHandInPlace(): void;
  4115. /**
  4116. * Creates a matrix from an array
  4117. * @param array defines the source array
  4118. * @param offset defines an offset in the source array
  4119. * @returns a new Matrix set from the starting index of the given array
  4120. */
  4121. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4122. /**
  4123. * Copy the content of an array into a given matrix
  4124. * @param array defines the source array
  4125. * @param offset defines an offset in the source array
  4126. * @param result defines the target matrix
  4127. */
  4128. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4129. /**
  4130. * Stores an array into a matrix after having multiplied each component by a given factor
  4131. * @param array defines the source array
  4132. * @param offset defines the offset in the source array
  4133. * @param scale defines the scaling factor
  4134. * @param result defines the target matrix
  4135. */
  4136. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4137. /**
  4138. * Gets an identity matrix that must not be updated
  4139. */
  4140. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4141. /**
  4142. * Stores a list of values (16) inside a given matrix
  4143. * @param initialM11 defines 1st value of 1st row
  4144. * @param initialM12 defines 2nd value of 1st row
  4145. * @param initialM13 defines 3rd value of 1st row
  4146. * @param initialM14 defines 4th value of 1st row
  4147. * @param initialM21 defines 1st value of 2nd row
  4148. * @param initialM22 defines 2nd value of 2nd row
  4149. * @param initialM23 defines 3rd value of 2nd row
  4150. * @param initialM24 defines 4th value of 2nd row
  4151. * @param initialM31 defines 1st value of 3rd row
  4152. * @param initialM32 defines 2nd value of 3rd row
  4153. * @param initialM33 defines 3rd value of 3rd row
  4154. * @param initialM34 defines 4th value of 3rd row
  4155. * @param initialM41 defines 1st value of 4th row
  4156. * @param initialM42 defines 2nd value of 4th row
  4157. * @param initialM43 defines 3rd value of 4th row
  4158. * @param initialM44 defines 4th value of 4th row
  4159. * @param result defines the target matrix
  4160. */
  4161. 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;
  4162. /**
  4163. * Creates new matrix from a list of values (16)
  4164. * @param initialM11 defines 1st value of 1st row
  4165. * @param initialM12 defines 2nd value of 1st row
  4166. * @param initialM13 defines 3rd value of 1st row
  4167. * @param initialM14 defines 4th value of 1st row
  4168. * @param initialM21 defines 1st value of 2nd row
  4169. * @param initialM22 defines 2nd value of 2nd row
  4170. * @param initialM23 defines 3rd value of 2nd row
  4171. * @param initialM24 defines 4th value of 2nd row
  4172. * @param initialM31 defines 1st value of 3rd row
  4173. * @param initialM32 defines 2nd value of 3rd row
  4174. * @param initialM33 defines 3rd value of 3rd row
  4175. * @param initialM34 defines 4th value of 3rd row
  4176. * @param initialM41 defines 1st value of 4th row
  4177. * @param initialM42 defines 2nd value of 4th row
  4178. * @param initialM43 defines 3rd value of 4th row
  4179. * @param initialM44 defines 4th value of 4th row
  4180. * @returns the new matrix
  4181. */
  4182. 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;
  4183. /**
  4184. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4185. * @param scale defines the scale vector3
  4186. * @param rotation defines the rotation quaternion
  4187. * @param translation defines the translation vector3
  4188. * @returns a new matrix
  4189. */
  4190. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4191. /**
  4192. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4193. * @param scale defines the scale vector3
  4194. * @param rotation defines the rotation quaternion
  4195. * @param translation defines the translation vector3
  4196. * @param result defines the target matrix
  4197. */
  4198. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4199. /**
  4200. * Creates a new identity matrix
  4201. * @returns a new identity matrix
  4202. */
  4203. static Identity(): Matrix;
  4204. /**
  4205. * Creates a new identity matrix and stores the result in a given matrix
  4206. * @param result defines the target matrix
  4207. */
  4208. static IdentityToRef(result: Matrix): void;
  4209. /**
  4210. * Creates a new zero matrix
  4211. * @returns a new zero matrix
  4212. */
  4213. static Zero(): Matrix;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the X axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationX(angle: number): Matrix;
  4220. /**
  4221. * Creates a new matrix as the invert of a given matrix
  4222. * @param source defines the source matrix
  4223. * @returns the new matrix
  4224. */
  4225. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4228. * @param angle defines the angle (in radians) to use
  4229. * @param result defines the target matrix
  4230. */
  4231. static RotationXToRef(angle: number, result: Matrix): void;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the Y axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationY(angle: number): Matrix;
  4238. /**
  4239. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4240. * @param angle defines the angle (in radians) to use
  4241. * @param result defines the target matrix
  4242. */
  4243. static RotationYToRef(angle: number, result: Matrix): void;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the Z axis
  4246. * @param angle defines the angle (in radians) to use
  4247. * @return the new matrix
  4248. */
  4249. static RotationZ(angle: number): Matrix;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4252. * @param angle defines the angle (in radians) to use
  4253. * @param result defines the target matrix
  4254. */
  4255. static RotationZToRef(angle: number, result: Matrix): void;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the given axis
  4258. * @param axis defines the axis to use
  4259. * @param angle defines the angle (in radians) to use
  4260. * @return the new matrix
  4261. */
  4262. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4265. * @param axis defines the axis to use
  4266. * @param angle defines the angle (in radians) to use
  4267. * @param result defines the target matrix
  4268. */
  4269. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4270. /**
  4271. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4272. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4273. * @param from defines the vector to align
  4274. * @param to defines the vector to align to
  4275. * @param result defines the target matrix
  4276. */
  4277. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4278. /**
  4279. * Creates a rotation matrix
  4280. * @param yaw defines the yaw angle in radians (Y axis)
  4281. * @param pitch defines the pitch angle in radians (X axis)
  4282. * @param roll defines the roll angle in radians (X axis)
  4283. * @returns the new rotation matrix
  4284. */
  4285. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4286. /**
  4287. * Creates a rotation matrix and stores it in a given matrix
  4288. * @param yaw defines the yaw angle in radians (Y axis)
  4289. * @param pitch defines the pitch angle in radians (X axis)
  4290. * @param roll defines the roll angle in radians (X axis)
  4291. * @param result defines the target matrix
  4292. */
  4293. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4294. /**
  4295. * Creates a scaling matrix
  4296. * @param x defines the scale factor on X axis
  4297. * @param y defines the scale factor on Y axis
  4298. * @param z defines the scale factor on Z axis
  4299. * @returns the new matrix
  4300. */
  4301. static Scaling(x: number, y: number, z: number): Matrix;
  4302. /**
  4303. * Creates a scaling matrix and stores it in a given matrix
  4304. * @param x defines the scale factor on X axis
  4305. * @param y defines the scale factor on Y axis
  4306. * @param z defines the scale factor on Z axis
  4307. * @param result defines the target matrix
  4308. */
  4309. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4310. /**
  4311. * Creates a translation matrix
  4312. * @param x defines the translation on X axis
  4313. * @param y defines the translation on Y axis
  4314. * @param z defines the translationon Z axis
  4315. * @returns the new matrix
  4316. */
  4317. static Translation(x: number, y: number, z: number): Matrix;
  4318. /**
  4319. * Creates a translation matrix and stores it in a given matrix
  4320. * @param x defines the translation on X axis
  4321. * @param y defines the translation on Y axis
  4322. * @param z defines the translationon Z axis
  4323. * @param result defines the target matrix
  4324. */
  4325. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4326. /**
  4327. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4328. * @param startValue defines the start value
  4329. * @param endValue defines the end value
  4330. * @param gradient defines the gradient factor
  4331. * @returns the new matrix
  4332. */
  4333. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4334. /**
  4335. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4336. * @param startValue defines the start value
  4337. * @param endValue defines the end value
  4338. * @param gradient defines the gradient factor
  4339. * @param result defines the Matrix object where to store data
  4340. */
  4341. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4342. /**
  4343. * Builds a new matrix whose values are computed by:
  4344. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4345. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4346. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4347. * @param startValue defines the first matrix
  4348. * @param endValue defines the second matrix
  4349. * @param gradient defines the gradient between the two matrices
  4350. * @returns the new matrix
  4351. */
  4352. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4353. /**
  4354. * Update a matrix to values which are computed by:
  4355. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4356. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4357. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4358. * @param startValue defines the first matrix
  4359. * @param endValue defines the second matrix
  4360. * @param gradient defines the gradient between the two matrices
  4361. * @param result defines the target matrix
  4362. */
  4363. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4364. /**
  4365. * 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"
  4366. * This function works in left handed mode
  4367. * @param eye defines the final position of the entity
  4368. * @param target defines where the entity should look at
  4369. * @param up defines the up vector for the entity
  4370. * @returns the new matrix
  4371. */
  4372. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4373. /**
  4374. * 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".
  4375. * This function works in left handed mode
  4376. * @param eye defines the final position of the entity
  4377. * @param target defines where the entity should look at
  4378. * @param up defines the up vector for the entity
  4379. * @param result defines the target matrix
  4380. */
  4381. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4382. /**
  4383. * 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"
  4384. * This function works in right handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * 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".
  4393. * This function works in right handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * Create a left-handed orthographic projection matrix
  4402. * @param width defines the viewport width
  4403. * @param height defines the viewport height
  4404. * @param znear defines the near clip plane
  4405. * @param zfar defines the far clip plane
  4406. * @returns a new matrix as a left-handed orthographic projection matrix
  4407. */
  4408. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4409. /**
  4410. * Store a left-handed orthographic projection to a given matrix
  4411. * @param width defines the viewport width
  4412. * @param height defines the viewport height
  4413. * @param znear defines the near clip plane
  4414. * @param zfar defines the far clip plane
  4415. * @param result defines the target matrix
  4416. */
  4417. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param left defines the viewport left coordinate
  4421. * @param right defines the viewport right coordinate
  4422. * @param bottom defines the viewport bottom coordinate
  4423. * @param top defines the viewport top coordinate
  4424. * @param znear defines the near clip plane
  4425. * @param zfar defines the far clip plane
  4426. * @returns a new matrix as a left-handed orthographic projection matrix
  4427. */
  4428. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4429. /**
  4430. * Stores a left-handed orthographic projection into a given matrix
  4431. * @param left defines the viewport left coordinate
  4432. * @param right defines the viewport right coordinate
  4433. * @param bottom defines the viewport bottom coordinate
  4434. * @param top defines the viewport top coordinate
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @param result defines the target matrix
  4438. */
  4439. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4440. /**
  4441. * Creates a right-handed orthographic projection matrix
  4442. * @param left defines the viewport left coordinate
  4443. * @param right defines the viewport right coordinate
  4444. * @param bottom defines the viewport bottom coordinate
  4445. * @param top defines the viewport top coordinate
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @returns a new matrix as a right-handed orthographic projection matrix
  4449. */
  4450. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4451. /**
  4452. * Stores a right-handed orthographic projection into a given matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @param result defines the target matrix
  4460. */
  4461. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4462. /**
  4463. * Creates a left-handed perspective projection matrix
  4464. * @param width defines the viewport width
  4465. * @param height defines the viewport height
  4466. * @param znear defines the near clip plane
  4467. * @param zfar defines the far clip plane
  4468. * @returns a new matrix as a left-handed perspective projection matrix
  4469. */
  4470. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4471. /**
  4472. * Creates a left-handed perspective projection matrix
  4473. * @param fov defines the horizontal field of view
  4474. * @param aspect defines the aspect ratio
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed perspective projection matrix
  4478. */
  4479. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed perspective projection into a given matrix
  4482. * @param fov defines the horizontal field of view
  4483. * @param aspect defines the aspect ratio
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4488. */
  4489. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4490. /**
  4491. * Creates a right-handed perspective projection matrix
  4492. * @param fov defines the horizontal field of view
  4493. * @param aspect defines the aspect ratio
  4494. * @param znear defines the near clip plane
  4495. * @param zfar defines the far clip plane
  4496. * @returns a new matrix as a right-handed perspective projection matrix
  4497. */
  4498. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4499. /**
  4500. * Stores a right-handed perspective projection into a given matrix
  4501. * @param fov defines the horizontal field of view
  4502. * @param aspect defines the aspect ratio
  4503. * @param znear defines the near clip plane
  4504. * @param zfar defines the far clip plane
  4505. * @param result defines the target matrix
  4506. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4507. */
  4508. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4509. /**
  4510. * Stores a perspective projection for WebVR info a given matrix
  4511. * @param fov defines the field of view
  4512. * @param znear defines the near clip plane
  4513. * @param zfar defines the far clip plane
  4514. * @param result defines the target matrix
  4515. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4516. */
  4517. static PerspectiveFovWebVRToRef(fov: {
  4518. upDegrees: number;
  4519. downDegrees: number;
  4520. leftDegrees: number;
  4521. rightDegrees: number;
  4522. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4523. /**
  4524. * Computes a complete transformation matrix
  4525. * @param viewport defines the viewport to use
  4526. * @param world defines the world matrix
  4527. * @param view defines the view matrix
  4528. * @param projection defines the projection matrix
  4529. * @param zmin defines the near clip plane
  4530. * @param zmax defines the far clip plane
  4531. * @returns the transformation matrix
  4532. */
  4533. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4534. /**
  4535. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4536. * @param matrix defines the matrix to use
  4537. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4538. */
  4539. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4540. /**
  4541. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4542. * @param matrix defines the matrix to use
  4543. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4544. */
  4545. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4546. /**
  4547. * Compute the transpose of a given matrix
  4548. * @param matrix defines the matrix to transpose
  4549. * @returns the new matrix
  4550. */
  4551. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4552. /**
  4553. * Compute the transpose of a matrix and store it in a target matrix
  4554. * @param matrix defines the matrix to transpose
  4555. * @param result defines the target matrix
  4556. */
  4557. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4558. /**
  4559. * Computes a reflection matrix from a plane
  4560. * @param plane defines the reflection plane
  4561. * @returns a new matrix
  4562. */
  4563. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4564. /**
  4565. * Computes a reflection matrix from a plane
  4566. * @param plane defines the reflection plane
  4567. * @param result defines the target matrix
  4568. */
  4569. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4570. /**
  4571. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4572. * @param xaxis defines the value of the 1st axis
  4573. * @param yaxis defines the value of the 2nd axis
  4574. * @param zaxis defines the value of the 3rd axis
  4575. * @param result defines the target matrix
  4576. */
  4577. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4578. /**
  4579. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4580. * @param quat defines the quaternion to use
  4581. * @param result defines the target matrix
  4582. */
  4583. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4584. }
  4585. /**
  4586. * @hidden
  4587. */
  4588. export class TmpVectors {
  4589. static Vector2: Vector2[];
  4590. static Vector3: Vector3[];
  4591. static Vector4: Vector4[];
  4592. static Quaternion: Quaternion[];
  4593. static Matrix: Matrix[];
  4594. }
  4595. }
  4596. declare module "babylonjs/Maths/math.path" {
  4597. import { DeepImmutable, Nullable } from "babylonjs/types";
  4598. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4599. /**
  4600. * Defines potential orientation for back face culling
  4601. */
  4602. export enum Orientation {
  4603. /**
  4604. * Clockwise
  4605. */
  4606. CW = 0,
  4607. /** Counter clockwise */
  4608. CCW = 1
  4609. }
  4610. /** Class used to represent a Bezier curve */
  4611. export class BezierCurve {
  4612. /**
  4613. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4614. * @param t defines the time
  4615. * @param x1 defines the left coordinate on X axis
  4616. * @param y1 defines the left coordinate on Y axis
  4617. * @param x2 defines the right coordinate on X axis
  4618. * @param y2 defines the right coordinate on Y axis
  4619. * @returns the interpolated value
  4620. */
  4621. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4622. }
  4623. /**
  4624. * Defines angle representation
  4625. */
  4626. export class Angle {
  4627. private _radians;
  4628. /**
  4629. * Creates an Angle object of "radians" radians (float).
  4630. * @param radians the angle in radians
  4631. */
  4632. constructor(radians: number);
  4633. /**
  4634. * Get value in degrees
  4635. * @returns the Angle value in degrees (float)
  4636. */
  4637. degrees(): number;
  4638. /**
  4639. * Get value in radians
  4640. * @returns the Angle value in radians (float)
  4641. */
  4642. radians(): number;
  4643. /**
  4644. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4645. * @param a defines first vector
  4646. * @param b defines second vector
  4647. * @returns a new Angle
  4648. */
  4649. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4650. /**
  4651. * Gets a new Angle object from the given float in radians
  4652. * @param radians defines the angle value in radians
  4653. * @returns a new Angle
  4654. */
  4655. static FromRadians(radians: number): Angle;
  4656. /**
  4657. * Gets a new Angle object from the given float in degrees
  4658. * @param degrees defines the angle value in degrees
  4659. * @returns a new Angle
  4660. */
  4661. static FromDegrees(degrees: number): Angle;
  4662. }
  4663. /**
  4664. * This represents an arc in a 2d space.
  4665. */
  4666. export class Arc2 {
  4667. /** Defines the start point of the arc */
  4668. startPoint: Vector2;
  4669. /** Defines the mid point of the arc */
  4670. midPoint: Vector2;
  4671. /** Defines the end point of the arc */
  4672. endPoint: Vector2;
  4673. /**
  4674. * Defines the center point of the arc.
  4675. */
  4676. centerPoint: Vector2;
  4677. /**
  4678. * Defines the radius of the arc.
  4679. */
  4680. radius: number;
  4681. /**
  4682. * Defines the angle of the arc (from mid point to end point).
  4683. */
  4684. angle: Angle;
  4685. /**
  4686. * Defines the start angle of the arc (from start point to middle point).
  4687. */
  4688. startAngle: Angle;
  4689. /**
  4690. * Defines the orientation of the arc (clock wise/counter clock wise).
  4691. */
  4692. orientation: Orientation;
  4693. /**
  4694. * Creates an Arc object from the three given points : start, middle and end.
  4695. * @param startPoint Defines the start point of the arc
  4696. * @param midPoint Defines the midlle point of the arc
  4697. * @param endPoint Defines the end point of the arc
  4698. */
  4699. constructor(
  4700. /** Defines the start point of the arc */
  4701. startPoint: Vector2,
  4702. /** Defines the mid point of the arc */
  4703. midPoint: Vector2,
  4704. /** Defines the end point of the arc */
  4705. endPoint: Vector2);
  4706. }
  4707. /**
  4708. * Represents a 2D path made up of multiple 2D points
  4709. */
  4710. export class Path2 {
  4711. private _points;
  4712. private _length;
  4713. /**
  4714. * If the path start and end point are the same
  4715. */
  4716. closed: boolean;
  4717. /**
  4718. * Creates a Path2 object from the starting 2D coordinates x and y.
  4719. * @param x the starting points x value
  4720. * @param y the starting points y value
  4721. */
  4722. constructor(x: number, y: number);
  4723. /**
  4724. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4725. * @param x the added points x value
  4726. * @param y the added points y value
  4727. * @returns the updated Path2.
  4728. */
  4729. addLineTo(x: number, y: number): Path2;
  4730. /**
  4731. * 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.
  4732. * @param midX middle point x value
  4733. * @param midY middle point y value
  4734. * @param endX end point x value
  4735. * @param endY end point y value
  4736. * @param numberOfSegments (default: 36)
  4737. * @returns the updated Path2.
  4738. */
  4739. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4740. /**
  4741. * Closes the Path2.
  4742. * @returns the Path2.
  4743. */
  4744. close(): Path2;
  4745. /**
  4746. * Gets the sum of the distance between each sequential point in the path
  4747. * @returns the Path2 total length (float).
  4748. */
  4749. length(): number;
  4750. /**
  4751. * Gets the points which construct the path
  4752. * @returns the Path2 internal array of points.
  4753. */
  4754. getPoints(): Vector2[];
  4755. /**
  4756. * Retreives the point at the distance aways from the starting point
  4757. * @param normalizedLengthPosition the length along the path to retreive the point from
  4758. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4759. */
  4760. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4761. /**
  4762. * Creates a new path starting from an x and y position
  4763. * @param x starting x value
  4764. * @param y starting y value
  4765. * @returns a new Path2 starting at the coordinates (x, y).
  4766. */
  4767. static StartingAt(x: number, y: number): Path2;
  4768. }
  4769. /**
  4770. * Represents a 3D path made up of multiple 3D points
  4771. */
  4772. export class Path3D {
  4773. /**
  4774. * an array of Vector3, the curve axis of the Path3D
  4775. */
  4776. path: Vector3[];
  4777. private _curve;
  4778. private _distances;
  4779. private _tangents;
  4780. private _normals;
  4781. private _binormals;
  4782. private _raw;
  4783. /**
  4784. * new Path3D(path, normal, raw)
  4785. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4786. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4787. * @param path an array of Vector3, the curve axis of the Path3D
  4788. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4789. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4790. */
  4791. constructor(
  4792. /**
  4793. * an array of Vector3, the curve axis of the Path3D
  4794. */
  4795. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4796. /**
  4797. * Returns the Path3D array of successive Vector3 designing its curve.
  4798. * @returns the Path3D array of successive Vector3 designing its curve.
  4799. */
  4800. getCurve(): Vector3[];
  4801. /**
  4802. * Returns an array populated with tangent vectors on each Path3D curve point.
  4803. * @returns an array populated with tangent vectors on each Path3D curve point.
  4804. */
  4805. getTangents(): Vector3[];
  4806. /**
  4807. * Returns an array populated with normal vectors on each Path3D curve point.
  4808. * @returns an array populated with normal vectors on each Path3D curve point.
  4809. */
  4810. getNormals(): Vector3[];
  4811. /**
  4812. * Returns an array populated with binormal vectors on each Path3D curve point.
  4813. * @returns an array populated with binormal vectors on each Path3D curve point.
  4814. */
  4815. getBinormals(): Vector3[];
  4816. /**
  4817. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4818. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4819. */
  4820. getDistances(): number[];
  4821. /**
  4822. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4823. * @param path path which all values are copied into the curves points
  4824. * @param firstNormal which should be projected onto the curve
  4825. * @returns the same object updated.
  4826. */
  4827. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4828. private _compute;
  4829. private _getFirstNonNullVector;
  4830. private _getLastNonNullVector;
  4831. private _normalVector;
  4832. }
  4833. /**
  4834. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4835. * A Curve3 is designed from a series of successive Vector3.
  4836. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4837. */
  4838. export class Curve3 {
  4839. private _points;
  4840. private _length;
  4841. /**
  4842. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4843. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4844. * @param v1 (Vector3) the control point
  4845. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4846. * @param nbPoints (integer) the wanted number of points in the curve
  4847. * @returns the created Curve3
  4848. */
  4849. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4850. /**
  4851. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4852. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4853. * @param v1 (Vector3) the first control point
  4854. * @param v2 (Vector3) the second control point
  4855. * @param v3 (Vector3) the end point of the Cubic Bezier
  4856. * @param nbPoints (integer) the wanted number of points in the curve
  4857. * @returns the created Curve3
  4858. */
  4859. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4860. /**
  4861. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4862. * @param p1 (Vector3) the origin point of the Hermite Spline
  4863. * @param t1 (Vector3) the tangent vector at the origin point
  4864. * @param p2 (Vector3) the end point of the Hermite Spline
  4865. * @param t2 (Vector3) the tangent vector at the end point
  4866. * @param nbPoints (integer) the wanted number of points in the curve
  4867. * @returns the created Curve3
  4868. */
  4869. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4870. /**
  4871. * Returns a Curve3 object along a CatmullRom Spline curve :
  4872. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4873. * @param nbPoints (integer) the wanted number of points between each curve control points
  4874. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4875. * @returns the created Curve3
  4876. */
  4877. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4878. /**
  4879. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4880. * A Curve3 is designed from a series of successive Vector3.
  4881. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4882. * @param points points which make up the curve
  4883. */
  4884. constructor(points: Vector3[]);
  4885. /**
  4886. * @returns the Curve3 stored array of successive Vector3
  4887. */
  4888. getPoints(): Vector3[];
  4889. /**
  4890. * @returns the computed length (float) of the curve.
  4891. */
  4892. length(): number;
  4893. /**
  4894. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4895. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4896. * curveA and curveB keep unchanged.
  4897. * @param curve the curve to continue from this curve
  4898. * @returns the newly constructed curve
  4899. */
  4900. continue(curve: DeepImmutable<Curve3>): Curve3;
  4901. private _computeLength;
  4902. }
  4903. }
  4904. declare module "babylonjs/Animations/easing" {
  4905. /**
  4906. * This represents the main contract an easing function should follow.
  4907. * Easing functions are used throughout the animation system.
  4908. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4909. */
  4910. export interface IEasingFunction {
  4911. /**
  4912. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4913. * of the easing function.
  4914. * The link below provides some of the most common examples of easing functions.
  4915. * @see https://easings.net/
  4916. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4917. * @returns the corresponding value on the curve defined by the easing function
  4918. */
  4919. ease(gradient: number): number;
  4920. }
  4921. /**
  4922. * Base class used for every default easing function.
  4923. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4924. */
  4925. export class EasingFunction implements IEasingFunction {
  4926. /**
  4927. * Interpolation follows the mathematical formula associated with the easing function.
  4928. */
  4929. static readonly EASINGMODE_EASEIN: number;
  4930. /**
  4931. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4932. */
  4933. static readonly EASINGMODE_EASEOUT: number;
  4934. /**
  4935. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4936. */
  4937. static readonly EASINGMODE_EASEINOUT: number;
  4938. private _easingMode;
  4939. /**
  4940. * Sets the easing mode of the current function.
  4941. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4942. */
  4943. setEasingMode(easingMode: number): void;
  4944. /**
  4945. * Gets the current easing mode.
  4946. * @returns the easing mode
  4947. */
  4948. getEasingMode(): number;
  4949. /**
  4950. * @hidden
  4951. */
  4952. easeInCore(gradient: number): number;
  4953. /**
  4954. * Given an input gradient between 0 and 1, this returns the corresponding value
  4955. * of the easing function.
  4956. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4957. * @returns the corresponding value on the curve defined by the easing function
  4958. */
  4959. ease(gradient: number): number;
  4960. }
  4961. /**
  4962. * Easing function with a circle shape (see link below).
  4963. * @see https://easings.net/#easeInCirc
  4964. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4965. */
  4966. export class CircleEase extends EasingFunction implements IEasingFunction {
  4967. /** @hidden */
  4968. easeInCore(gradient: number): number;
  4969. }
  4970. /**
  4971. * Easing function with a ease back shape (see link below).
  4972. * @see https://easings.net/#easeInBack
  4973. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4974. */
  4975. export class BackEase extends EasingFunction implements IEasingFunction {
  4976. /** Defines the amplitude of the function */
  4977. amplitude: number;
  4978. /**
  4979. * Instantiates a back ease easing
  4980. * @see https://easings.net/#easeInBack
  4981. * @param amplitude Defines the amplitude of the function
  4982. */
  4983. constructor(
  4984. /** Defines the amplitude of the function */
  4985. amplitude?: number);
  4986. /** @hidden */
  4987. easeInCore(gradient: number): number;
  4988. }
  4989. /**
  4990. * Easing function with a bouncing shape (see link below).
  4991. * @see https://easings.net/#easeInBounce
  4992. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4993. */
  4994. export class BounceEase extends EasingFunction implements IEasingFunction {
  4995. /** Defines the number of bounces */
  4996. bounces: number;
  4997. /** Defines the amplitude of the bounce */
  4998. bounciness: number;
  4999. /**
  5000. * Instantiates a bounce easing
  5001. * @see https://easings.net/#easeInBounce
  5002. * @param bounces Defines the number of bounces
  5003. * @param bounciness Defines the amplitude of the bounce
  5004. */
  5005. constructor(
  5006. /** Defines the number of bounces */
  5007. bounces?: number,
  5008. /** Defines the amplitude of the bounce */
  5009. bounciness?: number);
  5010. /** @hidden */
  5011. easeInCore(gradient: number): number;
  5012. }
  5013. /**
  5014. * Easing function with a power of 3 shape (see link below).
  5015. * @see https://easings.net/#easeInCubic
  5016. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5017. */
  5018. export class CubicEase extends EasingFunction implements IEasingFunction {
  5019. /** @hidden */
  5020. easeInCore(gradient: number): number;
  5021. }
  5022. /**
  5023. * Easing function with an elastic shape (see link below).
  5024. * @see https://easings.net/#easeInElastic
  5025. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5026. */
  5027. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5028. /** Defines the number of oscillations*/
  5029. oscillations: number;
  5030. /** Defines the amplitude of the oscillations*/
  5031. springiness: number;
  5032. /**
  5033. * Instantiates an elastic easing function
  5034. * @see https://easings.net/#easeInElastic
  5035. * @param oscillations Defines the number of oscillations
  5036. * @param springiness Defines the amplitude of the oscillations
  5037. */
  5038. constructor(
  5039. /** Defines the number of oscillations*/
  5040. oscillations?: number,
  5041. /** Defines the amplitude of the oscillations*/
  5042. springiness?: number);
  5043. /** @hidden */
  5044. easeInCore(gradient: number): number;
  5045. }
  5046. /**
  5047. * Easing function with an exponential shape (see link below).
  5048. * @see https://easings.net/#easeInExpo
  5049. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5050. */
  5051. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5052. /** Defines the exponent of the function */
  5053. exponent: number;
  5054. /**
  5055. * Instantiates an exponential easing function
  5056. * @see https://easings.net/#easeInExpo
  5057. * @param exponent Defines the exponent of the function
  5058. */
  5059. constructor(
  5060. /** Defines the exponent of the function */
  5061. exponent?: number);
  5062. /** @hidden */
  5063. easeInCore(gradient: number): number;
  5064. }
  5065. /**
  5066. * Easing function with a power shape (see link below).
  5067. * @see https://easings.net/#easeInQuad
  5068. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5069. */
  5070. export class PowerEase extends EasingFunction implements IEasingFunction {
  5071. /** Defines the power of the function */
  5072. power: number;
  5073. /**
  5074. * Instantiates an power base easing function
  5075. * @see https://easings.net/#easeInQuad
  5076. * @param power Defines the power of the function
  5077. */
  5078. constructor(
  5079. /** Defines the power of the function */
  5080. power?: number);
  5081. /** @hidden */
  5082. easeInCore(gradient: number): number;
  5083. }
  5084. /**
  5085. * Easing function with a power of 2 shape (see link below).
  5086. * @see https://easings.net/#easeInQuad
  5087. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5088. */
  5089. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5090. /** @hidden */
  5091. easeInCore(gradient: number): number;
  5092. }
  5093. /**
  5094. * Easing function with a power of 4 shape (see link below).
  5095. * @see https://easings.net/#easeInQuart
  5096. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5097. */
  5098. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5099. /** @hidden */
  5100. easeInCore(gradient: number): number;
  5101. }
  5102. /**
  5103. * Easing function with a power of 5 shape (see link below).
  5104. * @see https://easings.net/#easeInQuint
  5105. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5106. */
  5107. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5108. /** @hidden */
  5109. easeInCore(gradient: number): number;
  5110. }
  5111. /**
  5112. * Easing function with a sin shape (see link below).
  5113. * @see https://easings.net/#easeInSine
  5114. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5115. */
  5116. export class SineEase extends EasingFunction implements IEasingFunction {
  5117. /** @hidden */
  5118. easeInCore(gradient: number): number;
  5119. }
  5120. /**
  5121. * Easing function with a bezier shape (see link below).
  5122. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5123. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5124. */
  5125. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5126. /** Defines the x component of the start tangent in the bezier curve */
  5127. x1: number;
  5128. /** Defines the y component of the start tangent in the bezier curve */
  5129. y1: number;
  5130. /** Defines the x component of the end tangent in the bezier curve */
  5131. x2: number;
  5132. /** Defines the y component of the end tangent in the bezier curve */
  5133. y2: number;
  5134. /**
  5135. * Instantiates a bezier function
  5136. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5137. * @param x1 Defines the x component of the start tangent in the bezier curve
  5138. * @param y1 Defines the y component of the start tangent in the bezier curve
  5139. * @param x2 Defines the x component of the end tangent in the bezier curve
  5140. * @param y2 Defines the y component of the end tangent in the bezier curve
  5141. */
  5142. constructor(
  5143. /** Defines the x component of the start tangent in the bezier curve */
  5144. x1?: number,
  5145. /** Defines the y component of the start tangent in the bezier curve */
  5146. y1?: number,
  5147. /** Defines the x component of the end tangent in the bezier curve */
  5148. x2?: number,
  5149. /** Defines the y component of the end tangent in the bezier curve */
  5150. y2?: number);
  5151. /** @hidden */
  5152. easeInCore(gradient: number): number;
  5153. }
  5154. }
  5155. declare module "babylonjs/Maths/math.color" {
  5156. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5157. /**
  5158. * Class used to hold a RBG color
  5159. */
  5160. export class Color3 {
  5161. /**
  5162. * Defines the red component (between 0 and 1, default is 0)
  5163. */
  5164. r: number;
  5165. /**
  5166. * Defines the green component (between 0 and 1, default is 0)
  5167. */
  5168. g: number;
  5169. /**
  5170. * Defines the blue component (between 0 and 1, default is 0)
  5171. */
  5172. b: number;
  5173. /**
  5174. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5175. * @param r defines the red component (between 0 and 1, default is 0)
  5176. * @param g defines the green component (between 0 and 1, default is 0)
  5177. * @param b defines the blue component (between 0 and 1, default is 0)
  5178. */
  5179. constructor(
  5180. /**
  5181. * Defines the red component (between 0 and 1, default is 0)
  5182. */
  5183. r?: number,
  5184. /**
  5185. * Defines the green component (between 0 and 1, default is 0)
  5186. */
  5187. g?: number,
  5188. /**
  5189. * Defines the blue component (between 0 and 1, default is 0)
  5190. */
  5191. b?: number);
  5192. /**
  5193. * Creates a string with the Color3 current values
  5194. * @returns the string representation of the Color3 object
  5195. */
  5196. toString(): string;
  5197. /**
  5198. * Returns the string "Color3"
  5199. * @returns "Color3"
  5200. */
  5201. getClassName(): string;
  5202. /**
  5203. * Compute the Color3 hash code
  5204. * @returns an unique number that can be used to hash Color3 objects
  5205. */
  5206. getHashCode(): number;
  5207. /**
  5208. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5209. * @param array defines the array where to store the r,g,b components
  5210. * @param index defines an optional index in the target array to define where to start storing values
  5211. * @returns the current Color3 object
  5212. */
  5213. toArray(array: FloatArray, index?: number): Color3;
  5214. /**
  5215. * Returns a new Color4 object from the current Color3 and the given alpha
  5216. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5217. * @returns a new Color4 object
  5218. */
  5219. toColor4(alpha?: number): Color4;
  5220. /**
  5221. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5222. * @returns the new array
  5223. */
  5224. asArray(): number[];
  5225. /**
  5226. * Returns the luminance value
  5227. * @returns a float value
  5228. */
  5229. toLuminance(): number;
  5230. /**
  5231. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5232. * @param otherColor defines the second operand
  5233. * @returns the new Color3 object
  5234. */
  5235. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5236. /**
  5237. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5238. * @param otherColor defines the second operand
  5239. * @param result defines the Color3 object where to store the result
  5240. * @returns the current Color3
  5241. */
  5242. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5243. /**
  5244. * Determines equality between Color3 objects
  5245. * @param otherColor defines the second operand
  5246. * @returns true if the rgb values are equal to the given ones
  5247. */
  5248. equals(otherColor: DeepImmutable<Color3>): boolean;
  5249. /**
  5250. * Determines equality between the current Color3 object and a set of r,b,g values
  5251. * @param r defines the red component to check
  5252. * @param g defines the green component to check
  5253. * @param b defines the blue component to check
  5254. * @returns true if the rgb values are equal to the given ones
  5255. */
  5256. equalsFloats(r: number, g: number, b: number): boolean;
  5257. /**
  5258. * Multiplies in place each rgb value by scale
  5259. * @param scale defines the scaling factor
  5260. * @returns the updated Color3
  5261. */
  5262. scale(scale: number): Color3;
  5263. /**
  5264. * Multiplies the rgb values by scale and stores the result into "result"
  5265. * @param scale defines the scaling factor
  5266. * @param result defines the Color3 object where to store the result
  5267. * @returns the unmodified current Color3
  5268. */
  5269. scaleToRef(scale: number, result: Color3): Color3;
  5270. /**
  5271. * Scale the current Color3 values by a factor and add the result to a given Color3
  5272. * @param scale defines the scale factor
  5273. * @param result defines color to store the result into
  5274. * @returns the unmodified current Color3
  5275. */
  5276. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5277. /**
  5278. * Clamps the rgb values by the min and max values and stores the result into "result"
  5279. * @param min defines minimum clamping value (default is 0)
  5280. * @param max defines maximum clamping value (default is 1)
  5281. * @param result defines color to store the result into
  5282. * @returns the original Color3
  5283. */
  5284. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5285. /**
  5286. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5287. * @param otherColor defines the second operand
  5288. * @returns the new Color3
  5289. */
  5290. add(otherColor: DeepImmutable<Color3>): Color3;
  5291. /**
  5292. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5293. * @param otherColor defines the second operand
  5294. * @param result defines Color3 object to store the result into
  5295. * @returns the unmodified current Color3
  5296. */
  5297. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5298. /**
  5299. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5300. * @param otherColor defines the second operand
  5301. * @returns the new Color3
  5302. */
  5303. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5304. /**
  5305. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5306. * @param otherColor defines the second operand
  5307. * @param result defines Color3 object to store the result into
  5308. * @returns the unmodified current Color3
  5309. */
  5310. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5311. /**
  5312. * Copy the current object
  5313. * @returns a new Color3 copied the current one
  5314. */
  5315. clone(): Color3;
  5316. /**
  5317. * Copies the rgb values from the source in the current Color3
  5318. * @param source defines the source Color3 object
  5319. * @returns the updated Color3 object
  5320. */
  5321. copyFrom(source: DeepImmutable<Color3>): Color3;
  5322. /**
  5323. * Updates the Color3 rgb values from the given floats
  5324. * @param r defines the red component to read from
  5325. * @param g defines the green component to read from
  5326. * @param b defines the blue component to read from
  5327. * @returns the current Color3 object
  5328. */
  5329. copyFromFloats(r: number, g: number, b: number): Color3;
  5330. /**
  5331. * Updates the Color3 rgb values from the given floats
  5332. * @param r defines the red component to read from
  5333. * @param g defines the green component to read from
  5334. * @param b defines the blue component to read from
  5335. * @returns the current Color3 object
  5336. */
  5337. set(r: number, g: number, b: number): Color3;
  5338. /**
  5339. * Compute the Color3 hexadecimal code as a string
  5340. * @returns a string containing the hexadecimal representation of the Color3 object
  5341. */
  5342. toHexString(): string;
  5343. /**
  5344. * Computes a new Color3 converted from the current one to linear space
  5345. * @returns a new Color3 object
  5346. */
  5347. toLinearSpace(): Color3;
  5348. /**
  5349. * Converts current color in rgb space to HSV values
  5350. * @returns a new color3 representing the HSV values
  5351. */
  5352. toHSV(): Color3;
  5353. /**
  5354. * Converts current color in rgb space to HSV values
  5355. * @param result defines the Color3 where to store the HSV values
  5356. */
  5357. toHSVToRef(result: Color3): void;
  5358. /**
  5359. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5360. * @param convertedColor defines the Color3 object where to store the linear space version
  5361. * @returns the unmodified Color3
  5362. */
  5363. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5364. /**
  5365. * Computes a new Color3 converted from the current one to gamma space
  5366. * @returns a new Color3 object
  5367. */
  5368. toGammaSpace(): Color3;
  5369. /**
  5370. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5371. * @param convertedColor defines the Color3 object where to store the gamma space version
  5372. * @returns the unmodified Color3
  5373. */
  5374. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5375. private static _BlackReadOnly;
  5376. /**
  5377. * Convert Hue, saturation and value to a Color3 (RGB)
  5378. * @param hue defines the hue
  5379. * @param saturation defines the saturation
  5380. * @param value defines the value
  5381. * @param result defines the Color3 where to store the RGB values
  5382. */
  5383. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5384. /**
  5385. * Creates a new Color3 from the string containing valid hexadecimal values
  5386. * @param hex defines a string containing valid hexadecimal values
  5387. * @returns a new Color3 object
  5388. */
  5389. static FromHexString(hex: string): Color3;
  5390. /**
  5391. * Creates a new Color3 from the starting index of the given array
  5392. * @param array defines the source array
  5393. * @param offset defines an offset in the source array
  5394. * @returns a new Color3 object
  5395. */
  5396. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5397. /**
  5398. * Creates a new Color3 from integer values (< 256)
  5399. * @param r defines the red component to read from (value between 0 and 255)
  5400. * @param g defines the green component to read from (value between 0 and 255)
  5401. * @param b defines the blue component to read from (value between 0 and 255)
  5402. * @returns a new Color3 object
  5403. */
  5404. static FromInts(r: number, g: number, b: number): Color3;
  5405. /**
  5406. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5407. * @param start defines the start Color3 value
  5408. * @param end defines the end Color3 value
  5409. * @param amount defines the gradient value between start and end
  5410. * @returns a new Color3 object
  5411. */
  5412. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5413. /**
  5414. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5415. * @param left defines the start value
  5416. * @param right defines the end value
  5417. * @param amount defines the gradient factor
  5418. * @param result defines the Color3 object where to store the result
  5419. */
  5420. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5421. /**
  5422. * Returns a Color3 value containing a red color
  5423. * @returns a new Color3 object
  5424. */
  5425. static Red(): Color3;
  5426. /**
  5427. * Returns a Color3 value containing a green color
  5428. * @returns a new Color3 object
  5429. */
  5430. static Green(): Color3;
  5431. /**
  5432. * Returns a Color3 value containing a blue color
  5433. * @returns a new Color3 object
  5434. */
  5435. static Blue(): Color3;
  5436. /**
  5437. * Returns a Color3 value containing a black color
  5438. * @returns a new Color3 object
  5439. */
  5440. static Black(): Color3;
  5441. /**
  5442. * Gets a Color3 value containing a black color that must not be updated
  5443. */
  5444. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5445. /**
  5446. * Returns a Color3 value containing a white color
  5447. * @returns a new Color3 object
  5448. */
  5449. static White(): Color3;
  5450. /**
  5451. * Returns a Color3 value containing a purple color
  5452. * @returns a new Color3 object
  5453. */
  5454. static Purple(): Color3;
  5455. /**
  5456. * Returns a Color3 value containing a magenta color
  5457. * @returns a new Color3 object
  5458. */
  5459. static Magenta(): Color3;
  5460. /**
  5461. * Returns a Color3 value containing a yellow color
  5462. * @returns a new Color3 object
  5463. */
  5464. static Yellow(): Color3;
  5465. /**
  5466. * Returns a Color3 value containing a gray color
  5467. * @returns a new Color3 object
  5468. */
  5469. static Gray(): Color3;
  5470. /**
  5471. * Returns a Color3 value containing a teal color
  5472. * @returns a new Color3 object
  5473. */
  5474. static Teal(): Color3;
  5475. /**
  5476. * Returns a Color3 value containing a random color
  5477. * @returns a new Color3 object
  5478. */
  5479. static Random(): Color3;
  5480. }
  5481. /**
  5482. * Class used to hold a RBGA color
  5483. */
  5484. export class Color4 {
  5485. /**
  5486. * Defines the red component (between 0 and 1, default is 0)
  5487. */
  5488. r: number;
  5489. /**
  5490. * Defines the green component (between 0 and 1, default is 0)
  5491. */
  5492. g: number;
  5493. /**
  5494. * Defines the blue component (between 0 and 1, default is 0)
  5495. */
  5496. b: number;
  5497. /**
  5498. * Defines the alpha component (between 0 and 1, default is 1)
  5499. */
  5500. a: number;
  5501. /**
  5502. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5503. * @param r defines the red component (between 0 and 1, default is 0)
  5504. * @param g defines the green component (between 0 and 1, default is 0)
  5505. * @param b defines the blue component (between 0 and 1, default is 0)
  5506. * @param a defines the alpha component (between 0 and 1, default is 1)
  5507. */
  5508. constructor(
  5509. /**
  5510. * Defines the red component (between 0 and 1, default is 0)
  5511. */
  5512. r?: number,
  5513. /**
  5514. * Defines the green component (between 0 and 1, default is 0)
  5515. */
  5516. g?: number,
  5517. /**
  5518. * Defines the blue component (between 0 and 1, default is 0)
  5519. */
  5520. b?: number,
  5521. /**
  5522. * Defines the alpha component (between 0 and 1, default is 1)
  5523. */
  5524. a?: number);
  5525. /**
  5526. * Adds in place the given Color4 values to the current Color4 object
  5527. * @param right defines the second operand
  5528. * @returns the current updated Color4 object
  5529. */
  5530. addInPlace(right: DeepImmutable<Color4>): Color4;
  5531. /**
  5532. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5533. * @returns the new array
  5534. */
  5535. asArray(): number[];
  5536. /**
  5537. * Stores from the starting index in the given array the Color4 successive values
  5538. * @param array defines the array where to store the r,g,b components
  5539. * @param index defines an optional index in the target array to define where to start storing values
  5540. * @returns the current Color4 object
  5541. */
  5542. toArray(array: number[], index?: number): Color4;
  5543. /**
  5544. * Determines equality between Color4 objects
  5545. * @param otherColor defines the second operand
  5546. * @returns true if the rgba values are equal to the given ones
  5547. */
  5548. equals(otherColor: DeepImmutable<Color4>): boolean;
  5549. /**
  5550. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5551. * @param right defines the second operand
  5552. * @returns a new Color4 object
  5553. */
  5554. add(right: DeepImmutable<Color4>): Color4;
  5555. /**
  5556. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5557. * @param right defines the second operand
  5558. * @returns a new Color4 object
  5559. */
  5560. subtract(right: DeepImmutable<Color4>): Color4;
  5561. /**
  5562. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5563. * @param right defines the second operand
  5564. * @param result defines the Color4 object where to store the result
  5565. * @returns the current Color4 object
  5566. */
  5567. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5568. /**
  5569. * Creates a new Color4 with the current Color4 values multiplied by scale
  5570. * @param scale defines the scaling factor to apply
  5571. * @returns a new Color4 object
  5572. */
  5573. scale(scale: number): Color4;
  5574. /**
  5575. * Multiplies the current Color4 values by scale and stores the result in "result"
  5576. * @param scale defines the scaling factor to apply
  5577. * @param result defines the Color4 object where to store the result
  5578. * @returns the current unmodified Color4
  5579. */
  5580. scaleToRef(scale: number, result: Color4): Color4;
  5581. /**
  5582. * Scale the current Color4 values by a factor and add the result to a given Color4
  5583. * @param scale defines the scale factor
  5584. * @param result defines the Color4 object where to store the result
  5585. * @returns the unmodified current Color4
  5586. */
  5587. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5588. /**
  5589. * Clamps the rgb values by the min and max values and stores the result into "result"
  5590. * @param min defines minimum clamping value (default is 0)
  5591. * @param max defines maximum clamping value (default is 1)
  5592. * @param result defines color to store the result into.
  5593. * @returns the cuurent Color4
  5594. */
  5595. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5596. /**
  5597. * Multipy an Color4 value by another and return a new Color4 object
  5598. * @param color defines the Color4 value to multiply by
  5599. * @returns a new Color4 object
  5600. */
  5601. multiply(color: Color4): Color4;
  5602. /**
  5603. * Multipy a Color4 value by another and push the result in a reference value
  5604. * @param color defines the Color4 value to multiply by
  5605. * @param result defines the Color4 to fill the result in
  5606. * @returns the result Color4
  5607. */
  5608. multiplyToRef(color: Color4, result: Color4): Color4;
  5609. /**
  5610. * Creates a string with the Color4 current values
  5611. * @returns the string representation of the Color4 object
  5612. */
  5613. toString(): string;
  5614. /**
  5615. * Returns the string "Color4"
  5616. * @returns "Color4"
  5617. */
  5618. getClassName(): string;
  5619. /**
  5620. * Compute the Color4 hash code
  5621. * @returns an unique number that can be used to hash Color4 objects
  5622. */
  5623. getHashCode(): number;
  5624. /**
  5625. * Creates a new Color4 copied from the current one
  5626. * @returns a new Color4 object
  5627. */
  5628. clone(): Color4;
  5629. /**
  5630. * Copies the given Color4 values into the current one
  5631. * @param source defines the source Color4 object
  5632. * @returns the current updated Color4 object
  5633. */
  5634. copyFrom(source: Color4): Color4;
  5635. /**
  5636. * Copies the given float values into the current one
  5637. * @param r defines the red component to read from
  5638. * @param g defines the green component to read from
  5639. * @param b defines the blue component to read from
  5640. * @param a defines the alpha component to read from
  5641. * @returns the current updated Color4 object
  5642. */
  5643. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5644. /**
  5645. * Copies the given float values into the current one
  5646. * @param r defines the red component to read from
  5647. * @param g defines the green component to read from
  5648. * @param b defines the blue component to read from
  5649. * @param a defines the alpha component to read from
  5650. * @returns the current updated Color4 object
  5651. */
  5652. set(r: number, g: number, b: number, a: number): Color4;
  5653. /**
  5654. * Compute the Color4 hexadecimal code as a string
  5655. * @returns a string containing the hexadecimal representation of the Color4 object
  5656. */
  5657. toHexString(): string;
  5658. /**
  5659. * Computes a new Color4 converted from the current one to linear space
  5660. * @returns a new Color4 object
  5661. */
  5662. toLinearSpace(): Color4;
  5663. /**
  5664. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5665. * @param convertedColor defines the Color4 object where to store the linear space version
  5666. * @returns the unmodified Color4
  5667. */
  5668. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5669. /**
  5670. * Computes a new Color4 converted from the current one to gamma space
  5671. * @returns a new Color4 object
  5672. */
  5673. toGammaSpace(): Color4;
  5674. /**
  5675. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5676. * @param convertedColor defines the Color4 object where to store the gamma space version
  5677. * @returns the unmodified Color4
  5678. */
  5679. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5680. /**
  5681. * Creates a new Color4 from the string containing valid hexadecimal values
  5682. * @param hex defines a string containing valid hexadecimal values
  5683. * @returns a new Color4 object
  5684. */
  5685. static FromHexString(hex: string): Color4;
  5686. /**
  5687. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5688. * @param left defines the start value
  5689. * @param right defines the end value
  5690. * @param amount defines the gradient factor
  5691. * @returns a new Color4 object
  5692. */
  5693. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5694. /**
  5695. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5696. * @param left defines the start value
  5697. * @param right defines the end value
  5698. * @param amount defines the gradient factor
  5699. * @param result defines the Color4 object where to store data
  5700. */
  5701. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5702. /**
  5703. * Creates a new Color4 from a Color3 and an alpha value
  5704. * @param color3 defines the source Color3 to read from
  5705. * @param alpha defines the alpha component (1.0 by default)
  5706. * @returns a new Color4 object
  5707. */
  5708. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5709. /**
  5710. * Creates a new Color4 from the starting index element of the given array
  5711. * @param array defines the source array to read from
  5712. * @param offset defines the offset in the source array
  5713. * @returns a new Color4 object
  5714. */
  5715. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5716. /**
  5717. * Creates a new Color3 from integer values (< 256)
  5718. * @param r defines the red component to read from (value between 0 and 255)
  5719. * @param g defines the green component to read from (value between 0 and 255)
  5720. * @param b defines the blue component to read from (value between 0 and 255)
  5721. * @param a defines the alpha component to read from (value between 0 and 255)
  5722. * @returns a new Color3 object
  5723. */
  5724. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5725. /**
  5726. * Check the content of a given array and convert it to an array containing RGBA data
  5727. * If the original array was already containing count * 4 values then it is returned directly
  5728. * @param colors defines the array to check
  5729. * @param count defines the number of RGBA data to expect
  5730. * @returns an array containing count * 4 values (RGBA)
  5731. */
  5732. static CheckColors4(colors: number[], count: number): number[];
  5733. }
  5734. /**
  5735. * @hidden
  5736. */
  5737. export class TmpColors {
  5738. static Color3: Color3[];
  5739. static Color4: Color4[];
  5740. }
  5741. }
  5742. declare module "babylonjs/Animations/animationKey" {
  5743. /**
  5744. * Defines an interface which represents an animation key frame
  5745. */
  5746. export interface IAnimationKey {
  5747. /**
  5748. * Frame of the key frame
  5749. */
  5750. frame: number;
  5751. /**
  5752. * Value at the specifies key frame
  5753. */
  5754. value: any;
  5755. /**
  5756. * The input tangent for the cubic hermite spline
  5757. */
  5758. inTangent?: any;
  5759. /**
  5760. * The output tangent for the cubic hermite spline
  5761. */
  5762. outTangent?: any;
  5763. /**
  5764. * The animation interpolation type
  5765. */
  5766. interpolation?: AnimationKeyInterpolation;
  5767. }
  5768. /**
  5769. * Enum for the animation key frame interpolation type
  5770. */
  5771. export enum AnimationKeyInterpolation {
  5772. /**
  5773. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5774. */
  5775. STEP = 1
  5776. }
  5777. }
  5778. declare module "babylonjs/Animations/animationRange" {
  5779. /**
  5780. * Represents the range of an animation
  5781. */
  5782. export class AnimationRange {
  5783. /**The name of the animation range**/
  5784. name: string;
  5785. /**The starting frame of the animation */
  5786. from: number;
  5787. /**The ending frame of the animation*/
  5788. to: number;
  5789. /**
  5790. * Initializes the range of an animation
  5791. * @param name The name of the animation range
  5792. * @param from The starting frame of the animation
  5793. * @param to The ending frame of the animation
  5794. */
  5795. constructor(
  5796. /**The name of the animation range**/
  5797. name: string,
  5798. /**The starting frame of the animation */
  5799. from: number,
  5800. /**The ending frame of the animation*/
  5801. to: number);
  5802. /**
  5803. * Makes a copy of the animation range
  5804. * @returns A copy of the animation range
  5805. */
  5806. clone(): AnimationRange;
  5807. }
  5808. }
  5809. declare module "babylonjs/Animations/animationEvent" {
  5810. /**
  5811. * Composed of a frame, and an action function
  5812. */
  5813. export class AnimationEvent {
  5814. /** The frame for which the event is triggered **/
  5815. frame: number;
  5816. /** The event to perform when triggered **/
  5817. action: (currentFrame: number) => void;
  5818. /** Specifies if the event should be triggered only once**/
  5819. onlyOnce?: boolean | undefined;
  5820. /**
  5821. * Specifies if the animation event is done
  5822. */
  5823. isDone: boolean;
  5824. /**
  5825. * Initializes the animation event
  5826. * @param frame The frame for which the event is triggered
  5827. * @param action The event to perform when triggered
  5828. * @param onlyOnce Specifies if the event should be triggered only once
  5829. */
  5830. constructor(
  5831. /** The frame for which the event is triggered **/
  5832. frame: number,
  5833. /** The event to perform when triggered **/
  5834. action: (currentFrame: number) => void,
  5835. /** Specifies if the event should be triggered only once**/
  5836. onlyOnce?: boolean | undefined);
  5837. /** @hidden */
  5838. _clone(): AnimationEvent;
  5839. }
  5840. }
  5841. declare module "babylonjs/Behaviors/behavior" {
  5842. import { Nullable } from "babylonjs/types";
  5843. /**
  5844. * Interface used to define a behavior
  5845. */
  5846. export interface Behavior<T> {
  5847. /** gets or sets behavior's name */
  5848. name: string;
  5849. /**
  5850. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5851. */
  5852. init(): void;
  5853. /**
  5854. * Called when the behavior is attached to a target
  5855. * @param target defines the target where the behavior is attached to
  5856. */
  5857. attach(target: T): void;
  5858. /**
  5859. * Called when the behavior is detached from its target
  5860. */
  5861. detach(): void;
  5862. }
  5863. /**
  5864. * Interface implemented by classes supporting behaviors
  5865. */
  5866. export interface IBehaviorAware<T> {
  5867. /**
  5868. * Attach a behavior
  5869. * @param behavior defines the behavior to attach
  5870. * @returns the current host
  5871. */
  5872. addBehavior(behavior: Behavior<T>): T;
  5873. /**
  5874. * Remove a behavior from the current object
  5875. * @param behavior defines the behavior to detach
  5876. * @returns the current host
  5877. */
  5878. removeBehavior(behavior: Behavior<T>): T;
  5879. /**
  5880. * Gets a behavior using its name to search
  5881. * @param name defines the name to search
  5882. * @returns the behavior or null if not found
  5883. */
  5884. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5885. }
  5886. }
  5887. declare module "babylonjs/Misc/smartArray" {
  5888. /**
  5889. * Defines an array and its length.
  5890. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5891. */
  5892. export interface ISmartArrayLike<T> {
  5893. /**
  5894. * The data of the array.
  5895. */
  5896. data: Array<T>;
  5897. /**
  5898. * The active length of the array.
  5899. */
  5900. length: number;
  5901. }
  5902. /**
  5903. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5904. */
  5905. export class SmartArray<T> implements ISmartArrayLike<T> {
  5906. /**
  5907. * The full set of data from the array.
  5908. */
  5909. data: Array<T>;
  5910. /**
  5911. * The active length of the array.
  5912. */
  5913. length: number;
  5914. protected _id: number;
  5915. /**
  5916. * Instantiates a Smart Array.
  5917. * @param capacity defines the default capacity of the array.
  5918. */
  5919. constructor(capacity: number);
  5920. /**
  5921. * Pushes a value at the end of the active data.
  5922. * @param value defines the object to push in the array.
  5923. */
  5924. push(value: T): void;
  5925. /**
  5926. * Iterates over the active data and apply the lambda to them.
  5927. * @param func defines the action to apply on each value.
  5928. */
  5929. forEach(func: (content: T) => void): void;
  5930. /**
  5931. * Sorts the full sets of data.
  5932. * @param compareFn defines the comparison function to apply.
  5933. */
  5934. sort(compareFn: (a: T, b: T) => number): void;
  5935. /**
  5936. * Resets the active data to an empty array.
  5937. */
  5938. reset(): void;
  5939. /**
  5940. * Releases all the data from the array as well as the array.
  5941. */
  5942. dispose(): void;
  5943. /**
  5944. * Concats the active data with a given array.
  5945. * @param array defines the data to concatenate with.
  5946. */
  5947. concat(array: any): void;
  5948. /**
  5949. * Returns the position of a value in the active data.
  5950. * @param value defines the value to find the index for
  5951. * @returns the index if found in the active data otherwise -1
  5952. */
  5953. indexOf(value: T): number;
  5954. /**
  5955. * Returns whether an element is part of the active data.
  5956. * @param value defines the value to look for
  5957. * @returns true if found in the active data otherwise false
  5958. */
  5959. contains(value: T): boolean;
  5960. private static _GlobalId;
  5961. }
  5962. /**
  5963. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5964. * The data in this array can only be present once
  5965. */
  5966. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5967. private _duplicateId;
  5968. /**
  5969. * Pushes a value at the end of the active data.
  5970. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5971. * @param value defines the object to push in the array.
  5972. */
  5973. push(value: T): void;
  5974. /**
  5975. * Pushes a value at the end of the active data.
  5976. * If the data is already present, it won t be added again
  5977. * @param value defines the object to push in the array.
  5978. * @returns true if added false if it was already present
  5979. */
  5980. pushNoDuplicate(value: T): boolean;
  5981. /**
  5982. * Resets the active data to an empty array.
  5983. */
  5984. reset(): void;
  5985. /**
  5986. * Concats the active data with a given array.
  5987. * This ensures no dupplicate will be present in the result.
  5988. * @param array defines the data to concatenate with.
  5989. */
  5990. concatWithNoDuplicate(array: any): void;
  5991. }
  5992. }
  5993. declare module "babylonjs/Cameras/cameraInputsManager" {
  5994. import { Nullable } from "babylonjs/types";
  5995. import { Camera } from "babylonjs/Cameras/camera";
  5996. /**
  5997. * @ignore
  5998. * This is a list of all the different input types that are available in the application.
  5999. * Fo instance: ArcRotateCameraGamepadInput...
  6000. */
  6001. export var CameraInputTypes: {};
  6002. /**
  6003. * This is the contract to implement in order to create a new input class.
  6004. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6005. */
  6006. export interface ICameraInput<TCamera extends Camera> {
  6007. /**
  6008. * Defines the camera the input is attached to.
  6009. */
  6010. camera: Nullable<TCamera>;
  6011. /**
  6012. * Gets the class name of the current intput.
  6013. * @returns the class name
  6014. */
  6015. getClassName(): string;
  6016. /**
  6017. * Get the friendly name associated with the input class.
  6018. * @returns the input friendly name
  6019. */
  6020. getSimpleName(): string;
  6021. /**
  6022. * Attach the input controls to a specific dom element to get the input from.
  6023. * @param element Defines the element the controls should be listened from
  6024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6025. */
  6026. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6027. /**
  6028. * Detach the current controls from the specified dom element.
  6029. * @param element Defines the element to stop listening the inputs from
  6030. */
  6031. detachControl(element: Nullable<HTMLElement>): void;
  6032. /**
  6033. * Update the current camera state depending on the inputs that have been used this frame.
  6034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6035. */
  6036. checkInputs?: () => void;
  6037. }
  6038. /**
  6039. * Represents a map of input types to input instance or input index to input instance.
  6040. */
  6041. export interface CameraInputsMap<TCamera extends Camera> {
  6042. /**
  6043. * Accessor to the input by input type.
  6044. */
  6045. [name: string]: ICameraInput<TCamera>;
  6046. /**
  6047. * Accessor to the input by input index.
  6048. */
  6049. [idx: number]: ICameraInput<TCamera>;
  6050. }
  6051. /**
  6052. * This represents the input manager used within a camera.
  6053. * It helps dealing with all the different kind of input attached to a camera.
  6054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6055. */
  6056. export class CameraInputsManager<TCamera extends Camera> {
  6057. /**
  6058. * Defines the list of inputs attahed to the camera.
  6059. */
  6060. attached: CameraInputsMap<TCamera>;
  6061. /**
  6062. * Defines the dom element the camera is collecting inputs from.
  6063. * This is null if the controls have not been attached.
  6064. */
  6065. attachedElement: Nullable<HTMLElement>;
  6066. /**
  6067. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6068. */
  6069. noPreventDefault: boolean;
  6070. /**
  6071. * Defined the camera the input manager belongs to.
  6072. */
  6073. camera: TCamera;
  6074. /**
  6075. * Update the current camera state depending on the inputs that have been used this frame.
  6076. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6077. */
  6078. checkInputs: () => void;
  6079. /**
  6080. * Instantiate a new Camera Input Manager.
  6081. * @param camera Defines the camera the input manager blongs to
  6082. */
  6083. constructor(camera: TCamera);
  6084. /**
  6085. * Add an input method to a camera
  6086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6087. * @param input camera input method
  6088. */
  6089. add(input: ICameraInput<TCamera>): void;
  6090. /**
  6091. * Remove a specific input method from a camera
  6092. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6093. * @param inputToRemove camera input method
  6094. */
  6095. remove(inputToRemove: ICameraInput<TCamera>): void;
  6096. /**
  6097. * Remove a specific input type from a camera
  6098. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6099. * @param inputType the type of the input to remove
  6100. */
  6101. removeByType(inputType: string): void;
  6102. private _addCheckInputs;
  6103. /**
  6104. * Attach the input controls to the currently attached dom element to listen the events from.
  6105. * @param input Defines the input to attach
  6106. */
  6107. attachInput(input: ICameraInput<TCamera>): void;
  6108. /**
  6109. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6110. * @param element Defines the dom element to collect the events from
  6111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6112. */
  6113. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6114. /**
  6115. * Detach the current manager inputs controls from a specific dom element.
  6116. * @param element Defines the dom element to collect the events from
  6117. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6118. */
  6119. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6120. /**
  6121. * Rebuild the dynamic inputCheck function from the current list of
  6122. * defined inputs in the manager.
  6123. */
  6124. rebuildInputCheck(): void;
  6125. /**
  6126. * Remove all attached input methods from a camera
  6127. */
  6128. clear(): void;
  6129. /**
  6130. * Serialize the current input manager attached to a camera.
  6131. * This ensures than once parsed,
  6132. * the input associated to the camera will be identical to the current ones
  6133. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6134. */
  6135. serialize(serializedCamera: any): void;
  6136. /**
  6137. * Parses an input manager serialized JSON to restore the previous list of inputs
  6138. * and states associated to a camera.
  6139. * @param parsedCamera Defines the JSON to parse
  6140. */
  6141. parse(parsedCamera: any): void;
  6142. }
  6143. }
  6144. declare module "babylonjs/Meshes/buffer" {
  6145. import { Nullable, DataArray } from "babylonjs/types";
  6146. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6147. /**
  6148. * Class used to store data that will be store in GPU memory
  6149. */
  6150. export class Buffer {
  6151. private _engine;
  6152. private _buffer;
  6153. /** @hidden */
  6154. _data: Nullable<DataArray>;
  6155. private _updatable;
  6156. private _instanced;
  6157. private _divisor;
  6158. /**
  6159. * Gets the byte stride.
  6160. */
  6161. readonly byteStride: number;
  6162. /**
  6163. * Constructor
  6164. * @param engine the engine
  6165. * @param data the data to use for this buffer
  6166. * @param updatable whether the data is updatable
  6167. * @param stride the stride (optional)
  6168. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6169. * @param instanced whether the buffer is instanced (optional)
  6170. * @param useBytes set to true if the stride in in bytes (optional)
  6171. * @param divisor sets an optional divisor for instances (1 by default)
  6172. */
  6173. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6174. /**
  6175. * Create a new VertexBuffer based on the current buffer
  6176. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6177. * @param offset defines offset in the buffer (0 by default)
  6178. * @param size defines the size in floats of attributes (position is 3 for instance)
  6179. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6180. * @param instanced defines if the vertex buffer contains indexed data
  6181. * @param useBytes defines if the offset and stride are in bytes *
  6182. * @param divisor sets an optional divisor for instances (1 by default)
  6183. * @returns the new vertex buffer
  6184. */
  6185. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6186. /**
  6187. * Gets a boolean indicating if the Buffer is updatable?
  6188. * @returns true if the buffer is updatable
  6189. */
  6190. isUpdatable(): boolean;
  6191. /**
  6192. * Gets current buffer's data
  6193. * @returns a DataArray or null
  6194. */
  6195. getData(): Nullable<DataArray>;
  6196. /**
  6197. * Gets underlying native buffer
  6198. * @returns underlying native buffer
  6199. */
  6200. getBuffer(): Nullable<DataBuffer>;
  6201. /**
  6202. * Gets the stride in float32 units (i.e. byte stride / 4).
  6203. * May not be an integer if the byte stride is not divisible by 4.
  6204. * DEPRECATED. Use byteStride instead.
  6205. * @returns the stride in float32 units
  6206. */
  6207. getStrideSize(): number;
  6208. /**
  6209. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6210. * @param data defines the data to store
  6211. */
  6212. create(data?: Nullable<DataArray>): void;
  6213. /** @hidden */
  6214. _rebuild(): void;
  6215. /**
  6216. * Update current buffer data
  6217. * @param data defines the data to store
  6218. */
  6219. update(data: DataArray): void;
  6220. /**
  6221. * Updates the data directly.
  6222. * @param data the new data
  6223. * @param offset the new offset
  6224. * @param vertexCount the vertex count (optional)
  6225. * @param useBytes set to true if the offset is in bytes
  6226. */
  6227. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6228. /**
  6229. * Release all resources
  6230. */
  6231. dispose(): void;
  6232. }
  6233. /**
  6234. * Specialized buffer used to store vertex data
  6235. */
  6236. export class VertexBuffer {
  6237. /** @hidden */
  6238. _buffer: Buffer;
  6239. private _kind;
  6240. private _size;
  6241. private _ownsBuffer;
  6242. private _instanced;
  6243. private _instanceDivisor;
  6244. /**
  6245. * The byte type.
  6246. */
  6247. static readonly BYTE: number;
  6248. /**
  6249. * The unsigned byte type.
  6250. */
  6251. static readonly UNSIGNED_BYTE: number;
  6252. /**
  6253. * The short type.
  6254. */
  6255. static readonly SHORT: number;
  6256. /**
  6257. * The unsigned short type.
  6258. */
  6259. static readonly UNSIGNED_SHORT: number;
  6260. /**
  6261. * The integer type.
  6262. */
  6263. static readonly INT: number;
  6264. /**
  6265. * The unsigned integer type.
  6266. */
  6267. static readonly UNSIGNED_INT: number;
  6268. /**
  6269. * The float type.
  6270. */
  6271. static readonly FLOAT: number;
  6272. /**
  6273. * Gets or sets the instance divisor when in instanced mode
  6274. */
  6275. instanceDivisor: number;
  6276. /**
  6277. * Gets the byte stride.
  6278. */
  6279. readonly byteStride: number;
  6280. /**
  6281. * Gets the byte offset.
  6282. */
  6283. readonly byteOffset: number;
  6284. /**
  6285. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6286. */
  6287. readonly normalized: boolean;
  6288. /**
  6289. * Gets the data type of each component in the array.
  6290. */
  6291. readonly type: number;
  6292. /**
  6293. * Constructor
  6294. * @param engine the engine
  6295. * @param data the data to use for this vertex buffer
  6296. * @param kind the vertex buffer kind
  6297. * @param updatable whether the data is updatable
  6298. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6299. * @param stride the stride (optional)
  6300. * @param instanced whether the buffer is instanced (optional)
  6301. * @param offset the offset of the data (optional)
  6302. * @param size the number of components (optional)
  6303. * @param type the type of the component (optional)
  6304. * @param normalized whether the data contains normalized data (optional)
  6305. * @param useBytes set to true if stride and offset are in bytes (optional)
  6306. * @param divisor defines the instance divisor to use (1 by default)
  6307. */
  6308. 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);
  6309. /** @hidden */
  6310. _rebuild(): void;
  6311. /**
  6312. * Returns the kind of the VertexBuffer (string)
  6313. * @returns a string
  6314. */
  6315. getKind(): string;
  6316. /**
  6317. * Gets a boolean indicating if the VertexBuffer is updatable?
  6318. * @returns true if the buffer is updatable
  6319. */
  6320. isUpdatable(): boolean;
  6321. /**
  6322. * Gets current buffer's data
  6323. * @returns a DataArray or null
  6324. */
  6325. getData(): Nullable<DataArray>;
  6326. /**
  6327. * Gets underlying native buffer
  6328. * @returns underlying native buffer
  6329. */
  6330. getBuffer(): Nullable<DataBuffer>;
  6331. /**
  6332. * Gets the stride in float32 units (i.e. byte stride / 4).
  6333. * May not be an integer if the byte stride is not divisible by 4.
  6334. * DEPRECATED. Use byteStride instead.
  6335. * @returns the stride in float32 units
  6336. */
  6337. getStrideSize(): number;
  6338. /**
  6339. * Returns the offset as a multiple of the type byte length.
  6340. * DEPRECATED. Use byteOffset instead.
  6341. * @returns the offset in bytes
  6342. */
  6343. getOffset(): number;
  6344. /**
  6345. * Returns the number of components per vertex attribute (integer)
  6346. * @returns the size in float
  6347. */
  6348. getSize(): number;
  6349. /**
  6350. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6351. * @returns true if this buffer is instanced
  6352. */
  6353. getIsInstanced(): boolean;
  6354. /**
  6355. * Returns the instancing divisor, zero for non-instanced (integer).
  6356. * @returns a number
  6357. */
  6358. getInstanceDivisor(): number;
  6359. /**
  6360. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6361. * @param data defines the data to store
  6362. */
  6363. create(data?: DataArray): void;
  6364. /**
  6365. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6366. * This function will create a new buffer if the current one is not updatable
  6367. * @param data defines the data to store
  6368. */
  6369. update(data: DataArray): void;
  6370. /**
  6371. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6372. * Returns the directly updated WebGLBuffer.
  6373. * @param data the new data
  6374. * @param offset the new offset
  6375. * @param useBytes set to true if the offset is in bytes
  6376. */
  6377. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6378. /**
  6379. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6380. */
  6381. dispose(): void;
  6382. /**
  6383. * Enumerates each value of this vertex buffer as numbers.
  6384. * @param count the number of values to enumerate
  6385. * @param callback the callback function called for each value
  6386. */
  6387. forEach(count: number, callback: (value: number, index: number) => void): void;
  6388. /**
  6389. * Positions
  6390. */
  6391. static readonly PositionKind: string;
  6392. /**
  6393. * Normals
  6394. */
  6395. static readonly NormalKind: string;
  6396. /**
  6397. * Tangents
  6398. */
  6399. static readonly TangentKind: string;
  6400. /**
  6401. * Texture coordinates
  6402. */
  6403. static readonly UVKind: string;
  6404. /**
  6405. * Texture coordinates 2
  6406. */
  6407. static readonly UV2Kind: string;
  6408. /**
  6409. * Texture coordinates 3
  6410. */
  6411. static readonly UV3Kind: string;
  6412. /**
  6413. * Texture coordinates 4
  6414. */
  6415. static readonly UV4Kind: string;
  6416. /**
  6417. * Texture coordinates 5
  6418. */
  6419. static readonly UV5Kind: string;
  6420. /**
  6421. * Texture coordinates 6
  6422. */
  6423. static readonly UV6Kind: string;
  6424. /**
  6425. * Colors
  6426. */
  6427. static readonly ColorKind: string;
  6428. /**
  6429. * Matrix indices (for bones)
  6430. */
  6431. static readonly MatricesIndicesKind: string;
  6432. /**
  6433. * Matrix weights (for bones)
  6434. */
  6435. static readonly MatricesWeightsKind: string;
  6436. /**
  6437. * Additional matrix indices (for bones)
  6438. */
  6439. static readonly MatricesIndicesExtraKind: string;
  6440. /**
  6441. * Additional matrix weights (for bones)
  6442. */
  6443. static readonly MatricesWeightsExtraKind: string;
  6444. /**
  6445. * Deduces the stride given a kind.
  6446. * @param kind The kind string to deduce
  6447. * @returns The deduced stride
  6448. */
  6449. static DeduceStride(kind: string): number;
  6450. /**
  6451. * Gets the byte length of the given type.
  6452. * @param type the type
  6453. * @returns the number of bytes
  6454. */
  6455. static GetTypeByteLength(type: number): number;
  6456. /**
  6457. * Enumerates each value of the given parameters as numbers.
  6458. * @param data the data to enumerate
  6459. * @param byteOffset the byte offset of the data
  6460. * @param byteStride the byte stride of the data
  6461. * @param componentCount the number of components per element
  6462. * @param componentType the type of the component
  6463. * @param count the number of values to enumerate
  6464. * @param normalized whether the data is normalized
  6465. * @param callback the callback function called for each value
  6466. */
  6467. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6468. private static _GetFloatValue;
  6469. }
  6470. }
  6471. declare module "babylonjs/Collisions/intersectionInfo" {
  6472. import { Nullable } from "babylonjs/types";
  6473. /**
  6474. * @hidden
  6475. */
  6476. export class IntersectionInfo {
  6477. bu: Nullable<number>;
  6478. bv: Nullable<number>;
  6479. distance: number;
  6480. faceId: number;
  6481. subMeshId: number;
  6482. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6483. }
  6484. }
  6485. declare module "babylonjs/Maths/math.plane" {
  6486. import { DeepImmutable } from "babylonjs/types";
  6487. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6488. /**
  6489. * Represens a plane by the equation ax + by + cz + d = 0
  6490. */
  6491. export class Plane {
  6492. private static _TmpMatrix;
  6493. /**
  6494. * Normal of the plane (a,b,c)
  6495. */
  6496. normal: Vector3;
  6497. /**
  6498. * d component of the plane
  6499. */
  6500. d: number;
  6501. /**
  6502. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6503. * @param a a component of the plane
  6504. * @param b b component of the plane
  6505. * @param c c component of the plane
  6506. * @param d d component of the plane
  6507. */
  6508. constructor(a: number, b: number, c: number, d: number);
  6509. /**
  6510. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6511. */
  6512. asArray(): number[];
  6513. /**
  6514. * @returns a new plane copied from the current Plane.
  6515. */
  6516. clone(): Plane;
  6517. /**
  6518. * @returns the string "Plane".
  6519. */
  6520. getClassName(): string;
  6521. /**
  6522. * @returns the Plane hash code.
  6523. */
  6524. getHashCode(): number;
  6525. /**
  6526. * Normalize the current Plane in place.
  6527. * @returns the updated Plane.
  6528. */
  6529. normalize(): Plane;
  6530. /**
  6531. * Applies a transformation the plane and returns the result
  6532. * @param transformation the transformation matrix to be applied to the plane
  6533. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6534. */
  6535. transform(transformation: DeepImmutable<Matrix>): Plane;
  6536. /**
  6537. * Calcualtte the dot product between the point and the plane normal
  6538. * @param point point to calculate the dot product with
  6539. * @returns the dot product (float) of the point coordinates and the plane normal.
  6540. */
  6541. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6542. /**
  6543. * Updates the current Plane from the plane defined by the three given points.
  6544. * @param point1 one of the points used to contruct the plane
  6545. * @param point2 one of the points used to contruct the plane
  6546. * @param point3 one of the points used to contruct the plane
  6547. * @returns the updated Plane.
  6548. */
  6549. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6550. /**
  6551. * Checks if the plane is facing a given direction
  6552. * @param direction the direction to check if the plane is facing
  6553. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6554. * @returns True is the vector "direction" is the same side than the plane normal.
  6555. */
  6556. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6557. /**
  6558. * Calculates the distance to a point
  6559. * @param point point to calculate distance to
  6560. * @returns the signed distance (float) from the given point to the Plane.
  6561. */
  6562. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6563. /**
  6564. * Creates a plane from an array
  6565. * @param array the array to create a plane from
  6566. * @returns a new Plane from the given array.
  6567. */
  6568. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6569. /**
  6570. * Creates a plane from three points
  6571. * @param point1 point used to create the plane
  6572. * @param point2 point used to create the plane
  6573. * @param point3 point used to create the plane
  6574. * @returns a new Plane defined by the three given points.
  6575. */
  6576. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6577. /**
  6578. * Creates a plane from an origin point and a normal
  6579. * @param origin origin of the plane to be constructed
  6580. * @param normal normal of the plane to be constructed
  6581. * @returns a new Plane the normal vector to this plane at the given origin point.
  6582. * Note : the vector "normal" is updated because normalized.
  6583. */
  6584. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6585. /**
  6586. * Calculates the distance from a plane and a point
  6587. * @param origin origin of the plane to be constructed
  6588. * @param normal normal of the plane to be constructed
  6589. * @param point point to calculate distance to
  6590. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6591. */
  6592. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6593. }
  6594. }
  6595. declare module "babylonjs/Culling/boundingSphere" {
  6596. import { DeepImmutable } from "babylonjs/types";
  6597. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6598. import { Plane } from "babylonjs/Maths/math.plane";
  6599. /**
  6600. * Class used to store bounding sphere information
  6601. */
  6602. export class BoundingSphere {
  6603. /**
  6604. * Gets the center of the bounding sphere in local space
  6605. */
  6606. readonly center: Vector3;
  6607. /**
  6608. * Radius of the bounding sphere in local space
  6609. */
  6610. radius: number;
  6611. /**
  6612. * Gets the center of the bounding sphere in world space
  6613. */
  6614. readonly centerWorld: Vector3;
  6615. /**
  6616. * Radius of the bounding sphere in world space
  6617. */
  6618. radiusWorld: number;
  6619. /**
  6620. * Gets the minimum vector in local space
  6621. */
  6622. readonly minimum: Vector3;
  6623. /**
  6624. * Gets the maximum vector in local space
  6625. */
  6626. readonly maximum: Vector3;
  6627. private _worldMatrix;
  6628. private static readonly TmpVector3;
  6629. /**
  6630. * Creates a new bounding sphere
  6631. * @param min defines the minimum vector (in local space)
  6632. * @param max defines the maximum vector (in local space)
  6633. * @param worldMatrix defines the new world matrix
  6634. */
  6635. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6636. /**
  6637. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6638. * @param min defines the new minimum vector (in local space)
  6639. * @param max defines the new maximum vector (in local space)
  6640. * @param worldMatrix defines the new world matrix
  6641. */
  6642. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6643. /**
  6644. * Scale the current bounding sphere by applying a scale factor
  6645. * @param factor defines the scale factor to apply
  6646. * @returns the current bounding box
  6647. */
  6648. scale(factor: number): BoundingSphere;
  6649. /**
  6650. * Gets the world matrix of the bounding box
  6651. * @returns a matrix
  6652. */
  6653. getWorldMatrix(): DeepImmutable<Matrix>;
  6654. /** @hidden */
  6655. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6656. /**
  6657. * Tests if the bounding sphere is intersecting the frustum planes
  6658. * @param frustumPlanes defines the frustum planes to test
  6659. * @returns true if there is an intersection
  6660. */
  6661. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6662. /**
  6663. * Tests if the bounding sphere center is in between the frustum planes.
  6664. * Used for optimistic fast inclusion.
  6665. * @param frustumPlanes defines the frustum planes to test
  6666. * @returns true if the sphere center is in between the frustum planes
  6667. */
  6668. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6669. /**
  6670. * Tests if a point is inside the bounding sphere
  6671. * @param point defines the point to test
  6672. * @returns true if the point is inside the bounding sphere
  6673. */
  6674. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6675. /**
  6676. * Checks if two sphere intersct
  6677. * @param sphere0 sphere 0
  6678. * @param sphere1 sphere 1
  6679. * @returns true if the speres intersect
  6680. */
  6681. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6682. }
  6683. }
  6684. declare module "babylonjs/Culling/boundingBox" {
  6685. import { DeepImmutable } from "babylonjs/types";
  6686. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6687. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6688. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6689. import { Plane } from "babylonjs/Maths/math.plane";
  6690. /**
  6691. * Class used to store bounding box information
  6692. */
  6693. export class BoundingBox implements ICullable {
  6694. /**
  6695. * Gets the 8 vectors representing the bounding box in local space
  6696. */
  6697. readonly vectors: Vector3[];
  6698. /**
  6699. * Gets the center of the bounding box in local space
  6700. */
  6701. readonly center: Vector3;
  6702. /**
  6703. * Gets the center of the bounding box in world space
  6704. */
  6705. readonly centerWorld: Vector3;
  6706. /**
  6707. * Gets the extend size in local space
  6708. */
  6709. readonly extendSize: Vector3;
  6710. /**
  6711. * Gets the extend size in world space
  6712. */
  6713. readonly extendSizeWorld: Vector3;
  6714. /**
  6715. * Gets the OBB (object bounding box) directions
  6716. */
  6717. readonly directions: Vector3[];
  6718. /**
  6719. * Gets the 8 vectors representing the bounding box in world space
  6720. */
  6721. readonly vectorsWorld: Vector3[];
  6722. /**
  6723. * Gets the minimum vector in world space
  6724. */
  6725. readonly minimumWorld: Vector3;
  6726. /**
  6727. * Gets the maximum vector in world space
  6728. */
  6729. readonly maximumWorld: Vector3;
  6730. /**
  6731. * Gets the minimum vector in local space
  6732. */
  6733. readonly minimum: Vector3;
  6734. /**
  6735. * Gets the maximum vector in local space
  6736. */
  6737. readonly maximum: Vector3;
  6738. private _worldMatrix;
  6739. private static readonly TmpVector3;
  6740. /**
  6741. * @hidden
  6742. */
  6743. _tag: number;
  6744. /**
  6745. * Creates a new bounding box
  6746. * @param min defines the minimum vector (in local space)
  6747. * @param max defines the maximum vector (in local space)
  6748. * @param worldMatrix defines the new world matrix
  6749. */
  6750. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6751. /**
  6752. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6753. * @param min defines the new minimum vector (in local space)
  6754. * @param max defines the new maximum vector (in local space)
  6755. * @param worldMatrix defines the new world matrix
  6756. */
  6757. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6758. /**
  6759. * Scale the current bounding box by applying a scale factor
  6760. * @param factor defines the scale factor to apply
  6761. * @returns the current bounding box
  6762. */
  6763. scale(factor: number): BoundingBox;
  6764. /**
  6765. * Gets the world matrix of the bounding box
  6766. * @returns a matrix
  6767. */
  6768. getWorldMatrix(): DeepImmutable<Matrix>;
  6769. /** @hidden */
  6770. _update(world: DeepImmutable<Matrix>): void;
  6771. /**
  6772. * Tests if the bounding box is intersecting the frustum planes
  6773. * @param frustumPlanes defines the frustum planes to test
  6774. * @returns true if there is an intersection
  6775. */
  6776. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6777. /**
  6778. * Tests if the bounding box is entirely inside the frustum planes
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @returns true if there is an inclusion
  6781. */
  6782. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. /**
  6784. * Tests if a point is inside the bounding box
  6785. * @param point defines the point to test
  6786. * @returns true if the point is inside the bounding box
  6787. */
  6788. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6789. /**
  6790. * Tests if the bounding box intersects with a bounding sphere
  6791. * @param sphere defines the sphere to test
  6792. * @returns true if there is an intersection
  6793. */
  6794. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6795. /**
  6796. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6797. * @param min defines the min vector to use
  6798. * @param max defines the max vector to use
  6799. * @returns true if there is an intersection
  6800. */
  6801. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6802. /**
  6803. * Tests if two bounding boxes are intersections
  6804. * @param box0 defines the first box to test
  6805. * @param box1 defines the second box to test
  6806. * @returns true if there is an intersection
  6807. */
  6808. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6809. /**
  6810. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6811. * @param minPoint defines the minimum vector of the bounding box
  6812. * @param maxPoint defines the maximum vector of the bounding box
  6813. * @param sphereCenter defines the sphere center
  6814. * @param sphereRadius defines the sphere radius
  6815. * @returns true if there is an intersection
  6816. */
  6817. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6818. /**
  6819. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6820. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6821. * @param frustumPlanes defines the frustum planes to test
  6822. * @return true if there is an inclusion
  6823. */
  6824. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6825. /**
  6826. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6827. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6828. * @param frustumPlanes defines the frustum planes to test
  6829. * @return true if there is an intersection
  6830. */
  6831. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6832. }
  6833. }
  6834. declare module "babylonjs/Collisions/collider" {
  6835. import { Nullable, IndicesArray } from "babylonjs/types";
  6836. import { Vector3 } from "babylonjs/Maths/math.vector";
  6837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6838. import { Plane } from "babylonjs/Maths/math.plane";
  6839. /** @hidden */
  6840. export class Collider {
  6841. /** Define if a collision was found */
  6842. collisionFound: boolean;
  6843. /**
  6844. * Define last intersection point in local space
  6845. */
  6846. intersectionPoint: Vector3;
  6847. /**
  6848. * Define last collided mesh
  6849. */
  6850. collidedMesh: Nullable<AbstractMesh>;
  6851. private _collisionPoint;
  6852. private _planeIntersectionPoint;
  6853. private _tempVector;
  6854. private _tempVector2;
  6855. private _tempVector3;
  6856. private _tempVector4;
  6857. private _edge;
  6858. private _baseToVertex;
  6859. private _destinationPoint;
  6860. private _slidePlaneNormal;
  6861. private _displacementVector;
  6862. /** @hidden */
  6863. _radius: Vector3;
  6864. /** @hidden */
  6865. _retry: number;
  6866. private _velocity;
  6867. private _basePoint;
  6868. private _epsilon;
  6869. /** @hidden */
  6870. _velocityWorldLength: number;
  6871. /** @hidden */
  6872. _basePointWorld: Vector3;
  6873. private _velocityWorld;
  6874. private _normalizedVelocity;
  6875. /** @hidden */
  6876. _initialVelocity: Vector3;
  6877. /** @hidden */
  6878. _initialPosition: Vector3;
  6879. private _nearestDistance;
  6880. private _collisionMask;
  6881. collisionMask: number;
  6882. /**
  6883. * Gets the plane normal used to compute the sliding response (in local space)
  6884. */
  6885. readonly slidePlaneNormal: Vector3;
  6886. /** @hidden */
  6887. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6888. /** @hidden */
  6889. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6890. /** @hidden */
  6891. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6892. /** @hidden */
  6893. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6894. /** @hidden */
  6895. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6896. /** @hidden */
  6897. _getResponse(pos: Vector3, vel: Vector3): void;
  6898. }
  6899. }
  6900. declare module "babylonjs/Culling/boundingInfo" {
  6901. import { DeepImmutable } from "babylonjs/types";
  6902. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6903. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6904. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6905. import { Plane } from "babylonjs/Maths/math.plane";
  6906. import { Collider } from "babylonjs/Collisions/collider";
  6907. /**
  6908. * Interface for cullable objects
  6909. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6910. */
  6911. export interface ICullable {
  6912. /**
  6913. * Checks if the object or part of the object is in the frustum
  6914. * @param frustumPlanes Camera near/planes
  6915. * @returns true if the object is in frustum otherwise false
  6916. */
  6917. isInFrustum(frustumPlanes: Plane[]): boolean;
  6918. /**
  6919. * Checks if a cullable object (mesh...) is in the camera frustum
  6920. * Unlike isInFrustum this cheks the full bounding box
  6921. * @param frustumPlanes Camera near/planes
  6922. * @returns true if the object is in frustum otherwise false
  6923. */
  6924. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6925. }
  6926. /**
  6927. * Info for a bounding data of a mesh
  6928. */
  6929. export class BoundingInfo implements ICullable {
  6930. /**
  6931. * Bounding box for the mesh
  6932. */
  6933. readonly boundingBox: BoundingBox;
  6934. /**
  6935. * Bounding sphere for the mesh
  6936. */
  6937. readonly boundingSphere: BoundingSphere;
  6938. private _isLocked;
  6939. private static readonly TmpVector3;
  6940. /**
  6941. * Constructs bounding info
  6942. * @param minimum min vector of the bounding box/sphere
  6943. * @param maximum max vector of the bounding box/sphere
  6944. * @param worldMatrix defines the new world matrix
  6945. */
  6946. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6947. /**
  6948. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6949. * @param min defines the new minimum vector (in local space)
  6950. * @param max defines the new maximum vector (in local space)
  6951. * @param worldMatrix defines the new world matrix
  6952. */
  6953. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6954. /**
  6955. * min vector of the bounding box/sphere
  6956. */
  6957. readonly minimum: Vector3;
  6958. /**
  6959. * max vector of the bounding box/sphere
  6960. */
  6961. readonly maximum: Vector3;
  6962. /**
  6963. * If the info is locked and won't be updated to avoid perf overhead
  6964. */
  6965. isLocked: boolean;
  6966. /**
  6967. * Updates the bounding sphere and box
  6968. * @param world world matrix to be used to update
  6969. */
  6970. update(world: DeepImmutable<Matrix>): void;
  6971. /**
  6972. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6973. * @param center New center of the bounding info
  6974. * @param extend New extend of the bounding info
  6975. * @returns the current bounding info
  6976. */
  6977. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6978. /**
  6979. * Scale the current bounding info by applying a scale factor
  6980. * @param factor defines the scale factor to apply
  6981. * @returns the current bounding info
  6982. */
  6983. scale(factor: number): BoundingInfo;
  6984. /**
  6985. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6986. * @param frustumPlanes defines the frustum to test
  6987. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6988. * @returns true if the bounding info is in the frustum planes
  6989. */
  6990. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6991. /**
  6992. * Gets the world distance between the min and max points of the bounding box
  6993. */
  6994. readonly diagonalLength: number;
  6995. /**
  6996. * Checks if a cullable object (mesh...) is in the camera frustum
  6997. * Unlike isInFrustum this cheks the full bounding box
  6998. * @param frustumPlanes Camera near/planes
  6999. * @returns true if the object is in frustum otherwise false
  7000. */
  7001. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7002. /** @hidden */
  7003. _checkCollision(collider: Collider): boolean;
  7004. /**
  7005. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7006. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7007. * @param point the point to check intersection with
  7008. * @returns if the point intersects
  7009. */
  7010. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7011. /**
  7012. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7013. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7014. * @param boundingInfo the bounding info to check intersection with
  7015. * @param precise if the intersection should be done using OBB
  7016. * @returns if the bounding info intersects
  7017. */
  7018. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7019. }
  7020. }
  7021. declare module "babylonjs/Maths/math.functions" {
  7022. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7023. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7024. /**
  7025. * Extracts minimum and maximum values from a list of indexed positions
  7026. * @param positions defines the positions to use
  7027. * @param indices defines the indices to the positions
  7028. * @param indexStart defines the start index
  7029. * @param indexCount defines the end index
  7030. * @param bias defines bias value to add to the result
  7031. * @return minimum and maximum values
  7032. */
  7033. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7034. minimum: Vector3;
  7035. maximum: Vector3;
  7036. };
  7037. /**
  7038. * Extracts minimum and maximum values from a list of positions
  7039. * @param positions defines the positions to use
  7040. * @param start defines the start index in the positions array
  7041. * @param count defines the number of positions to handle
  7042. * @param bias defines bias value to add to the result
  7043. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7044. * @return minimum and maximum values
  7045. */
  7046. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7047. minimum: Vector3;
  7048. maximum: Vector3;
  7049. };
  7050. }
  7051. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7052. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7053. /** @hidden */
  7054. export class WebGLDataBuffer extends DataBuffer {
  7055. private _buffer;
  7056. constructor(resource: WebGLBuffer);
  7057. readonly underlyingResource: any;
  7058. }
  7059. }
  7060. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7061. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7062. import { Nullable } from "babylonjs/types";
  7063. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7064. /** @hidden */
  7065. export class WebGLPipelineContext implements IPipelineContext {
  7066. engine: ThinEngine;
  7067. program: Nullable<WebGLProgram>;
  7068. context?: WebGLRenderingContext;
  7069. vertexShader?: WebGLShader;
  7070. fragmentShader?: WebGLShader;
  7071. isParallelCompiled: boolean;
  7072. onCompiled?: () => void;
  7073. transformFeedback?: WebGLTransformFeedback | null;
  7074. readonly isAsync: boolean;
  7075. readonly isReady: boolean;
  7076. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7077. }
  7078. }
  7079. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7080. import { FloatArray, Nullable } from "babylonjs/types";
  7081. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7082. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7083. module "babylonjs/Engines/thinEngine" {
  7084. interface ThinEngine {
  7085. /**
  7086. * Create an uniform buffer
  7087. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7088. * @param elements defines the content of the uniform buffer
  7089. * @returns the webGL uniform buffer
  7090. */
  7091. createUniformBuffer(elements: FloatArray): DataBuffer;
  7092. /**
  7093. * Create a dynamic uniform buffer
  7094. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7095. * @param elements defines the content of the uniform buffer
  7096. * @returns the webGL uniform buffer
  7097. */
  7098. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7099. /**
  7100. * Update an existing uniform buffer
  7101. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7102. * @param uniformBuffer defines the target uniform buffer
  7103. * @param elements defines the content to update
  7104. * @param offset defines the offset in the uniform buffer where update should start
  7105. * @param count defines the size of the data to update
  7106. */
  7107. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7108. /**
  7109. * Bind an uniform buffer to the current webGL context
  7110. * @param buffer defines the buffer to bind
  7111. */
  7112. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7113. /**
  7114. * Bind a buffer to the current webGL context at a given location
  7115. * @param buffer defines the buffer to bind
  7116. * @param location defines the index where to bind the buffer
  7117. */
  7118. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7119. /**
  7120. * Bind a specific block at a given index in a specific shader program
  7121. * @param pipelineContext defines the pipeline context to use
  7122. * @param blockName defines the block name
  7123. * @param index defines the index where to bind the block
  7124. */
  7125. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7126. }
  7127. }
  7128. }
  7129. declare module "babylonjs/Materials/uniformBuffer" {
  7130. import { Nullable, FloatArray } from "babylonjs/types";
  7131. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7132. import { Engine } from "babylonjs/Engines/engine";
  7133. import { Effect } from "babylonjs/Materials/effect";
  7134. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7135. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7136. import { Color3 } from "babylonjs/Maths/math.color";
  7137. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7138. /**
  7139. * Uniform buffer objects.
  7140. *
  7141. * Handles blocks of uniform on the GPU.
  7142. *
  7143. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7144. *
  7145. * For more information, please refer to :
  7146. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7147. */
  7148. export class UniformBuffer {
  7149. private _engine;
  7150. private _buffer;
  7151. private _data;
  7152. private _bufferData;
  7153. private _dynamic?;
  7154. private _uniformLocations;
  7155. private _uniformSizes;
  7156. private _uniformLocationPointer;
  7157. private _needSync;
  7158. private _noUBO;
  7159. private _currentEffect;
  7160. /** @hidden */
  7161. _alreadyBound: boolean;
  7162. private static _MAX_UNIFORM_SIZE;
  7163. private static _tempBuffer;
  7164. /**
  7165. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7166. * This is dynamic to allow compat with webgl 1 and 2.
  7167. * You will need to pass the name of the uniform as well as the value.
  7168. */
  7169. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7170. /**
  7171. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7172. * This is dynamic to allow compat with webgl 1 and 2.
  7173. * You will need to pass the name of the uniform as well as the value.
  7174. */
  7175. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7176. /**
  7177. * Lambda to Update a single float in a uniform buffer.
  7178. * This is dynamic to allow compat with webgl 1 and 2.
  7179. * You will need to pass the name of the uniform as well as the value.
  7180. */
  7181. updateFloat: (name: string, x: number) => void;
  7182. /**
  7183. * Lambda to Update a vec2 of float in a uniform buffer.
  7184. * This is dynamic to allow compat with webgl 1 and 2.
  7185. * You will need to pass the name of the uniform as well as the value.
  7186. */
  7187. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7188. /**
  7189. * Lambda to Update a vec3 of float in a uniform buffer.
  7190. * This is dynamic to allow compat with webgl 1 and 2.
  7191. * You will need to pass the name of the uniform as well as the value.
  7192. */
  7193. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7194. /**
  7195. * Lambda to Update a vec4 of float in a uniform buffer.
  7196. * This is dynamic to allow compat with webgl 1 and 2.
  7197. * You will need to pass the name of the uniform as well as the value.
  7198. */
  7199. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7200. /**
  7201. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7202. * This is dynamic to allow compat with webgl 1 and 2.
  7203. * You will need to pass the name of the uniform as well as the value.
  7204. */
  7205. updateMatrix: (name: string, mat: Matrix) => void;
  7206. /**
  7207. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7208. * This is dynamic to allow compat with webgl 1 and 2.
  7209. * You will need to pass the name of the uniform as well as the value.
  7210. */
  7211. updateVector3: (name: string, vector: Vector3) => void;
  7212. /**
  7213. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7214. * This is dynamic to allow compat with webgl 1 and 2.
  7215. * You will need to pass the name of the uniform as well as the value.
  7216. */
  7217. updateVector4: (name: string, vector: Vector4) => void;
  7218. /**
  7219. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7220. * This is dynamic to allow compat with webgl 1 and 2.
  7221. * You will need to pass the name of the uniform as well as the value.
  7222. */
  7223. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7224. /**
  7225. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7226. * This is dynamic to allow compat with webgl 1 and 2.
  7227. * You will need to pass the name of the uniform as well as the value.
  7228. */
  7229. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7230. /**
  7231. * Instantiates a new Uniform buffer objects.
  7232. *
  7233. * Handles blocks of uniform on the GPU.
  7234. *
  7235. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7236. *
  7237. * For more information, please refer to :
  7238. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7239. * @param engine Define the engine the buffer is associated with
  7240. * @param data Define the data contained in the buffer
  7241. * @param dynamic Define if the buffer is updatable
  7242. */
  7243. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7244. /**
  7245. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7246. * or just falling back on setUniformXXX calls.
  7247. */
  7248. readonly useUbo: boolean;
  7249. /**
  7250. * Indicates if the WebGL underlying uniform buffer is in sync
  7251. * with the javascript cache data.
  7252. */
  7253. readonly isSync: boolean;
  7254. /**
  7255. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7256. * Also, a dynamic UniformBuffer will disable cache verification and always
  7257. * update the underlying WebGL uniform buffer to the GPU.
  7258. * @returns if Dynamic, otherwise false
  7259. */
  7260. isDynamic(): boolean;
  7261. /**
  7262. * The data cache on JS side.
  7263. * @returns the underlying data as a float array
  7264. */
  7265. getData(): Float32Array;
  7266. /**
  7267. * The underlying WebGL Uniform buffer.
  7268. * @returns the webgl buffer
  7269. */
  7270. getBuffer(): Nullable<DataBuffer>;
  7271. /**
  7272. * std140 layout specifies how to align data within an UBO structure.
  7273. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7274. * for specs.
  7275. */
  7276. private _fillAlignment;
  7277. /**
  7278. * Adds an uniform in the buffer.
  7279. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7280. * for the layout to be correct !
  7281. * @param name Name of the uniform, as used in the uniform block in the shader.
  7282. * @param size Data size, or data directly.
  7283. */
  7284. addUniform(name: string, size: number | number[]): void;
  7285. /**
  7286. * Adds a Matrix 4x4 to the uniform buffer.
  7287. * @param name Name of the uniform, as used in the uniform block in the shader.
  7288. * @param mat A 4x4 matrix.
  7289. */
  7290. addMatrix(name: string, mat: Matrix): void;
  7291. /**
  7292. * Adds a vec2 to the uniform buffer.
  7293. * @param name Name of the uniform, as used in the uniform block in the shader.
  7294. * @param x Define the x component value of the vec2
  7295. * @param y Define the y component value of the vec2
  7296. */
  7297. addFloat2(name: string, x: number, y: number): void;
  7298. /**
  7299. * Adds a vec3 to the uniform buffer.
  7300. * @param name Name of the uniform, as used in the uniform block in the shader.
  7301. * @param x Define the x component value of the vec3
  7302. * @param y Define the y component value of the vec3
  7303. * @param z Define the z component value of the vec3
  7304. */
  7305. addFloat3(name: string, x: number, y: number, z: number): void;
  7306. /**
  7307. * Adds a vec3 to the uniform buffer.
  7308. * @param name Name of the uniform, as used in the uniform block in the shader.
  7309. * @param color Define the vec3 from a Color
  7310. */
  7311. addColor3(name: string, color: Color3): void;
  7312. /**
  7313. * Adds a vec4 to the uniform buffer.
  7314. * @param name Name of the uniform, as used in the uniform block in the shader.
  7315. * @param color Define the rgb components from a Color
  7316. * @param alpha Define the a component of the vec4
  7317. */
  7318. addColor4(name: string, color: Color3, alpha: number): void;
  7319. /**
  7320. * Adds a vec3 to the uniform buffer.
  7321. * @param name Name of the uniform, as used in the uniform block in the shader.
  7322. * @param vector Define the vec3 components from a Vector
  7323. */
  7324. addVector3(name: string, vector: Vector3): void;
  7325. /**
  7326. * Adds a Matrix 3x3 to the uniform buffer.
  7327. * @param name Name of the uniform, as used in the uniform block in the shader.
  7328. */
  7329. addMatrix3x3(name: string): void;
  7330. /**
  7331. * Adds a Matrix 2x2 to the uniform buffer.
  7332. * @param name Name of the uniform, as used in the uniform block in the shader.
  7333. */
  7334. addMatrix2x2(name: string): void;
  7335. /**
  7336. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7337. */
  7338. create(): void;
  7339. /** @hidden */
  7340. _rebuild(): void;
  7341. /**
  7342. * Updates the WebGL Uniform Buffer on the GPU.
  7343. * If the `dynamic` flag is set to true, no cache comparison is done.
  7344. * Otherwise, the buffer will be updated only if the cache differs.
  7345. */
  7346. update(): void;
  7347. /**
  7348. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7349. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7350. * @param data Define the flattened data
  7351. * @param size Define the size of the data.
  7352. */
  7353. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7354. private _valueCache;
  7355. private _cacheMatrix;
  7356. private _updateMatrix3x3ForUniform;
  7357. private _updateMatrix3x3ForEffect;
  7358. private _updateMatrix2x2ForEffect;
  7359. private _updateMatrix2x2ForUniform;
  7360. private _updateFloatForEffect;
  7361. private _updateFloatForUniform;
  7362. private _updateFloat2ForEffect;
  7363. private _updateFloat2ForUniform;
  7364. private _updateFloat3ForEffect;
  7365. private _updateFloat3ForUniform;
  7366. private _updateFloat4ForEffect;
  7367. private _updateFloat4ForUniform;
  7368. private _updateMatrixForEffect;
  7369. private _updateMatrixForUniform;
  7370. private _updateVector3ForEffect;
  7371. private _updateVector3ForUniform;
  7372. private _updateVector4ForEffect;
  7373. private _updateVector4ForUniform;
  7374. private _updateColor3ForEffect;
  7375. private _updateColor3ForUniform;
  7376. private _updateColor4ForEffect;
  7377. private _updateColor4ForUniform;
  7378. /**
  7379. * Sets a sampler uniform on the effect.
  7380. * @param name Define the name of the sampler.
  7381. * @param texture Define the texture to set in the sampler
  7382. */
  7383. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7384. /**
  7385. * Directly updates the value of the uniform in the cache AND on the GPU.
  7386. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7387. * @param data Define the flattened data
  7388. */
  7389. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7390. /**
  7391. * Binds this uniform buffer to an effect.
  7392. * @param effect Define the effect to bind the buffer to
  7393. * @param name Name of the uniform block in the shader.
  7394. */
  7395. bindToEffect(effect: Effect, name: string): void;
  7396. /**
  7397. * Disposes the uniform buffer.
  7398. */
  7399. dispose(): void;
  7400. }
  7401. }
  7402. declare module "babylonjs/Misc/iInspectable" {
  7403. /**
  7404. * Enum that determines the text-wrapping mode to use.
  7405. */
  7406. export enum InspectableType {
  7407. /**
  7408. * Checkbox for booleans
  7409. */
  7410. Checkbox = 0,
  7411. /**
  7412. * Sliders for numbers
  7413. */
  7414. Slider = 1,
  7415. /**
  7416. * Vector3
  7417. */
  7418. Vector3 = 2,
  7419. /**
  7420. * Quaternions
  7421. */
  7422. Quaternion = 3,
  7423. /**
  7424. * Color3
  7425. */
  7426. Color3 = 4,
  7427. /**
  7428. * String
  7429. */
  7430. String = 5
  7431. }
  7432. /**
  7433. * Interface used to define custom inspectable properties.
  7434. * This interface is used by the inspector to display custom property grids
  7435. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7436. */
  7437. export interface IInspectable {
  7438. /**
  7439. * Gets the label to display
  7440. */
  7441. label: string;
  7442. /**
  7443. * Gets the name of the property to edit
  7444. */
  7445. propertyName: string;
  7446. /**
  7447. * Gets the type of the editor to use
  7448. */
  7449. type: InspectableType;
  7450. /**
  7451. * Gets the minimum value of the property when using in "slider" mode
  7452. */
  7453. min?: number;
  7454. /**
  7455. * Gets the maximum value of the property when using in "slider" mode
  7456. */
  7457. max?: number;
  7458. /**
  7459. * Gets the setp to use when using in "slider" mode
  7460. */
  7461. step?: number;
  7462. }
  7463. }
  7464. declare module "babylonjs/Misc/timingTools" {
  7465. /**
  7466. * Class used to provide helper for timing
  7467. */
  7468. export class TimingTools {
  7469. /**
  7470. * Polyfill for setImmediate
  7471. * @param action defines the action to execute after the current execution block
  7472. */
  7473. static SetImmediate(action: () => void): void;
  7474. }
  7475. }
  7476. declare module "babylonjs/Misc/instantiationTools" {
  7477. /**
  7478. * Class used to enable instatition of objects by class name
  7479. */
  7480. export class InstantiationTools {
  7481. /**
  7482. * Use this object to register external classes like custom textures or material
  7483. * to allow the laoders to instantiate them
  7484. */
  7485. static RegisteredExternalClasses: {
  7486. [key: string]: Object;
  7487. };
  7488. /**
  7489. * Tries to instantiate a new object from a given class name
  7490. * @param className defines the class name to instantiate
  7491. * @returns the new object or null if the system was not able to do the instantiation
  7492. */
  7493. static Instantiate(className: string): any;
  7494. }
  7495. }
  7496. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7497. /**
  7498. * Define options used to create a depth texture
  7499. */
  7500. export class DepthTextureCreationOptions {
  7501. /** Specifies whether or not a stencil should be allocated in the texture */
  7502. generateStencil?: boolean;
  7503. /** Specifies whether or not bilinear filtering is enable on the texture */
  7504. bilinearFiltering?: boolean;
  7505. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7506. comparisonFunction?: number;
  7507. /** Specifies if the created texture is a cube texture */
  7508. isCube?: boolean;
  7509. }
  7510. }
  7511. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7512. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7513. import { Nullable } from "babylonjs/types";
  7514. import { Scene } from "babylonjs/scene";
  7515. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7516. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7517. module "babylonjs/Engines/thinEngine" {
  7518. interface ThinEngine {
  7519. /**
  7520. * Creates a depth stencil cube texture.
  7521. * This is only available in WebGL 2.
  7522. * @param size The size of face edge in the cube texture.
  7523. * @param options The options defining the cube texture.
  7524. * @returns The cube texture
  7525. */
  7526. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7527. /**
  7528. * Creates a cube texture
  7529. * @param rootUrl defines the url where the files to load is located
  7530. * @param scene defines the current scene
  7531. * @param files defines the list of files to load (1 per face)
  7532. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7533. * @param onLoad defines an optional callback raised when the texture is loaded
  7534. * @param onError defines an optional callback raised if there is an issue to load the texture
  7535. * @param format defines the format of the data
  7536. * @param forcedExtension defines the extension to use to pick the right loader
  7537. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7538. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7539. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7540. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7541. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7542. * @returns the cube texture as an InternalTexture
  7543. */
  7544. 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;
  7545. /**
  7546. * Creates a cube texture
  7547. * @param rootUrl defines the url where the files to load is located
  7548. * @param scene defines the current scene
  7549. * @param files defines the list of files to load (1 per face)
  7550. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7551. * @param onLoad defines an optional callback raised when the texture is loaded
  7552. * @param onError defines an optional callback raised if there is an issue to load the texture
  7553. * @param format defines the format of the data
  7554. * @param forcedExtension defines the extension to use to pick the right loader
  7555. * @returns the cube texture as an InternalTexture
  7556. */
  7557. 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;
  7558. /**
  7559. * Creates a cube texture
  7560. * @param rootUrl defines the url where the files to load is located
  7561. * @param scene defines the current scene
  7562. * @param files defines the list of files to load (1 per face)
  7563. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7564. * @param onLoad defines an optional callback raised when the texture is loaded
  7565. * @param onError defines an optional callback raised if there is an issue to load the texture
  7566. * @param format defines the format of the data
  7567. * @param forcedExtension defines the extension to use to pick the right loader
  7568. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7569. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7570. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7571. * @returns the cube texture as an InternalTexture
  7572. */
  7573. 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;
  7574. /** @hidden */
  7575. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7576. /** @hidden */
  7577. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7578. /** @hidden */
  7579. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7580. /** @hidden */
  7581. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7582. /**
  7583. * @hidden
  7584. */
  7585. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7586. }
  7587. }
  7588. }
  7589. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7590. import { Nullable } from "babylonjs/types";
  7591. import { Scene } from "babylonjs/scene";
  7592. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7593. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7594. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7595. /**
  7596. * Class for creating a cube texture
  7597. */
  7598. export class CubeTexture extends BaseTexture {
  7599. private _delayedOnLoad;
  7600. /**
  7601. * The url of the texture
  7602. */
  7603. url: string;
  7604. /**
  7605. * Gets or sets the center of the bounding box associated with the cube texture.
  7606. * It must define where the camera used to render the texture was set
  7607. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7608. */
  7609. boundingBoxPosition: Vector3;
  7610. private _boundingBoxSize;
  7611. /**
  7612. * Gets or sets the size of the bounding box associated with the cube texture
  7613. * When defined, the cubemap will switch to local mode
  7614. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7615. * @example https://www.babylonjs-playground.com/#RNASML
  7616. */
  7617. /**
  7618. * Returns the bounding box size
  7619. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7620. */
  7621. boundingBoxSize: Vector3;
  7622. protected _rotationY: number;
  7623. /**
  7624. * Sets texture matrix rotation angle around Y axis in radians.
  7625. */
  7626. /**
  7627. * Gets texture matrix rotation angle around Y axis radians.
  7628. */
  7629. rotationY: number;
  7630. /**
  7631. * Are mip maps generated for this texture or not.
  7632. */
  7633. readonly noMipmap: boolean;
  7634. private _noMipmap;
  7635. private _files;
  7636. protected _forcedExtension: Nullable<string>;
  7637. private _extensions;
  7638. private _textureMatrix;
  7639. private _format;
  7640. private _createPolynomials;
  7641. /** @hidden */
  7642. _prefiltered: boolean;
  7643. /**
  7644. * Creates a cube texture from an array of image urls
  7645. * @param files defines an array of image urls
  7646. * @param scene defines the hosting scene
  7647. * @param noMipmap specifies if mip maps are not used
  7648. * @returns a cube texture
  7649. */
  7650. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7651. /**
  7652. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7653. * @param url defines the url of the prefiltered texture
  7654. * @param scene defines the scene the texture is attached to
  7655. * @param forcedExtension defines the extension of the file if different from the url
  7656. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7657. * @return the prefiltered texture
  7658. */
  7659. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7660. /**
  7661. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7662. * as prefiltered data.
  7663. * @param rootUrl defines the url of the texture or the root name of the six images
  7664. * @param scene defines the scene the texture is attached to
  7665. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7666. * @param noMipmap defines if mipmaps should be created or not
  7667. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7668. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7669. * @param onError defines a callback triggered in case of error during load
  7670. * @param format defines the internal format to use for the texture once loaded
  7671. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7672. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7673. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7674. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7675. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7676. * @return the cube texture
  7677. */
  7678. 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);
  7679. /**
  7680. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7681. */
  7682. readonly isPrefiltered: boolean;
  7683. /**
  7684. * Get the current class name of the texture useful for serialization or dynamic coding.
  7685. * @returns "CubeTexture"
  7686. */
  7687. getClassName(): string;
  7688. /**
  7689. * Update the url (and optional buffer) of this texture if url was null during construction.
  7690. * @param url the url of the texture
  7691. * @param forcedExtension defines the extension to use
  7692. * @param onLoad callback called when the texture is loaded (defaults to null)
  7693. */
  7694. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7695. /**
  7696. * Delays loading of the cube texture
  7697. * @param forcedExtension defines the extension to use
  7698. */
  7699. delayLoad(forcedExtension?: string): void;
  7700. /**
  7701. * Returns the reflection texture matrix
  7702. * @returns the reflection texture matrix
  7703. */
  7704. getReflectionTextureMatrix(): Matrix;
  7705. /**
  7706. * Sets the reflection texture matrix
  7707. * @param value Reflection texture matrix
  7708. */
  7709. setReflectionTextureMatrix(value: Matrix): void;
  7710. /**
  7711. * Parses text to create a cube texture
  7712. * @param parsedTexture define the serialized text to read from
  7713. * @param scene defines the hosting scene
  7714. * @param rootUrl defines the root url of the cube texture
  7715. * @returns a cube texture
  7716. */
  7717. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7718. /**
  7719. * Makes a clone, or deep copy, of the cube texture
  7720. * @returns a new cube texture
  7721. */
  7722. clone(): CubeTexture;
  7723. }
  7724. }
  7725. declare module "babylonjs/Materials/materialDefines" {
  7726. /**
  7727. * Manages the defines for the Material
  7728. */
  7729. export class MaterialDefines {
  7730. /** @hidden */
  7731. protected _keys: string[];
  7732. private _isDirty;
  7733. /** @hidden */
  7734. _renderId: number;
  7735. /** @hidden */
  7736. _areLightsDirty: boolean;
  7737. /** @hidden */
  7738. _areLightsDisposed: boolean;
  7739. /** @hidden */
  7740. _areAttributesDirty: boolean;
  7741. /** @hidden */
  7742. _areTexturesDirty: boolean;
  7743. /** @hidden */
  7744. _areFresnelDirty: boolean;
  7745. /** @hidden */
  7746. _areMiscDirty: boolean;
  7747. /** @hidden */
  7748. _areImageProcessingDirty: boolean;
  7749. /** @hidden */
  7750. _normals: boolean;
  7751. /** @hidden */
  7752. _uvs: boolean;
  7753. /** @hidden */
  7754. _needNormals: boolean;
  7755. /** @hidden */
  7756. _needUVs: boolean;
  7757. [id: string]: any;
  7758. /**
  7759. * Specifies if the material needs to be re-calculated
  7760. */
  7761. readonly isDirty: boolean;
  7762. /**
  7763. * Marks the material to indicate that it has been re-calculated
  7764. */
  7765. markAsProcessed(): void;
  7766. /**
  7767. * Marks the material to indicate that it needs to be re-calculated
  7768. */
  7769. markAsUnprocessed(): void;
  7770. /**
  7771. * Marks the material to indicate all of its defines need to be re-calculated
  7772. */
  7773. markAllAsDirty(): void;
  7774. /**
  7775. * Marks the material to indicate that image processing needs to be re-calculated
  7776. */
  7777. markAsImageProcessingDirty(): void;
  7778. /**
  7779. * Marks the material to indicate the lights need to be re-calculated
  7780. * @param disposed Defines whether the light is dirty due to dispose or not
  7781. */
  7782. markAsLightDirty(disposed?: boolean): void;
  7783. /**
  7784. * Marks the attribute state as changed
  7785. */
  7786. markAsAttributesDirty(): void;
  7787. /**
  7788. * Marks the texture state as changed
  7789. */
  7790. markAsTexturesDirty(): void;
  7791. /**
  7792. * Marks the fresnel state as changed
  7793. */
  7794. markAsFresnelDirty(): void;
  7795. /**
  7796. * Marks the misc state as changed
  7797. */
  7798. markAsMiscDirty(): void;
  7799. /**
  7800. * Rebuilds the material defines
  7801. */
  7802. rebuild(): void;
  7803. /**
  7804. * Specifies if two material defines are equal
  7805. * @param other - A material define instance to compare to
  7806. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7807. */
  7808. isEqual(other: MaterialDefines): boolean;
  7809. /**
  7810. * Clones this instance's defines to another instance
  7811. * @param other - material defines to clone values to
  7812. */
  7813. cloneTo(other: MaterialDefines): void;
  7814. /**
  7815. * Resets the material define values
  7816. */
  7817. reset(): void;
  7818. /**
  7819. * Converts the material define values to a string
  7820. * @returns - String of material define information
  7821. */
  7822. toString(): string;
  7823. }
  7824. }
  7825. declare module "babylonjs/Materials/colorCurves" {
  7826. import { Effect } from "babylonjs/Materials/effect";
  7827. /**
  7828. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7829. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7830. * 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;
  7831. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7832. */
  7833. export class ColorCurves {
  7834. private _dirty;
  7835. private _tempColor;
  7836. private _globalCurve;
  7837. private _highlightsCurve;
  7838. private _midtonesCurve;
  7839. private _shadowsCurve;
  7840. private _positiveCurve;
  7841. private _negativeCurve;
  7842. private _globalHue;
  7843. private _globalDensity;
  7844. private _globalSaturation;
  7845. private _globalExposure;
  7846. /**
  7847. * Gets the global Hue value.
  7848. * 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).
  7849. */
  7850. /**
  7851. * Sets the global Hue value.
  7852. * 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).
  7853. */
  7854. globalHue: number;
  7855. /**
  7856. * Gets the global Density value.
  7857. * 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.
  7858. * Values less than zero provide a filter of opposite hue.
  7859. */
  7860. /**
  7861. * Sets the global Density value.
  7862. * 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.
  7863. * Values less than zero provide a filter of opposite hue.
  7864. */
  7865. globalDensity: number;
  7866. /**
  7867. * Gets the global Saturation value.
  7868. * 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.
  7869. */
  7870. /**
  7871. * Sets the global Saturation value.
  7872. * 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.
  7873. */
  7874. globalSaturation: number;
  7875. /**
  7876. * Gets the global Exposure value.
  7877. * 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.
  7878. */
  7879. /**
  7880. * Sets the global Exposure value.
  7881. * 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.
  7882. */
  7883. globalExposure: number;
  7884. private _highlightsHue;
  7885. private _highlightsDensity;
  7886. private _highlightsSaturation;
  7887. private _highlightsExposure;
  7888. /**
  7889. * Gets the highlights Hue value.
  7890. * 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).
  7891. */
  7892. /**
  7893. * Sets the highlights Hue value.
  7894. * 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).
  7895. */
  7896. highlightsHue: number;
  7897. /**
  7898. * Gets the highlights Density value.
  7899. * 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.
  7900. * Values less than zero provide a filter of opposite hue.
  7901. */
  7902. /**
  7903. * Sets the highlights Density value.
  7904. * 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.
  7905. * Values less than zero provide a filter of opposite hue.
  7906. */
  7907. highlightsDensity: number;
  7908. /**
  7909. * Gets the highlights Saturation value.
  7910. * 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.
  7911. */
  7912. /**
  7913. * Sets the highlights Saturation value.
  7914. * 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.
  7915. */
  7916. highlightsSaturation: number;
  7917. /**
  7918. * Gets the highlights Exposure value.
  7919. * 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.
  7920. */
  7921. /**
  7922. * Sets the highlights Exposure value.
  7923. * 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.
  7924. */
  7925. highlightsExposure: number;
  7926. private _midtonesHue;
  7927. private _midtonesDensity;
  7928. private _midtonesSaturation;
  7929. private _midtonesExposure;
  7930. /**
  7931. * Gets the midtones Hue value.
  7932. * 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).
  7933. */
  7934. /**
  7935. * Sets the midtones Hue value.
  7936. * 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).
  7937. */
  7938. midtonesHue: number;
  7939. /**
  7940. * Gets the midtones Density value.
  7941. * 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.
  7942. * Values less than zero provide a filter of opposite hue.
  7943. */
  7944. /**
  7945. * Sets the midtones Density value.
  7946. * 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.
  7947. * Values less than zero provide a filter of opposite hue.
  7948. */
  7949. midtonesDensity: number;
  7950. /**
  7951. * Gets the midtones Saturation value.
  7952. * 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.
  7953. */
  7954. /**
  7955. * Sets the midtones Saturation value.
  7956. * 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.
  7957. */
  7958. midtonesSaturation: number;
  7959. /**
  7960. * Gets the midtones Exposure value.
  7961. * 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.
  7962. */
  7963. /**
  7964. * Sets the midtones Exposure value.
  7965. * 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.
  7966. */
  7967. midtonesExposure: number;
  7968. private _shadowsHue;
  7969. private _shadowsDensity;
  7970. private _shadowsSaturation;
  7971. private _shadowsExposure;
  7972. /**
  7973. * Gets the shadows Hue value.
  7974. * 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).
  7975. */
  7976. /**
  7977. * Sets the shadows Hue value.
  7978. * 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).
  7979. */
  7980. shadowsHue: number;
  7981. /**
  7982. * Gets the shadows Density value.
  7983. * 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.
  7984. * Values less than zero provide a filter of opposite hue.
  7985. */
  7986. /**
  7987. * Sets the shadows Density value.
  7988. * 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.
  7989. * Values less than zero provide a filter of opposite hue.
  7990. */
  7991. shadowsDensity: number;
  7992. /**
  7993. * Gets the shadows Saturation value.
  7994. * 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.
  7995. */
  7996. /**
  7997. * Sets the shadows Saturation value.
  7998. * 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.
  7999. */
  8000. shadowsSaturation: number;
  8001. /**
  8002. * Gets the shadows Exposure value.
  8003. * 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.
  8004. */
  8005. /**
  8006. * Sets the shadows Exposure value.
  8007. * 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.
  8008. */
  8009. shadowsExposure: number;
  8010. /**
  8011. * Returns the class name
  8012. * @returns The class name
  8013. */
  8014. getClassName(): string;
  8015. /**
  8016. * Binds the color curves to the shader.
  8017. * @param colorCurves The color curve to bind
  8018. * @param effect The effect to bind to
  8019. * @param positiveUniform The positive uniform shader parameter
  8020. * @param neutralUniform The neutral uniform shader parameter
  8021. * @param negativeUniform The negative uniform shader parameter
  8022. */
  8023. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8024. /**
  8025. * Prepare the list of uniforms associated with the ColorCurves effects.
  8026. * @param uniformsList The list of uniforms used in the effect
  8027. */
  8028. static PrepareUniforms(uniformsList: string[]): void;
  8029. /**
  8030. * Returns color grading data based on a hue, density, saturation and exposure value.
  8031. * @param filterHue The hue of the color filter.
  8032. * @param filterDensity The density of the color filter.
  8033. * @param saturation The saturation.
  8034. * @param exposure The exposure.
  8035. * @param result The result data container.
  8036. */
  8037. private getColorGradingDataToRef;
  8038. /**
  8039. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8040. * @param value The input slider value in range [-100,100].
  8041. * @returns Adjusted value.
  8042. */
  8043. private static applyColorGradingSliderNonlinear;
  8044. /**
  8045. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8046. * @param hue The hue (H) input.
  8047. * @param saturation The saturation (S) input.
  8048. * @param brightness The brightness (B) input.
  8049. * @result An RGBA color represented as Vector4.
  8050. */
  8051. private static fromHSBToRef;
  8052. /**
  8053. * Returns a value clamped between min and max
  8054. * @param value The value to clamp
  8055. * @param min The minimum of value
  8056. * @param max The maximum of value
  8057. * @returns The clamped value.
  8058. */
  8059. private static clamp;
  8060. /**
  8061. * Clones the current color curve instance.
  8062. * @return The cloned curves
  8063. */
  8064. clone(): ColorCurves;
  8065. /**
  8066. * Serializes the current color curve instance to a json representation.
  8067. * @return a JSON representation
  8068. */
  8069. serialize(): any;
  8070. /**
  8071. * Parses the color curve from a json representation.
  8072. * @param source the JSON source to parse
  8073. * @return The parsed curves
  8074. */
  8075. static Parse(source: any): ColorCurves;
  8076. }
  8077. }
  8078. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8079. import { Observable } from "babylonjs/Misc/observable";
  8080. import { Nullable } from "babylonjs/types";
  8081. import { Color4 } from "babylonjs/Maths/math.color";
  8082. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8083. import { Effect } from "babylonjs/Materials/effect";
  8084. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8085. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8086. /**
  8087. * Interface to follow in your material defines to integrate easily the
  8088. * Image proccessing functions.
  8089. * @hidden
  8090. */
  8091. export interface IImageProcessingConfigurationDefines {
  8092. IMAGEPROCESSING: boolean;
  8093. VIGNETTE: boolean;
  8094. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8095. VIGNETTEBLENDMODEOPAQUE: boolean;
  8096. TONEMAPPING: boolean;
  8097. TONEMAPPING_ACES: boolean;
  8098. CONTRAST: boolean;
  8099. EXPOSURE: boolean;
  8100. COLORCURVES: boolean;
  8101. COLORGRADING: boolean;
  8102. COLORGRADING3D: boolean;
  8103. SAMPLER3DGREENDEPTH: boolean;
  8104. SAMPLER3DBGRMAP: boolean;
  8105. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8106. }
  8107. /**
  8108. * @hidden
  8109. */
  8110. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8111. IMAGEPROCESSING: boolean;
  8112. VIGNETTE: boolean;
  8113. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8114. VIGNETTEBLENDMODEOPAQUE: boolean;
  8115. TONEMAPPING: boolean;
  8116. TONEMAPPING_ACES: boolean;
  8117. CONTRAST: boolean;
  8118. COLORCURVES: boolean;
  8119. COLORGRADING: boolean;
  8120. COLORGRADING3D: boolean;
  8121. SAMPLER3DGREENDEPTH: boolean;
  8122. SAMPLER3DBGRMAP: boolean;
  8123. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8124. EXPOSURE: boolean;
  8125. constructor();
  8126. }
  8127. /**
  8128. * This groups together the common properties used for image processing either in direct forward pass
  8129. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8130. * or not.
  8131. */
  8132. export class ImageProcessingConfiguration {
  8133. /**
  8134. * Default tone mapping applied in BabylonJS.
  8135. */
  8136. static readonly TONEMAPPING_STANDARD: number;
  8137. /**
  8138. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8139. * to other engines rendering to increase portability.
  8140. */
  8141. static readonly TONEMAPPING_ACES: number;
  8142. /**
  8143. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8144. */
  8145. colorCurves: Nullable<ColorCurves>;
  8146. private _colorCurvesEnabled;
  8147. /**
  8148. * Gets wether the color curves effect is enabled.
  8149. */
  8150. /**
  8151. * Sets wether the color curves effect is enabled.
  8152. */
  8153. colorCurvesEnabled: boolean;
  8154. private _colorGradingTexture;
  8155. /**
  8156. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8157. */
  8158. /**
  8159. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8160. */
  8161. colorGradingTexture: Nullable<BaseTexture>;
  8162. private _colorGradingEnabled;
  8163. /**
  8164. * Gets wether the color grading effect is enabled.
  8165. */
  8166. /**
  8167. * Sets wether the color grading effect is enabled.
  8168. */
  8169. colorGradingEnabled: boolean;
  8170. private _colorGradingWithGreenDepth;
  8171. /**
  8172. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8173. */
  8174. /**
  8175. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8176. */
  8177. colorGradingWithGreenDepth: boolean;
  8178. private _colorGradingBGR;
  8179. /**
  8180. * Gets wether the color grading texture contains BGR values.
  8181. */
  8182. /**
  8183. * Sets wether the color grading texture contains BGR values.
  8184. */
  8185. colorGradingBGR: boolean;
  8186. /** @hidden */
  8187. _exposure: number;
  8188. /**
  8189. * Gets the Exposure used in the effect.
  8190. */
  8191. /**
  8192. * Sets the Exposure used in the effect.
  8193. */
  8194. exposure: number;
  8195. private _toneMappingEnabled;
  8196. /**
  8197. * Gets wether the tone mapping effect is enabled.
  8198. */
  8199. /**
  8200. * Sets wether the tone mapping effect is enabled.
  8201. */
  8202. toneMappingEnabled: boolean;
  8203. private _toneMappingType;
  8204. /**
  8205. * Gets the type of tone mapping effect.
  8206. */
  8207. /**
  8208. * Sets the type of tone mapping effect used in BabylonJS.
  8209. */
  8210. toneMappingType: number;
  8211. protected _contrast: number;
  8212. /**
  8213. * Gets the contrast used in the effect.
  8214. */
  8215. /**
  8216. * Sets the contrast used in the effect.
  8217. */
  8218. contrast: number;
  8219. /**
  8220. * Vignette stretch size.
  8221. */
  8222. vignetteStretch: number;
  8223. /**
  8224. * Vignette centre X Offset.
  8225. */
  8226. vignetteCentreX: number;
  8227. /**
  8228. * Vignette centre Y Offset.
  8229. */
  8230. vignetteCentreY: number;
  8231. /**
  8232. * Vignette weight or intensity of the vignette effect.
  8233. */
  8234. vignetteWeight: number;
  8235. /**
  8236. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8237. * if vignetteEnabled is set to true.
  8238. */
  8239. vignetteColor: Color4;
  8240. /**
  8241. * Camera field of view used by the Vignette effect.
  8242. */
  8243. vignetteCameraFov: number;
  8244. private _vignetteBlendMode;
  8245. /**
  8246. * Gets the vignette blend mode allowing different kind of effect.
  8247. */
  8248. /**
  8249. * Sets the vignette blend mode allowing different kind of effect.
  8250. */
  8251. vignetteBlendMode: number;
  8252. private _vignetteEnabled;
  8253. /**
  8254. * Gets wether the vignette effect is enabled.
  8255. */
  8256. /**
  8257. * Sets wether the vignette effect is enabled.
  8258. */
  8259. vignetteEnabled: boolean;
  8260. private _applyByPostProcess;
  8261. /**
  8262. * Gets wether the image processing is applied through a post process or not.
  8263. */
  8264. /**
  8265. * Sets wether the image processing is applied through a post process or not.
  8266. */
  8267. applyByPostProcess: boolean;
  8268. private _isEnabled;
  8269. /**
  8270. * Gets wether the image processing is enabled or not.
  8271. */
  8272. /**
  8273. * Sets wether the image processing is enabled or not.
  8274. */
  8275. isEnabled: boolean;
  8276. /**
  8277. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8278. */
  8279. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8280. /**
  8281. * Method called each time the image processing information changes requires to recompile the effect.
  8282. */
  8283. protected _updateParameters(): void;
  8284. /**
  8285. * Gets the current class name.
  8286. * @return "ImageProcessingConfiguration"
  8287. */
  8288. getClassName(): string;
  8289. /**
  8290. * Prepare the list of uniforms associated with the Image Processing effects.
  8291. * @param uniforms The list of uniforms used in the effect
  8292. * @param defines the list of defines currently in use
  8293. */
  8294. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8295. /**
  8296. * Prepare the list of samplers associated with the Image Processing effects.
  8297. * @param samplersList The list of uniforms used in the effect
  8298. * @param defines the list of defines currently in use
  8299. */
  8300. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8301. /**
  8302. * Prepare the list of defines associated to the shader.
  8303. * @param defines the list of defines to complete
  8304. * @param forPostProcess Define if we are currently in post process mode or not
  8305. */
  8306. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8307. /**
  8308. * Returns true if all the image processing information are ready.
  8309. * @returns True if ready, otherwise, false
  8310. */
  8311. isReady(): boolean;
  8312. /**
  8313. * Binds the image processing to the shader.
  8314. * @param effect The effect to bind to
  8315. * @param overrideAspectRatio Override the aspect ratio of the effect
  8316. */
  8317. bind(effect: Effect, overrideAspectRatio?: number): void;
  8318. /**
  8319. * Clones the current image processing instance.
  8320. * @return The cloned image processing
  8321. */
  8322. clone(): ImageProcessingConfiguration;
  8323. /**
  8324. * Serializes the current image processing instance to a json representation.
  8325. * @return a JSON representation
  8326. */
  8327. serialize(): any;
  8328. /**
  8329. * Parses the image processing from a json representation.
  8330. * @param source the JSON source to parse
  8331. * @return The parsed image processing
  8332. */
  8333. static Parse(source: any): ImageProcessingConfiguration;
  8334. private static _VIGNETTEMODE_MULTIPLY;
  8335. private static _VIGNETTEMODE_OPAQUE;
  8336. /**
  8337. * Used to apply the vignette as a mix with the pixel color.
  8338. */
  8339. static readonly VIGNETTEMODE_MULTIPLY: number;
  8340. /**
  8341. * Used to apply the vignette as a replacement of the pixel color.
  8342. */
  8343. static readonly VIGNETTEMODE_OPAQUE: number;
  8344. }
  8345. }
  8346. declare module "babylonjs/Shaders/postprocess.vertex" {
  8347. /** @hidden */
  8348. export var postprocessVertexShader: {
  8349. name: string;
  8350. shader: string;
  8351. };
  8352. }
  8353. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8354. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8355. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8356. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8357. module "babylonjs/Engines/thinEngine" {
  8358. interface ThinEngine {
  8359. /**
  8360. * Creates a new render target texture
  8361. * @param size defines the size of the texture
  8362. * @param options defines the options used to create the texture
  8363. * @returns a new render target texture stored in an InternalTexture
  8364. */
  8365. createRenderTargetTexture(size: number | {
  8366. width: number;
  8367. height: number;
  8368. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8369. /**
  8370. * Creates a depth stencil texture.
  8371. * This is only available in WebGL 2 or with the depth texture extension available.
  8372. * @param size The size of face edge in the texture.
  8373. * @param options The options defining the texture.
  8374. * @returns The texture
  8375. */
  8376. createDepthStencilTexture(size: number | {
  8377. width: number;
  8378. height: number;
  8379. }, options: DepthTextureCreationOptions): InternalTexture;
  8380. /** @hidden */
  8381. _createDepthStencilTexture(size: number | {
  8382. width: number;
  8383. height: number;
  8384. }, options: DepthTextureCreationOptions): InternalTexture;
  8385. }
  8386. }
  8387. }
  8388. declare module "babylonjs/Maths/math.axis" {
  8389. import { Vector3 } from "babylonjs/Maths/math.vector";
  8390. /** Defines supported spaces */
  8391. export enum Space {
  8392. /** Local (object) space */
  8393. LOCAL = 0,
  8394. /** World space */
  8395. WORLD = 1,
  8396. /** Bone space */
  8397. BONE = 2
  8398. }
  8399. /** Defines the 3 main axes */
  8400. export class Axis {
  8401. /** X axis */
  8402. static X: Vector3;
  8403. /** Y axis */
  8404. static Y: Vector3;
  8405. /** Z axis */
  8406. static Z: Vector3;
  8407. }
  8408. }
  8409. declare module "babylonjs/Cameras/targetCamera" {
  8410. import { Nullable } from "babylonjs/types";
  8411. import { Camera } from "babylonjs/Cameras/camera";
  8412. import { Scene } from "babylonjs/scene";
  8413. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8414. /**
  8415. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8416. * This is the base of the follow, arc rotate cameras and Free camera
  8417. * @see http://doc.babylonjs.com/features/cameras
  8418. */
  8419. export class TargetCamera extends Camera {
  8420. private static _RigCamTransformMatrix;
  8421. private static _TargetTransformMatrix;
  8422. private static _TargetFocalPoint;
  8423. /**
  8424. * Define the current direction the camera is moving to
  8425. */
  8426. cameraDirection: Vector3;
  8427. /**
  8428. * Define the current rotation the camera is rotating to
  8429. */
  8430. cameraRotation: Vector2;
  8431. /**
  8432. * When set, the up vector of the camera will be updated by the rotation of the camera
  8433. */
  8434. updateUpVectorFromRotation: boolean;
  8435. private _tmpQuaternion;
  8436. /**
  8437. * Define the current rotation of the camera
  8438. */
  8439. rotation: Vector3;
  8440. /**
  8441. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8442. */
  8443. rotationQuaternion: Quaternion;
  8444. /**
  8445. * Define the current speed of the camera
  8446. */
  8447. speed: number;
  8448. /**
  8449. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8450. * around all axis.
  8451. */
  8452. noRotationConstraint: boolean;
  8453. /**
  8454. * Define the current target of the camera as an object or a position.
  8455. */
  8456. lockedTarget: any;
  8457. /** @hidden */
  8458. _currentTarget: Vector3;
  8459. /** @hidden */
  8460. _initialFocalDistance: number;
  8461. /** @hidden */
  8462. _viewMatrix: Matrix;
  8463. /** @hidden */
  8464. _camMatrix: Matrix;
  8465. /** @hidden */
  8466. _cameraTransformMatrix: Matrix;
  8467. /** @hidden */
  8468. _cameraRotationMatrix: Matrix;
  8469. /** @hidden */
  8470. _referencePoint: Vector3;
  8471. /** @hidden */
  8472. _transformedReferencePoint: Vector3;
  8473. protected _globalCurrentTarget: Vector3;
  8474. protected _globalCurrentUpVector: Vector3;
  8475. /** @hidden */
  8476. _reset: () => void;
  8477. private _defaultUp;
  8478. /**
  8479. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8480. * This is the base of the follow, arc rotate cameras and Free camera
  8481. * @see http://doc.babylonjs.com/features/cameras
  8482. * @param name Defines the name of the camera in the scene
  8483. * @param position Defines the start position of the camera in the scene
  8484. * @param scene Defines the scene the camera belongs to
  8485. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8486. */
  8487. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8488. /**
  8489. * Gets the position in front of the camera at a given distance.
  8490. * @param distance The distance from the camera we want the position to be
  8491. * @returns the position
  8492. */
  8493. getFrontPosition(distance: number): Vector3;
  8494. /** @hidden */
  8495. _getLockedTargetPosition(): Nullable<Vector3>;
  8496. private _storedPosition;
  8497. private _storedRotation;
  8498. private _storedRotationQuaternion;
  8499. /**
  8500. * Store current camera state of the camera (fov, position, rotation, etc..)
  8501. * @returns the camera
  8502. */
  8503. storeState(): Camera;
  8504. /**
  8505. * Restored camera state. You must call storeState() first
  8506. * @returns whether it was successful or not
  8507. * @hidden
  8508. */
  8509. _restoreStateValues(): boolean;
  8510. /** @hidden */
  8511. _initCache(): void;
  8512. /** @hidden */
  8513. _updateCache(ignoreParentClass?: boolean): void;
  8514. /** @hidden */
  8515. _isSynchronizedViewMatrix(): boolean;
  8516. /** @hidden */
  8517. _computeLocalCameraSpeed(): number;
  8518. /**
  8519. * Defines the target the camera should look at.
  8520. * @param target Defines the new target as a Vector or a mesh
  8521. */
  8522. setTarget(target: Vector3): void;
  8523. /**
  8524. * Return the current target position of the camera. This value is expressed in local space.
  8525. * @returns the target position
  8526. */
  8527. getTarget(): Vector3;
  8528. /** @hidden */
  8529. _decideIfNeedsToMove(): boolean;
  8530. /** @hidden */
  8531. _updatePosition(): void;
  8532. /** @hidden */
  8533. _checkInputs(): void;
  8534. protected _updateCameraRotationMatrix(): void;
  8535. /**
  8536. * 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)
  8537. * @returns the current camera
  8538. */
  8539. private _rotateUpVectorWithCameraRotationMatrix;
  8540. private _cachedRotationZ;
  8541. private _cachedQuaternionRotationZ;
  8542. /** @hidden */
  8543. _getViewMatrix(): Matrix;
  8544. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8545. /**
  8546. * @hidden
  8547. */
  8548. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8549. /**
  8550. * @hidden
  8551. */
  8552. _updateRigCameras(): void;
  8553. private _getRigCamPositionAndTarget;
  8554. /**
  8555. * Gets the current object class name.
  8556. * @return the class name
  8557. */
  8558. getClassName(): string;
  8559. }
  8560. }
  8561. declare module "babylonjs/Events/keyboardEvents" {
  8562. /**
  8563. * Gather the list of keyboard event types as constants.
  8564. */
  8565. export class KeyboardEventTypes {
  8566. /**
  8567. * The keydown event is fired when a key becomes active (pressed).
  8568. */
  8569. static readonly KEYDOWN: number;
  8570. /**
  8571. * The keyup event is fired when a key has been released.
  8572. */
  8573. static readonly KEYUP: number;
  8574. }
  8575. /**
  8576. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8577. */
  8578. export class KeyboardInfo {
  8579. /**
  8580. * Defines the type of event (KeyboardEventTypes)
  8581. */
  8582. type: number;
  8583. /**
  8584. * Defines the related dom event
  8585. */
  8586. event: KeyboardEvent;
  8587. /**
  8588. * Instantiates a new keyboard info.
  8589. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8590. * @param type Defines the type of event (KeyboardEventTypes)
  8591. * @param event Defines the related dom event
  8592. */
  8593. constructor(
  8594. /**
  8595. * Defines the type of event (KeyboardEventTypes)
  8596. */
  8597. type: number,
  8598. /**
  8599. * Defines the related dom event
  8600. */
  8601. event: KeyboardEvent);
  8602. }
  8603. /**
  8604. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8605. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8606. */
  8607. export class KeyboardInfoPre extends KeyboardInfo {
  8608. /**
  8609. * Defines the type of event (KeyboardEventTypes)
  8610. */
  8611. type: number;
  8612. /**
  8613. * Defines the related dom event
  8614. */
  8615. event: KeyboardEvent;
  8616. /**
  8617. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8618. */
  8619. skipOnPointerObservable: boolean;
  8620. /**
  8621. * Instantiates a new keyboard pre info.
  8622. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8623. * @param type Defines the type of event (KeyboardEventTypes)
  8624. * @param event Defines the related dom event
  8625. */
  8626. constructor(
  8627. /**
  8628. * Defines the type of event (KeyboardEventTypes)
  8629. */
  8630. type: number,
  8631. /**
  8632. * Defines the related dom event
  8633. */
  8634. event: KeyboardEvent);
  8635. }
  8636. }
  8637. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8638. import { Nullable } from "babylonjs/types";
  8639. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8640. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8641. /**
  8642. * Manage the keyboard inputs to control the movement of a free camera.
  8643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8644. */
  8645. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8646. /**
  8647. * Defines the camera the input is attached to.
  8648. */
  8649. camera: FreeCamera;
  8650. /**
  8651. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8652. */
  8653. keysUp: number[];
  8654. /**
  8655. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8656. */
  8657. keysDown: number[];
  8658. /**
  8659. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8660. */
  8661. keysLeft: number[];
  8662. /**
  8663. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8664. */
  8665. keysRight: number[];
  8666. private _keys;
  8667. private _onCanvasBlurObserver;
  8668. private _onKeyboardObserver;
  8669. private _engine;
  8670. private _scene;
  8671. /**
  8672. * Attach the input controls to a specific dom element to get the input from.
  8673. * @param element Defines the element the controls should be listened from
  8674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8675. */
  8676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8677. /**
  8678. * Detach the current controls from the specified dom element.
  8679. * @param element Defines the element to stop listening the inputs from
  8680. */
  8681. detachControl(element: Nullable<HTMLElement>): void;
  8682. /**
  8683. * Update the current camera state depending on the inputs that have been used this frame.
  8684. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8685. */
  8686. checkInputs(): void;
  8687. /**
  8688. * Gets the class name of the current intput.
  8689. * @returns the class name
  8690. */
  8691. getClassName(): string;
  8692. /** @hidden */
  8693. _onLostFocus(): void;
  8694. /**
  8695. * Get the friendly name associated with the input class.
  8696. * @returns the input friendly name
  8697. */
  8698. getSimpleName(): string;
  8699. }
  8700. }
  8701. declare module "babylonjs/Lights/shadowLight" {
  8702. import { Camera } from "babylonjs/Cameras/camera";
  8703. import { Scene } from "babylonjs/scene";
  8704. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8706. import { Light } from "babylonjs/Lights/light";
  8707. /**
  8708. * Interface describing all the common properties and methods a shadow light needs to implement.
  8709. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8710. * as well as binding the different shadow properties to the effects.
  8711. */
  8712. export interface IShadowLight extends Light {
  8713. /**
  8714. * The light id in the scene (used in scene.findLighById for instance)
  8715. */
  8716. id: string;
  8717. /**
  8718. * The position the shdow will be casted from.
  8719. */
  8720. position: Vector3;
  8721. /**
  8722. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8723. */
  8724. direction: Vector3;
  8725. /**
  8726. * The transformed position. Position of the light in world space taking parenting in account.
  8727. */
  8728. transformedPosition: Vector3;
  8729. /**
  8730. * The transformed direction. Direction of the light in world space taking parenting in account.
  8731. */
  8732. transformedDirection: Vector3;
  8733. /**
  8734. * The friendly name of the light in the scene.
  8735. */
  8736. name: string;
  8737. /**
  8738. * Defines the shadow projection clipping minimum z value.
  8739. */
  8740. shadowMinZ: number;
  8741. /**
  8742. * Defines the shadow projection clipping maximum z value.
  8743. */
  8744. shadowMaxZ: number;
  8745. /**
  8746. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8747. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8748. */
  8749. computeTransformedInformation(): boolean;
  8750. /**
  8751. * Gets the scene the light belongs to.
  8752. * @returns The scene
  8753. */
  8754. getScene(): Scene;
  8755. /**
  8756. * Callback defining a custom Projection Matrix Builder.
  8757. * This can be used to override the default projection matrix computation.
  8758. */
  8759. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8760. /**
  8761. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8762. * @param matrix The materix to updated with the projection information
  8763. * @param viewMatrix The transform matrix of the light
  8764. * @param renderList The list of mesh to render in the map
  8765. * @returns The current light
  8766. */
  8767. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8768. /**
  8769. * Gets the current depth scale used in ESM.
  8770. * @returns The scale
  8771. */
  8772. getDepthScale(): number;
  8773. /**
  8774. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8775. * @returns true if a cube texture needs to be use
  8776. */
  8777. needCube(): boolean;
  8778. /**
  8779. * Detects if the projection matrix requires to be recomputed this frame.
  8780. * @returns true if it requires to be recomputed otherwise, false.
  8781. */
  8782. needProjectionMatrixCompute(): boolean;
  8783. /**
  8784. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8785. */
  8786. forceProjectionMatrixCompute(): void;
  8787. /**
  8788. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8789. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8790. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8791. */
  8792. getShadowDirection(faceIndex?: number): Vector3;
  8793. /**
  8794. * Gets the minZ used for shadow according to both the scene and the light.
  8795. * @param activeCamera The camera we are returning the min for
  8796. * @returns the depth min z
  8797. */
  8798. getDepthMinZ(activeCamera: Camera): number;
  8799. /**
  8800. * Gets the maxZ used for shadow according to both the scene and the light.
  8801. * @param activeCamera The camera we are returning the max for
  8802. * @returns the depth max z
  8803. */
  8804. getDepthMaxZ(activeCamera: Camera): number;
  8805. }
  8806. /**
  8807. * Base implementation IShadowLight
  8808. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8809. */
  8810. export abstract class ShadowLight extends Light implements IShadowLight {
  8811. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8812. protected _position: Vector3;
  8813. protected _setPosition(value: Vector3): void;
  8814. /**
  8815. * Sets the position the shadow will be casted from. Also use as the light position for both
  8816. * point and spot lights.
  8817. */
  8818. /**
  8819. * Sets the position the shadow will be casted from. Also use as the light position for both
  8820. * point and spot lights.
  8821. */
  8822. position: Vector3;
  8823. protected _direction: Vector3;
  8824. protected _setDirection(value: Vector3): void;
  8825. /**
  8826. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8827. * Also use as the light direction on spot and directional lights.
  8828. */
  8829. /**
  8830. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8831. * Also use as the light direction on spot and directional lights.
  8832. */
  8833. direction: Vector3;
  8834. private _shadowMinZ;
  8835. /**
  8836. * Gets the shadow projection clipping minimum z value.
  8837. */
  8838. /**
  8839. * Sets the shadow projection clipping minimum z value.
  8840. */
  8841. shadowMinZ: number;
  8842. private _shadowMaxZ;
  8843. /**
  8844. * Sets the shadow projection clipping maximum z value.
  8845. */
  8846. /**
  8847. * Gets the shadow projection clipping maximum z value.
  8848. */
  8849. shadowMaxZ: number;
  8850. /**
  8851. * Callback defining a custom Projection Matrix Builder.
  8852. * This can be used to override the default projection matrix computation.
  8853. */
  8854. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8855. /**
  8856. * The transformed position. Position of the light in world space taking parenting in account.
  8857. */
  8858. transformedPosition: Vector3;
  8859. /**
  8860. * The transformed direction. Direction of the light in world space taking parenting in account.
  8861. */
  8862. transformedDirection: Vector3;
  8863. private _needProjectionMatrixCompute;
  8864. /**
  8865. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8866. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8867. */
  8868. computeTransformedInformation(): boolean;
  8869. /**
  8870. * Return the depth scale used for the shadow map.
  8871. * @returns the depth scale.
  8872. */
  8873. getDepthScale(): number;
  8874. /**
  8875. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8876. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8877. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8878. */
  8879. getShadowDirection(faceIndex?: number): Vector3;
  8880. /**
  8881. * Returns the ShadowLight absolute position in the World.
  8882. * @returns the position vector in world space
  8883. */
  8884. getAbsolutePosition(): Vector3;
  8885. /**
  8886. * Sets the ShadowLight direction toward the passed target.
  8887. * @param target The point to target in local space
  8888. * @returns the updated ShadowLight direction
  8889. */
  8890. setDirectionToTarget(target: Vector3): Vector3;
  8891. /**
  8892. * Returns the light rotation in euler definition.
  8893. * @returns the x y z rotation in local space.
  8894. */
  8895. getRotation(): Vector3;
  8896. /**
  8897. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8898. * @returns true if a cube texture needs to be use
  8899. */
  8900. needCube(): boolean;
  8901. /**
  8902. * Detects if the projection matrix requires to be recomputed this frame.
  8903. * @returns true if it requires to be recomputed otherwise, false.
  8904. */
  8905. needProjectionMatrixCompute(): boolean;
  8906. /**
  8907. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8908. */
  8909. forceProjectionMatrixCompute(): void;
  8910. /** @hidden */
  8911. _initCache(): void;
  8912. /** @hidden */
  8913. _isSynchronized(): boolean;
  8914. /**
  8915. * Computes the world matrix of the node
  8916. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8917. * @returns the world matrix
  8918. */
  8919. computeWorldMatrix(force?: boolean): Matrix;
  8920. /**
  8921. * Gets the minZ used for shadow according to both the scene and the light.
  8922. * @param activeCamera The camera we are returning the min for
  8923. * @returns the depth min z
  8924. */
  8925. getDepthMinZ(activeCamera: Camera): number;
  8926. /**
  8927. * Gets the maxZ used for shadow according to both the scene and the light.
  8928. * @param activeCamera The camera we are returning the max for
  8929. * @returns the depth max z
  8930. */
  8931. getDepthMaxZ(activeCamera: Camera): number;
  8932. /**
  8933. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8934. * @param matrix The materix to updated with the projection information
  8935. * @param viewMatrix The transform matrix of the light
  8936. * @param renderList The list of mesh to render in the map
  8937. * @returns The current light
  8938. */
  8939. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8940. }
  8941. }
  8942. declare module "babylonjs/Materials/effectFallbacks" {
  8943. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8944. import { Effect } from "babylonjs/Materials/effect";
  8945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8946. /**
  8947. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8948. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8949. */
  8950. export class EffectFallbacks implements IEffectFallbacks {
  8951. private _defines;
  8952. private _currentRank;
  8953. private _maxRank;
  8954. private _mesh;
  8955. /**
  8956. * Removes the fallback from the bound mesh.
  8957. */
  8958. unBindMesh(): void;
  8959. /**
  8960. * Adds a fallback on the specified property.
  8961. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8962. * @param define The name of the define in the shader
  8963. */
  8964. addFallback(rank: number, define: string): void;
  8965. /**
  8966. * Sets the mesh to use CPU skinning when needing to fallback.
  8967. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8968. * @param mesh The mesh to use the fallbacks.
  8969. */
  8970. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8971. /**
  8972. * Checks to see if more fallbacks are still availible.
  8973. */
  8974. readonly hasMoreFallbacks: boolean;
  8975. /**
  8976. * Removes the defines that should be removed when falling back.
  8977. * @param currentDefines defines the current define statements for the shader.
  8978. * @param effect defines the current effect we try to compile
  8979. * @returns The resulting defines with defines of the current rank removed.
  8980. */
  8981. reduce(currentDefines: string, effect: Effect): string;
  8982. }
  8983. }
  8984. declare module "babylonjs/Materials/materialHelper" {
  8985. import { Nullable } from "babylonjs/types";
  8986. import { Scene } from "babylonjs/scene";
  8987. import { Engine } from "babylonjs/Engines/engine";
  8988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8989. import { Light } from "babylonjs/Lights/light";
  8990. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8991. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  8992. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8993. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8994. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  8995. /**
  8996. * "Static Class" containing the most commonly used helper while dealing with material for
  8997. * rendering purpose.
  8998. *
  8999. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9000. *
  9001. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9002. */
  9003. export class MaterialHelper {
  9004. /**
  9005. * Bind the current view position to an effect.
  9006. * @param effect The effect to be bound
  9007. * @param scene The scene the eyes position is used from
  9008. */
  9009. static BindEyePosition(effect: Effect, scene: Scene): void;
  9010. /**
  9011. * Helps preparing the defines values about the UVs in used in the effect.
  9012. * UVs are shared as much as we can accross channels in the shaders.
  9013. * @param texture The texture we are preparing the UVs for
  9014. * @param defines The defines to update
  9015. * @param key The channel key "diffuse", "specular"... used in the shader
  9016. */
  9017. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9018. /**
  9019. * Binds a texture matrix value to its corrsponding uniform
  9020. * @param texture The texture to bind the matrix for
  9021. * @param uniformBuffer The uniform buffer receivin the data
  9022. * @param key The channel key "diffuse", "specular"... used in the shader
  9023. */
  9024. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9025. /**
  9026. * Gets the current status of the fog (should it be enabled?)
  9027. * @param mesh defines the mesh to evaluate for fog support
  9028. * @param scene defines the hosting scene
  9029. * @returns true if fog must be enabled
  9030. */
  9031. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9032. /**
  9033. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9034. * @param mesh defines the current mesh
  9035. * @param scene defines the current scene
  9036. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9037. * @param pointsCloud defines if point cloud rendering has to be turned on
  9038. * @param fogEnabled defines if fog has to be turned on
  9039. * @param alphaTest defines if alpha testing has to be turned on
  9040. * @param defines defines the current list of defines
  9041. */
  9042. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9043. /**
  9044. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9045. * @param scene defines the current scene
  9046. * @param engine defines the current engine
  9047. * @param defines specifies the list of active defines
  9048. * @param useInstances defines if instances have to be turned on
  9049. * @param useClipPlane defines if clip plane have to be turned on
  9050. */
  9051. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9052. /**
  9053. * Prepares the defines for bones
  9054. * @param mesh The mesh containing the geometry data we will draw
  9055. * @param defines The defines to update
  9056. */
  9057. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9058. /**
  9059. * Prepares the defines for morph targets
  9060. * @param mesh The mesh containing the geometry data we will draw
  9061. * @param defines The defines to update
  9062. */
  9063. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9064. /**
  9065. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9066. * @param mesh The mesh containing the geometry data we will draw
  9067. * @param defines The defines to update
  9068. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9069. * @param useBones Precise whether bones should be used or not (override mesh info)
  9070. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9071. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9072. * @returns false if defines are considered not dirty and have not been checked
  9073. */
  9074. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9075. /**
  9076. * Prepares the defines related to multiview
  9077. * @param scene The scene we are intending to draw
  9078. * @param defines The defines to update
  9079. */
  9080. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9081. /**
  9082. * Prepares the defines related to the light information passed in parameter
  9083. * @param scene The scene we are intending to draw
  9084. * @param mesh The mesh the effect is compiling for
  9085. * @param light The light the effect is compiling for
  9086. * @param lightIndex The index of the light
  9087. * @param defines The defines to update
  9088. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9089. * @param state Defines the current state regarding what is needed (normals, etc...)
  9090. */
  9091. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9092. needNormals: boolean;
  9093. needRebuild: boolean;
  9094. shadowEnabled: boolean;
  9095. specularEnabled: boolean;
  9096. lightmapMode: boolean;
  9097. }): void;
  9098. /**
  9099. * Prepares the defines related to the light information passed in parameter
  9100. * @param scene The scene we are intending to draw
  9101. * @param mesh The mesh the effect is compiling for
  9102. * @param defines The defines to update
  9103. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9104. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9105. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9106. * @returns true if normals will be required for the rest of the effect
  9107. */
  9108. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9109. /**
  9110. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9111. * @param lightIndex defines the light index
  9112. * @param uniformsList The uniform list
  9113. * @param samplersList The sampler list
  9114. * @param projectedLightTexture defines if projected texture must be used
  9115. * @param uniformBuffersList defines an optional list of uniform buffers
  9116. */
  9117. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9118. /**
  9119. * Prepares the uniforms and samplers list to be used in the effect
  9120. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9121. * @param samplersList The sampler list
  9122. * @param defines The defines helping in the list generation
  9123. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9124. */
  9125. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9126. /**
  9127. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9128. * @param defines The defines to update while falling back
  9129. * @param fallbacks The authorized effect fallbacks
  9130. * @param maxSimultaneousLights The maximum number of lights allowed
  9131. * @param rank the current rank of the Effect
  9132. * @returns The newly affected rank
  9133. */
  9134. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9135. private static _TmpMorphInfluencers;
  9136. /**
  9137. * Prepares the list of attributes required for morph targets according to the effect defines.
  9138. * @param attribs The current list of supported attribs
  9139. * @param mesh The mesh to prepare the morph targets attributes for
  9140. * @param influencers The number of influencers
  9141. */
  9142. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9143. /**
  9144. * Prepares the list of attributes required for morph targets according to the effect defines.
  9145. * @param attribs The current list of supported attribs
  9146. * @param mesh The mesh to prepare the morph targets attributes for
  9147. * @param defines The current Defines of the effect
  9148. */
  9149. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9150. /**
  9151. * Prepares the list of attributes required for bones according to the effect defines.
  9152. * @param attribs The current list of supported attribs
  9153. * @param mesh The mesh to prepare the bones attributes for
  9154. * @param defines The current Defines of the effect
  9155. * @param fallbacks The current efffect fallback strategy
  9156. */
  9157. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9158. /**
  9159. * Check and prepare the list of attributes required for instances according to the effect defines.
  9160. * @param attribs The current list of supported attribs
  9161. * @param defines The current MaterialDefines of the effect
  9162. */
  9163. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9164. /**
  9165. * Add the list of attributes required for instances to the attribs array.
  9166. * @param attribs The current list of supported attribs
  9167. */
  9168. static PushAttributesForInstances(attribs: string[]): void;
  9169. /**
  9170. * Binds the light information to the effect.
  9171. * @param light The light containing the generator
  9172. * @param effect The effect we are binding the data to
  9173. * @param lightIndex The light index in the effect used to render
  9174. */
  9175. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9176. /**
  9177. * Binds the lights information from the scene to the effect for the given mesh.
  9178. * @param light Light to bind
  9179. * @param lightIndex Light index
  9180. * @param scene The scene where the light belongs to
  9181. * @param effect The effect we are binding the data to
  9182. * @param useSpecular Defines if specular is supported
  9183. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9184. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9185. */
  9186. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9187. /**
  9188. * Binds the lights information from the scene to the effect for the given mesh.
  9189. * @param scene The scene the lights belongs to
  9190. * @param mesh The mesh we are binding the information to render
  9191. * @param effect The effect we are binding the data to
  9192. * @param defines The generated defines for the effect
  9193. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9194. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9195. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9196. */
  9197. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9198. private static _tempFogColor;
  9199. /**
  9200. * Binds the fog information from the scene to the effect for the given mesh.
  9201. * @param scene The scene the lights belongs to
  9202. * @param mesh The mesh we are binding the information to render
  9203. * @param effect The effect we are binding the data to
  9204. * @param linearSpace Defines if the fog effect is applied in linear space
  9205. */
  9206. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9207. /**
  9208. * Binds the bones information from the mesh to the effect.
  9209. * @param mesh The mesh we are binding the information to render
  9210. * @param effect The effect we are binding the data to
  9211. */
  9212. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9213. /**
  9214. * Binds the morph targets information from the mesh to the effect.
  9215. * @param abstractMesh The mesh we are binding the information to render
  9216. * @param effect The effect we are binding the data to
  9217. */
  9218. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9219. /**
  9220. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9221. * @param defines The generated defines used in the effect
  9222. * @param effect The effect we are binding the data to
  9223. * @param scene The scene we are willing to render with logarithmic scale for
  9224. */
  9225. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9226. /**
  9227. * Binds the clip plane information from the scene to the effect.
  9228. * @param scene The scene the clip plane information are extracted from
  9229. * @param effect The effect we are binding the data to
  9230. */
  9231. static BindClipPlane(effect: Effect, scene: Scene): void;
  9232. }
  9233. }
  9234. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9235. /** @hidden */
  9236. export var packingFunctions: {
  9237. name: string;
  9238. shader: string;
  9239. };
  9240. }
  9241. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9242. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9243. /** @hidden */
  9244. export var shadowMapPixelShader: {
  9245. name: string;
  9246. shader: string;
  9247. };
  9248. }
  9249. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9250. /** @hidden */
  9251. export var bonesDeclaration: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9257. /** @hidden */
  9258. export var morphTargetsVertexGlobalDeclaration: {
  9259. name: string;
  9260. shader: string;
  9261. };
  9262. }
  9263. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9264. /** @hidden */
  9265. export var morphTargetsVertexDeclaration: {
  9266. name: string;
  9267. shader: string;
  9268. };
  9269. }
  9270. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9271. /** @hidden */
  9272. export var instancesDeclaration: {
  9273. name: string;
  9274. shader: string;
  9275. };
  9276. }
  9277. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9278. /** @hidden */
  9279. export var helperFunctions: {
  9280. name: string;
  9281. shader: string;
  9282. };
  9283. }
  9284. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9285. /** @hidden */
  9286. export var morphTargetsVertex: {
  9287. name: string;
  9288. shader: string;
  9289. };
  9290. }
  9291. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9292. /** @hidden */
  9293. export var instancesVertex: {
  9294. name: string;
  9295. shader: string;
  9296. };
  9297. }
  9298. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9299. /** @hidden */
  9300. export var bonesVertex: {
  9301. name: string;
  9302. shader: string;
  9303. };
  9304. }
  9305. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9306. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9307. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9308. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9309. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9310. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9311. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9312. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9313. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9314. /** @hidden */
  9315. export var shadowMapVertexShader: {
  9316. name: string;
  9317. shader: string;
  9318. };
  9319. }
  9320. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9321. /** @hidden */
  9322. export var depthBoxBlurPixelShader: {
  9323. name: string;
  9324. shader: string;
  9325. };
  9326. }
  9327. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9328. import { Nullable } from "babylonjs/types";
  9329. import { Scene } from "babylonjs/scene";
  9330. import { Matrix } from "babylonjs/Maths/math.vector";
  9331. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9333. import { Mesh } from "babylonjs/Meshes/mesh";
  9334. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9335. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9336. import { Effect } from "babylonjs/Materials/effect";
  9337. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9338. import "babylonjs/Shaders/shadowMap.fragment";
  9339. import "babylonjs/Shaders/shadowMap.vertex";
  9340. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9341. import { Observable } from "babylonjs/Misc/observable";
  9342. /**
  9343. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9344. */
  9345. export interface ICustomShaderOptions {
  9346. /**
  9347. * Gets or sets the custom shader name to use
  9348. */
  9349. shaderName: string;
  9350. /**
  9351. * The list of attribute names used in the shader
  9352. */
  9353. attributes?: string[];
  9354. /**
  9355. * The list of unifrom names used in the shader
  9356. */
  9357. uniforms?: string[];
  9358. /**
  9359. * The list of sampler names used in the shader
  9360. */
  9361. samplers?: string[];
  9362. /**
  9363. * The list of defines used in the shader
  9364. */
  9365. defines?: string[];
  9366. }
  9367. /**
  9368. * Interface to implement to create a shadow generator compatible with BJS.
  9369. */
  9370. export interface IShadowGenerator {
  9371. /**
  9372. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9373. * @returns The render target texture if present otherwise, null
  9374. */
  9375. getShadowMap(): Nullable<RenderTargetTexture>;
  9376. /**
  9377. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9378. * @returns The render target texture if the shadow map is present otherwise, null
  9379. */
  9380. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9381. /**
  9382. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9383. * @param subMesh The submesh we want to render in the shadow map
  9384. * @param useInstances Defines wether will draw in the map using instances
  9385. * @returns true if ready otherwise, false
  9386. */
  9387. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9388. /**
  9389. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9390. * @param defines Defines of the material we want to update
  9391. * @param lightIndex Index of the light in the enabled light list of the material
  9392. */
  9393. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9394. /**
  9395. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9396. * defined in the generator but impacting the effect).
  9397. * It implies the unifroms available on the materials are the standard BJS ones.
  9398. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9399. * @param effect The effect we are binfing the information for
  9400. */
  9401. bindShadowLight(lightIndex: string, effect: Effect): void;
  9402. /**
  9403. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9404. * (eq to shadow prjection matrix * light transform matrix)
  9405. * @returns The transform matrix used to create the shadow map
  9406. */
  9407. getTransformMatrix(): Matrix;
  9408. /**
  9409. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9410. * Cube and 2D textures for instance.
  9411. */
  9412. recreateShadowMap(): void;
  9413. /**
  9414. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9415. * @param onCompiled Callback triggered at the and of the effects compilation
  9416. * @param options Sets of optional options forcing the compilation with different modes
  9417. */
  9418. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9419. useInstances: boolean;
  9420. }>): void;
  9421. /**
  9422. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9423. * @param options Sets of optional options forcing the compilation with different modes
  9424. * @returns A promise that resolves when the compilation completes
  9425. */
  9426. forceCompilationAsync(options?: Partial<{
  9427. useInstances: boolean;
  9428. }>): Promise<void>;
  9429. /**
  9430. * Serializes the shadow generator setup to a json object.
  9431. * @returns The serialized JSON object
  9432. */
  9433. serialize(): any;
  9434. /**
  9435. * Disposes the Shadow map and related Textures and effects.
  9436. */
  9437. dispose(): void;
  9438. }
  9439. /**
  9440. * Default implementation IShadowGenerator.
  9441. * This is the main object responsible of generating shadows in the framework.
  9442. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9443. */
  9444. export class ShadowGenerator implements IShadowGenerator {
  9445. /**
  9446. * Shadow generator mode None: no filtering applied.
  9447. */
  9448. static readonly FILTER_NONE: number;
  9449. /**
  9450. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9451. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9452. */
  9453. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9454. /**
  9455. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9456. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9457. */
  9458. static readonly FILTER_POISSONSAMPLING: number;
  9459. /**
  9460. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9461. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9462. */
  9463. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9464. /**
  9465. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9466. * edge artifacts on steep falloff.
  9467. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9468. */
  9469. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9470. /**
  9471. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9472. * edge artifacts on steep falloff.
  9473. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9474. */
  9475. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9476. /**
  9477. * Shadow generator mode PCF: Percentage Closer Filtering
  9478. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9479. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9480. */
  9481. static readonly FILTER_PCF: number;
  9482. /**
  9483. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9484. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9485. * Contact Hardening
  9486. */
  9487. static readonly FILTER_PCSS: number;
  9488. /**
  9489. * Reserved for PCF and PCSS
  9490. * Highest Quality.
  9491. *
  9492. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9493. *
  9494. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9495. */
  9496. static readonly QUALITY_HIGH: number;
  9497. /**
  9498. * Reserved for PCF and PCSS
  9499. * Good tradeoff for quality/perf cross devices
  9500. *
  9501. * Execute PCF on a 3*3 kernel.
  9502. *
  9503. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9504. */
  9505. static readonly QUALITY_MEDIUM: number;
  9506. /**
  9507. * Reserved for PCF and PCSS
  9508. * The lowest quality but the fastest.
  9509. *
  9510. * Execute PCF on a 1*1 kernel.
  9511. *
  9512. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9513. */
  9514. static readonly QUALITY_LOW: number;
  9515. /** Gets or sets the custom shader name to use */
  9516. customShaderOptions: ICustomShaderOptions;
  9517. /**
  9518. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9519. */
  9520. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9521. /**
  9522. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9523. */
  9524. onAfterShadowMapRenderObservable: Observable<Effect>;
  9525. /**
  9526. * Observable triggered before a mesh is rendered in the shadow map.
  9527. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9528. */
  9529. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9530. /**
  9531. * Observable triggered after a mesh is rendered in the shadow map.
  9532. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9533. */
  9534. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9535. private _bias;
  9536. /**
  9537. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9538. */
  9539. /**
  9540. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9541. */
  9542. bias: number;
  9543. private _normalBias;
  9544. /**
  9545. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9546. */
  9547. /**
  9548. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9549. */
  9550. normalBias: number;
  9551. private _blurBoxOffset;
  9552. /**
  9553. * Gets the blur box offset: offset applied during the blur pass.
  9554. * Only useful if useKernelBlur = false
  9555. */
  9556. /**
  9557. * Sets the blur box offset: offset applied during the blur pass.
  9558. * Only useful if useKernelBlur = false
  9559. */
  9560. blurBoxOffset: number;
  9561. private _blurScale;
  9562. /**
  9563. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9564. * 2 means half of the size.
  9565. */
  9566. /**
  9567. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9568. * 2 means half of the size.
  9569. */
  9570. blurScale: number;
  9571. private _blurKernel;
  9572. /**
  9573. * Gets the blur kernel: kernel size of the blur pass.
  9574. * Only useful if useKernelBlur = true
  9575. */
  9576. /**
  9577. * Sets the blur kernel: kernel size of the blur pass.
  9578. * Only useful if useKernelBlur = true
  9579. */
  9580. blurKernel: number;
  9581. private _useKernelBlur;
  9582. /**
  9583. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9584. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9585. */
  9586. /**
  9587. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9588. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9589. */
  9590. useKernelBlur: boolean;
  9591. private _depthScale;
  9592. /**
  9593. * Gets the depth scale used in ESM mode.
  9594. */
  9595. /**
  9596. * Sets the depth scale used in ESM mode.
  9597. * This can override the scale stored on the light.
  9598. */
  9599. depthScale: number;
  9600. private _filter;
  9601. /**
  9602. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9603. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9604. */
  9605. /**
  9606. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9607. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9608. */
  9609. filter: number;
  9610. /**
  9611. * Gets if the current filter is set to Poisson Sampling.
  9612. */
  9613. /**
  9614. * Sets the current filter to Poisson Sampling.
  9615. */
  9616. usePoissonSampling: boolean;
  9617. /**
  9618. * Gets if the current filter is set to ESM.
  9619. */
  9620. /**
  9621. * Sets the current filter is to ESM.
  9622. */
  9623. useExponentialShadowMap: boolean;
  9624. /**
  9625. * Gets if the current filter is set to filtered ESM.
  9626. */
  9627. /**
  9628. * Gets if the current filter is set to filtered ESM.
  9629. */
  9630. useBlurExponentialShadowMap: boolean;
  9631. /**
  9632. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9633. * exponential to prevent steep falloff artifacts).
  9634. */
  9635. /**
  9636. * Sets the current filter to "close ESM" (using the inverse of the
  9637. * exponential to prevent steep falloff artifacts).
  9638. */
  9639. useCloseExponentialShadowMap: boolean;
  9640. /**
  9641. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9642. * exponential to prevent steep falloff artifacts).
  9643. */
  9644. /**
  9645. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9646. * exponential to prevent steep falloff artifacts).
  9647. */
  9648. useBlurCloseExponentialShadowMap: boolean;
  9649. /**
  9650. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9651. */
  9652. /**
  9653. * Sets the current filter to "PCF" (percentage closer filtering).
  9654. */
  9655. usePercentageCloserFiltering: boolean;
  9656. private _filteringQuality;
  9657. /**
  9658. * Gets the PCF or PCSS Quality.
  9659. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9660. */
  9661. /**
  9662. * Sets the PCF or PCSS Quality.
  9663. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9664. */
  9665. filteringQuality: number;
  9666. /**
  9667. * Gets if the current filter is set to "PCSS" (contact hardening).
  9668. */
  9669. /**
  9670. * Sets the current filter to "PCSS" (contact hardening).
  9671. */
  9672. useContactHardeningShadow: boolean;
  9673. private _contactHardeningLightSizeUVRatio;
  9674. /**
  9675. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9676. * Using a ratio helps keeping shape stability independently of the map size.
  9677. *
  9678. * It does not account for the light projection as it was having too much
  9679. * instability during the light setup or during light position changes.
  9680. *
  9681. * Only valid if useContactHardeningShadow is true.
  9682. */
  9683. /**
  9684. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9685. * Using a ratio helps keeping shape stability independently of the map size.
  9686. *
  9687. * It does not account for the light projection as it was having too much
  9688. * instability during the light setup or during light position changes.
  9689. *
  9690. * Only valid if useContactHardeningShadow is true.
  9691. */
  9692. contactHardeningLightSizeUVRatio: number;
  9693. private _darkness;
  9694. /** Gets or sets the actual darkness of a shadow */
  9695. darkness: number;
  9696. /**
  9697. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9698. * 0 means strongest and 1 would means no shadow.
  9699. * @returns the darkness.
  9700. */
  9701. getDarkness(): number;
  9702. /**
  9703. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9704. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9705. * @returns the shadow generator allowing fluent coding.
  9706. */
  9707. setDarkness(darkness: number): ShadowGenerator;
  9708. private _transparencyShadow;
  9709. /** Gets or sets the ability to have transparent shadow */
  9710. transparencyShadow: boolean;
  9711. /**
  9712. * Sets the ability to have transparent shadow (boolean).
  9713. * @param transparent True if transparent else False
  9714. * @returns the shadow generator allowing fluent coding
  9715. */
  9716. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9717. private _shadowMap;
  9718. private _shadowMap2;
  9719. /**
  9720. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9721. * @returns The render target texture if present otherwise, null
  9722. */
  9723. getShadowMap(): Nullable<RenderTargetTexture>;
  9724. /**
  9725. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9726. * @returns The render target texture if the shadow map is present otherwise, null
  9727. */
  9728. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9729. /**
  9730. * Gets the class name of that object
  9731. * @returns "ShadowGenerator"
  9732. */
  9733. getClassName(): string;
  9734. /**
  9735. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9736. * @param mesh Mesh to add
  9737. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9738. * @returns the Shadow Generator itself
  9739. */
  9740. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9741. /**
  9742. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9743. * @param mesh Mesh to remove
  9744. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9745. * @returns the Shadow Generator itself
  9746. */
  9747. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9748. /**
  9749. * Controls the extent to which the shadows fade out at the edge of the frustum
  9750. * Used only by directionals and spots
  9751. */
  9752. frustumEdgeFalloff: number;
  9753. private _light;
  9754. /**
  9755. * Returns the associated light object.
  9756. * @returns the light generating the shadow
  9757. */
  9758. getLight(): IShadowLight;
  9759. /**
  9760. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9761. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9762. * It might on the other hand introduce peter panning.
  9763. */
  9764. forceBackFacesOnly: boolean;
  9765. private _scene;
  9766. private _lightDirection;
  9767. private _effect;
  9768. private _viewMatrix;
  9769. private _projectionMatrix;
  9770. private _transformMatrix;
  9771. private _cachedPosition;
  9772. private _cachedDirection;
  9773. private _cachedDefines;
  9774. private _currentRenderID;
  9775. private _boxBlurPostprocess;
  9776. private _kernelBlurXPostprocess;
  9777. private _kernelBlurYPostprocess;
  9778. private _blurPostProcesses;
  9779. private _mapSize;
  9780. private _currentFaceIndex;
  9781. private _currentFaceIndexCache;
  9782. private _textureType;
  9783. private _defaultTextureMatrix;
  9784. private _storedUniqueId;
  9785. /** @hidden */
  9786. static _SceneComponentInitialization: (scene: Scene) => void;
  9787. /**
  9788. * Creates a ShadowGenerator object.
  9789. * A ShadowGenerator is the required tool to use the shadows.
  9790. * Each light casting shadows needs to use its own ShadowGenerator.
  9791. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9792. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9793. * @param light The light object generating the shadows.
  9794. * @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.
  9795. */
  9796. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9797. private _initializeGenerator;
  9798. private _initializeShadowMap;
  9799. private _initializeBlurRTTAndPostProcesses;
  9800. private _renderForShadowMap;
  9801. private _renderSubMeshForShadowMap;
  9802. private _applyFilterValues;
  9803. /**
  9804. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9805. * @param onCompiled Callback triggered at the and of the effects compilation
  9806. * @param options Sets of optional options forcing the compilation with different modes
  9807. */
  9808. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9809. useInstances: boolean;
  9810. }>): void;
  9811. /**
  9812. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9813. * @param options Sets of optional options forcing the compilation with different modes
  9814. * @returns A promise that resolves when the compilation completes
  9815. */
  9816. forceCompilationAsync(options?: Partial<{
  9817. useInstances: boolean;
  9818. }>): Promise<void>;
  9819. /**
  9820. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9821. * @param subMesh The submesh we want to render in the shadow map
  9822. * @param useInstances Defines wether will draw in the map using instances
  9823. * @returns true if ready otherwise, false
  9824. */
  9825. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9826. /**
  9827. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9828. * @param defines Defines of the material we want to update
  9829. * @param lightIndex Index of the light in the enabled light list of the material
  9830. */
  9831. prepareDefines(defines: any, lightIndex: number): void;
  9832. /**
  9833. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9834. * defined in the generator but impacting the effect).
  9835. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9836. * @param effect The effect we are binfing the information for
  9837. */
  9838. bindShadowLight(lightIndex: string, effect: Effect): void;
  9839. /**
  9840. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9841. * (eq to shadow prjection matrix * light transform matrix)
  9842. * @returns The transform matrix used to create the shadow map
  9843. */
  9844. getTransformMatrix(): Matrix;
  9845. /**
  9846. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9847. * Cube and 2D textures for instance.
  9848. */
  9849. recreateShadowMap(): void;
  9850. private _disposeBlurPostProcesses;
  9851. private _disposeRTTandPostProcesses;
  9852. /**
  9853. * Disposes the ShadowGenerator.
  9854. * Returns nothing.
  9855. */
  9856. dispose(): void;
  9857. /**
  9858. * Serializes the shadow generator setup to a json object.
  9859. * @returns The serialized JSON object
  9860. */
  9861. serialize(): any;
  9862. /**
  9863. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9864. * @param parsedShadowGenerator The JSON object to parse
  9865. * @param scene The scene to create the shadow map for
  9866. * @returns The parsed shadow generator
  9867. */
  9868. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9869. }
  9870. }
  9871. declare module "babylonjs/Lights/light" {
  9872. import { Nullable } from "babylonjs/types";
  9873. import { Scene } from "babylonjs/scene";
  9874. import { Vector3 } from "babylonjs/Maths/math.vector";
  9875. import { Color3 } from "babylonjs/Maths/math.color";
  9876. import { Node } from "babylonjs/node";
  9877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9878. import { Effect } from "babylonjs/Materials/effect";
  9879. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9880. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9881. /**
  9882. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9883. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9884. * 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.
  9885. */
  9886. export abstract class Light extends Node {
  9887. /**
  9888. * Falloff Default: light is falling off following the material specification:
  9889. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9890. */
  9891. static readonly FALLOFF_DEFAULT: number;
  9892. /**
  9893. * Falloff Physical: light is falling off following the inverse squared distance law.
  9894. */
  9895. static readonly FALLOFF_PHYSICAL: number;
  9896. /**
  9897. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9898. * to enhance interoperability with other engines.
  9899. */
  9900. static readonly FALLOFF_GLTF: number;
  9901. /**
  9902. * Falloff Standard: light is falling off like in the standard material
  9903. * to enhance interoperability with other materials.
  9904. */
  9905. static readonly FALLOFF_STANDARD: number;
  9906. /**
  9907. * If every light affecting the material is in this lightmapMode,
  9908. * material.lightmapTexture adds or multiplies
  9909. * (depends on material.useLightmapAsShadowmap)
  9910. * after every other light calculations.
  9911. */
  9912. static readonly LIGHTMAP_DEFAULT: number;
  9913. /**
  9914. * material.lightmapTexture as only diffuse lighting from this light
  9915. * adds only specular lighting from this light
  9916. * adds dynamic shadows
  9917. */
  9918. static readonly LIGHTMAP_SPECULAR: number;
  9919. /**
  9920. * material.lightmapTexture as only lighting
  9921. * no light calculation from this light
  9922. * only adds dynamic shadows from this light
  9923. */
  9924. static readonly LIGHTMAP_SHADOWSONLY: number;
  9925. /**
  9926. * Each light type uses the default quantity according to its type:
  9927. * point/spot lights use luminous intensity
  9928. * directional lights use illuminance
  9929. */
  9930. static readonly INTENSITYMODE_AUTOMATIC: number;
  9931. /**
  9932. * lumen (lm)
  9933. */
  9934. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9935. /**
  9936. * candela (lm/sr)
  9937. */
  9938. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9939. /**
  9940. * lux (lm/m^2)
  9941. */
  9942. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9943. /**
  9944. * nit (cd/m^2)
  9945. */
  9946. static readonly INTENSITYMODE_LUMINANCE: number;
  9947. /**
  9948. * Light type const id of the point light.
  9949. */
  9950. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9951. /**
  9952. * Light type const id of the directional light.
  9953. */
  9954. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9955. /**
  9956. * Light type const id of the spot light.
  9957. */
  9958. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9959. /**
  9960. * Light type const id of the hemispheric light.
  9961. */
  9962. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9963. /**
  9964. * Diffuse gives the basic color to an object.
  9965. */
  9966. diffuse: Color3;
  9967. /**
  9968. * Specular produces a highlight color on an object.
  9969. * Note: This is note affecting PBR materials.
  9970. */
  9971. specular: Color3;
  9972. /**
  9973. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9974. * falling off base on range or angle.
  9975. * This can be set to any values in Light.FALLOFF_x.
  9976. *
  9977. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9978. * other types of materials.
  9979. */
  9980. falloffType: number;
  9981. /**
  9982. * Strength of the light.
  9983. * Note: By default it is define in the framework own unit.
  9984. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9985. */
  9986. intensity: number;
  9987. private _range;
  9988. protected _inverseSquaredRange: number;
  9989. /**
  9990. * Defines how far from the source the light is impacting in scene units.
  9991. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9992. */
  9993. /**
  9994. * Defines how far from the source the light is impacting in scene units.
  9995. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9996. */
  9997. range: number;
  9998. /**
  9999. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10000. * of light.
  10001. */
  10002. private _photometricScale;
  10003. private _intensityMode;
  10004. /**
  10005. * Gets the photometric scale used to interpret the intensity.
  10006. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10007. */
  10008. /**
  10009. * Sets the photometric scale used to interpret the intensity.
  10010. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10011. */
  10012. intensityMode: number;
  10013. private _radius;
  10014. /**
  10015. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10016. */
  10017. /**
  10018. * sets the light radius used by PBR Materials to simulate soft area lights.
  10019. */
  10020. radius: number;
  10021. private _renderPriority;
  10022. /**
  10023. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10024. * exceeding the number allowed of the materials.
  10025. */
  10026. renderPriority: number;
  10027. private _shadowEnabled;
  10028. /**
  10029. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10030. * the current shadow generator.
  10031. */
  10032. /**
  10033. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10034. * the current shadow generator.
  10035. */
  10036. shadowEnabled: boolean;
  10037. private _includedOnlyMeshes;
  10038. /**
  10039. * Gets the only meshes impacted by this light.
  10040. */
  10041. /**
  10042. * Sets the only meshes impacted by this light.
  10043. */
  10044. includedOnlyMeshes: AbstractMesh[];
  10045. private _excludedMeshes;
  10046. /**
  10047. * Gets the meshes not impacted by this light.
  10048. */
  10049. /**
  10050. * Sets the meshes not impacted by this light.
  10051. */
  10052. excludedMeshes: AbstractMesh[];
  10053. private _excludeWithLayerMask;
  10054. /**
  10055. * Gets the layer id use to find what meshes are not impacted by the light.
  10056. * Inactive if 0
  10057. */
  10058. /**
  10059. * Sets the layer id use to find what meshes are not impacted by the light.
  10060. * Inactive if 0
  10061. */
  10062. excludeWithLayerMask: number;
  10063. private _includeOnlyWithLayerMask;
  10064. /**
  10065. * Gets the layer id use to find what meshes are impacted by the light.
  10066. * Inactive if 0
  10067. */
  10068. /**
  10069. * Sets the layer id use to find what meshes are impacted by the light.
  10070. * Inactive if 0
  10071. */
  10072. includeOnlyWithLayerMask: number;
  10073. private _lightmapMode;
  10074. /**
  10075. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10076. */
  10077. /**
  10078. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10079. */
  10080. lightmapMode: number;
  10081. /**
  10082. * Shadow generator associted to the light.
  10083. * @hidden Internal use only.
  10084. */
  10085. _shadowGenerator: Nullable<IShadowGenerator>;
  10086. /**
  10087. * @hidden Internal use only.
  10088. */
  10089. _excludedMeshesIds: string[];
  10090. /**
  10091. * @hidden Internal use only.
  10092. */
  10093. _includedOnlyMeshesIds: string[];
  10094. /**
  10095. * The current light unifom buffer.
  10096. * @hidden Internal use only.
  10097. */
  10098. _uniformBuffer: UniformBuffer;
  10099. /** @hidden */
  10100. _renderId: number;
  10101. /**
  10102. * Creates a Light object in the scene.
  10103. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10104. * @param name The firendly name of the light
  10105. * @param scene The scene the light belongs too
  10106. */
  10107. constructor(name: string, scene: Scene);
  10108. protected abstract _buildUniformLayout(): void;
  10109. /**
  10110. * Sets the passed Effect "effect" with the Light information.
  10111. * @param effect The effect to update
  10112. * @param lightIndex The index of the light in the effect to update
  10113. * @returns The light
  10114. */
  10115. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10116. /**
  10117. * Sets the passed Effect "effect" with the Light information.
  10118. * @param effect The effect to update
  10119. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10120. * @returns The light
  10121. */
  10122. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10123. /**
  10124. * Returns the string "Light".
  10125. * @returns the class name
  10126. */
  10127. getClassName(): string;
  10128. /** @hidden */
  10129. readonly _isLight: boolean;
  10130. /**
  10131. * Converts the light information to a readable string for debug purpose.
  10132. * @param fullDetails Supports for multiple levels of logging within scene loading
  10133. * @returns the human readable light info
  10134. */
  10135. toString(fullDetails?: boolean): string;
  10136. /** @hidden */
  10137. protected _syncParentEnabledState(): void;
  10138. /**
  10139. * Set the enabled state of this node.
  10140. * @param value - the new enabled state
  10141. */
  10142. setEnabled(value: boolean): void;
  10143. /**
  10144. * Returns the Light associated shadow generator if any.
  10145. * @return the associated shadow generator.
  10146. */
  10147. getShadowGenerator(): Nullable<IShadowGenerator>;
  10148. /**
  10149. * Returns a Vector3, the absolute light position in the World.
  10150. * @returns the world space position of the light
  10151. */
  10152. getAbsolutePosition(): Vector3;
  10153. /**
  10154. * Specifies if the light will affect the passed mesh.
  10155. * @param mesh The mesh to test against the light
  10156. * @return true the mesh is affected otherwise, false.
  10157. */
  10158. canAffectMesh(mesh: AbstractMesh): boolean;
  10159. /**
  10160. * Sort function to order lights for rendering.
  10161. * @param a First Light object to compare to second.
  10162. * @param b Second Light object to compare first.
  10163. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10164. */
  10165. static CompareLightsPriority(a: Light, b: Light): number;
  10166. /**
  10167. * Releases resources associated with this node.
  10168. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10169. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10170. */
  10171. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10172. /**
  10173. * Returns the light type ID (integer).
  10174. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10175. */
  10176. getTypeID(): number;
  10177. /**
  10178. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10179. * @returns the scaled intensity in intensity mode unit
  10180. */
  10181. getScaledIntensity(): number;
  10182. /**
  10183. * Returns a new Light object, named "name", from the current one.
  10184. * @param name The name of the cloned light
  10185. * @returns the new created light
  10186. */
  10187. clone(name: string): Nullable<Light>;
  10188. /**
  10189. * Serializes the current light into a Serialization object.
  10190. * @returns the serialized object.
  10191. */
  10192. serialize(): any;
  10193. /**
  10194. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10195. * This new light is named "name" and added to the passed scene.
  10196. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10197. * @param name The friendly name of the light
  10198. * @param scene The scene the new light will belong to
  10199. * @returns the constructor function
  10200. */
  10201. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10202. /**
  10203. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10204. * @param parsedLight The JSON representation of the light
  10205. * @param scene The scene to create the parsed light in
  10206. * @returns the created light after parsing
  10207. */
  10208. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10209. private _hookArrayForExcluded;
  10210. private _hookArrayForIncludedOnly;
  10211. private _resyncMeshes;
  10212. /**
  10213. * Forces the meshes to update their light related information in their rendering used effects
  10214. * @hidden Internal Use Only
  10215. */
  10216. _markMeshesAsLightDirty(): void;
  10217. /**
  10218. * Recomputes the cached photometric scale if needed.
  10219. */
  10220. private _computePhotometricScale;
  10221. /**
  10222. * Returns the Photometric Scale according to the light type and intensity mode.
  10223. */
  10224. private _getPhotometricScale;
  10225. /**
  10226. * Reorder the light in the scene according to their defined priority.
  10227. * @hidden Internal Use Only
  10228. */
  10229. _reorderLightsInScene(): void;
  10230. /**
  10231. * Prepares the list of defines specific to the light type.
  10232. * @param defines the list of defines
  10233. * @param lightIndex defines the index of the light for the effect
  10234. */
  10235. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10236. }
  10237. }
  10238. declare module "babylonjs/Actions/action" {
  10239. import { Observable } from "babylonjs/Misc/observable";
  10240. import { Condition } from "babylonjs/Actions/condition";
  10241. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10242. import { ActionManager } from "babylonjs/Actions/actionManager";
  10243. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10244. /**
  10245. * Interface used to define Action
  10246. */
  10247. export interface IAction {
  10248. /**
  10249. * Trigger for the action
  10250. */
  10251. trigger: number;
  10252. /** Options of the trigger */
  10253. triggerOptions: any;
  10254. /**
  10255. * Gets the trigger parameters
  10256. * @returns the trigger parameters
  10257. */
  10258. getTriggerParameter(): any;
  10259. /**
  10260. * Internal only - executes current action event
  10261. * @hidden
  10262. */
  10263. _executeCurrent(evt?: ActionEvent): void;
  10264. /**
  10265. * Serialize placeholder for child classes
  10266. * @param parent of child
  10267. * @returns the serialized object
  10268. */
  10269. serialize(parent: any): any;
  10270. /**
  10271. * Internal only
  10272. * @hidden
  10273. */
  10274. _prepare(): void;
  10275. /**
  10276. * Internal only - manager for action
  10277. * @hidden
  10278. */
  10279. _actionManager: AbstractActionManager;
  10280. /**
  10281. * Adds action to chain of actions, may be a DoNothingAction
  10282. * @param action defines the next action to execute
  10283. * @returns The action passed in
  10284. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10285. */
  10286. then(action: IAction): IAction;
  10287. }
  10288. /**
  10289. * The action to be carried out following a trigger
  10290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10291. */
  10292. export class Action implements IAction {
  10293. /** the trigger, with or without parameters, for the action */
  10294. triggerOptions: any;
  10295. /**
  10296. * Trigger for the action
  10297. */
  10298. trigger: number;
  10299. /**
  10300. * Internal only - manager for action
  10301. * @hidden
  10302. */
  10303. _actionManager: ActionManager;
  10304. private _nextActiveAction;
  10305. private _child;
  10306. private _condition?;
  10307. private _triggerParameter;
  10308. /**
  10309. * An event triggered prior to action being executed.
  10310. */
  10311. onBeforeExecuteObservable: Observable<Action>;
  10312. /**
  10313. * Creates a new Action
  10314. * @param triggerOptions the trigger, with or without parameters, for the action
  10315. * @param condition an optional determinant of action
  10316. */
  10317. constructor(
  10318. /** the trigger, with or without parameters, for the action */
  10319. triggerOptions: any, condition?: Condition);
  10320. /**
  10321. * Internal only
  10322. * @hidden
  10323. */
  10324. _prepare(): void;
  10325. /**
  10326. * Gets the trigger parameters
  10327. * @returns the trigger parameters
  10328. */
  10329. getTriggerParameter(): any;
  10330. /**
  10331. * Internal only - executes current action event
  10332. * @hidden
  10333. */
  10334. _executeCurrent(evt?: ActionEvent): void;
  10335. /**
  10336. * Execute placeholder for child classes
  10337. * @param evt optional action event
  10338. */
  10339. execute(evt?: ActionEvent): void;
  10340. /**
  10341. * Skips to next active action
  10342. */
  10343. skipToNextActiveAction(): void;
  10344. /**
  10345. * Adds action to chain of actions, may be a DoNothingAction
  10346. * @param action defines the next action to execute
  10347. * @returns The action passed in
  10348. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10349. */
  10350. then(action: Action): Action;
  10351. /**
  10352. * Internal only
  10353. * @hidden
  10354. */
  10355. _getProperty(propertyPath: string): string;
  10356. /**
  10357. * Internal only
  10358. * @hidden
  10359. */
  10360. _getEffectiveTarget(target: any, propertyPath: string): any;
  10361. /**
  10362. * Serialize placeholder for child classes
  10363. * @param parent of child
  10364. * @returns the serialized object
  10365. */
  10366. serialize(parent: any): any;
  10367. /**
  10368. * Internal only called by serialize
  10369. * @hidden
  10370. */
  10371. protected _serialize(serializedAction: any, parent?: any): any;
  10372. /**
  10373. * Internal only
  10374. * @hidden
  10375. */
  10376. static _SerializeValueAsString: (value: any) => string;
  10377. /**
  10378. * Internal only
  10379. * @hidden
  10380. */
  10381. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10382. name: string;
  10383. targetType: string;
  10384. value: string;
  10385. };
  10386. }
  10387. }
  10388. declare module "babylonjs/Actions/condition" {
  10389. import { ActionManager } from "babylonjs/Actions/actionManager";
  10390. /**
  10391. * A Condition applied to an Action
  10392. */
  10393. export class Condition {
  10394. /**
  10395. * Internal only - manager for action
  10396. * @hidden
  10397. */
  10398. _actionManager: ActionManager;
  10399. /**
  10400. * Internal only
  10401. * @hidden
  10402. */
  10403. _evaluationId: number;
  10404. /**
  10405. * Internal only
  10406. * @hidden
  10407. */
  10408. _currentResult: boolean;
  10409. /**
  10410. * Creates a new Condition
  10411. * @param actionManager the manager of the action the condition is applied to
  10412. */
  10413. constructor(actionManager: ActionManager);
  10414. /**
  10415. * Check if the current condition is valid
  10416. * @returns a boolean
  10417. */
  10418. isValid(): boolean;
  10419. /**
  10420. * Internal only
  10421. * @hidden
  10422. */
  10423. _getProperty(propertyPath: string): string;
  10424. /**
  10425. * Internal only
  10426. * @hidden
  10427. */
  10428. _getEffectiveTarget(target: any, propertyPath: string): any;
  10429. /**
  10430. * Serialize placeholder for child classes
  10431. * @returns the serialized object
  10432. */
  10433. serialize(): any;
  10434. /**
  10435. * Internal only
  10436. * @hidden
  10437. */
  10438. protected _serialize(serializedCondition: any): any;
  10439. }
  10440. /**
  10441. * Defines specific conditional operators as extensions of Condition
  10442. */
  10443. export class ValueCondition extends Condition {
  10444. /** path to specify the property of the target the conditional operator uses */
  10445. propertyPath: string;
  10446. /** the value compared by the conditional operator against the current value of the property */
  10447. value: any;
  10448. /** the conditional operator, default ValueCondition.IsEqual */
  10449. operator: number;
  10450. /**
  10451. * Internal only
  10452. * @hidden
  10453. */
  10454. private static _IsEqual;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. private static _IsDifferent;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. private static _IsGreater;
  10465. /**
  10466. * Internal only
  10467. * @hidden
  10468. */
  10469. private static _IsLesser;
  10470. /**
  10471. * returns the number for IsEqual
  10472. */
  10473. static readonly IsEqual: number;
  10474. /**
  10475. * Returns the number for IsDifferent
  10476. */
  10477. static readonly IsDifferent: number;
  10478. /**
  10479. * Returns the number for IsGreater
  10480. */
  10481. static readonly IsGreater: number;
  10482. /**
  10483. * Returns the number for IsLesser
  10484. */
  10485. static readonly IsLesser: number;
  10486. /**
  10487. * Internal only The action manager for the condition
  10488. * @hidden
  10489. */
  10490. _actionManager: ActionManager;
  10491. /**
  10492. * Internal only
  10493. * @hidden
  10494. */
  10495. private _target;
  10496. /**
  10497. * Internal only
  10498. * @hidden
  10499. */
  10500. private _effectiveTarget;
  10501. /**
  10502. * Internal only
  10503. * @hidden
  10504. */
  10505. private _property;
  10506. /**
  10507. * Creates a new ValueCondition
  10508. * @param actionManager manager for the action the condition applies to
  10509. * @param target for the action
  10510. * @param propertyPath path to specify the property of the target the conditional operator uses
  10511. * @param value the value compared by the conditional operator against the current value of the property
  10512. * @param operator the conditional operator, default ValueCondition.IsEqual
  10513. */
  10514. constructor(actionManager: ActionManager, target: any,
  10515. /** path to specify the property of the target the conditional operator uses */
  10516. propertyPath: string,
  10517. /** the value compared by the conditional operator against the current value of the property */
  10518. value: any,
  10519. /** the conditional operator, default ValueCondition.IsEqual */
  10520. operator?: number);
  10521. /**
  10522. * Compares the given value with the property value for the specified conditional operator
  10523. * @returns the result of the comparison
  10524. */
  10525. isValid(): boolean;
  10526. /**
  10527. * Serialize the ValueCondition into a JSON compatible object
  10528. * @returns serialization object
  10529. */
  10530. serialize(): any;
  10531. /**
  10532. * Gets the name of the conditional operator for the ValueCondition
  10533. * @param operator the conditional operator
  10534. * @returns the name
  10535. */
  10536. static GetOperatorName(operator: number): string;
  10537. }
  10538. /**
  10539. * Defines a predicate condition as an extension of Condition
  10540. */
  10541. export class PredicateCondition extends Condition {
  10542. /** defines the predicate function used to validate the condition */
  10543. predicate: () => boolean;
  10544. /**
  10545. * Internal only - manager for action
  10546. * @hidden
  10547. */
  10548. _actionManager: ActionManager;
  10549. /**
  10550. * Creates a new PredicateCondition
  10551. * @param actionManager manager for the action the condition applies to
  10552. * @param predicate defines the predicate function used to validate the condition
  10553. */
  10554. constructor(actionManager: ActionManager,
  10555. /** defines the predicate function used to validate the condition */
  10556. predicate: () => boolean);
  10557. /**
  10558. * @returns the validity of the predicate condition
  10559. */
  10560. isValid(): boolean;
  10561. }
  10562. /**
  10563. * Defines a state condition as an extension of Condition
  10564. */
  10565. export class StateCondition extends Condition {
  10566. /** Value to compare with target state */
  10567. value: string;
  10568. /**
  10569. * Internal only - manager for action
  10570. * @hidden
  10571. */
  10572. _actionManager: ActionManager;
  10573. /**
  10574. * Internal only
  10575. * @hidden
  10576. */
  10577. private _target;
  10578. /**
  10579. * Creates a new StateCondition
  10580. * @param actionManager manager for the action the condition applies to
  10581. * @param target of the condition
  10582. * @param value to compare with target state
  10583. */
  10584. constructor(actionManager: ActionManager, target: any,
  10585. /** Value to compare with target state */
  10586. value: string);
  10587. /**
  10588. * Gets a boolean indicating if the current condition is met
  10589. * @returns the validity of the state
  10590. */
  10591. isValid(): boolean;
  10592. /**
  10593. * Serialize the StateCondition into a JSON compatible object
  10594. * @returns serialization object
  10595. */
  10596. serialize(): any;
  10597. }
  10598. }
  10599. declare module "babylonjs/Actions/directActions" {
  10600. import { Action } from "babylonjs/Actions/action";
  10601. import { Condition } from "babylonjs/Actions/condition";
  10602. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10603. /**
  10604. * This defines an action responsible to toggle a boolean once triggered.
  10605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10606. */
  10607. export class SwitchBooleanAction extends Action {
  10608. /**
  10609. * The path to the boolean property in the target object
  10610. */
  10611. propertyPath: string;
  10612. private _target;
  10613. private _effectiveTarget;
  10614. private _property;
  10615. /**
  10616. * Instantiate the action
  10617. * @param triggerOptions defines the trigger options
  10618. * @param target defines the object containing the boolean
  10619. * @param propertyPath defines the path to the boolean property in the target object
  10620. * @param condition defines the trigger related conditions
  10621. */
  10622. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10623. /** @hidden */
  10624. _prepare(): void;
  10625. /**
  10626. * Execute the action toggle the boolean value.
  10627. */
  10628. execute(): void;
  10629. /**
  10630. * Serializes the actions and its related information.
  10631. * @param parent defines the object to serialize in
  10632. * @returns the serialized object
  10633. */
  10634. serialize(parent: any): any;
  10635. }
  10636. /**
  10637. * This defines an action responsible to set a the state field of the target
  10638. * to a desired value once triggered.
  10639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10640. */
  10641. export class SetStateAction extends Action {
  10642. /**
  10643. * The value to store in the state field.
  10644. */
  10645. value: string;
  10646. private _target;
  10647. /**
  10648. * Instantiate the action
  10649. * @param triggerOptions defines the trigger options
  10650. * @param target defines the object containing the state property
  10651. * @param value defines the value to store in the state field
  10652. * @param condition defines the trigger related conditions
  10653. */
  10654. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10655. /**
  10656. * Execute the action and store the value on the target state property.
  10657. */
  10658. execute(): void;
  10659. /**
  10660. * Serializes the actions and its related information.
  10661. * @param parent defines the object to serialize in
  10662. * @returns the serialized object
  10663. */
  10664. serialize(parent: any): any;
  10665. }
  10666. /**
  10667. * This defines an action responsible to set a property of the target
  10668. * to a desired value once triggered.
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10670. */
  10671. export class SetValueAction extends Action {
  10672. /**
  10673. * The path of the property to set in the target.
  10674. */
  10675. propertyPath: string;
  10676. /**
  10677. * The value to set in the property
  10678. */
  10679. value: any;
  10680. private _target;
  10681. private _effectiveTarget;
  10682. private _property;
  10683. /**
  10684. * Instantiate the action
  10685. * @param triggerOptions defines the trigger options
  10686. * @param target defines the object containing the property
  10687. * @param propertyPath defines the path of the property to set in the target
  10688. * @param value defines the value to set in the property
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10692. /** @hidden */
  10693. _prepare(): void;
  10694. /**
  10695. * Execute the action and set the targetted property to the desired value.
  10696. */
  10697. execute(): void;
  10698. /**
  10699. * Serializes the actions and its related information.
  10700. * @param parent defines the object to serialize in
  10701. * @returns the serialized object
  10702. */
  10703. serialize(parent: any): any;
  10704. }
  10705. /**
  10706. * This defines an action responsible to increment the target value
  10707. * to a desired value once triggered.
  10708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10709. */
  10710. export class IncrementValueAction extends Action {
  10711. /**
  10712. * The path of the property to increment in the target.
  10713. */
  10714. propertyPath: string;
  10715. /**
  10716. * The value we should increment the property by.
  10717. */
  10718. value: any;
  10719. private _target;
  10720. private _effectiveTarget;
  10721. private _property;
  10722. /**
  10723. * Instantiate the action
  10724. * @param triggerOptions defines the trigger options
  10725. * @param target defines the object containing the property
  10726. * @param propertyPath defines the path of the property to increment in the target
  10727. * @param value defines the value value we should increment the property by
  10728. * @param condition defines the trigger related conditions
  10729. */
  10730. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10731. /** @hidden */
  10732. _prepare(): void;
  10733. /**
  10734. * Execute the action and increment the target of the value amount.
  10735. */
  10736. execute(): void;
  10737. /**
  10738. * Serializes the actions and its related information.
  10739. * @param parent defines the object to serialize in
  10740. * @returns the serialized object
  10741. */
  10742. serialize(parent: any): any;
  10743. }
  10744. /**
  10745. * This defines an action responsible to start an animation once triggered.
  10746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10747. */
  10748. export class PlayAnimationAction extends Action {
  10749. /**
  10750. * Where the animation should start (animation frame)
  10751. */
  10752. from: number;
  10753. /**
  10754. * Where the animation should stop (animation frame)
  10755. */
  10756. to: number;
  10757. /**
  10758. * Define if the animation should loop or stop after the first play.
  10759. */
  10760. loop?: boolean;
  10761. private _target;
  10762. /**
  10763. * Instantiate the action
  10764. * @param triggerOptions defines the trigger options
  10765. * @param target defines the target animation or animation name
  10766. * @param from defines from where the animation should start (animation frame)
  10767. * @param end defines where the animation should stop (animation frame)
  10768. * @param loop defines if the animation should loop or stop after the first play
  10769. * @param condition defines the trigger related conditions
  10770. */
  10771. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10772. /** @hidden */
  10773. _prepare(): void;
  10774. /**
  10775. * Execute the action and play the animation.
  10776. */
  10777. execute(): void;
  10778. /**
  10779. * Serializes the actions and its related information.
  10780. * @param parent defines the object to serialize in
  10781. * @returns the serialized object
  10782. */
  10783. serialize(parent: any): any;
  10784. }
  10785. /**
  10786. * This defines an action responsible to stop an animation once triggered.
  10787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10788. */
  10789. export class StopAnimationAction extends Action {
  10790. private _target;
  10791. /**
  10792. * Instantiate the action
  10793. * @param triggerOptions defines the trigger options
  10794. * @param target defines the target animation or animation name
  10795. * @param condition defines the trigger related conditions
  10796. */
  10797. constructor(triggerOptions: any, target: any, condition?: Condition);
  10798. /** @hidden */
  10799. _prepare(): void;
  10800. /**
  10801. * Execute the action and stop the animation.
  10802. */
  10803. execute(): void;
  10804. /**
  10805. * Serializes the actions and its related information.
  10806. * @param parent defines the object to serialize in
  10807. * @returns the serialized object
  10808. */
  10809. serialize(parent: any): any;
  10810. }
  10811. /**
  10812. * This defines an action responsible that does nothing once triggered.
  10813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10814. */
  10815. export class DoNothingAction extends Action {
  10816. /**
  10817. * Instantiate the action
  10818. * @param triggerOptions defines the trigger options
  10819. * @param condition defines the trigger related conditions
  10820. */
  10821. constructor(triggerOptions?: any, condition?: Condition);
  10822. /**
  10823. * Execute the action and do nothing.
  10824. */
  10825. execute(): void;
  10826. /**
  10827. * Serializes the actions and its related information.
  10828. * @param parent defines the object to serialize in
  10829. * @returns the serialized object
  10830. */
  10831. serialize(parent: any): any;
  10832. }
  10833. /**
  10834. * This defines an action responsible to trigger several actions once triggered.
  10835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10836. */
  10837. export class CombineAction extends Action {
  10838. /**
  10839. * The list of aggregated animations to run.
  10840. */
  10841. children: Action[];
  10842. /**
  10843. * Instantiate the action
  10844. * @param triggerOptions defines the trigger options
  10845. * @param children defines the list of aggregated animations to run
  10846. * @param condition defines the trigger related conditions
  10847. */
  10848. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10849. /** @hidden */
  10850. _prepare(): void;
  10851. /**
  10852. * Execute the action and executes all the aggregated actions.
  10853. */
  10854. execute(evt: ActionEvent): void;
  10855. /**
  10856. * Serializes the actions and its related information.
  10857. * @param parent defines the object to serialize in
  10858. * @returns the serialized object
  10859. */
  10860. serialize(parent: any): any;
  10861. }
  10862. /**
  10863. * This defines an action responsible to run code (external event) once triggered.
  10864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10865. */
  10866. export class ExecuteCodeAction extends Action {
  10867. /**
  10868. * The callback function to run.
  10869. */
  10870. func: (evt: ActionEvent) => void;
  10871. /**
  10872. * Instantiate the action
  10873. * @param triggerOptions defines the trigger options
  10874. * @param func defines the callback function to run
  10875. * @param condition defines the trigger related conditions
  10876. */
  10877. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10878. /**
  10879. * Execute the action and run the attached code.
  10880. */
  10881. execute(evt: ActionEvent): void;
  10882. }
  10883. /**
  10884. * This defines an action responsible to set the parent property of the target once triggered.
  10885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10886. */
  10887. export class SetParentAction extends Action {
  10888. private _parent;
  10889. private _target;
  10890. /**
  10891. * Instantiate the action
  10892. * @param triggerOptions defines the trigger options
  10893. * @param target defines the target containing the parent property
  10894. * @param parent defines from where the animation should start (animation frame)
  10895. * @param condition defines the trigger related conditions
  10896. */
  10897. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10898. /** @hidden */
  10899. _prepare(): void;
  10900. /**
  10901. * Execute the action and set the parent property.
  10902. */
  10903. execute(): void;
  10904. /**
  10905. * Serializes the actions and its related information.
  10906. * @param parent defines the object to serialize in
  10907. * @returns the serialized object
  10908. */
  10909. serialize(parent: any): any;
  10910. }
  10911. }
  10912. declare module "babylonjs/Actions/actionManager" {
  10913. import { Nullable } from "babylonjs/types";
  10914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10915. import { Scene } from "babylonjs/scene";
  10916. import { IAction } from "babylonjs/Actions/action";
  10917. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10918. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10919. /**
  10920. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10921. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10923. */
  10924. export class ActionManager extends AbstractActionManager {
  10925. /**
  10926. * Nothing
  10927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10928. */
  10929. static readonly NothingTrigger: number;
  10930. /**
  10931. * On pick
  10932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10933. */
  10934. static readonly OnPickTrigger: number;
  10935. /**
  10936. * On left pick
  10937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10938. */
  10939. static readonly OnLeftPickTrigger: number;
  10940. /**
  10941. * On right pick
  10942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10943. */
  10944. static readonly OnRightPickTrigger: number;
  10945. /**
  10946. * On center pick
  10947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10948. */
  10949. static readonly OnCenterPickTrigger: number;
  10950. /**
  10951. * On pick down
  10952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10953. */
  10954. static readonly OnPickDownTrigger: number;
  10955. /**
  10956. * On double pick
  10957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10958. */
  10959. static readonly OnDoublePickTrigger: number;
  10960. /**
  10961. * On pick up
  10962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10963. */
  10964. static readonly OnPickUpTrigger: number;
  10965. /**
  10966. * On pick out.
  10967. * This trigger will only be raised if you also declared a OnPickDown
  10968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10969. */
  10970. static readonly OnPickOutTrigger: number;
  10971. /**
  10972. * On long press
  10973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10974. */
  10975. static readonly OnLongPressTrigger: number;
  10976. /**
  10977. * On pointer over
  10978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10979. */
  10980. static readonly OnPointerOverTrigger: number;
  10981. /**
  10982. * On pointer out
  10983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10984. */
  10985. static readonly OnPointerOutTrigger: number;
  10986. /**
  10987. * On every frame
  10988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10989. */
  10990. static readonly OnEveryFrameTrigger: number;
  10991. /**
  10992. * On intersection enter
  10993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10994. */
  10995. static readonly OnIntersectionEnterTrigger: number;
  10996. /**
  10997. * On intersection exit
  10998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10999. */
  11000. static readonly OnIntersectionExitTrigger: number;
  11001. /**
  11002. * On key down
  11003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11004. */
  11005. static readonly OnKeyDownTrigger: number;
  11006. /**
  11007. * On key up
  11008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11009. */
  11010. static readonly OnKeyUpTrigger: number;
  11011. private _scene;
  11012. /**
  11013. * Creates a new action manager
  11014. * @param scene defines the hosting scene
  11015. */
  11016. constructor(scene: Scene);
  11017. /**
  11018. * Releases all associated resources
  11019. */
  11020. dispose(): void;
  11021. /**
  11022. * Gets hosting scene
  11023. * @returns the hosting scene
  11024. */
  11025. getScene(): Scene;
  11026. /**
  11027. * Does this action manager handles actions of any of the given triggers
  11028. * @param triggers defines the triggers to be tested
  11029. * @return a boolean indicating whether one (or more) of the triggers is handled
  11030. */
  11031. hasSpecificTriggers(triggers: number[]): boolean;
  11032. /**
  11033. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11034. * speed.
  11035. * @param triggerA defines the trigger to be tested
  11036. * @param triggerB defines the trigger to be tested
  11037. * @return a boolean indicating whether one (or more) of the triggers is handled
  11038. */
  11039. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11040. /**
  11041. * Does this action manager handles actions of a given trigger
  11042. * @param trigger defines the trigger to be tested
  11043. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11044. * @return whether the trigger is handled
  11045. */
  11046. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11047. /**
  11048. * Does this action manager has pointer triggers
  11049. */
  11050. readonly hasPointerTriggers: boolean;
  11051. /**
  11052. * Does this action manager has pick triggers
  11053. */
  11054. readonly hasPickTriggers: boolean;
  11055. /**
  11056. * Registers an action to this action manager
  11057. * @param action defines the action to be registered
  11058. * @return the action amended (prepared) after registration
  11059. */
  11060. registerAction(action: IAction): Nullable<IAction>;
  11061. /**
  11062. * Unregisters an action to this action manager
  11063. * @param action defines the action to be unregistered
  11064. * @return a boolean indicating whether the action has been unregistered
  11065. */
  11066. unregisterAction(action: IAction): Boolean;
  11067. /**
  11068. * Process a specific trigger
  11069. * @param trigger defines the trigger to process
  11070. * @param evt defines the event details to be processed
  11071. */
  11072. processTrigger(trigger: number, evt?: IActionEvent): void;
  11073. /** @hidden */
  11074. _getEffectiveTarget(target: any, propertyPath: string): any;
  11075. /** @hidden */
  11076. _getProperty(propertyPath: string): string;
  11077. /**
  11078. * Serialize this manager to a JSON object
  11079. * @param name defines the property name to store this manager
  11080. * @returns a JSON representation of this manager
  11081. */
  11082. serialize(name: string): any;
  11083. /**
  11084. * Creates a new ActionManager from a JSON data
  11085. * @param parsedActions defines the JSON data to read from
  11086. * @param object defines the hosting mesh
  11087. * @param scene defines the hosting scene
  11088. */
  11089. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11090. /**
  11091. * Get a trigger name by index
  11092. * @param trigger defines the trigger index
  11093. * @returns a trigger name
  11094. */
  11095. static GetTriggerName(trigger: number): string;
  11096. }
  11097. }
  11098. declare module "babylonjs/Culling/ray" {
  11099. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11100. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11102. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11103. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11104. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11105. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11106. import { Plane } from "babylonjs/Maths/math.plane";
  11107. /**
  11108. * Class representing a ray with position and direction
  11109. */
  11110. export class Ray {
  11111. /** origin point */
  11112. origin: Vector3;
  11113. /** direction */
  11114. direction: Vector3;
  11115. /** length of the ray */
  11116. length: number;
  11117. private static readonly TmpVector3;
  11118. private _tmpRay;
  11119. /**
  11120. * Creates a new ray
  11121. * @param origin origin point
  11122. * @param direction direction
  11123. * @param length length of the ray
  11124. */
  11125. constructor(
  11126. /** origin point */
  11127. origin: Vector3,
  11128. /** direction */
  11129. direction: Vector3,
  11130. /** length of the ray */
  11131. length?: number);
  11132. /**
  11133. * Checks if the ray intersects a box
  11134. * @param minimum bound of the box
  11135. * @param maximum bound of the box
  11136. * @param intersectionTreshold extra extend to be added to the box in all direction
  11137. * @returns if the box was hit
  11138. */
  11139. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11140. /**
  11141. * Checks if the ray intersects a box
  11142. * @param box the bounding box to check
  11143. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11144. * @returns if the box was hit
  11145. */
  11146. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11147. /**
  11148. * If the ray hits a sphere
  11149. * @param sphere the bounding sphere to check
  11150. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11151. * @returns true if it hits the sphere
  11152. */
  11153. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11154. /**
  11155. * If the ray hits a triange
  11156. * @param vertex0 triangle vertex
  11157. * @param vertex1 triangle vertex
  11158. * @param vertex2 triangle vertex
  11159. * @returns intersection information if hit
  11160. */
  11161. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11162. /**
  11163. * Checks if ray intersects a plane
  11164. * @param plane the plane to check
  11165. * @returns the distance away it was hit
  11166. */
  11167. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11168. /**
  11169. * Calculate the intercept of a ray on a given axis
  11170. * @param axis to check 'x' | 'y' | 'z'
  11171. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11172. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11173. */
  11174. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11175. /**
  11176. * Checks if ray intersects a mesh
  11177. * @param mesh the mesh to check
  11178. * @param fastCheck if only the bounding box should checked
  11179. * @returns picking info of the intersecton
  11180. */
  11181. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11182. /**
  11183. * Checks if ray intersects a mesh
  11184. * @param meshes the meshes to check
  11185. * @param fastCheck if only the bounding box should checked
  11186. * @param results array to store result in
  11187. * @returns Array of picking infos
  11188. */
  11189. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11190. private _comparePickingInfo;
  11191. private static smallnum;
  11192. private static rayl;
  11193. /**
  11194. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11195. * @param sega the first point of the segment to test the intersection against
  11196. * @param segb the second point of the segment to test the intersection against
  11197. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11198. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11199. */
  11200. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11201. /**
  11202. * Update the ray from viewport position
  11203. * @param x position
  11204. * @param y y position
  11205. * @param viewportWidth viewport width
  11206. * @param viewportHeight viewport height
  11207. * @param world world matrix
  11208. * @param view view matrix
  11209. * @param projection projection matrix
  11210. * @returns this ray updated
  11211. */
  11212. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11213. /**
  11214. * Creates a ray with origin and direction of 0,0,0
  11215. * @returns the new ray
  11216. */
  11217. static Zero(): Ray;
  11218. /**
  11219. * Creates a new ray from screen space and viewport
  11220. * @param x position
  11221. * @param y y position
  11222. * @param viewportWidth viewport width
  11223. * @param viewportHeight viewport height
  11224. * @param world world matrix
  11225. * @param view view matrix
  11226. * @param projection projection matrix
  11227. * @returns new ray
  11228. */
  11229. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11230. /**
  11231. * 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
  11232. * transformed to the given world matrix.
  11233. * @param origin The origin point
  11234. * @param end The end point
  11235. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11236. * @returns the new ray
  11237. */
  11238. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11239. /**
  11240. * Transforms a ray by a matrix
  11241. * @param ray ray to transform
  11242. * @param matrix matrix to apply
  11243. * @returns the resulting new ray
  11244. */
  11245. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11246. /**
  11247. * Transforms a ray by a matrix
  11248. * @param ray ray to transform
  11249. * @param matrix matrix to apply
  11250. * @param result ray to store result in
  11251. */
  11252. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11253. /**
  11254. * Unproject a ray from screen space to object space
  11255. * @param sourceX defines the screen space x coordinate to use
  11256. * @param sourceY defines the screen space y coordinate to use
  11257. * @param viewportWidth defines the current width of the viewport
  11258. * @param viewportHeight defines the current height of the viewport
  11259. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11260. * @param view defines the view matrix to use
  11261. * @param projection defines the projection matrix to use
  11262. */
  11263. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11264. }
  11265. /**
  11266. * Type used to define predicate used to select faces when a mesh intersection is detected
  11267. */
  11268. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11269. module "babylonjs/scene" {
  11270. interface Scene {
  11271. /** @hidden */
  11272. _tempPickingRay: Nullable<Ray>;
  11273. /** @hidden */
  11274. _cachedRayForTransform: Ray;
  11275. /** @hidden */
  11276. _pickWithRayInverseMatrix: Matrix;
  11277. /** @hidden */
  11278. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11279. /** @hidden */
  11280. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11281. }
  11282. }
  11283. }
  11284. declare module "babylonjs/sceneComponent" {
  11285. import { Scene } from "babylonjs/scene";
  11286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11287. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11288. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11289. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11290. import { Nullable } from "babylonjs/types";
  11291. import { Camera } from "babylonjs/Cameras/camera";
  11292. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11293. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11294. import { AbstractScene } from "babylonjs/abstractScene";
  11295. import { Mesh } from "babylonjs/Meshes/mesh";
  11296. /**
  11297. * Groups all the scene component constants in one place to ease maintenance.
  11298. * @hidden
  11299. */
  11300. export class SceneComponentConstants {
  11301. static readonly NAME_EFFECTLAYER: string;
  11302. static readonly NAME_LAYER: string;
  11303. static readonly NAME_LENSFLARESYSTEM: string;
  11304. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11305. static readonly NAME_PARTICLESYSTEM: string;
  11306. static readonly NAME_GAMEPAD: string;
  11307. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11308. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11309. static readonly NAME_DEPTHRENDERER: string;
  11310. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11311. static readonly NAME_SPRITE: string;
  11312. static readonly NAME_OUTLINERENDERER: string;
  11313. static readonly NAME_PROCEDURALTEXTURE: string;
  11314. static readonly NAME_SHADOWGENERATOR: string;
  11315. static readonly NAME_OCTREE: string;
  11316. static readonly NAME_PHYSICSENGINE: string;
  11317. static readonly NAME_AUDIO: string;
  11318. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11319. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11320. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11321. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11322. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11323. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11324. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11325. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11326. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11327. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11328. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11329. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11330. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11331. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11332. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11333. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11334. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11335. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11336. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11337. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11338. static readonly STEP_AFTERRENDER_AUDIO: number;
  11339. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11340. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11341. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11342. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11343. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11344. static readonly STEP_POINTERMOVE_SPRITE: number;
  11345. static readonly STEP_POINTERDOWN_SPRITE: number;
  11346. static readonly STEP_POINTERUP_SPRITE: number;
  11347. }
  11348. /**
  11349. * This represents a scene component.
  11350. *
  11351. * This is used to decouple the dependency the scene is having on the different workloads like
  11352. * layers, post processes...
  11353. */
  11354. export interface ISceneComponent {
  11355. /**
  11356. * The name of the component. Each component must have a unique name.
  11357. */
  11358. name: string;
  11359. /**
  11360. * The scene the component belongs to.
  11361. */
  11362. scene: Scene;
  11363. /**
  11364. * Register the component to one instance of a scene.
  11365. */
  11366. register(): void;
  11367. /**
  11368. * Rebuilds the elements related to this component in case of
  11369. * context lost for instance.
  11370. */
  11371. rebuild(): void;
  11372. /**
  11373. * Disposes the component and the associated ressources.
  11374. */
  11375. dispose(): void;
  11376. }
  11377. /**
  11378. * This represents a SERIALIZABLE scene component.
  11379. *
  11380. * This extends Scene Component to add Serialization methods on top.
  11381. */
  11382. export interface ISceneSerializableComponent extends ISceneComponent {
  11383. /**
  11384. * Adds all the elements from the container to the scene
  11385. * @param container the container holding the elements
  11386. */
  11387. addFromContainer(container: AbstractScene): void;
  11388. /**
  11389. * Removes all the elements in the container from the scene
  11390. * @param container contains the elements to remove
  11391. * @param dispose if the removed element should be disposed (default: false)
  11392. */
  11393. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11394. /**
  11395. * Serializes the component data to the specified json object
  11396. * @param serializationObject The object to serialize to
  11397. */
  11398. serialize(serializationObject: any): void;
  11399. }
  11400. /**
  11401. * Strong typing of a Mesh related stage step action
  11402. */
  11403. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11404. /**
  11405. * Strong typing of a Evaluate Sub Mesh related stage step action
  11406. */
  11407. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11408. /**
  11409. * Strong typing of a Active Mesh related stage step action
  11410. */
  11411. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11412. /**
  11413. * Strong typing of a Camera related stage step action
  11414. */
  11415. export type CameraStageAction = (camera: Camera) => void;
  11416. /**
  11417. * Strong typing of a Camera Frame buffer related stage step action
  11418. */
  11419. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11420. /**
  11421. * Strong typing of a Render Target related stage step action
  11422. */
  11423. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11424. /**
  11425. * Strong typing of a RenderingGroup related stage step action
  11426. */
  11427. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11428. /**
  11429. * Strong typing of a Mesh Render related stage step action
  11430. */
  11431. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11432. /**
  11433. * Strong typing of a simple stage step action
  11434. */
  11435. export type SimpleStageAction = () => void;
  11436. /**
  11437. * Strong typing of a render target action.
  11438. */
  11439. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11440. /**
  11441. * Strong typing of a pointer move action.
  11442. */
  11443. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11444. /**
  11445. * Strong typing of a pointer up/down action.
  11446. */
  11447. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11448. /**
  11449. * Representation of a stage in the scene (Basically a list of ordered steps)
  11450. * @hidden
  11451. */
  11452. export class Stage<T extends Function> extends Array<{
  11453. index: number;
  11454. component: ISceneComponent;
  11455. action: T;
  11456. }> {
  11457. /**
  11458. * Hide ctor from the rest of the world.
  11459. * @param items The items to add.
  11460. */
  11461. private constructor();
  11462. /**
  11463. * Creates a new Stage.
  11464. * @returns A new instance of a Stage
  11465. */
  11466. static Create<T extends Function>(): Stage<T>;
  11467. /**
  11468. * Registers a step in an ordered way in the targeted stage.
  11469. * @param index Defines the position to register the step in
  11470. * @param component Defines the component attached to the step
  11471. * @param action Defines the action to launch during the step
  11472. */
  11473. registerStep(index: number, component: ISceneComponent, action: T): void;
  11474. /**
  11475. * Clears all the steps from the stage.
  11476. */
  11477. clear(): void;
  11478. }
  11479. }
  11480. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11481. import { Nullable } from "babylonjs/types";
  11482. import { Observable } from "babylonjs/Misc/observable";
  11483. import { Scene } from "babylonjs/scene";
  11484. import { Sprite } from "babylonjs/Sprites/sprite";
  11485. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11486. import { Ray } from "babylonjs/Culling/ray";
  11487. import { Camera } from "babylonjs/Cameras/camera";
  11488. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11489. import { ISceneComponent } from "babylonjs/sceneComponent";
  11490. module "babylonjs/scene" {
  11491. interface Scene {
  11492. /** @hidden */
  11493. _pointerOverSprite: Nullable<Sprite>;
  11494. /** @hidden */
  11495. _pickedDownSprite: Nullable<Sprite>;
  11496. /** @hidden */
  11497. _tempSpritePickingRay: Nullable<Ray>;
  11498. /**
  11499. * All of the sprite managers added to this scene
  11500. * @see http://doc.babylonjs.com/babylon101/sprites
  11501. */
  11502. spriteManagers: Array<ISpriteManager>;
  11503. /**
  11504. * An event triggered when sprites rendering is about to start
  11505. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11506. */
  11507. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11508. /**
  11509. * An event triggered when sprites rendering is done
  11510. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11511. */
  11512. onAfterSpritesRenderingObservable: Observable<Scene>;
  11513. /** @hidden */
  11514. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11515. /** Launch a ray to try to pick a sprite in the scene
  11516. * @param x position on screen
  11517. * @param y position on screen
  11518. * @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
  11519. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11520. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11521. * @returns a PickingInfo
  11522. */
  11523. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11524. /** Use the given ray to pick a sprite in the scene
  11525. * @param ray The ray (in world space) to use to pick meshes
  11526. * @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
  11527. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11528. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11529. * @returns a PickingInfo
  11530. */
  11531. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11532. /** @hidden */
  11533. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11534. /** Launch a ray to try to pick sprites in the scene
  11535. * @param x position on screen
  11536. * @param y position on screen
  11537. * @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
  11538. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11539. * @returns a PickingInfo array
  11540. */
  11541. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11542. /** Use the given ray to pick sprites in the scene
  11543. * @param ray The ray (in world space) to use to pick meshes
  11544. * @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
  11545. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11546. * @returns a PickingInfo array
  11547. */
  11548. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11549. /**
  11550. * Force the sprite under the pointer
  11551. * @param sprite defines the sprite to use
  11552. */
  11553. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11554. /**
  11555. * Gets the sprite under the pointer
  11556. * @returns a Sprite or null if no sprite is under the pointer
  11557. */
  11558. getPointerOverSprite(): Nullable<Sprite>;
  11559. }
  11560. }
  11561. /**
  11562. * Defines the sprite scene component responsible to manage sprites
  11563. * in a given scene.
  11564. */
  11565. export class SpriteSceneComponent implements ISceneComponent {
  11566. /**
  11567. * The component name helpfull to identify the component in the list of scene components.
  11568. */
  11569. readonly name: string;
  11570. /**
  11571. * The scene the component belongs to.
  11572. */
  11573. scene: Scene;
  11574. /** @hidden */
  11575. private _spritePredicate;
  11576. /**
  11577. * Creates a new instance of the component for the given scene
  11578. * @param scene Defines the scene to register the component in
  11579. */
  11580. constructor(scene: Scene);
  11581. /**
  11582. * Registers the component in a given scene
  11583. */
  11584. register(): void;
  11585. /**
  11586. * Rebuilds the elements related to this component in case of
  11587. * context lost for instance.
  11588. */
  11589. rebuild(): void;
  11590. /**
  11591. * Disposes the component and the associated ressources.
  11592. */
  11593. dispose(): void;
  11594. private _pickSpriteButKeepRay;
  11595. private _pointerMove;
  11596. private _pointerDown;
  11597. private _pointerUp;
  11598. }
  11599. }
  11600. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11601. /** @hidden */
  11602. export var fogFragmentDeclaration: {
  11603. name: string;
  11604. shader: string;
  11605. };
  11606. }
  11607. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11608. /** @hidden */
  11609. export var fogFragment: {
  11610. name: string;
  11611. shader: string;
  11612. };
  11613. }
  11614. declare module "babylonjs/Shaders/sprites.fragment" {
  11615. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11616. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11617. /** @hidden */
  11618. export var spritesPixelShader: {
  11619. name: string;
  11620. shader: string;
  11621. };
  11622. }
  11623. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11624. /** @hidden */
  11625. export var fogVertexDeclaration: {
  11626. name: string;
  11627. shader: string;
  11628. };
  11629. }
  11630. declare module "babylonjs/Shaders/sprites.vertex" {
  11631. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11632. /** @hidden */
  11633. export var spritesVertexShader: {
  11634. name: string;
  11635. shader: string;
  11636. };
  11637. }
  11638. declare module "babylonjs/Sprites/spriteManager" {
  11639. import { IDisposable, Scene } from "babylonjs/scene";
  11640. import { Nullable } from "babylonjs/types";
  11641. import { Observable } from "babylonjs/Misc/observable";
  11642. import { Sprite } from "babylonjs/Sprites/sprite";
  11643. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11644. import { Camera } from "babylonjs/Cameras/camera";
  11645. import { Texture } from "babylonjs/Materials/Textures/texture";
  11646. import "babylonjs/Shaders/sprites.fragment";
  11647. import "babylonjs/Shaders/sprites.vertex";
  11648. import { Ray } from "babylonjs/Culling/ray";
  11649. /**
  11650. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11651. */
  11652. export interface ISpriteManager extends IDisposable {
  11653. /**
  11654. * Restricts the camera to viewing objects with the same layerMask.
  11655. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11656. */
  11657. layerMask: number;
  11658. /**
  11659. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11660. */
  11661. isPickable: boolean;
  11662. /**
  11663. * Specifies the rendering group id for this mesh (0 by default)
  11664. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11665. */
  11666. renderingGroupId: number;
  11667. /**
  11668. * Defines the list of sprites managed by the manager.
  11669. */
  11670. sprites: Array<Sprite>;
  11671. /**
  11672. * Tests the intersection of a sprite with a specific ray.
  11673. * @param ray The ray we are sending to test the collision
  11674. * @param camera The camera space we are sending rays in
  11675. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11676. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11677. * @returns picking info or null.
  11678. */
  11679. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11680. /**
  11681. * Intersects the sprites with a ray
  11682. * @param ray defines the ray to intersect with
  11683. * @param camera defines the current active camera
  11684. * @param predicate defines a predicate used to select candidate sprites
  11685. * @returns null if no hit or a PickingInfo array
  11686. */
  11687. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11688. /**
  11689. * Renders the list of sprites on screen.
  11690. */
  11691. render(): void;
  11692. }
  11693. /**
  11694. * Class used to manage multiple sprites on the same spritesheet
  11695. * @see http://doc.babylonjs.com/babylon101/sprites
  11696. */
  11697. export class SpriteManager implements ISpriteManager {
  11698. /** defines the manager's name */
  11699. name: string;
  11700. /** Gets the list of sprites */
  11701. sprites: Sprite[];
  11702. /** Gets or sets the rendering group id (0 by default) */
  11703. renderingGroupId: number;
  11704. /** Gets or sets camera layer mask */
  11705. layerMask: number;
  11706. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11707. fogEnabled: boolean;
  11708. /** Gets or sets a boolean indicating if the sprites are pickable */
  11709. isPickable: boolean;
  11710. /** Defines the default width of a cell in the spritesheet */
  11711. cellWidth: number;
  11712. /** Defines the default height of a cell in the spritesheet */
  11713. cellHeight: number;
  11714. /** Associative array from JSON sprite data file */
  11715. private _cellData;
  11716. /** Array of sprite names from JSON sprite data file */
  11717. private _spriteMap;
  11718. /** True when packed cell data from JSON file is ready*/
  11719. private _packedAndReady;
  11720. /**
  11721. * An event triggered when the manager is disposed.
  11722. */
  11723. onDisposeObservable: Observable<SpriteManager>;
  11724. private _onDisposeObserver;
  11725. /**
  11726. * Callback called when the manager is disposed
  11727. */
  11728. onDispose: () => void;
  11729. private _capacity;
  11730. private _fromPacked;
  11731. private _spriteTexture;
  11732. private _epsilon;
  11733. private _scene;
  11734. private _vertexData;
  11735. private _buffer;
  11736. private _vertexBuffers;
  11737. private _indexBuffer;
  11738. private _effectBase;
  11739. private _effectFog;
  11740. /**
  11741. * Gets or sets the spritesheet texture
  11742. */
  11743. texture: Texture;
  11744. /**
  11745. * Creates a new sprite manager
  11746. * @param name defines the manager's name
  11747. * @param imgUrl defines the sprite sheet url
  11748. * @param capacity defines the maximum allowed number of sprites
  11749. * @param cellSize defines the size of a sprite cell
  11750. * @param scene defines the hosting scene
  11751. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11752. * @param samplingMode defines the smapling mode to use with spritesheet
  11753. * @param fromPacked set to false; do not alter
  11754. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11755. */
  11756. constructor(
  11757. /** defines the manager's name */
  11758. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11759. private _makePacked;
  11760. private _appendSpriteVertex;
  11761. /**
  11762. * Intersects the sprites with a ray
  11763. * @param ray defines the ray to intersect with
  11764. * @param camera defines the current active camera
  11765. * @param predicate defines a predicate used to select candidate sprites
  11766. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11767. * @returns null if no hit or a PickingInfo
  11768. */
  11769. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11770. /**
  11771. * Intersects the sprites with a ray
  11772. * @param ray defines the ray to intersect with
  11773. * @param camera defines the current active camera
  11774. * @param predicate defines a predicate used to select candidate sprites
  11775. * @returns null if no hit or a PickingInfo array
  11776. */
  11777. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11778. /**
  11779. * Render all child sprites
  11780. */
  11781. render(): void;
  11782. /**
  11783. * Release associated resources
  11784. */
  11785. dispose(): void;
  11786. }
  11787. }
  11788. declare module "babylonjs/Sprites/sprite" {
  11789. import { Vector3 } from "babylonjs/Maths/math.vector";
  11790. import { Nullable } from "babylonjs/types";
  11791. import { ActionManager } from "babylonjs/Actions/actionManager";
  11792. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11793. import { Color4 } from "babylonjs/Maths/math.color";
  11794. /**
  11795. * Class used to represent a sprite
  11796. * @see http://doc.babylonjs.com/babylon101/sprites
  11797. */
  11798. export class Sprite {
  11799. /** defines the name */
  11800. name: string;
  11801. /** Gets or sets the current world position */
  11802. position: Vector3;
  11803. /** Gets or sets the main color */
  11804. color: Color4;
  11805. /** Gets or sets the width */
  11806. width: number;
  11807. /** Gets or sets the height */
  11808. height: number;
  11809. /** Gets or sets rotation angle */
  11810. angle: number;
  11811. /** Gets or sets the cell index in the sprite sheet */
  11812. cellIndex: number;
  11813. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11814. cellRef: string;
  11815. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11816. invertU: number;
  11817. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11818. invertV: number;
  11819. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11820. disposeWhenFinishedAnimating: boolean;
  11821. /** Gets the list of attached animations */
  11822. animations: Animation[];
  11823. /** Gets or sets a boolean indicating if the sprite can be picked */
  11824. isPickable: boolean;
  11825. /**
  11826. * Gets or sets the associated action manager
  11827. */
  11828. actionManager: Nullable<ActionManager>;
  11829. private _animationStarted;
  11830. private _loopAnimation;
  11831. private _fromIndex;
  11832. private _toIndex;
  11833. private _delay;
  11834. private _direction;
  11835. private _manager;
  11836. private _time;
  11837. private _onAnimationEnd;
  11838. /**
  11839. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11840. */
  11841. isVisible: boolean;
  11842. /**
  11843. * Gets or sets the sprite size
  11844. */
  11845. size: number;
  11846. /**
  11847. * Creates a new Sprite
  11848. * @param name defines the name
  11849. * @param manager defines the manager
  11850. */
  11851. constructor(
  11852. /** defines the name */
  11853. name: string, manager: ISpriteManager);
  11854. /**
  11855. * Starts an animation
  11856. * @param from defines the initial key
  11857. * @param to defines the end key
  11858. * @param loop defines if the animation must loop
  11859. * @param delay defines the start delay (in ms)
  11860. * @param onAnimationEnd defines a callback to call when animation ends
  11861. */
  11862. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11863. /** Stops current animation (if any) */
  11864. stopAnimation(): void;
  11865. /** @hidden */
  11866. _animate(deltaTime: number): void;
  11867. /** Release associated resources */
  11868. dispose(): void;
  11869. }
  11870. }
  11871. declare module "babylonjs/Collisions/pickingInfo" {
  11872. import { Nullable } from "babylonjs/types";
  11873. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11875. import { Sprite } from "babylonjs/Sprites/sprite";
  11876. import { Ray } from "babylonjs/Culling/ray";
  11877. /**
  11878. * Information about the result of picking within a scene
  11879. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11880. */
  11881. export class PickingInfo {
  11882. /** @hidden */
  11883. _pickingUnavailable: boolean;
  11884. /**
  11885. * If the pick collided with an object
  11886. */
  11887. hit: boolean;
  11888. /**
  11889. * Distance away where the pick collided
  11890. */
  11891. distance: number;
  11892. /**
  11893. * The location of pick collision
  11894. */
  11895. pickedPoint: Nullable<Vector3>;
  11896. /**
  11897. * The mesh corresponding the the pick collision
  11898. */
  11899. pickedMesh: Nullable<AbstractMesh>;
  11900. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11901. bu: number;
  11902. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11903. bv: number;
  11904. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11905. faceId: number;
  11906. /** Id of the the submesh that was picked */
  11907. subMeshId: number;
  11908. /** If a sprite was picked, this will be the sprite the pick collided with */
  11909. pickedSprite: Nullable<Sprite>;
  11910. /**
  11911. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11912. */
  11913. originMesh: Nullable<AbstractMesh>;
  11914. /**
  11915. * The ray that was used to perform the picking.
  11916. */
  11917. ray: Nullable<Ray>;
  11918. /**
  11919. * Gets the normal correspodning to the face the pick collided with
  11920. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11921. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11922. * @returns The normal correspodning to the face the pick collided with
  11923. */
  11924. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11925. /**
  11926. * Gets the texture coordinates of where the pick occured
  11927. * @returns the vector containing the coordnates of the texture
  11928. */
  11929. getTextureCoordinates(): Nullable<Vector2>;
  11930. }
  11931. }
  11932. declare module "babylonjs/Events/pointerEvents" {
  11933. import { Nullable } from "babylonjs/types";
  11934. import { Vector2 } from "babylonjs/Maths/math.vector";
  11935. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11936. import { Ray } from "babylonjs/Culling/ray";
  11937. /**
  11938. * Gather the list of pointer event types as constants.
  11939. */
  11940. export class PointerEventTypes {
  11941. /**
  11942. * 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.
  11943. */
  11944. static readonly POINTERDOWN: number;
  11945. /**
  11946. * The pointerup event is fired when a pointer is no longer active.
  11947. */
  11948. static readonly POINTERUP: number;
  11949. /**
  11950. * The pointermove event is fired when a pointer changes coordinates.
  11951. */
  11952. static readonly POINTERMOVE: number;
  11953. /**
  11954. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11955. */
  11956. static readonly POINTERWHEEL: number;
  11957. /**
  11958. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11959. */
  11960. static readonly POINTERPICK: number;
  11961. /**
  11962. * The pointertap event is fired when a the object has been touched and released without drag.
  11963. */
  11964. static readonly POINTERTAP: number;
  11965. /**
  11966. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11967. */
  11968. static readonly POINTERDOUBLETAP: number;
  11969. }
  11970. /**
  11971. * Base class of pointer info types.
  11972. */
  11973. export class PointerInfoBase {
  11974. /**
  11975. * Defines the type of event (PointerEventTypes)
  11976. */
  11977. type: number;
  11978. /**
  11979. * Defines the related dom event
  11980. */
  11981. event: PointerEvent | MouseWheelEvent;
  11982. /**
  11983. * Instantiates the base class of pointers info.
  11984. * @param type Defines the type of event (PointerEventTypes)
  11985. * @param event Defines the related dom event
  11986. */
  11987. constructor(
  11988. /**
  11989. * Defines the type of event (PointerEventTypes)
  11990. */
  11991. type: number,
  11992. /**
  11993. * Defines the related dom event
  11994. */
  11995. event: PointerEvent | MouseWheelEvent);
  11996. }
  11997. /**
  11998. * This class is used to store pointer related info for the onPrePointerObservable event.
  11999. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12000. */
  12001. export class PointerInfoPre extends PointerInfoBase {
  12002. /**
  12003. * Ray from a pointer if availible (eg. 6dof controller)
  12004. */
  12005. ray: Nullable<Ray>;
  12006. /**
  12007. * Defines the local position of the pointer on the canvas.
  12008. */
  12009. localPosition: Vector2;
  12010. /**
  12011. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12012. */
  12013. skipOnPointerObservable: boolean;
  12014. /**
  12015. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12016. * @param type Defines the type of event (PointerEventTypes)
  12017. * @param event Defines the related dom event
  12018. * @param localX Defines the local x coordinates of the pointer when the event occured
  12019. * @param localY Defines the local y coordinates of the pointer when the event occured
  12020. */
  12021. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12022. }
  12023. /**
  12024. * This type contains all the data related to a pointer event in Babylon.js.
  12025. * 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.
  12026. */
  12027. export class PointerInfo extends PointerInfoBase {
  12028. /**
  12029. * Defines the picking info associated to the info (if any)\
  12030. */
  12031. pickInfo: Nullable<PickingInfo>;
  12032. /**
  12033. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12034. * @param type Defines the type of event (PointerEventTypes)
  12035. * @param event Defines the related dom event
  12036. * @param pickInfo Defines the picking info associated to the info (if any)\
  12037. */
  12038. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12039. /**
  12040. * Defines the picking info associated to the info (if any)\
  12041. */
  12042. pickInfo: Nullable<PickingInfo>);
  12043. }
  12044. /**
  12045. * Data relating to a touch event on the screen.
  12046. */
  12047. export interface PointerTouch {
  12048. /**
  12049. * X coordinate of touch.
  12050. */
  12051. x: number;
  12052. /**
  12053. * Y coordinate of touch.
  12054. */
  12055. y: number;
  12056. /**
  12057. * Id of touch. Unique for each finger.
  12058. */
  12059. pointerId: number;
  12060. /**
  12061. * Event type passed from DOM.
  12062. */
  12063. type: any;
  12064. }
  12065. }
  12066. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12067. import { Observable } from "babylonjs/Misc/observable";
  12068. import { Nullable } from "babylonjs/types";
  12069. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12070. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12071. /**
  12072. * Manage the mouse inputs to control the movement of a free camera.
  12073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12074. */
  12075. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12076. /**
  12077. * Define if touch is enabled in the mouse input
  12078. */
  12079. touchEnabled: boolean;
  12080. /**
  12081. * Defines the camera the input is attached to.
  12082. */
  12083. camera: FreeCamera;
  12084. /**
  12085. * Defines the buttons associated with the input to handle camera move.
  12086. */
  12087. buttons: number[];
  12088. /**
  12089. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12090. */
  12091. angularSensibility: number;
  12092. private _pointerInput;
  12093. private _onMouseMove;
  12094. private _observer;
  12095. private previousPosition;
  12096. /**
  12097. * Observable for when a pointer move event occurs containing the move offset
  12098. */
  12099. onPointerMovedObservable: Observable<{
  12100. offsetX: number;
  12101. offsetY: number;
  12102. }>;
  12103. /**
  12104. * @hidden
  12105. * If the camera should be rotated automatically based on pointer movement
  12106. */
  12107. _allowCameraRotation: boolean;
  12108. /**
  12109. * Manage the mouse inputs to control the movement of a free camera.
  12110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12111. * @param touchEnabled Defines if touch is enabled or not
  12112. */
  12113. constructor(
  12114. /**
  12115. * Define if touch is enabled in the mouse input
  12116. */
  12117. touchEnabled?: boolean);
  12118. /**
  12119. * Attach the input controls to a specific dom element to get the input from.
  12120. * @param element Defines the element the controls should be listened from
  12121. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12122. */
  12123. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12124. /**
  12125. * Called on JS contextmenu event.
  12126. * Override this method to provide functionality.
  12127. */
  12128. protected onContextMenu(evt: PointerEvent): void;
  12129. /**
  12130. * Detach the current controls from the specified dom element.
  12131. * @param element Defines the element to stop listening the inputs from
  12132. */
  12133. detachControl(element: Nullable<HTMLElement>): void;
  12134. /**
  12135. * Gets the class name of the current intput.
  12136. * @returns the class name
  12137. */
  12138. getClassName(): string;
  12139. /**
  12140. * Get the friendly name associated with the input class.
  12141. * @returns the input friendly name
  12142. */
  12143. getSimpleName(): string;
  12144. }
  12145. }
  12146. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12147. import { Nullable } from "babylonjs/types";
  12148. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12149. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12150. /**
  12151. * Manage the touch inputs to control the movement of a free camera.
  12152. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12153. */
  12154. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12155. /**
  12156. * Defines the camera the input is attached to.
  12157. */
  12158. camera: FreeCamera;
  12159. /**
  12160. * Defines the touch sensibility for rotation.
  12161. * The higher the faster.
  12162. */
  12163. touchAngularSensibility: number;
  12164. /**
  12165. * Defines the touch sensibility for move.
  12166. * The higher the faster.
  12167. */
  12168. touchMoveSensibility: number;
  12169. private _offsetX;
  12170. private _offsetY;
  12171. private _pointerPressed;
  12172. private _pointerInput;
  12173. private _observer;
  12174. private _onLostFocus;
  12175. /**
  12176. * Attach the input controls to a specific dom element to get the input from.
  12177. * @param element Defines the element the controls should be listened from
  12178. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12179. */
  12180. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12181. /**
  12182. * Detach the current controls from the specified dom element.
  12183. * @param element Defines the element to stop listening the inputs from
  12184. */
  12185. detachControl(element: Nullable<HTMLElement>): void;
  12186. /**
  12187. * Update the current camera state depending on the inputs that have been used this frame.
  12188. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12189. */
  12190. checkInputs(): void;
  12191. /**
  12192. * Gets the class name of the current intput.
  12193. * @returns the class name
  12194. */
  12195. getClassName(): string;
  12196. /**
  12197. * Get the friendly name associated with the input class.
  12198. * @returns the input friendly name
  12199. */
  12200. getSimpleName(): string;
  12201. }
  12202. }
  12203. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12204. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12205. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12206. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12207. import { Nullable } from "babylonjs/types";
  12208. /**
  12209. * Default Inputs manager for the FreeCamera.
  12210. * It groups all the default supported inputs for ease of use.
  12211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12212. */
  12213. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12214. /**
  12215. * @hidden
  12216. */
  12217. _mouseInput: Nullable<FreeCameraMouseInput>;
  12218. /**
  12219. * Instantiates a new FreeCameraInputsManager.
  12220. * @param camera Defines the camera the inputs belong to
  12221. */
  12222. constructor(camera: FreeCamera);
  12223. /**
  12224. * Add keyboard input support to the input manager.
  12225. * @returns the current input manager
  12226. */
  12227. addKeyboard(): FreeCameraInputsManager;
  12228. /**
  12229. * Add mouse input support to the input manager.
  12230. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12231. * @returns the current input manager
  12232. */
  12233. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12234. /**
  12235. * Removes the mouse input support from the manager
  12236. * @returns the current input manager
  12237. */
  12238. removeMouse(): FreeCameraInputsManager;
  12239. /**
  12240. * Add touch input support to the input manager.
  12241. * @returns the current input manager
  12242. */
  12243. addTouch(): FreeCameraInputsManager;
  12244. /**
  12245. * Remove all attached input methods from a camera
  12246. */
  12247. clear(): void;
  12248. }
  12249. }
  12250. declare module "babylonjs/Cameras/freeCamera" {
  12251. import { Vector3 } from "babylonjs/Maths/math.vector";
  12252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12253. import { Scene } from "babylonjs/scene";
  12254. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12255. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12256. /**
  12257. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12258. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12259. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12260. */
  12261. export class FreeCamera extends TargetCamera {
  12262. /**
  12263. * Define the collision ellipsoid of the camera.
  12264. * This is helpful to simulate a camera body like the player body around the camera
  12265. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12266. */
  12267. ellipsoid: Vector3;
  12268. /**
  12269. * Define an offset for the position of the ellipsoid around the camera.
  12270. * This can be helpful to determine the center of the body near the gravity center of the body
  12271. * instead of its head.
  12272. */
  12273. ellipsoidOffset: Vector3;
  12274. /**
  12275. * Enable or disable collisions of the camera with the rest of the scene objects.
  12276. */
  12277. checkCollisions: boolean;
  12278. /**
  12279. * Enable or disable gravity on the camera.
  12280. */
  12281. applyGravity: boolean;
  12282. /**
  12283. * Define the input manager associated to the camera.
  12284. */
  12285. inputs: FreeCameraInputsManager;
  12286. /**
  12287. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12288. * Higher values reduce sensitivity.
  12289. */
  12290. /**
  12291. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12292. * Higher values reduce sensitivity.
  12293. */
  12294. angularSensibility: number;
  12295. /**
  12296. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12297. */
  12298. keysUp: number[];
  12299. /**
  12300. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12301. */
  12302. keysDown: number[];
  12303. /**
  12304. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12305. */
  12306. keysLeft: number[];
  12307. /**
  12308. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12309. */
  12310. keysRight: number[];
  12311. /**
  12312. * Event raised when the camera collide with a mesh in the scene.
  12313. */
  12314. onCollide: (collidedMesh: AbstractMesh) => void;
  12315. private _collider;
  12316. private _needMoveForGravity;
  12317. private _oldPosition;
  12318. private _diffPosition;
  12319. private _newPosition;
  12320. /** @hidden */
  12321. _localDirection: Vector3;
  12322. /** @hidden */
  12323. _transformedDirection: Vector3;
  12324. /**
  12325. * Instantiates a Free Camera.
  12326. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12327. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12328. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12329. * @param name Define the name of the camera in the scene
  12330. * @param position Define the start position of the camera in the scene
  12331. * @param scene Define the scene the camera belongs to
  12332. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12333. */
  12334. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12335. /**
  12336. * Attached controls to the current camera.
  12337. * @param element Defines the element the controls should be listened from
  12338. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12339. */
  12340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12341. /**
  12342. * Detach the current controls from the camera.
  12343. * The camera will stop reacting to inputs.
  12344. * @param element Defines the element to stop listening the inputs from
  12345. */
  12346. detachControl(element: HTMLElement): void;
  12347. private _collisionMask;
  12348. /**
  12349. * Define a collision mask to limit the list of object the camera can collide with
  12350. */
  12351. collisionMask: number;
  12352. /** @hidden */
  12353. _collideWithWorld(displacement: Vector3): void;
  12354. private _onCollisionPositionChange;
  12355. /** @hidden */
  12356. _checkInputs(): void;
  12357. /** @hidden */
  12358. _decideIfNeedsToMove(): boolean;
  12359. /** @hidden */
  12360. _updatePosition(): void;
  12361. /**
  12362. * Destroy the camera and release the current resources hold by it.
  12363. */
  12364. dispose(): void;
  12365. /**
  12366. * Gets the current object class name.
  12367. * @return the class name
  12368. */
  12369. getClassName(): string;
  12370. }
  12371. }
  12372. declare module "babylonjs/Gamepads/gamepad" {
  12373. import { Observable } from "babylonjs/Misc/observable";
  12374. /**
  12375. * Represents a gamepad control stick position
  12376. */
  12377. export class StickValues {
  12378. /**
  12379. * The x component of the control stick
  12380. */
  12381. x: number;
  12382. /**
  12383. * The y component of the control stick
  12384. */
  12385. y: number;
  12386. /**
  12387. * Initializes the gamepad x and y control stick values
  12388. * @param x The x component of the gamepad control stick value
  12389. * @param y The y component of the gamepad control stick value
  12390. */
  12391. constructor(
  12392. /**
  12393. * The x component of the control stick
  12394. */
  12395. x: number,
  12396. /**
  12397. * The y component of the control stick
  12398. */
  12399. y: number);
  12400. }
  12401. /**
  12402. * An interface which manages callbacks for gamepad button changes
  12403. */
  12404. export interface GamepadButtonChanges {
  12405. /**
  12406. * Called when a gamepad has been changed
  12407. */
  12408. changed: boolean;
  12409. /**
  12410. * Called when a gamepad press event has been triggered
  12411. */
  12412. pressChanged: boolean;
  12413. /**
  12414. * Called when a touch event has been triggered
  12415. */
  12416. touchChanged: boolean;
  12417. /**
  12418. * Called when a value has changed
  12419. */
  12420. valueChanged: boolean;
  12421. }
  12422. /**
  12423. * Represents a gamepad
  12424. */
  12425. export class Gamepad {
  12426. /**
  12427. * The id of the gamepad
  12428. */
  12429. id: string;
  12430. /**
  12431. * The index of the gamepad
  12432. */
  12433. index: number;
  12434. /**
  12435. * The browser gamepad
  12436. */
  12437. browserGamepad: any;
  12438. /**
  12439. * Specifies what type of gamepad this represents
  12440. */
  12441. type: number;
  12442. private _leftStick;
  12443. private _rightStick;
  12444. /** @hidden */
  12445. _isConnected: boolean;
  12446. private _leftStickAxisX;
  12447. private _leftStickAxisY;
  12448. private _rightStickAxisX;
  12449. private _rightStickAxisY;
  12450. /**
  12451. * Triggered when the left control stick has been changed
  12452. */
  12453. private _onleftstickchanged;
  12454. /**
  12455. * Triggered when the right control stick has been changed
  12456. */
  12457. private _onrightstickchanged;
  12458. /**
  12459. * Represents a gamepad controller
  12460. */
  12461. static GAMEPAD: number;
  12462. /**
  12463. * Represents a generic controller
  12464. */
  12465. static GENERIC: number;
  12466. /**
  12467. * Represents an XBox controller
  12468. */
  12469. static XBOX: number;
  12470. /**
  12471. * Represents a pose-enabled controller
  12472. */
  12473. static POSE_ENABLED: number;
  12474. /**
  12475. * Represents an Dual Shock controller
  12476. */
  12477. static DUALSHOCK: number;
  12478. /**
  12479. * Specifies whether the left control stick should be Y-inverted
  12480. */
  12481. protected _invertLeftStickY: boolean;
  12482. /**
  12483. * Specifies if the gamepad has been connected
  12484. */
  12485. readonly isConnected: boolean;
  12486. /**
  12487. * Initializes the gamepad
  12488. * @param id The id of the gamepad
  12489. * @param index The index of the gamepad
  12490. * @param browserGamepad The browser gamepad
  12491. * @param leftStickX The x component of the left joystick
  12492. * @param leftStickY The y component of the left joystick
  12493. * @param rightStickX The x component of the right joystick
  12494. * @param rightStickY The y component of the right joystick
  12495. */
  12496. constructor(
  12497. /**
  12498. * The id of the gamepad
  12499. */
  12500. id: string,
  12501. /**
  12502. * The index of the gamepad
  12503. */
  12504. index: number,
  12505. /**
  12506. * The browser gamepad
  12507. */
  12508. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12509. /**
  12510. * Callback triggered when the left joystick has changed
  12511. * @param callback
  12512. */
  12513. onleftstickchanged(callback: (values: StickValues) => void): void;
  12514. /**
  12515. * Callback triggered when the right joystick has changed
  12516. * @param callback
  12517. */
  12518. onrightstickchanged(callback: (values: StickValues) => void): void;
  12519. /**
  12520. * Gets the left joystick
  12521. */
  12522. /**
  12523. * Sets the left joystick values
  12524. */
  12525. leftStick: StickValues;
  12526. /**
  12527. * Gets the right joystick
  12528. */
  12529. /**
  12530. * Sets the right joystick value
  12531. */
  12532. rightStick: StickValues;
  12533. /**
  12534. * Updates the gamepad joystick positions
  12535. */
  12536. update(): void;
  12537. /**
  12538. * Disposes the gamepad
  12539. */
  12540. dispose(): void;
  12541. }
  12542. /**
  12543. * Represents a generic gamepad
  12544. */
  12545. export class GenericPad extends Gamepad {
  12546. private _buttons;
  12547. private _onbuttondown;
  12548. private _onbuttonup;
  12549. /**
  12550. * Observable triggered when a button has been pressed
  12551. */
  12552. onButtonDownObservable: Observable<number>;
  12553. /**
  12554. * Observable triggered when a button has been released
  12555. */
  12556. onButtonUpObservable: Observable<number>;
  12557. /**
  12558. * Callback triggered when a button has been pressed
  12559. * @param callback Called when a button has been pressed
  12560. */
  12561. onbuttondown(callback: (buttonPressed: number) => void): void;
  12562. /**
  12563. * Callback triggered when a button has been released
  12564. * @param callback Called when a button has been released
  12565. */
  12566. onbuttonup(callback: (buttonReleased: number) => void): void;
  12567. /**
  12568. * Initializes the generic gamepad
  12569. * @param id The id of the generic gamepad
  12570. * @param index The index of the generic gamepad
  12571. * @param browserGamepad The browser gamepad
  12572. */
  12573. constructor(id: string, index: number, browserGamepad: any);
  12574. private _setButtonValue;
  12575. /**
  12576. * Updates the generic gamepad
  12577. */
  12578. update(): void;
  12579. /**
  12580. * Disposes the generic gamepad
  12581. */
  12582. dispose(): void;
  12583. }
  12584. }
  12585. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12586. import { Nullable } from "babylonjs/types";
  12587. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12588. import { Scene } from "babylonjs/scene";
  12589. module "babylonjs/Engines/engine" {
  12590. interface Engine {
  12591. /**
  12592. * Creates a raw texture
  12593. * @param data defines the data to store in the texture
  12594. * @param width defines the width of the texture
  12595. * @param height defines the height of the texture
  12596. * @param format defines the format of the data
  12597. * @param generateMipMaps defines if the engine should generate the mip levels
  12598. * @param invertY defines if data must be stored with Y axis inverted
  12599. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12600. * @param compression defines the compression used (null by default)
  12601. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12602. * @returns the raw texture inside an InternalTexture
  12603. */
  12604. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12605. /**
  12606. * Update a raw texture
  12607. * @param texture defines the texture to update
  12608. * @param data defines the data to store in the texture
  12609. * @param format defines the format of the data
  12610. * @param invertY defines if data must be stored with Y axis inverted
  12611. */
  12612. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12613. /**
  12614. * Update a raw texture
  12615. * @param texture defines the texture to update
  12616. * @param data defines the data to store in the texture
  12617. * @param format defines the format of the data
  12618. * @param invertY defines if data must be stored with Y axis inverted
  12619. * @param compression defines the compression used (null by default)
  12620. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12621. */
  12622. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12623. /**
  12624. * Creates a new raw cube texture
  12625. * @param data defines the array of data to use to create each face
  12626. * @param size defines the size of the textures
  12627. * @param format defines the format of the data
  12628. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12629. * @param generateMipMaps defines if the engine should generate the mip levels
  12630. * @param invertY defines if data must be stored with Y axis inverted
  12631. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12632. * @param compression defines the compression used (null by default)
  12633. * @returns the cube texture as an InternalTexture
  12634. */
  12635. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12636. /**
  12637. * Update a raw cube texture
  12638. * @param texture defines the texture to udpdate
  12639. * @param data defines the data to store
  12640. * @param format defines the data format
  12641. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12642. * @param invertY defines if data must be stored with Y axis inverted
  12643. */
  12644. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12645. /**
  12646. * Update a raw cube texture
  12647. * @param texture defines the texture to udpdate
  12648. * @param data defines the data to store
  12649. * @param format defines the data format
  12650. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12651. * @param invertY defines if data must be stored with Y axis inverted
  12652. * @param compression defines the compression used (null by default)
  12653. */
  12654. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12655. /**
  12656. * Update a raw cube texture
  12657. * @param texture defines the texture to udpdate
  12658. * @param data defines the data to store
  12659. * @param format defines the data format
  12660. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12661. * @param invertY defines if data must be stored with Y axis inverted
  12662. * @param compression defines the compression used (null by default)
  12663. * @param level defines which level of the texture to update
  12664. */
  12665. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12666. /**
  12667. * Creates a new raw cube texture from a specified url
  12668. * @param url defines the url where the data is located
  12669. * @param scene defines the current scene
  12670. * @param size defines the size of the textures
  12671. * @param format defines the format of the data
  12672. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12673. * @param noMipmap defines if the engine should avoid generating the mip levels
  12674. * @param callback defines a callback used to extract texture data from loaded data
  12675. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12676. * @param onLoad defines a callback called when texture is loaded
  12677. * @param onError defines a callback called if there is an error
  12678. * @returns the cube texture as an InternalTexture
  12679. */
  12680. 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;
  12681. /**
  12682. * Creates a new raw cube texture from a specified url
  12683. * @param url defines the url where the data is located
  12684. * @param scene defines the current scene
  12685. * @param size defines the size of the textures
  12686. * @param format defines the format of the data
  12687. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12688. * @param noMipmap defines if the engine should avoid generating the mip levels
  12689. * @param callback defines a callback used to extract texture data from loaded data
  12690. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12691. * @param onLoad defines a callback called when texture is loaded
  12692. * @param onError defines a callback called if there is an error
  12693. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12694. * @param invertY defines if data must be stored with Y axis inverted
  12695. * @returns the cube texture as an InternalTexture
  12696. */
  12697. 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;
  12698. /**
  12699. * Creates a new raw 3D texture
  12700. * @param data defines the data used to create the texture
  12701. * @param width defines the width of the texture
  12702. * @param height defines the height of the texture
  12703. * @param depth defines the depth of the texture
  12704. * @param format defines the format of the texture
  12705. * @param generateMipMaps defines if the engine must generate mip levels
  12706. * @param invertY defines if data must be stored with Y axis inverted
  12707. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12708. * @param compression defines the compressed used (can be null)
  12709. * @param textureType defines the compressed used (can be null)
  12710. * @returns a new raw 3D texture (stored in an InternalTexture)
  12711. */
  12712. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12713. /**
  12714. * Update a raw 3D texture
  12715. * @param texture defines the texture to update
  12716. * @param data defines the data to store
  12717. * @param format defines the data format
  12718. * @param invertY defines if data must be stored with Y axis inverted
  12719. */
  12720. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12721. /**
  12722. * Update a raw 3D texture
  12723. * @param texture defines the texture to update
  12724. * @param data defines the data to store
  12725. * @param format defines the data format
  12726. * @param invertY defines if data must be stored with Y axis inverted
  12727. * @param compression defines the used compression (can be null)
  12728. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12729. */
  12730. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12731. /**
  12732. * Creates a new raw 2D array texture
  12733. * @param data defines the data used to create the texture
  12734. * @param width defines the width of the texture
  12735. * @param height defines the height of the texture
  12736. * @param depth defines the number of layers of the texture
  12737. * @param format defines the format of the texture
  12738. * @param generateMipMaps defines if the engine must generate mip levels
  12739. * @param invertY defines if data must be stored with Y axis inverted
  12740. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12741. * @param compression defines the compressed used (can be null)
  12742. * @param textureType defines the compressed used (can be null)
  12743. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12744. */
  12745. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12746. /**
  12747. * Update a raw 2D array texture
  12748. * @param texture defines the texture to update
  12749. * @param data defines the data to store
  12750. * @param format defines the data format
  12751. * @param invertY defines if data must be stored with Y axis inverted
  12752. */
  12753. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12754. /**
  12755. * Update a raw 2D array texture
  12756. * @param texture defines the texture to update
  12757. * @param data defines the data to store
  12758. * @param format defines the data format
  12759. * @param invertY defines if data must be stored with Y axis inverted
  12760. * @param compression defines the used compression (can be null)
  12761. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12762. */
  12763. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12764. }
  12765. }
  12766. }
  12767. declare module "babylonjs/Materials/Textures/rawTexture" {
  12768. import { Scene } from "babylonjs/scene";
  12769. import { Texture } from "babylonjs/Materials/Textures/texture";
  12770. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12771. /**
  12772. * Raw texture can help creating a texture directly from an array of data.
  12773. * This can be super useful if you either get the data from an uncompressed source or
  12774. * if you wish to create your texture pixel by pixel.
  12775. */
  12776. export class RawTexture extends Texture {
  12777. /**
  12778. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12779. */
  12780. format: number;
  12781. private _engine;
  12782. /**
  12783. * Instantiates a new RawTexture.
  12784. * Raw texture can help creating a texture directly from an array of data.
  12785. * This can be super useful if you either get the data from an uncompressed source or
  12786. * if you wish to create your texture pixel by pixel.
  12787. * @param data define the array of data to use to create the texture
  12788. * @param width define the width of the texture
  12789. * @param height define the height of the texture
  12790. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12791. * @param scene define the scene the texture belongs to
  12792. * @param generateMipMaps define whether mip maps should be generated or not
  12793. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12794. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12795. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12796. */
  12797. constructor(data: ArrayBufferView, width: number, height: number,
  12798. /**
  12799. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12800. */
  12801. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12802. /**
  12803. * Updates the texture underlying data.
  12804. * @param data Define the new data of the texture
  12805. */
  12806. update(data: ArrayBufferView): void;
  12807. /**
  12808. * Creates a luminance texture from some data.
  12809. * @param data Define the texture data
  12810. * @param width Define the width of the texture
  12811. * @param height Define the height of the texture
  12812. * @param scene Define the scene the texture belongs to
  12813. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12814. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12815. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12816. * @returns the luminance texture
  12817. */
  12818. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12819. /**
  12820. * Creates a luminance alpha texture from some data.
  12821. * @param data Define the texture data
  12822. * @param width Define the width of the texture
  12823. * @param height Define the height of the texture
  12824. * @param scene Define the scene the texture belongs to
  12825. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12826. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12827. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12828. * @returns the luminance alpha texture
  12829. */
  12830. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12831. /**
  12832. * Creates an alpha texture from some data.
  12833. * @param data Define the texture data
  12834. * @param width Define the width of the texture
  12835. * @param height Define the height of the texture
  12836. * @param scene Define the scene the texture belongs to
  12837. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12838. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12839. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12840. * @returns the alpha texture
  12841. */
  12842. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12843. /**
  12844. * Creates a RGB texture from some data.
  12845. * @param data Define the texture data
  12846. * @param width Define the width of the texture
  12847. * @param height Define the height of the texture
  12848. * @param scene Define the scene the texture belongs to
  12849. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12850. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12851. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12852. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12853. * @returns the RGB alpha texture
  12854. */
  12855. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12856. /**
  12857. * Creates a RGBA texture from some data.
  12858. * @param data Define the texture data
  12859. * @param width Define the width of the texture
  12860. * @param height Define the height of the texture
  12861. * @param scene Define the scene the texture belongs to
  12862. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12863. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12864. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12865. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12866. * @returns the RGBA texture
  12867. */
  12868. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12869. /**
  12870. * Creates a R texture from some data.
  12871. * @param data Define the texture data
  12872. * @param width Define the width of the texture
  12873. * @param height Define the height of the texture
  12874. * @param scene Define the scene the texture belongs to
  12875. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12876. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12877. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12878. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12879. * @returns the R texture
  12880. */
  12881. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12882. }
  12883. }
  12884. declare module "babylonjs/Maths/math.size" {
  12885. /**
  12886. * Interface for the size containing width and height
  12887. */
  12888. export interface ISize {
  12889. /**
  12890. * Width
  12891. */
  12892. width: number;
  12893. /**
  12894. * Heighht
  12895. */
  12896. height: number;
  12897. }
  12898. /**
  12899. * Size containing widht and height
  12900. */
  12901. export class Size implements ISize {
  12902. /**
  12903. * Width
  12904. */
  12905. width: number;
  12906. /**
  12907. * Height
  12908. */
  12909. height: number;
  12910. /**
  12911. * Creates a Size object from the given width and height (floats).
  12912. * @param width width of the new size
  12913. * @param height height of the new size
  12914. */
  12915. constructor(width: number, height: number);
  12916. /**
  12917. * Returns a string with the Size width and height
  12918. * @returns a string with the Size width and height
  12919. */
  12920. toString(): string;
  12921. /**
  12922. * "Size"
  12923. * @returns the string "Size"
  12924. */
  12925. getClassName(): string;
  12926. /**
  12927. * Returns the Size hash code.
  12928. * @returns a hash code for a unique width and height
  12929. */
  12930. getHashCode(): number;
  12931. /**
  12932. * Updates the current size from the given one.
  12933. * @param src the given size
  12934. */
  12935. copyFrom(src: Size): void;
  12936. /**
  12937. * Updates in place the current Size from the given floats.
  12938. * @param width width of the new size
  12939. * @param height height of the new size
  12940. * @returns the updated Size.
  12941. */
  12942. copyFromFloats(width: number, height: number): Size;
  12943. /**
  12944. * Updates in place the current Size from the given floats.
  12945. * @param width width to set
  12946. * @param height height to set
  12947. * @returns the updated Size.
  12948. */
  12949. set(width: number, height: number): Size;
  12950. /**
  12951. * Multiplies the width and height by numbers
  12952. * @param w factor to multiple the width by
  12953. * @param h factor to multiple the height by
  12954. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12955. */
  12956. multiplyByFloats(w: number, h: number): Size;
  12957. /**
  12958. * Clones the size
  12959. * @returns a new Size copied from the given one.
  12960. */
  12961. clone(): Size;
  12962. /**
  12963. * True if the current Size and the given one width and height are strictly equal.
  12964. * @param other the other size to compare against
  12965. * @returns True if the current Size and the given one width and height are strictly equal.
  12966. */
  12967. equals(other: Size): boolean;
  12968. /**
  12969. * The surface of the Size : width * height (float).
  12970. */
  12971. readonly surface: number;
  12972. /**
  12973. * Create a new size of zero
  12974. * @returns a new Size set to (0.0, 0.0)
  12975. */
  12976. static Zero(): Size;
  12977. /**
  12978. * Sums the width and height of two sizes
  12979. * @param otherSize size to add to this size
  12980. * @returns a new Size set as the addition result of the current Size and the given one.
  12981. */
  12982. add(otherSize: Size): Size;
  12983. /**
  12984. * Subtracts the width and height of two
  12985. * @param otherSize size to subtract to this size
  12986. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12987. */
  12988. subtract(otherSize: Size): Size;
  12989. /**
  12990. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12991. * @param start starting size to lerp between
  12992. * @param end end size to lerp between
  12993. * @param amount amount to lerp between the start and end values
  12994. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12995. */
  12996. static Lerp(start: Size, end: Size, amount: number): Size;
  12997. }
  12998. }
  12999. declare module "babylonjs/Animations/runtimeAnimation" {
  13000. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13001. import { Animatable } from "babylonjs/Animations/animatable";
  13002. import { Scene } from "babylonjs/scene";
  13003. /**
  13004. * Defines a runtime animation
  13005. */
  13006. export class RuntimeAnimation {
  13007. private _events;
  13008. /**
  13009. * The current frame of the runtime animation
  13010. */
  13011. private _currentFrame;
  13012. /**
  13013. * The animation used by the runtime animation
  13014. */
  13015. private _animation;
  13016. /**
  13017. * The target of the runtime animation
  13018. */
  13019. private _target;
  13020. /**
  13021. * The initiating animatable
  13022. */
  13023. private _host;
  13024. /**
  13025. * The original value of the runtime animation
  13026. */
  13027. private _originalValue;
  13028. /**
  13029. * The original blend value of the runtime animation
  13030. */
  13031. private _originalBlendValue;
  13032. /**
  13033. * The offsets cache of the runtime animation
  13034. */
  13035. private _offsetsCache;
  13036. /**
  13037. * The high limits cache of the runtime animation
  13038. */
  13039. private _highLimitsCache;
  13040. /**
  13041. * Specifies if the runtime animation has been stopped
  13042. */
  13043. private _stopped;
  13044. /**
  13045. * The blending factor of the runtime animation
  13046. */
  13047. private _blendingFactor;
  13048. /**
  13049. * The BabylonJS scene
  13050. */
  13051. private _scene;
  13052. /**
  13053. * The current value of the runtime animation
  13054. */
  13055. private _currentValue;
  13056. /** @hidden */
  13057. _animationState: _IAnimationState;
  13058. /**
  13059. * The active target of the runtime animation
  13060. */
  13061. private _activeTargets;
  13062. private _currentActiveTarget;
  13063. private _directTarget;
  13064. /**
  13065. * The target path of the runtime animation
  13066. */
  13067. private _targetPath;
  13068. /**
  13069. * The weight of the runtime animation
  13070. */
  13071. private _weight;
  13072. /**
  13073. * The ratio offset of the runtime animation
  13074. */
  13075. private _ratioOffset;
  13076. /**
  13077. * The previous delay of the runtime animation
  13078. */
  13079. private _previousDelay;
  13080. /**
  13081. * The previous ratio of the runtime animation
  13082. */
  13083. private _previousRatio;
  13084. private _enableBlending;
  13085. private _keys;
  13086. private _minFrame;
  13087. private _maxFrame;
  13088. private _minValue;
  13089. private _maxValue;
  13090. private _targetIsArray;
  13091. /**
  13092. * Gets the current frame of the runtime animation
  13093. */
  13094. readonly currentFrame: number;
  13095. /**
  13096. * Gets the weight of the runtime animation
  13097. */
  13098. readonly weight: number;
  13099. /**
  13100. * Gets the current value of the runtime animation
  13101. */
  13102. readonly currentValue: any;
  13103. /**
  13104. * Gets the target path of the runtime animation
  13105. */
  13106. readonly targetPath: string;
  13107. /**
  13108. * Gets the actual target of the runtime animation
  13109. */
  13110. readonly target: any;
  13111. /** @hidden */
  13112. _onLoop: () => void;
  13113. /**
  13114. * Create a new RuntimeAnimation object
  13115. * @param target defines the target of the animation
  13116. * @param animation defines the source animation object
  13117. * @param scene defines the hosting scene
  13118. * @param host defines the initiating Animatable
  13119. */
  13120. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13121. private _preparePath;
  13122. /**
  13123. * Gets the animation from the runtime animation
  13124. */
  13125. readonly animation: Animation;
  13126. /**
  13127. * Resets the runtime animation to the beginning
  13128. * @param restoreOriginal defines whether to restore the target property to the original value
  13129. */
  13130. reset(restoreOriginal?: boolean): void;
  13131. /**
  13132. * Specifies if the runtime animation is stopped
  13133. * @returns Boolean specifying if the runtime animation is stopped
  13134. */
  13135. isStopped(): boolean;
  13136. /**
  13137. * Disposes of the runtime animation
  13138. */
  13139. dispose(): void;
  13140. /**
  13141. * Apply the interpolated value to the target
  13142. * @param currentValue defines the value computed by the animation
  13143. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13144. */
  13145. setValue(currentValue: any, weight: number): void;
  13146. private _getOriginalValues;
  13147. private _setValue;
  13148. /**
  13149. * Gets the loop pmode of the runtime animation
  13150. * @returns Loop Mode
  13151. */
  13152. private _getCorrectLoopMode;
  13153. /**
  13154. * Move the current animation to a given frame
  13155. * @param frame defines the frame to move to
  13156. */
  13157. goToFrame(frame: number): void;
  13158. /**
  13159. * @hidden Internal use only
  13160. */
  13161. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13162. /**
  13163. * Execute the current animation
  13164. * @param delay defines the delay to add to the current frame
  13165. * @param from defines the lower bound of the animation range
  13166. * @param to defines the upper bound of the animation range
  13167. * @param loop defines if the current animation must loop
  13168. * @param speedRatio defines the current speed ratio
  13169. * @param weight defines the weight of the animation (default is -1 so no weight)
  13170. * @param onLoop optional callback called when animation loops
  13171. * @returns a boolean indicating if the animation is running
  13172. */
  13173. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13174. }
  13175. }
  13176. declare module "babylonjs/Animations/animatable" {
  13177. import { Animation } from "babylonjs/Animations/animation";
  13178. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13179. import { Nullable } from "babylonjs/types";
  13180. import { Observable } from "babylonjs/Misc/observable";
  13181. import { Scene } from "babylonjs/scene";
  13182. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13183. import { Node } from "babylonjs/node";
  13184. /**
  13185. * Class used to store an actual running animation
  13186. */
  13187. export class Animatable {
  13188. /** defines the target object */
  13189. target: any;
  13190. /** defines the starting frame number (default is 0) */
  13191. fromFrame: number;
  13192. /** defines the ending frame number (default is 100) */
  13193. toFrame: number;
  13194. /** defines if the animation must loop (default is false) */
  13195. loopAnimation: boolean;
  13196. /** defines a callback to call when animation ends if it is not looping */
  13197. onAnimationEnd?: (() => void) | null | undefined;
  13198. /** defines a callback to call when animation loops */
  13199. onAnimationLoop?: (() => void) | null | undefined;
  13200. private _localDelayOffset;
  13201. private _pausedDelay;
  13202. private _runtimeAnimations;
  13203. private _paused;
  13204. private _scene;
  13205. private _speedRatio;
  13206. private _weight;
  13207. private _syncRoot;
  13208. /**
  13209. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13210. * This will only apply for non looping animation (default is true)
  13211. */
  13212. disposeOnEnd: boolean;
  13213. /**
  13214. * Gets a boolean indicating if the animation has started
  13215. */
  13216. animationStarted: boolean;
  13217. /**
  13218. * Observer raised when the animation ends
  13219. */
  13220. onAnimationEndObservable: Observable<Animatable>;
  13221. /**
  13222. * Observer raised when the animation loops
  13223. */
  13224. onAnimationLoopObservable: Observable<Animatable>;
  13225. /**
  13226. * Gets the root Animatable used to synchronize and normalize animations
  13227. */
  13228. readonly syncRoot: Nullable<Animatable>;
  13229. /**
  13230. * Gets the current frame of the first RuntimeAnimation
  13231. * Used to synchronize Animatables
  13232. */
  13233. readonly masterFrame: number;
  13234. /**
  13235. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13236. */
  13237. weight: number;
  13238. /**
  13239. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13240. */
  13241. speedRatio: number;
  13242. /**
  13243. * Creates a new Animatable
  13244. * @param scene defines the hosting scene
  13245. * @param target defines the target object
  13246. * @param fromFrame defines the starting frame number (default is 0)
  13247. * @param toFrame defines the ending frame number (default is 100)
  13248. * @param loopAnimation defines if the animation must loop (default is false)
  13249. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13250. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13251. * @param animations defines a group of animation to add to the new Animatable
  13252. * @param onAnimationLoop defines a callback to call when animation loops
  13253. */
  13254. constructor(scene: Scene,
  13255. /** defines the target object */
  13256. target: any,
  13257. /** defines the starting frame number (default is 0) */
  13258. fromFrame?: number,
  13259. /** defines the ending frame number (default is 100) */
  13260. toFrame?: number,
  13261. /** defines if the animation must loop (default is false) */
  13262. loopAnimation?: boolean, speedRatio?: number,
  13263. /** defines a callback to call when animation ends if it is not looping */
  13264. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13265. /** defines a callback to call when animation loops */
  13266. onAnimationLoop?: (() => void) | null | undefined);
  13267. /**
  13268. * Synchronize and normalize current Animatable with a source Animatable
  13269. * This is useful when using animation weights and when animations are not of the same length
  13270. * @param root defines the root Animatable to synchronize with
  13271. * @returns the current Animatable
  13272. */
  13273. syncWith(root: Animatable): Animatable;
  13274. /**
  13275. * Gets the list of runtime animations
  13276. * @returns an array of RuntimeAnimation
  13277. */
  13278. getAnimations(): RuntimeAnimation[];
  13279. /**
  13280. * Adds more animations to the current animatable
  13281. * @param target defines the target of the animations
  13282. * @param animations defines the new animations to add
  13283. */
  13284. appendAnimations(target: any, animations: Animation[]): void;
  13285. /**
  13286. * Gets the source animation for a specific property
  13287. * @param property defines the propertyu to look for
  13288. * @returns null or the source animation for the given property
  13289. */
  13290. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13291. /**
  13292. * Gets the runtime animation for a specific property
  13293. * @param property defines the propertyu to look for
  13294. * @returns null or the runtime animation for the given property
  13295. */
  13296. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13297. /**
  13298. * Resets the animatable to its original state
  13299. */
  13300. reset(): void;
  13301. /**
  13302. * Allows the animatable to blend with current running animations
  13303. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13304. * @param blendingSpeed defines the blending speed to use
  13305. */
  13306. enableBlending(blendingSpeed: number): void;
  13307. /**
  13308. * Disable animation blending
  13309. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13310. */
  13311. disableBlending(): void;
  13312. /**
  13313. * Jump directly to a given frame
  13314. * @param frame defines the frame to jump to
  13315. */
  13316. goToFrame(frame: number): void;
  13317. /**
  13318. * Pause the animation
  13319. */
  13320. pause(): void;
  13321. /**
  13322. * Restart the animation
  13323. */
  13324. restart(): void;
  13325. private _raiseOnAnimationEnd;
  13326. /**
  13327. * Stop and delete the current animation
  13328. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13329. * @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)
  13330. */
  13331. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13332. /**
  13333. * Wait asynchronously for the animation to end
  13334. * @returns a promise which will be fullfilled when the animation ends
  13335. */
  13336. waitAsync(): Promise<Animatable>;
  13337. /** @hidden */
  13338. _animate(delay: number): boolean;
  13339. }
  13340. module "babylonjs/scene" {
  13341. interface Scene {
  13342. /** @hidden */
  13343. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13344. /** @hidden */
  13345. _processLateAnimationBindingsForMatrices(holder: {
  13346. totalWeight: number;
  13347. animations: RuntimeAnimation[];
  13348. originalValue: Matrix;
  13349. }): any;
  13350. /** @hidden */
  13351. _processLateAnimationBindingsForQuaternions(holder: {
  13352. totalWeight: number;
  13353. animations: RuntimeAnimation[];
  13354. originalValue: Quaternion;
  13355. }, refQuaternion: Quaternion): Quaternion;
  13356. /** @hidden */
  13357. _processLateAnimationBindings(): void;
  13358. /**
  13359. * Will start the animation sequence of a given target
  13360. * @param target defines the target
  13361. * @param from defines from which frame should animation start
  13362. * @param to defines until which frame should animation run.
  13363. * @param weight defines the weight to apply to the animation (1.0 by default)
  13364. * @param loop defines if the animation loops
  13365. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13366. * @param onAnimationEnd defines the function to be executed when the animation ends
  13367. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13368. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13369. * @param onAnimationLoop defines the callback to call when an animation loops
  13370. * @returns the animatable object created for this animation
  13371. */
  13372. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13373. /**
  13374. * Will start the animation sequence of a given target
  13375. * @param target defines the target
  13376. * @param from defines from which frame should animation start
  13377. * @param to defines until which frame should animation run.
  13378. * @param loop defines if the animation loops
  13379. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13380. * @param onAnimationEnd defines the function to be executed when the animation ends
  13381. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13382. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13383. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13384. * @param onAnimationLoop defines the callback to call when an animation loops
  13385. * @returns the animatable object created for this animation
  13386. */
  13387. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13388. /**
  13389. * Will start the animation sequence of a given target and its hierarchy
  13390. * @param target defines the target
  13391. * @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.
  13392. * @param from defines from which frame should animation start
  13393. * @param to defines until which frame should animation run.
  13394. * @param loop defines if the animation loops
  13395. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13396. * @param onAnimationEnd defines the function to be executed when the animation ends
  13397. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13398. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13399. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13400. * @param onAnimationLoop defines the callback to call when an animation loops
  13401. * @returns the list of created animatables
  13402. */
  13403. 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[];
  13404. /**
  13405. * Begin a new animation on a given node
  13406. * @param target defines the target where the animation will take place
  13407. * @param animations defines the list of animations to start
  13408. * @param from defines the initial value
  13409. * @param to defines the final value
  13410. * @param loop defines if you want animation to loop (off by default)
  13411. * @param speedRatio defines the speed ratio to apply to all animations
  13412. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13413. * @param onAnimationLoop defines the callback to call when an animation loops
  13414. * @returns the list of created animatables
  13415. */
  13416. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13417. /**
  13418. * Begin a new animation on a given node and its hierarchy
  13419. * @param target defines the root node where the animation will take place
  13420. * @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.
  13421. * @param animations defines the list of animations to start
  13422. * @param from defines the initial value
  13423. * @param to defines the final value
  13424. * @param loop defines if you want animation to loop (off by default)
  13425. * @param speedRatio defines the speed ratio to apply to all animations
  13426. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13427. * @param onAnimationLoop defines the callback to call when an animation loops
  13428. * @returns the list of animatables created for all nodes
  13429. */
  13430. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13431. /**
  13432. * Gets the animatable associated with a specific target
  13433. * @param target defines the target of the animatable
  13434. * @returns the required animatable if found
  13435. */
  13436. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13437. /**
  13438. * Gets all animatables associated with a given target
  13439. * @param target defines the target to look animatables for
  13440. * @returns an array of Animatables
  13441. */
  13442. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13443. /**
  13444. * Stops and removes all animations that have been applied to the scene
  13445. */
  13446. stopAllAnimations(): void;
  13447. /**
  13448. * Gets the current delta time used by animation engine
  13449. */
  13450. deltaTime: number;
  13451. }
  13452. }
  13453. module "babylonjs/Bones/bone" {
  13454. interface Bone {
  13455. /**
  13456. * Copy an animation range from another bone
  13457. * @param source defines the source bone
  13458. * @param rangeName defines the range name to copy
  13459. * @param frameOffset defines the frame offset
  13460. * @param rescaleAsRequired defines if rescaling must be applied if required
  13461. * @param skelDimensionsRatio defines the scaling ratio
  13462. * @returns true if operation was successful
  13463. */
  13464. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13465. }
  13466. }
  13467. }
  13468. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13469. /**
  13470. * Class used to override all child animations of a given target
  13471. */
  13472. export class AnimationPropertiesOverride {
  13473. /**
  13474. * Gets or sets a value indicating if animation blending must be used
  13475. */
  13476. enableBlending: boolean;
  13477. /**
  13478. * Gets or sets the blending speed to use when enableBlending is true
  13479. */
  13480. blendingSpeed: number;
  13481. /**
  13482. * Gets or sets the default loop mode to use
  13483. */
  13484. loopMode: number;
  13485. }
  13486. }
  13487. declare module "babylonjs/Bones/skeleton" {
  13488. import { Bone } from "babylonjs/Bones/bone";
  13489. import { Observable } from "babylonjs/Misc/observable";
  13490. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13491. import { Scene } from "babylonjs/scene";
  13492. import { Nullable } from "babylonjs/types";
  13493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13494. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13495. import { Animatable } from "babylonjs/Animations/animatable";
  13496. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13497. import { Animation } from "babylonjs/Animations/animation";
  13498. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13499. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13500. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13501. /**
  13502. * Class used to handle skinning animations
  13503. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13504. */
  13505. export class Skeleton implements IAnimatable {
  13506. /** defines the skeleton name */
  13507. name: string;
  13508. /** defines the skeleton Id */
  13509. id: string;
  13510. /**
  13511. * Defines the list of child bones
  13512. */
  13513. bones: Bone[];
  13514. /**
  13515. * Defines an estimate of the dimension of the skeleton at rest
  13516. */
  13517. dimensionsAtRest: Vector3;
  13518. /**
  13519. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13520. */
  13521. needInitialSkinMatrix: boolean;
  13522. /**
  13523. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13524. */
  13525. overrideMesh: Nullable<AbstractMesh>;
  13526. /**
  13527. * Gets the list of animations attached to this skeleton
  13528. */
  13529. animations: Array<Animation>;
  13530. private _scene;
  13531. private _isDirty;
  13532. private _transformMatrices;
  13533. private _transformMatrixTexture;
  13534. private _meshesWithPoseMatrix;
  13535. private _animatables;
  13536. private _identity;
  13537. private _synchronizedWithMesh;
  13538. private _ranges;
  13539. private _lastAbsoluteTransformsUpdateId;
  13540. private _canUseTextureForBones;
  13541. private _uniqueId;
  13542. /** @hidden */
  13543. _numBonesWithLinkedTransformNode: number;
  13544. /** @hidden */
  13545. _hasWaitingData: Nullable<boolean>;
  13546. /**
  13547. * Specifies if the skeleton should be serialized
  13548. */
  13549. doNotSerialize: boolean;
  13550. private _useTextureToStoreBoneMatrices;
  13551. /**
  13552. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13553. * Please note that this option is not available if the hardware does not support it
  13554. */
  13555. useTextureToStoreBoneMatrices: boolean;
  13556. private _animationPropertiesOverride;
  13557. /**
  13558. * Gets or sets the animation properties override
  13559. */
  13560. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13561. /**
  13562. * List of inspectable custom properties (used by the Inspector)
  13563. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13564. */
  13565. inspectableCustomProperties: IInspectable[];
  13566. /**
  13567. * An observable triggered before computing the skeleton's matrices
  13568. */
  13569. onBeforeComputeObservable: Observable<Skeleton>;
  13570. /**
  13571. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13572. */
  13573. readonly isUsingTextureForMatrices: boolean;
  13574. /**
  13575. * Gets the unique ID of this skeleton
  13576. */
  13577. readonly uniqueId: number;
  13578. /**
  13579. * Creates a new skeleton
  13580. * @param name defines the skeleton name
  13581. * @param id defines the skeleton Id
  13582. * @param scene defines the hosting scene
  13583. */
  13584. constructor(
  13585. /** defines the skeleton name */
  13586. name: string,
  13587. /** defines the skeleton Id */
  13588. id: string, scene: Scene);
  13589. /**
  13590. * Gets the current object class name.
  13591. * @return the class name
  13592. */
  13593. getClassName(): string;
  13594. /**
  13595. * Returns an array containing the root bones
  13596. * @returns an array containing the root bones
  13597. */
  13598. getChildren(): Array<Bone>;
  13599. /**
  13600. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13601. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13602. * @returns a Float32Array containing matrices data
  13603. */
  13604. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13605. /**
  13606. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13607. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13608. * @returns a raw texture containing the data
  13609. */
  13610. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13611. /**
  13612. * Gets the current hosting scene
  13613. * @returns a scene object
  13614. */
  13615. getScene(): Scene;
  13616. /**
  13617. * Gets a string representing the current skeleton data
  13618. * @param fullDetails defines a boolean indicating if we want a verbose version
  13619. * @returns a string representing the current skeleton data
  13620. */
  13621. toString(fullDetails?: boolean): string;
  13622. /**
  13623. * Get bone's index searching by name
  13624. * @param name defines bone's name to search for
  13625. * @return the indice of the bone. Returns -1 if not found
  13626. */
  13627. getBoneIndexByName(name: string): number;
  13628. /**
  13629. * Creater a new animation range
  13630. * @param name defines the name of the range
  13631. * @param from defines the start key
  13632. * @param to defines the end key
  13633. */
  13634. createAnimationRange(name: string, from: number, to: number): void;
  13635. /**
  13636. * Delete a specific animation range
  13637. * @param name defines the name of the range
  13638. * @param deleteFrames defines if frames must be removed as well
  13639. */
  13640. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13641. /**
  13642. * Gets a specific animation range
  13643. * @param name defines the name of the range to look for
  13644. * @returns the requested animation range or null if not found
  13645. */
  13646. getAnimationRange(name: string): Nullable<AnimationRange>;
  13647. /**
  13648. * Gets the list of all animation ranges defined on this skeleton
  13649. * @returns an array
  13650. */
  13651. getAnimationRanges(): Nullable<AnimationRange>[];
  13652. /**
  13653. * Copy animation range from a source skeleton.
  13654. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13655. * @param source defines the source skeleton
  13656. * @param name defines the name of the range to copy
  13657. * @param rescaleAsRequired defines if rescaling must be applied if required
  13658. * @returns true if operation was successful
  13659. */
  13660. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13661. /**
  13662. * Forces the skeleton to go to rest pose
  13663. */
  13664. returnToRest(): void;
  13665. private _getHighestAnimationFrame;
  13666. /**
  13667. * Begin a specific animation range
  13668. * @param name defines the name of the range to start
  13669. * @param loop defines if looping must be turned on (false by default)
  13670. * @param speedRatio defines the speed ratio to apply (1 by default)
  13671. * @param onAnimationEnd defines a callback which will be called when animation will end
  13672. * @returns a new animatable
  13673. */
  13674. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13675. /** @hidden */
  13676. _markAsDirty(): void;
  13677. /** @hidden */
  13678. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13679. /** @hidden */
  13680. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13681. private _computeTransformMatrices;
  13682. /**
  13683. * Build all resources required to render a skeleton
  13684. */
  13685. prepare(): void;
  13686. /**
  13687. * Gets the list of animatables currently running for this skeleton
  13688. * @returns an array of animatables
  13689. */
  13690. getAnimatables(): IAnimatable[];
  13691. /**
  13692. * Clone the current skeleton
  13693. * @param name defines the name of the new skeleton
  13694. * @param id defines the id of the new skeleton
  13695. * @returns the new skeleton
  13696. */
  13697. clone(name: string, id?: string): Skeleton;
  13698. /**
  13699. * Enable animation blending for this skeleton
  13700. * @param blendingSpeed defines the blending speed to apply
  13701. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13702. */
  13703. enableBlending(blendingSpeed?: number): void;
  13704. /**
  13705. * Releases all resources associated with the current skeleton
  13706. */
  13707. dispose(): void;
  13708. /**
  13709. * Serialize the skeleton in a JSON object
  13710. * @returns a JSON object
  13711. */
  13712. serialize(): any;
  13713. /**
  13714. * Creates a new skeleton from serialized data
  13715. * @param parsedSkeleton defines the serialized data
  13716. * @param scene defines the hosting scene
  13717. * @returns a new skeleton
  13718. */
  13719. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13720. /**
  13721. * Compute all node absolute transforms
  13722. * @param forceUpdate defines if computation must be done even if cache is up to date
  13723. */
  13724. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13725. /**
  13726. * Gets the root pose matrix
  13727. * @returns a matrix
  13728. */
  13729. getPoseMatrix(): Nullable<Matrix>;
  13730. /**
  13731. * Sorts bones per internal index
  13732. */
  13733. sortBones(): void;
  13734. private _sortBones;
  13735. }
  13736. }
  13737. declare module "babylonjs/Bones/bone" {
  13738. import { Skeleton } from "babylonjs/Bones/skeleton";
  13739. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13740. import { Nullable } from "babylonjs/types";
  13741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13742. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13743. import { Node } from "babylonjs/node";
  13744. import { Space } from "babylonjs/Maths/math.axis";
  13745. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13746. /**
  13747. * Class used to store bone information
  13748. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13749. */
  13750. export class Bone extends Node {
  13751. /**
  13752. * defines the bone name
  13753. */
  13754. name: string;
  13755. private static _tmpVecs;
  13756. private static _tmpQuat;
  13757. private static _tmpMats;
  13758. /**
  13759. * Gets the list of child bones
  13760. */
  13761. children: Bone[];
  13762. /** Gets the animations associated with this bone */
  13763. animations: import("babylonjs/Animations/animation").Animation[];
  13764. /**
  13765. * Gets or sets bone length
  13766. */
  13767. length: number;
  13768. /**
  13769. * @hidden Internal only
  13770. * Set this value to map this bone to a different index in the transform matrices
  13771. * Set this value to -1 to exclude the bone from the transform matrices
  13772. */
  13773. _index: Nullable<number>;
  13774. private _skeleton;
  13775. private _localMatrix;
  13776. private _restPose;
  13777. private _baseMatrix;
  13778. private _absoluteTransform;
  13779. private _invertedAbsoluteTransform;
  13780. private _parent;
  13781. private _scalingDeterminant;
  13782. private _worldTransform;
  13783. private _localScaling;
  13784. private _localRotation;
  13785. private _localPosition;
  13786. private _needToDecompose;
  13787. private _needToCompose;
  13788. /** @hidden */
  13789. _linkedTransformNode: Nullable<TransformNode>;
  13790. /** @hidden */
  13791. _waitingTransformNodeId: Nullable<string>;
  13792. /** @hidden */
  13793. /** @hidden */
  13794. _matrix: Matrix;
  13795. /**
  13796. * Create a new bone
  13797. * @param name defines the bone name
  13798. * @param skeleton defines the parent skeleton
  13799. * @param parentBone defines the parent (can be null if the bone is the root)
  13800. * @param localMatrix defines the local matrix
  13801. * @param restPose defines the rest pose matrix
  13802. * @param baseMatrix defines the base matrix
  13803. * @param index defines index of the bone in the hiearchy
  13804. */
  13805. constructor(
  13806. /**
  13807. * defines the bone name
  13808. */
  13809. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13810. /**
  13811. * Gets the current object class name.
  13812. * @return the class name
  13813. */
  13814. getClassName(): string;
  13815. /**
  13816. * Gets the parent skeleton
  13817. * @returns a skeleton
  13818. */
  13819. getSkeleton(): Skeleton;
  13820. /**
  13821. * Gets parent bone
  13822. * @returns a bone or null if the bone is the root of the bone hierarchy
  13823. */
  13824. getParent(): Nullable<Bone>;
  13825. /**
  13826. * Returns an array containing the root bones
  13827. * @returns an array containing the root bones
  13828. */
  13829. getChildren(): Array<Bone>;
  13830. /**
  13831. * Gets the node index in matrix array generated for rendering
  13832. * @returns the node index
  13833. */
  13834. getIndex(): number;
  13835. /**
  13836. * Sets the parent bone
  13837. * @param parent defines the parent (can be null if the bone is the root)
  13838. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13839. */
  13840. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13841. /**
  13842. * Gets the local matrix
  13843. * @returns a matrix
  13844. */
  13845. getLocalMatrix(): Matrix;
  13846. /**
  13847. * Gets the base matrix (initial matrix which remains unchanged)
  13848. * @returns a matrix
  13849. */
  13850. getBaseMatrix(): Matrix;
  13851. /**
  13852. * Gets the rest pose matrix
  13853. * @returns a matrix
  13854. */
  13855. getRestPose(): Matrix;
  13856. /**
  13857. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13858. */
  13859. getWorldMatrix(): Matrix;
  13860. /**
  13861. * Sets the local matrix to rest pose matrix
  13862. */
  13863. returnToRest(): void;
  13864. /**
  13865. * Gets the inverse of the absolute transform matrix.
  13866. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13867. * @returns a matrix
  13868. */
  13869. getInvertedAbsoluteTransform(): Matrix;
  13870. /**
  13871. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13872. * @returns a matrix
  13873. */
  13874. getAbsoluteTransform(): Matrix;
  13875. /**
  13876. * Links with the given transform node.
  13877. * The local matrix of this bone is copied from the transform node every frame.
  13878. * @param transformNode defines the transform node to link to
  13879. */
  13880. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13881. /**
  13882. * Gets the node used to drive the bone's transformation
  13883. * @returns a transform node or null
  13884. */
  13885. getTransformNode(): Nullable<TransformNode>;
  13886. /** Gets or sets current position (in local space) */
  13887. position: Vector3;
  13888. /** Gets or sets current rotation (in local space) */
  13889. rotation: Vector3;
  13890. /** Gets or sets current rotation quaternion (in local space) */
  13891. rotationQuaternion: Quaternion;
  13892. /** Gets or sets current scaling (in local space) */
  13893. scaling: Vector3;
  13894. /**
  13895. * Gets the animation properties override
  13896. */
  13897. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13898. private _decompose;
  13899. private _compose;
  13900. /**
  13901. * Update the base and local matrices
  13902. * @param matrix defines the new base or local matrix
  13903. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13904. * @param updateLocalMatrix defines if the local matrix should be updated
  13905. */
  13906. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13907. /** @hidden */
  13908. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13909. /**
  13910. * Flag the bone as dirty (Forcing it to update everything)
  13911. */
  13912. markAsDirty(): void;
  13913. /** @hidden */
  13914. _markAsDirtyAndCompose(): void;
  13915. private _markAsDirtyAndDecompose;
  13916. /**
  13917. * Translate the bone in local or world space
  13918. * @param vec The amount to translate the bone
  13919. * @param space The space that the translation is in
  13920. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13921. */
  13922. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13923. /**
  13924. * Set the postion of the bone in local or world space
  13925. * @param position The position to set the bone
  13926. * @param space The space that the position is in
  13927. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13928. */
  13929. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13930. /**
  13931. * Set the absolute position of the bone (world space)
  13932. * @param position The position to set the bone
  13933. * @param mesh The mesh that this bone is attached to
  13934. */
  13935. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13936. /**
  13937. * Scale the bone on the x, y and z axes (in local space)
  13938. * @param x The amount to scale the bone on the x axis
  13939. * @param y The amount to scale the bone on the y axis
  13940. * @param z The amount to scale the bone on the z axis
  13941. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13942. */
  13943. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13944. /**
  13945. * Set the bone scaling in local space
  13946. * @param scale defines the scaling vector
  13947. */
  13948. setScale(scale: Vector3): void;
  13949. /**
  13950. * Gets the current scaling in local space
  13951. * @returns the current scaling vector
  13952. */
  13953. getScale(): Vector3;
  13954. /**
  13955. * Gets the current scaling in local space and stores it in a target vector
  13956. * @param result defines the target vector
  13957. */
  13958. getScaleToRef(result: Vector3): void;
  13959. /**
  13960. * Set the yaw, pitch, and roll of the bone in local or world space
  13961. * @param yaw The rotation of the bone on the y axis
  13962. * @param pitch The rotation of the bone on the x axis
  13963. * @param roll The rotation of the bone on the z axis
  13964. * @param space The space that the axes of rotation are in
  13965. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13966. */
  13967. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13968. /**
  13969. * Add a rotation to the bone on an axis in local or world space
  13970. * @param axis The axis to rotate the bone on
  13971. * @param amount The amount to rotate the bone
  13972. * @param space The space that the axis is in
  13973. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13974. */
  13975. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13976. /**
  13977. * Set the rotation of the bone to a particular axis angle in local or world space
  13978. * @param axis The axis to rotate the bone on
  13979. * @param angle The angle that the bone should be rotated to
  13980. * @param space The space that the axis is in
  13981. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13982. */
  13983. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13984. /**
  13985. * Set the euler rotation of the bone in local of world space
  13986. * @param rotation The euler rotation that the bone should be set to
  13987. * @param space The space that the rotation is in
  13988. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13989. */
  13990. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13991. /**
  13992. * Set the quaternion rotation of the bone in local of world space
  13993. * @param quat The quaternion rotation that the bone should be set to
  13994. * @param space The space that the rotation is in
  13995. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13996. */
  13997. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13998. /**
  13999. * Set the rotation matrix of the bone in local of world space
  14000. * @param rotMat The rotation matrix that the bone should be set to
  14001. * @param space The space that the rotation is in
  14002. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14003. */
  14004. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14005. private _rotateWithMatrix;
  14006. private _getNegativeRotationToRef;
  14007. /**
  14008. * Get the position of the bone in local or world space
  14009. * @param space The space that the returned position is in
  14010. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14011. * @returns The position of the bone
  14012. */
  14013. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14014. /**
  14015. * Copy the position of the bone to a vector3 in local or world space
  14016. * @param space The space that the returned position is in
  14017. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14018. * @param result The vector3 to copy the position to
  14019. */
  14020. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14021. /**
  14022. * Get the absolute position of the bone (world space)
  14023. * @param mesh The mesh that this bone is attached to
  14024. * @returns The absolute position of the bone
  14025. */
  14026. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14027. /**
  14028. * Copy the absolute position of the bone (world space) to the result param
  14029. * @param mesh The mesh that this bone is attached to
  14030. * @param result The vector3 to copy the absolute position to
  14031. */
  14032. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14033. /**
  14034. * Compute the absolute transforms of this bone and its children
  14035. */
  14036. computeAbsoluteTransforms(): void;
  14037. /**
  14038. * Get the world direction from an axis that is in the local space of the bone
  14039. * @param localAxis The local direction that is used to compute the world direction
  14040. * @param mesh The mesh that this bone is attached to
  14041. * @returns The world direction
  14042. */
  14043. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14044. /**
  14045. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14046. * @param localAxis The local direction that is used to compute the world direction
  14047. * @param mesh The mesh that this bone is attached to
  14048. * @param result The vector3 that the world direction will be copied to
  14049. */
  14050. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14051. /**
  14052. * Get the euler rotation of the bone in local or world space
  14053. * @param space The space that the rotation should be in
  14054. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14055. * @returns The euler rotation
  14056. */
  14057. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14058. /**
  14059. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14060. * @param space The space that the rotation should be in
  14061. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14062. * @param result The vector3 that the rotation should be copied to
  14063. */
  14064. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14065. /**
  14066. * Get the quaternion rotation of the bone in either local or world space
  14067. * @param space The space that the rotation should be in
  14068. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14069. * @returns The quaternion rotation
  14070. */
  14071. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14072. /**
  14073. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14074. * @param space The space that the rotation should be in
  14075. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14076. * @param result The quaternion that the rotation should be copied to
  14077. */
  14078. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14079. /**
  14080. * Get the rotation matrix of the bone in local or world space
  14081. * @param space The space that the rotation should be in
  14082. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14083. * @returns The rotation matrix
  14084. */
  14085. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14086. /**
  14087. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14088. * @param space The space that the rotation should be in
  14089. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14090. * @param result The quaternion that the rotation should be copied to
  14091. */
  14092. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14093. /**
  14094. * Get the world position of a point that is in the local space of the bone
  14095. * @param position The local position
  14096. * @param mesh The mesh that this bone is attached to
  14097. * @returns The world position
  14098. */
  14099. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14100. /**
  14101. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14102. * @param position The local position
  14103. * @param mesh The mesh that this bone is attached to
  14104. * @param result The vector3 that the world position should be copied to
  14105. */
  14106. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14107. /**
  14108. * Get the local position of a point that is in world space
  14109. * @param position The world position
  14110. * @param mesh The mesh that this bone is attached to
  14111. * @returns The local position
  14112. */
  14113. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14114. /**
  14115. * Get the local position of a point that is in world space and copy it to the result param
  14116. * @param position The world position
  14117. * @param mesh The mesh that this bone is attached to
  14118. * @param result The vector3 that the local position should be copied to
  14119. */
  14120. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14121. }
  14122. }
  14123. declare module "babylonjs/Meshes/transformNode" {
  14124. import { DeepImmutable } from "babylonjs/types";
  14125. import { Observable } from "babylonjs/Misc/observable";
  14126. import { Nullable } from "babylonjs/types";
  14127. import { Camera } from "babylonjs/Cameras/camera";
  14128. import { Scene } from "babylonjs/scene";
  14129. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14130. import { Node } from "babylonjs/node";
  14131. import { Bone } from "babylonjs/Bones/bone";
  14132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14133. import { Space } from "babylonjs/Maths/math.axis";
  14134. /**
  14135. * 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.
  14136. * @see https://doc.babylonjs.com/how_to/transformnode
  14137. */
  14138. export class TransformNode extends Node {
  14139. /**
  14140. * Object will not rotate to face the camera
  14141. */
  14142. static BILLBOARDMODE_NONE: number;
  14143. /**
  14144. * Object will rotate to face the camera but only on the x axis
  14145. */
  14146. static BILLBOARDMODE_X: number;
  14147. /**
  14148. * Object will rotate to face the camera but only on the y axis
  14149. */
  14150. static BILLBOARDMODE_Y: number;
  14151. /**
  14152. * Object will rotate to face the camera but only on the z axis
  14153. */
  14154. static BILLBOARDMODE_Z: number;
  14155. /**
  14156. * Object will rotate to face the camera
  14157. */
  14158. static BILLBOARDMODE_ALL: number;
  14159. /**
  14160. * Object will rotate to face the camera's position instead of orientation
  14161. */
  14162. static BILLBOARDMODE_USE_POSITION: number;
  14163. private _forward;
  14164. private _forwardInverted;
  14165. private _up;
  14166. private _right;
  14167. private _rightInverted;
  14168. private _position;
  14169. private _rotation;
  14170. private _rotationQuaternion;
  14171. protected _scaling: Vector3;
  14172. protected _isDirty: boolean;
  14173. private _transformToBoneReferal;
  14174. private _isAbsoluteSynced;
  14175. private _billboardMode;
  14176. /**
  14177. * Gets or sets the billboard mode. Default is 0.
  14178. *
  14179. * | Value | Type | Description |
  14180. * | --- | --- | --- |
  14181. * | 0 | BILLBOARDMODE_NONE | |
  14182. * | 1 | BILLBOARDMODE_X | |
  14183. * | 2 | BILLBOARDMODE_Y | |
  14184. * | 4 | BILLBOARDMODE_Z | |
  14185. * | 7 | BILLBOARDMODE_ALL | |
  14186. *
  14187. */
  14188. billboardMode: number;
  14189. private _preserveParentRotationForBillboard;
  14190. /**
  14191. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14192. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14193. */
  14194. preserveParentRotationForBillboard: boolean;
  14195. /**
  14196. * 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
  14197. */
  14198. scalingDeterminant: number;
  14199. private _infiniteDistance;
  14200. /**
  14201. * Gets or sets the distance of the object to max, often used by skybox
  14202. */
  14203. infiniteDistance: boolean;
  14204. /**
  14205. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14206. * By default the system will update normals to compensate
  14207. */
  14208. ignoreNonUniformScaling: boolean;
  14209. /**
  14210. * 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
  14211. */
  14212. reIntegrateRotationIntoRotationQuaternion: boolean;
  14213. /** @hidden */
  14214. _poseMatrix: Nullable<Matrix>;
  14215. /** @hidden */
  14216. _localMatrix: Matrix;
  14217. private _usePivotMatrix;
  14218. private _absolutePosition;
  14219. private _absoluteScaling;
  14220. private _absoluteRotationQuaternion;
  14221. private _pivotMatrix;
  14222. private _pivotMatrixInverse;
  14223. protected _postMultiplyPivotMatrix: boolean;
  14224. protected _isWorldMatrixFrozen: boolean;
  14225. /** @hidden */
  14226. _indexInSceneTransformNodesArray: number;
  14227. /**
  14228. * An event triggered after the world matrix is updated
  14229. */
  14230. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14231. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14232. /**
  14233. * Gets a string identifying the name of the class
  14234. * @returns "TransformNode" string
  14235. */
  14236. getClassName(): string;
  14237. /**
  14238. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14239. */
  14240. position: Vector3;
  14241. /**
  14242. * 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)).
  14243. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14244. */
  14245. rotation: Vector3;
  14246. /**
  14247. * 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)).
  14248. */
  14249. scaling: Vector3;
  14250. /**
  14251. * 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).
  14252. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14253. */
  14254. rotationQuaternion: Nullable<Quaternion>;
  14255. /**
  14256. * The forward direction of that transform in world space.
  14257. */
  14258. readonly forward: Vector3;
  14259. /**
  14260. * The up direction of that transform in world space.
  14261. */
  14262. readonly up: Vector3;
  14263. /**
  14264. * The right direction of that transform in world space.
  14265. */
  14266. readonly right: Vector3;
  14267. /**
  14268. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14269. * @param matrix the matrix to copy the pose from
  14270. * @returns this TransformNode.
  14271. */
  14272. updatePoseMatrix(matrix: Matrix): TransformNode;
  14273. /**
  14274. * Returns the mesh Pose matrix.
  14275. * @returns the pose matrix
  14276. */
  14277. getPoseMatrix(): Matrix;
  14278. /** @hidden */
  14279. _isSynchronized(): boolean;
  14280. /** @hidden */
  14281. _initCache(): void;
  14282. /**
  14283. * Flag the transform node as dirty (Forcing it to update everything)
  14284. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14285. * @returns this transform node
  14286. */
  14287. markAsDirty(property: string): TransformNode;
  14288. /**
  14289. * Returns the current mesh absolute position.
  14290. * Returns a Vector3.
  14291. */
  14292. readonly absolutePosition: Vector3;
  14293. /**
  14294. * Returns the current mesh absolute scaling.
  14295. * Returns a Vector3.
  14296. */
  14297. readonly absoluteScaling: Vector3;
  14298. /**
  14299. * Returns the current mesh absolute rotation.
  14300. * Returns a Quaternion.
  14301. */
  14302. readonly absoluteRotationQuaternion: Quaternion;
  14303. /**
  14304. * Sets a new matrix to apply before all other transformation
  14305. * @param matrix defines the transform matrix
  14306. * @returns the current TransformNode
  14307. */
  14308. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14309. /**
  14310. * Sets a new pivot matrix to the current node
  14311. * @param matrix defines the new pivot matrix to use
  14312. * @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
  14313. * @returns the current TransformNode
  14314. */
  14315. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14316. /**
  14317. * Returns the mesh pivot matrix.
  14318. * Default : Identity.
  14319. * @returns the matrix
  14320. */
  14321. getPivotMatrix(): Matrix;
  14322. /**
  14323. * Instantiate (when possible) or clone that node with its hierarchy
  14324. * @param newParent defines the new parent to use for the instance (or clone)
  14325. * @param options defines options to configure how copy is done
  14326. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14327. * @returns an instance (or a clone) of the current node with its hiearchy
  14328. */
  14329. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14330. doNotInstantiate: boolean;
  14331. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14332. /**
  14333. * Prevents the World matrix to be computed any longer
  14334. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14335. * @returns the TransformNode.
  14336. */
  14337. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14338. /**
  14339. * Allows back the World matrix computation.
  14340. * @returns the TransformNode.
  14341. */
  14342. unfreezeWorldMatrix(): this;
  14343. /**
  14344. * True if the World matrix has been frozen.
  14345. */
  14346. readonly isWorldMatrixFrozen: boolean;
  14347. /**
  14348. * Retuns the mesh absolute position in the World.
  14349. * @returns a Vector3.
  14350. */
  14351. getAbsolutePosition(): Vector3;
  14352. /**
  14353. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14354. * @param absolutePosition the absolute position to set
  14355. * @returns the TransformNode.
  14356. */
  14357. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14358. /**
  14359. * Sets the mesh position in its local space.
  14360. * @param vector3 the position to set in localspace
  14361. * @returns the TransformNode.
  14362. */
  14363. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14364. /**
  14365. * Returns the mesh position in the local space from the current World matrix values.
  14366. * @returns a new Vector3.
  14367. */
  14368. getPositionExpressedInLocalSpace(): Vector3;
  14369. /**
  14370. * Translates the mesh along the passed Vector3 in its local space.
  14371. * @param vector3 the distance to translate in localspace
  14372. * @returns the TransformNode.
  14373. */
  14374. locallyTranslate(vector3: Vector3): TransformNode;
  14375. private static _lookAtVectorCache;
  14376. /**
  14377. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14378. * @param targetPoint the position (must be in same space as current mesh) to look at
  14379. * @param yawCor optional yaw (y-axis) correction in radians
  14380. * @param pitchCor optional pitch (x-axis) correction in radians
  14381. * @param rollCor optional roll (z-axis) correction in radians
  14382. * @param space the choosen space of the target
  14383. * @returns the TransformNode.
  14384. */
  14385. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14386. /**
  14387. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14388. * This Vector3 is expressed in the World space.
  14389. * @param localAxis axis to rotate
  14390. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14391. */
  14392. getDirection(localAxis: Vector3): Vector3;
  14393. /**
  14394. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14395. * localAxis is expressed in the mesh local space.
  14396. * result is computed in the Wordl space from the mesh World matrix.
  14397. * @param localAxis axis to rotate
  14398. * @param result the resulting transformnode
  14399. * @returns this TransformNode.
  14400. */
  14401. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14402. /**
  14403. * Sets this transform node rotation to the given local axis.
  14404. * @param localAxis the axis in local space
  14405. * @param yawCor optional yaw (y-axis) correction in radians
  14406. * @param pitchCor optional pitch (x-axis) correction in radians
  14407. * @param rollCor optional roll (z-axis) correction in radians
  14408. * @returns this TransformNode
  14409. */
  14410. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14411. /**
  14412. * Sets a new pivot point to the current node
  14413. * @param point defines the new pivot point to use
  14414. * @param space defines if the point is in world or local space (local by default)
  14415. * @returns the current TransformNode
  14416. */
  14417. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14418. /**
  14419. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14420. * @returns the pivot point
  14421. */
  14422. getPivotPoint(): Vector3;
  14423. /**
  14424. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14425. * @param result the vector3 to store the result
  14426. * @returns this TransformNode.
  14427. */
  14428. getPivotPointToRef(result: Vector3): TransformNode;
  14429. /**
  14430. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14431. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14432. */
  14433. getAbsolutePivotPoint(): Vector3;
  14434. /**
  14435. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14436. * @param result vector3 to store the result
  14437. * @returns this TransformNode.
  14438. */
  14439. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14440. /**
  14441. * Defines the passed node as the parent of the current node.
  14442. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14443. * @see https://doc.babylonjs.com/how_to/parenting
  14444. * @param node the node ot set as the parent
  14445. * @returns this TransformNode.
  14446. */
  14447. setParent(node: Nullable<Node>): TransformNode;
  14448. private _nonUniformScaling;
  14449. /**
  14450. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14451. */
  14452. readonly nonUniformScaling: boolean;
  14453. /** @hidden */
  14454. _updateNonUniformScalingState(value: boolean): boolean;
  14455. /**
  14456. * Attach the current TransformNode to another TransformNode associated with a bone
  14457. * @param bone Bone affecting the TransformNode
  14458. * @param affectedTransformNode TransformNode associated with the bone
  14459. * @returns this object
  14460. */
  14461. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14462. /**
  14463. * Detach the transform node if its associated with a bone
  14464. * @returns this object
  14465. */
  14466. detachFromBone(): TransformNode;
  14467. private static _rotationAxisCache;
  14468. /**
  14469. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14470. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14471. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14472. * The passed axis is also normalized.
  14473. * @param axis the axis to rotate around
  14474. * @param amount the amount to rotate in radians
  14475. * @param space Space to rotate in (Default: local)
  14476. * @returns the TransformNode.
  14477. */
  14478. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14479. /**
  14480. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14481. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14482. * The passed axis is also normalized. .
  14483. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14484. * @param point the point to rotate around
  14485. * @param axis the axis to rotate around
  14486. * @param amount the amount to rotate in radians
  14487. * @returns the TransformNode
  14488. */
  14489. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14490. /**
  14491. * Translates the mesh along the axis vector for the passed distance in the given space.
  14492. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14493. * @param axis the axis to translate in
  14494. * @param distance the distance to translate
  14495. * @param space Space to rotate in (Default: local)
  14496. * @returns the TransformNode.
  14497. */
  14498. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14499. /**
  14500. * Adds a rotation step to the mesh current rotation.
  14501. * x, y, z are Euler angles expressed in radians.
  14502. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14503. * This means this rotation is made in the mesh local space only.
  14504. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14505. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14506. * ```javascript
  14507. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14508. * ```
  14509. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14510. * 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.
  14511. * @param x Rotation to add
  14512. * @param y Rotation to add
  14513. * @param z Rotation to add
  14514. * @returns the TransformNode.
  14515. */
  14516. addRotation(x: number, y: number, z: number): TransformNode;
  14517. /**
  14518. * @hidden
  14519. */
  14520. protected _getEffectiveParent(): Nullable<Node>;
  14521. /**
  14522. * Computes the world matrix of the node
  14523. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14524. * @returns the world matrix
  14525. */
  14526. computeWorldMatrix(force?: boolean): Matrix;
  14527. protected _afterComputeWorldMatrix(): void;
  14528. /**
  14529. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14530. * @param func callback function to add
  14531. *
  14532. * @returns the TransformNode.
  14533. */
  14534. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14535. /**
  14536. * Removes a registered callback function.
  14537. * @param func callback function to remove
  14538. * @returns the TransformNode.
  14539. */
  14540. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14541. /**
  14542. * Gets the position of the current mesh in camera space
  14543. * @param camera defines the camera to use
  14544. * @returns a position
  14545. */
  14546. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14547. /**
  14548. * Returns the distance from the mesh to the active camera
  14549. * @param camera defines the camera to use
  14550. * @returns the distance
  14551. */
  14552. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14553. /**
  14554. * Clone the current transform node
  14555. * @param name Name of the new clone
  14556. * @param newParent New parent for the clone
  14557. * @param doNotCloneChildren Do not clone children hierarchy
  14558. * @returns the new transform node
  14559. */
  14560. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14561. /**
  14562. * Serializes the objects information.
  14563. * @param currentSerializationObject defines the object to serialize in
  14564. * @returns the serialized object
  14565. */
  14566. serialize(currentSerializationObject?: any): any;
  14567. /**
  14568. * Returns a new TransformNode object parsed from the source provided.
  14569. * @param parsedTransformNode is the source.
  14570. * @param scene the scne the object belongs to
  14571. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14572. * @returns a new TransformNode object parsed from the source provided.
  14573. */
  14574. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14575. /**
  14576. * Get all child-transformNodes of this node
  14577. * @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
  14578. * @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
  14579. * @returns an array of TransformNode
  14580. */
  14581. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14582. /**
  14583. * Releases resources associated with this transform node.
  14584. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14585. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14586. */
  14587. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14588. /**
  14589. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14590. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14591. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14592. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14593. * @returns the current mesh
  14594. */
  14595. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14596. private _syncAbsoluteScalingAndRotation;
  14597. }
  14598. }
  14599. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14600. import { Observable } from "babylonjs/Misc/observable";
  14601. import { Nullable } from "babylonjs/types";
  14602. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14603. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14605. import { Ray } from "babylonjs/Culling/ray";
  14606. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14607. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14608. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14609. /**
  14610. * Defines the types of pose enabled controllers that are supported
  14611. */
  14612. export enum PoseEnabledControllerType {
  14613. /**
  14614. * HTC Vive
  14615. */
  14616. VIVE = 0,
  14617. /**
  14618. * Oculus Rift
  14619. */
  14620. OCULUS = 1,
  14621. /**
  14622. * Windows mixed reality
  14623. */
  14624. WINDOWS = 2,
  14625. /**
  14626. * Samsung gear VR
  14627. */
  14628. GEAR_VR = 3,
  14629. /**
  14630. * Google Daydream
  14631. */
  14632. DAYDREAM = 4,
  14633. /**
  14634. * Generic
  14635. */
  14636. GENERIC = 5
  14637. }
  14638. /**
  14639. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14640. */
  14641. export interface MutableGamepadButton {
  14642. /**
  14643. * Value of the button/trigger
  14644. */
  14645. value: number;
  14646. /**
  14647. * If the button/trigger is currently touched
  14648. */
  14649. touched: boolean;
  14650. /**
  14651. * If the button/trigger is currently pressed
  14652. */
  14653. pressed: boolean;
  14654. }
  14655. /**
  14656. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14657. * @hidden
  14658. */
  14659. export interface ExtendedGamepadButton extends GamepadButton {
  14660. /**
  14661. * If the button/trigger is currently pressed
  14662. */
  14663. readonly pressed: boolean;
  14664. /**
  14665. * If the button/trigger is currently touched
  14666. */
  14667. readonly touched: boolean;
  14668. /**
  14669. * Value of the button/trigger
  14670. */
  14671. readonly value: number;
  14672. }
  14673. /** @hidden */
  14674. export interface _GamePadFactory {
  14675. /**
  14676. * Returns wether or not the current gamepad can be created for this type of controller.
  14677. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14678. * @returns true if it can be created, otherwise false
  14679. */
  14680. canCreate(gamepadInfo: any): boolean;
  14681. /**
  14682. * Creates a new instance of the Gamepad.
  14683. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14684. * @returns the new gamepad instance
  14685. */
  14686. create(gamepadInfo: any): Gamepad;
  14687. }
  14688. /**
  14689. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14690. */
  14691. export class PoseEnabledControllerHelper {
  14692. /** @hidden */
  14693. static _ControllerFactories: _GamePadFactory[];
  14694. /** @hidden */
  14695. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14696. /**
  14697. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14698. * @param vrGamepad the gamepad to initialized
  14699. * @returns a vr controller of the type the gamepad identified as
  14700. */
  14701. static InitiateController(vrGamepad: any): Gamepad;
  14702. }
  14703. /**
  14704. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14705. */
  14706. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14707. /**
  14708. * If the controller is used in a webXR session
  14709. */
  14710. isXR: boolean;
  14711. private _deviceRoomPosition;
  14712. private _deviceRoomRotationQuaternion;
  14713. /**
  14714. * The device position in babylon space
  14715. */
  14716. devicePosition: Vector3;
  14717. /**
  14718. * The device rotation in babylon space
  14719. */
  14720. deviceRotationQuaternion: Quaternion;
  14721. /**
  14722. * The scale factor of the device in babylon space
  14723. */
  14724. deviceScaleFactor: number;
  14725. /**
  14726. * (Likely devicePosition should be used instead) The device position in its room space
  14727. */
  14728. position: Vector3;
  14729. /**
  14730. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14731. */
  14732. rotationQuaternion: Quaternion;
  14733. /**
  14734. * The type of controller (Eg. Windows mixed reality)
  14735. */
  14736. controllerType: PoseEnabledControllerType;
  14737. protected _calculatedPosition: Vector3;
  14738. private _calculatedRotation;
  14739. /**
  14740. * The raw pose from the device
  14741. */
  14742. rawPose: DevicePose;
  14743. private _trackPosition;
  14744. private _maxRotationDistFromHeadset;
  14745. private _draggedRoomRotation;
  14746. /**
  14747. * @hidden
  14748. */
  14749. _disableTrackPosition(fixedPosition: Vector3): void;
  14750. /**
  14751. * Internal, the mesh attached to the controller
  14752. * @hidden
  14753. */
  14754. _mesh: Nullable<AbstractMesh>;
  14755. private _poseControlledCamera;
  14756. private _leftHandSystemQuaternion;
  14757. /**
  14758. * Internal, matrix used to convert room space to babylon space
  14759. * @hidden
  14760. */
  14761. _deviceToWorld: Matrix;
  14762. /**
  14763. * Node to be used when casting a ray from the controller
  14764. * @hidden
  14765. */
  14766. _pointingPoseNode: Nullable<TransformNode>;
  14767. /**
  14768. * Name of the child mesh that can be used to cast a ray from the controller
  14769. */
  14770. static readonly POINTING_POSE: string;
  14771. /**
  14772. * Creates a new PoseEnabledController from a gamepad
  14773. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14774. */
  14775. constructor(browserGamepad: any);
  14776. private _workingMatrix;
  14777. /**
  14778. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14779. */
  14780. update(): void;
  14781. /**
  14782. * Updates only the pose device and mesh without doing any button event checking
  14783. */
  14784. protected _updatePoseAndMesh(): void;
  14785. /**
  14786. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14787. * @param poseData raw pose fromthe device
  14788. */
  14789. updateFromDevice(poseData: DevicePose): void;
  14790. /**
  14791. * @hidden
  14792. */
  14793. _meshAttachedObservable: Observable<AbstractMesh>;
  14794. /**
  14795. * Attaches a mesh to the controller
  14796. * @param mesh the mesh to be attached
  14797. */
  14798. attachToMesh(mesh: AbstractMesh): void;
  14799. /**
  14800. * Attaches the controllers mesh to a camera
  14801. * @param camera the camera the mesh should be attached to
  14802. */
  14803. attachToPoseControlledCamera(camera: TargetCamera): void;
  14804. /**
  14805. * Disposes of the controller
  14806. */
  14807. dispose(): void;
  14808. /**
  14809. * The mesh that is attached to the controller
  14810. */
  14811. readonly mesh: Nullable<AbstractMesh>;
  14812. /**
  14813. * Gets the ray of the controller in the direction the controller is pointing
  14814. * @param length the length the resulting ray should be
  14815. * @returns a ray in the direction the controller is pointing
  14816. */
  14817. getForwardRay(length?: number): Ray;
  14818. }
  14819. }
  14820. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14821. import { Observable } from "babylonjs/Misc/observable";
  14822. import { Scene } from "babylonjs/scene";
  14823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14824. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14825. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14826. import { Nullable } from "babylonjs/types";
  14827. /**
  14828. * Defines the WebVRController object that represents controllers tracked in 3D space
  14829. */
  14830. export abstract class WebVRController extends PoseEnabledController {
  14831. /**
  14832. * Internal, the default controller model for the controller
  14833. */
  14834. protected _defaultModel: Nullable<AbstractMesh>;
  14835. /**
  14836. * Fired when the trigger state has changed
  14837. */
  14838. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14839. /**
  14840. * Fired when the main button state has changed
  14841. */
  14842. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14843. /**
  14844. * Fired when the secondary button state has changed
  14845. */
  14846. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14847. /**
  14848. * Fired when the pad state has changed
  14849. */
  14850. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14851. /**
  14852. * Fired when controllers stick values have changed
  14853. */
  14854. onPadValuesChangedObservable: Observable<StickValues>;
  14855. /**
  14856. * Array of button availible on the controller
  14857. */
  14858. protected _buttons: Array<MutableGamepadButton>;
  14859. private _onButtonStateChange;
  14860. /**
  14861. * Fired when a controller button's state has changed
  14862. * @param callback the callback containing the button that was modified
  14863. */
  14864. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14865. /**
  14866. * X and Y axis corresponding to the controllers joystick
  14867. */
  14868. pad: StickValues;
  14869. /**
  14870. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14871. */
  14872. hand: string;
  14873. /**
  14874. * The default controller model for the controller
  14875. */
  14876. readonly defaultModel: Nullable<AbstractMesh>;
  14877. /**
  14878. * Creates a new WebVRController from a gamepad
  14879. * @param vrGamepad the gamepad that the WebVRController should be created from
  14880. */
  14881. constructor(vrGamepad: any);
  14882. /**
  14883. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14884. */
  14885. update(): void;
  14886. /**
  14887. * Function to be called when a button is modified
  14888. */
  14889. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14890. /**
  14891. * Loads a mesh and attaches it to the controller
  14892. * @param scene the scene the mesh should be added to
  14893. * @param meshLoaded callback for when the mesh has been loaded
  14894. */
  14895. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14896. private _setButtonValue;
  14897. private _changes;
  14898. private _checkChanges;
  14899. /**
  14900. * Disposes of th webVRCOntroller
  14901. */
  14902. dispose(): void;
  14903. }
  14904. }
  14905. declare module "babylonjs/Lights/hemisphericLight" {
  14906. import { Nullable } from "babylonjs/types";
  14907. import { Scene } from "babylonjs/scene";
  14908. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14909. import { Color3 } from "babylonjs/Maths/math.color";
  14910. import { Effect } from "babylonjs/Materials/effect";
  14911. import { Light } from "babylonjs/Lights/light";
  14912. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14913. /**
  14914. * The HemisphericLight simulates the ambient environment light,
  14915. * so the passed direction is the light reflection direction, not the incoming direction.
  14916. */
  14917. export class HemisphericLight extends Light {
  14918. /**
  14919. * The groundColor is the light in the opposite direction to the one specified during creation.
  14920. * 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.
  14921. */
  14922. groundColor: Color3;
  14923. /**
  14924. * The light reflection direction, not the incoming direction.
  14925. */
  14926. direction: Vector3;
  14927. /**
  14928. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14929. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14930. * The HemisphericLight can't cast shadows.
  14931. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14932. * @param name The friendly name of the light
  14933. * @param direction The direction of the light reflection
  14934. * @param scene The scene the light belongs to
  14935. */
  14936. constructor(name: string, direction: Vector3, scene: Scene);
  14937. protected _buildUniformLayout(): void;
  14938. /**
  14939. * Returns the string "HemisphericLight".
  14940. * @return The class name
  14941. */
  14942. getClassName(): string;
  14943. /**
  14944. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14945. * Returns the updated direction.
  14946. * @param target The target the direction should point to
  14947. * @return The computed direction
  14948. */
  14949. setDirectionToTarget(target: Vector3): Vector3;
  14950. /**
  14951. * Returns the shadow generator associated to the light.
  14952. * @returns Always null for hemispheric lights because it does not support shadows.
  14953. */
  14954. getShadowGenerator(): Nullable<IShadowGenerator>;
  14955. /**
  14956. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14957. * @param effect The effect to update
  14958. * @param lightIndex The index of the light in the effect to update
  14959. * @returns The hemispheric light
  14960. */
  14961. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14962. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14963. /**
  14964. * Computes the world matrix of the node
  14965. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14966. * @param useWasUpdatedFlag defines a reserved property
  14967. * @returns the world matrix
  14968. */
  14969. computeWorldMatrix(): Matrix;
  14970. /**
  14971. * Returns the integer 3.
  14972. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14973. */
  14974. getTypeID(): number;
  14975. /**
  14976. * Prepares the list of defines specific to the light type.
  14977. * @param defines the list of defines
  14978. * @param lightIndex defines the index of the light for the effect
  14979. */
  14980. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14981. }
  14982. }
  14983. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14984. /** @hidden */
  14985. export var vrMultiviewToSingleviewPixelShader: {
  14986. name: string;
  14987. shader: string;
  14988. };
  14989. }
  14990. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14991. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14992. import { Scene } from "babylonjs/scene";
  14993. /**
  14994. * Renders to multiple views with a single draw call
  14995. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14996. */
  14997. export class MultiviewRenderTarget extends RenderTargetTexture {
  14998. /**
  14999. * Creates a multiview render target
  15000. * @param scene scene used with the render target
  15001. * @param size the size of the render target (used for each view)
  15002. */
  15003. constructor(scene: Scene, size?: number | {
  15004. width: number;
  15005. height: number;
  15006. } | {
  15007. ratio: number;
  15008. });
  15009. /**
  15010. * @hidden
  15011. * @param faceIndex the face index, if its a cube texture
  15012. */
  15013. _bindFrameBuffer(faceIndex?: number): void;
  15014. /**
  15015. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15016. * @returns the view count
  15017. */
  15018. getViewCount(): number;
  15019. }
  15020. }
  15021. declare module "babylonjs/Maths/math.frustum" {
  15022. import { Matrix } from "babylonjs/Maths/math.vector";
  15023. import { DeepImmutable } from "babylonjs/types";
  15024. import { Plane } from "babylonjs/Maths/math.plane";
  15025. /**
  15026. * Represents a camera frustum
  15027. */
  15028. export class Frustum {
  15029. /**
  15030. * Gets the planes representing the frustum
  15031. * @param transform matrix to be applied to the returned planes
  15032. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15033. */
  15034. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15035. /**
  15036. * Gets the near frustum plane transformed by the transform matrix
  15037. * @param transform transformation matrix to be applied to the resulting frustum plane
  15038. * @param frustumPlane the resuling frustum plane
  15039. */
  15040. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15041. /**
  15042. * Gets the far frustum plane transformed by the transform matrix
  15043. * @param transform transformation matrix to be applied to the resulting frustum plane
  15044. * @param frustumPlane the resuling frustum plane
  15045. */
  15046. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15047. /**
  15048. * Gets the left frustum plane transformed by the transform matrix
  15049. * @param transform transformation matrix to be applied to the resulting frustum plane
  15050. * @param frustumPlane the resuling frustum plane
  15051. */
  15052. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15053. /**
  15054. * Gets the right frustum plane transformed by the transform matrix
  15055. * @param transform transformation matrix to be applied to the resulting frustum plane
  15056. * @param frustumPlane the resuling frustum plane
  15057. */
  15058. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15059. /**
  15060. * Gets the top frustum plane transformed by the transform matrix
  15061. * @param transform transformation matrix to be applied to the resulting frustum plane
  15062. * @param frustumPlane the resuling frustum plane
  15063. */
  15064. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15065. /**
  15066. * Gets the bottom frustum plane transformed by the transform matrix
  15067. * @param transform transformation matrix to be applied to the resulting frustum plane
  15068. * @param frustumPlane the resuling frustum plane
  15069. */
  15070. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15071. /**
  15072. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15073. * @param transform transformation matrix to be applied to the resulting frustum planes
  15074. * @param frustumPlanes the resuling frustum planes
  15075. */
  15076. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15077. }
  15078. }
  15079. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15080. import { Camera } from "babylonjs/Cameras/camera";
  15081. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15082. import { Nullable } from "babylonjs/types";
  15083. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15084. import { Matrix } from "babylonjs/Maths/math.vector";
  15085. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15086. module "babylonjs/Engines/engine" {
  15087. interface Engine {
  15088. /**
  15089. * Creates a new multiview render target
  15090. * @param width defines the width of the texture
  15091. * @param height defines the height of the texture
  15092. * @returns the created multiview texture
  15093. */
  15094. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15095. /**
  15096. * Binds a multiview framebuffer to be drawn to
  15097. * @param multiviewTexture texture to bind
  15098. */
  15099. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15100. }
  15101. }
  15102. module "babylonjs/Cameras/camera" {
  15103. interface Camera {
  15104. /**
  15105. * @hidden
  15106. * 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)
  15107. */
  15108. _useMultiviewToSingleView: boolean;
  15109. /**
  15110. * @hidden
  15111. * 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)
  15112. */
  15113. _multiviewTexture: Nullable<RenderTargetTexture>;
  15114. /**
  15115. * @hidden
  15116. * ensures the multiview texture of the camera exists and has the specified width/height
  15117. * @param width height to set on the multiview texture
  15118. * @param height width to set on the multiview texture
  15119. */
  15120. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15121. }
  15122. }
  15123. module "babylonjs/scene" {
  15124. interface Scene {
  15125. /** @hidden */
  15126. _transformMatrixR: Matrix;
  15127. /** @hidden */
  15128. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15129. /** @hidden */
  15130. _createMultiviewUbo(): void;
  15131. /** @hidden */
  15132. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15133. /** @hidden */
  15134. _renderMultiviewToSingleView(camera: Camera): void;
  15135. }
  15136. }
  15137. }
  15138. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15139. import { Camera } from "babylonjs/Cameras/camera";
  15140. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15141. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15142. import "babylonjs/Engines/Extensions/engine.multiview";
  15143. /**
  15144. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15145. * This will not be used for webXR as it supports displaying texture arrays directly
  15146. */
  15147. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15148. /**
  15149. * Initializes a VRMultiviewToSingleview
  15150. * @param name name of the post process
  15151. * @param camera camera to be applied to
  15152. * @param scaleFactor scaling factor to the size of the output texture
  15153. */
  15154. constructor(name: string, camera: Camera, scaleFactor: number);
  15155. }
  15156. }
  15157. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15158. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15159. import { Nullable } from "babylonjs/types";
  15160. import { Size } from "babylonjs/Maths/math.size";
  15161. import { Observable } from "babylonjs/Misc/observable";
  15162. /**
  15163. * Interface used to define additional presentation attributes
  15164. */
  15165. export interface IVRPresentationAttributes {
  15166. /**
  15167. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15168. */
  15169. highRefreshRate: boolean;
  15170. /**
  15171. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15172. */
  15173. foveationLevel: number;
  15174. }
  15175. module "babylonjs/Engines/engine" {
  15176. interface Engine {
  15177. /** @hidden */
  15178. _vrDisplay: any;
  15179. /** @hidden */
  15180. _vrSupported: boolean;
  15181. /** @hidden */
  15182. _oldSize: Size;
  15183. /** @hidden */
  15184. _oldHardwareScaleFactor: number;
  15185. /** @hidden */
  15186. _vrExclusivePointerMode: boolean;
  15187. /** @hidden */
  15188. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15189. /** @hidden */
  15190. _onVRDisplayPointerRestricted: () => void;
  15191. /** @hidden */
  15192. _onVRDisplayPointerUnrestricted: () => void;
  15193. /** @hidden */
  15194. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15195. /** @hidden */
  15196. _onVrDisplayDisconnect: Nullable<() => void>;
  15197. /** @hidden */
  15198. _onVrDisplayPresentChange: Nullable<() => void>;
  15199. /**
  15200. * Observable signaled when VR display mode changes
  15201. */
  15202. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15203. /**
  15204. * Observable signaled when VR request present is complete
  15205. */
  15206. onVRRequestPresentComplete: Observable<boolean>;
  15207. /**
  15208. * Observable signaled when VR request present starts
  15209. */
  15210. onVRRequestPresentStart: Observable<Engine>;
  15211. /**
  15212. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15213. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15214. */
  15215. isInVRExclusivePointerMode: boolean;
  15216. /**
  15217. * Gets a boolean indicating if a webVR device was detected
  15218. * @returns true if a webVR device was detected
  15219. */
  15220. isVRDevicePresent(): boolean;
  15221. /**
  15222. * Gets the current webVR device
  15223. * @returns the current webVR device (or null)
  15224. */
  15225. getVRDevice(): any;
  15226. /**
  15227. * Initializes a webVR display and starts listening to display change events
  15228. * The onVRDisplayChangedObservable will be notified upon these changes
  15229. * @returns A promise containing a VRDisplay and if vr is supported
  15230. */
  15231. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15232. /** @hidden */
  15233. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15234. /**
  15235. * Gets or sets the presentation attributes used to configure VR rendering
  15236. */
  15237. vrPresentationAttributes?: IVRPresentationAttributes;
  15238. /**
  15239. * Call this function to switch to webVR mode
  15240. * Will do nothing if webVR is not supported or if there is no webVR device
  15241. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15242. */
  15243. enableVR(): void;
  15244. /** @hidden */
  15245. _onVRFullScreenTriggered(): void;
  15246. }
  15247. }
  15248. }
  15249. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15250. import { Nullable } from "babylonjs/types";
  15251. import { Observable } from "babylonjs/Misc/observable";
  15252. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15253. import { Scene } from "babylonjs/scene";
  15254. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15255. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15256. import { Node } from "babylonjs/node";
  15257. import { Ray } from "babylonjs/Culling/ray";
  15258. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15259. import "babylonjs/Engines/Extensions/engine.webVR";
  15260. /**
  15261. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15262. * IMPORTANT!! The data is right-hand data.
  15263. * @export
  15264. * @interface DevicePose
  15265. */
  15266. export interface DevicePose {
  15267. /**
  15268. * The position of the device, values in array are [x,y,z].
  15269. */
  15270. readonly position: Nullable<Float32Array>;
  15271. /**
  15272. * The linearVelocity of the device, values in array are [x,y,z].
  15273. */
  15274. readonly linearVelocity: Nullable<Float32Array>;
  15275. /**
  15276. * The linearAcceleration of the device, values in array are [x,y,z].
  15277. */
  15278. readonly linearAcceleration: Nullable<Float32Array>;
  15279. /**
  15280. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15281. */
  15282. readonly orientation: Nullable<Float32Array>;
  15283. /**
  15284. * The angularVelocity of the device, values in array are [x,y,z].
  15285. */
  15286. readonly angularVelocity: Nullable<Float32Array>;
  15287. /**
  15288. * The angularAcceleration of the device, values in array are [x,y,z].
  15289. */
  15290. readonly angularAcceleration: Nullable<Float32Array>;
  15291. }
  15292. /**
  15293. * Interface representing a pose controlled object in Babylon.
  15294. * A pose controlled object has both regular pose values as well as pose values
  15295. * from an external device such as a VR head mounted display
  15296. */
  15297. export interface PoseControlled {
  15298. /**
  15299. * The position of the object in babylon space.
  15300. */
  15301. position: Vector3;
  15302. /**
  15303. * The rotation quaternion of the object in babylon space.
  15304. */
  15305. rotationQuaternion: Quaternion;
  15306. /**
  15307. * The position of the device in babylon space.
  15308. */
  15309. devicePosition?: Vector3;
  15310. /**
  15311. * The rotation quaternion of the device in babylon space.
  15312. */
  15313. deviceRotationQuaternion: Quaternion;
  15314. /**
  15315. * The raw pose coming from the device.
  15316. */
  15317. rawPose: Nullable<DevicePose>;
  15318. /**
  15319. * The scale of the device to be used when translating from device space to babylon space.
  15320. */
  15321. deviceScaleFactor: number;
  15322. /**
  15323. * Updates the poseControlled values based on the input device pose.
  15324. * @param poseData the pose data to update the object with
  15325. */
  15326. updateFromDevice(poseData: DevicePose): void;
  15327. }
  15328. /**
  15329. * Set of options to customize the webVRCamera
  15330. */
  15331. export interface WebVROptions {
  15332. /**
  15333. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15334. */
  15335. trackPosition?: boolean;
  15336. /**
  15337. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15338. */
  15339. positionScale?: number;
  15340. /**
  15341. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15342. */
  15343. displayName?: string;
  15344. /**
  15345. * Should the native controller meshes be initialized. (default: true)
  15346. */
  15347. controllerMeshes?: boolean;
  15348. /**
  15349. * Creating a default HemiLight only on controllers. (default: true)
  15350. */
  15351. defaultLightingOnControllers?: boolean;
  15352. /**
  15353. * If you don't want to use the default VR button of the helper. (default: false)
  15354. */
  15355. useCustomVRButton?: boolean;
  15356. /**
  15357. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15358. */
  15359. customVRButton?: HTMLButtonElement;
  15360. /**
  15361. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15362. */
  15363. rayLength?: number;
  15364. /**
  15365. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15366. */
  15367. defaultHeight?: number;
  15368. /**
  15369. * If multiview should be used if availible (default: false)
  15370. */
  15371. useMultiview?: boolean;
  15372. }
  15373. /**
  15374. * This represents a WebVR camera.
  15375. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15376. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15377. */
  15378. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15379. private webVROptions;
  15380. /**
  15381. * @hidden
  15382. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15383. */
  15384. _vrDevice: any;
  15385. /**
  15386. * The rawPose of the vrDevice.
  15387. */
  15388. rawPose: Nullable<DevicePose>;
  15389. private _onVREnabled;
  15390. private _specsVersion;
  15391. private _attached;
  15392. private _frameData;
  15393. protected _descendants: Array<Node>;
  15394. private _deviceRoomPosition;
  15395. /** @hidden */
  15396. _deviceRoomRotationQuaternion: Quaternion;
  15397. private _standingMatrix;
  15398. /**
  15399. * Represents device position in babylon space.
  15400. */
  15401. devicePosition: Vector3;
  15402. /**
  15403. * Represents device rotation in babylon space.
  15404. */
  15405. deviceRotationQuaternion: Quaternion;
  15406. /**
  15407. * The scale of the device to be used when translating from device space to babylon space.
  15408. */
  15409. deviceScaleFactor: number;
  15410. private _deviceToWorld;
  15411. private _worldToDevice;
  15412. /**
  15413. * References to the webVR controllers for the vrDevice.
  15414. */
  15415. controllers: Array<WebVRController>;
  15416. /**
  15417. * Emits an event when a controller is attached.
  15418. */
  15419. onControllersAttachedObservable: Observable<WebVRController[]>;
  15420. /**
  15421. * Emits an event when a controller's mesh has been loaded;
  15422. */
  15423. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15424. /**
  15425. * Emits an event when the HMD's pose has been updated.
  15426. */
  15427. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15428. private _poseSet;
  15429. /**
  15430. * If the rig cameras be used as parent instead of this camera.
  15431. */
  15432. rigParenting: boolean;
  15433. private _lightOnControllers;
  15434. private _defaultHeight?;
  15435. /**
  15436. * Instantiates a WebVRFreeCamera.
  15437. * @param name The name of the WebVRFreeCamera
  15438. * @param position The starting anchor position for the camera
  15439. * @param scene The scene the camera belongs to
  15440. * @param webVROptions a set of customizable options for the webVRCamera
  15441. */
  15442. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15443. /**
  15444. * Gets the device distance from the ground in meters.
  15445. * @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.
  15446. */
  15447. deviceDistanceToRoomGround(): number;
  15448. /**
  15449. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15450. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15451. */
  15452. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15453. /**
  15454. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15455. * @returns A promise with a boolean set to if the standing matrix is supported.
  15456. */
  15457. useStandingMatrixAsync(): Promise<boolean>;
  15458. /**
  15459. * Disposes the camera
  15460. */
  15461. dispose(): void;
  15462. /**
  15463. * Gets a vrController by name.
  15464. * @param name The name of the controller to retreive
  15465. * @returns the controller matching the name specified or null if not found
  15466. */
  15467. getControllerByName(name: string): Nullable<WebVRController>;
  15468. private _leftController;
  15469. /**
  15470. * The controller corresponding to the users left hand.
  15471. */
  15472. readonly leftController: Nullable<WebVRController>;
  15473. private _rightController;
  15474. /**
  15475. * The controller corresponding to the users right hand.
  15476. */
  15477. readonly rightController: Nullable<WebVRController>;
  15478. /**
  15479. * Casts a ray forward from the vrCamera's gaze.
  15480. * @param length Length of the ray (default: 100)
  15481. * @returns the ray corresponding to the gaze
  15482. */
  15483. getForwardRay(length?: number): Ray;
  15484. /**
  15485. * @hidden
  15486. * Updates the camera based on device's frame data
  15487. */
  15488. _checkInputs(): void;
  15489. /**
  15490. * Updates the poseControlled values based on the input device pose.
  15491. * @param poseData Pose coming from the device
  15492. */
  15493. updateFromDevice(poseData: DevicePose): void;
  15494. private _htmlElementAttached;
  15495. private _detachIfAttached;
  15496. /**
  15497. * WebVR's attach control will start broadcasting frames to the device.
  15498. * Note that in certain browsers (chrome for example) this function must be called
  15499. * within a user-interaction callback. Example:
  15500. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15501. *
  15502. * @param element html element to attach the vrDevice to
  15503. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15504. */
  15505. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15506. /**
  15507. * Detaches the camera from the html element and disables VR
  15508. *
  15509. * @param element html element to detach from
  15510. */
  15511. detachControl(element: HTMLElement): void;
  15512. /**
  15513. * @returns the name of this class
  15514. */
  15515. getClassName(): string;
  15516. /**
  15517. * Calls resetPose on the vrDisplay
  15518. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15519. */
  15520. resetToCurrentRotation(): void;
  15521. /**
  15522. * @hidden
  15523. * Updates the rig cameras (left and right eye)
  15524. */
  15525. _updateRigCameras(): void;
  15526. private _workingVector;
  15527. private _oneVector;
  15528. private _workingMatrix;
  15529. private updateCacheCalled;
  15530. private _correctPositionIfNotTrackPosition;
  15531. /**
  15532. * @hidden
  15533. * Updates the cached values of the camera
  15534. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15535. */
  15536. _updateCache(ignoreParentClass?: boolean): void;
  15537. /**
  15538. * @hidden
  15539. * Get current device position in babylon world
  15540. */
  15541. _computeDevicePosition(): void;
  15542. /**
  15543. * Updates the current device position and rotation in the babylon world
  15544. */
  15545. update(): void;
  15546. /**
  15547. * @hidden
  15548. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15549. * @returns an identity matrix
  15550. */
  15551. _getViewMatrix(): Matrix;
  15552. private _tmpMatrix;
  15553. /**
  15554. * This function is called by the two RIG cameras.
  15555. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15556. * @hidden
  15557. */
  15558. _getWebVRViewMatrix(): Matrix;
  15559. /** @hidden */
  15560. _getWebVRProjectionMatrix(): Matrix;
  15561. private _onGamepadConnectedObserver;
  15562. private _onGamepadDisconnectedObserver;
  15563. private _updateCacheWhenTrackingDisabledObserver;
  15564. /**
  15565. * Initializes the controllers and their meshes
  15566. */
  15567. initControllers(): void;
  15568. }
  15569. }
  15570. declare module "babylonjs/PostProcesses/postProcess" {
  15571. import { Nullable } from "babylonjs/types";
  15572. import { SmartArray } from "babylonjs/Misc/smartArray";
  15573. import { Observable } from "babylonjs/Misc/observable";
  15574. import { Vector2 } from "babylonjs/Maths/math.vector";
  15575. import { Camera } from "babylonjs/Cameras/camera";
  15576. import { Effect } from "babylonjs/Materials/effect";
  15577. import "babylonjs/Shaders/postprocess.vertex";
  15578. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15579. import { Engine } from "babylonjs/Engines/engine";
  15580. import { Color4 } from "babylonjs/Maths/math.color";
  15581. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15582. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15583. /**
  15584. * Size options for a post process
  15585. */
  15586. export type PostProcessOptions = {
  15587. width: number;
  15588. height: number;
  15589. };
  15590. /**
  15591. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15592. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15593. */
  15594. export class PostProcess {
  15595. /** Name of the PostProcess. */
  15596. name: string;
  15597. /**
  15598. * Gets or sets the unique id of the post process
  15599. */
  15600. uniqueId: number;
  15601. /**
  15602. * Width of the texture to apply the post process on
  15603. */
  15604. width: number;
  15605. /**
  15606. * Height of the texture to apply the post process on
  15607. */
  15608. height: number;
  15609. /**
  15610. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15611. * @hidden
  15612. */
  15613. _outputTexture: Nullable<InternalTexture>;
  15614. /**
  15615. * Sampling mode used by the shader
  15616. * See https://doc.babylonjs.com/classes/3.1/texture
  15617. */
  15618. renderTargetSamplingMode: number;
  15619. /**
  15620. * Clear color to use when screen clearing
  15621. */
  15622. clearColor: Color4;
  15623. /**
  15624. * If the buffer needs to be cleared before applying the post process. (default: true)
  15625. * Should be set to false if shader will overwrite all previous pixels.
  15626. */
  15627. autoClear: boolean;
  15628. /**
  15629. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15630. */
  15631. alphaMode: number;
  15632. /**
  15633. * Sets the setAlphaBlendConstants of the babylon engine
  15634. */
  15635. alphaConstants: Color4;
  15636. /**
  15637. * Animations to be used for the post processing
  15638. */
  15639. animations: import("babylonjs/Animations/animation").Animation[];
  15640. /**
  15641. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15642. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15643. */
  15644. enablePixelPerfectMode: boolean;
  15645. /**
  15646. * Force the postprocess to be applied without taking in account viewport
  15647. */
  15648. forceFullscreenViewport: boolean;
  15649. /**
  15650. * List of inspectable custom properties (used by the Inspector)
  15651. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15652. */
  15653. inspectableCustomProperties: IInspectable[];
  15654. /**
  15655. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15656. *
  15657. * | Value | Type | Description |
  15658. * | ----- | ----------------------------------- | ----------- |
  15659. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15660. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15661. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15662. *
  15663. */
  15664. scaleMode: number;
  15665. /**
  15666. * Force textures to be a power of two (default: false)
  15667. */
  15668. alwaysForcePOT: boolean;
  15669. private _samples;
  15670. /**
  15671. * Number of sample textures (default: 1)
  15672. */
  15673. samples: number;
  15674. /**
  15675. * Modify the scale of the post process to be the same as the viewport (default: false)
  15676. */
  15677. adaptScaleToCurrentViewport: boolean;
  15678. private _camera;
  15679. private _scene;
  15680. private _engine;
  15681. private _options;
  15682. private _reusable;
  15683. private _textureType;
  15684. /**
  15685. * Smart array of input and output textures for the post process.
  15686. * @hidden
  15687. */
  15688. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15689. /**
  15690. * The index in _textures that corresponds to the output texture.
  15691. * @hidden
  15692. */
  15693. _currentRenderTextureInd: number;
  15694. private _effect;
  15695. private _samplers;
  15696. private _fragmentUrl;
  15697. private _vertexUrl;
  15698. private _parameters;
  15699. private _scaleRatio;
  15700. protected _indexParameters: any;
  15701. private _shareOutputWithPostProcess;
  15702. private _texelSize;
  15703. private _forcedOutputTexture;
  15704. /**
  15705. * Returns the fragment url or shader name used in the post process.
  15706. * @returns the fragment url or name in the shader store.
  15707. */
  15708. getEffectName(): string;
  15709. /**
  15710. * An event triggered when the postprocess is activated.
  15711. */
  15712. onActivateObservable: Observable<Camera>;
  15713. private _onActivateObserver;
  15714. /**
  15715. * A function that is added to the onActivateObservable
  15716. */
  15717. onActivate: Nullable<(camera: Camera) => void>;
  15718. /**
  15719. * An event triggered when the postprocess changes its size.
  15720. */
  15721. onSizeChangedObservable: Observable<PostProcess>;
  15722. private _onSizeChangedObserver;
  15723. /**
  15724. * A function that is added to the onSizeChangedObservable
  15725. */
  15726. onSizeChanged: (postProcess: PostProcess) => void;
  15727. /**
  15728. * An event triggered when the postprocess applies its effect.
  15729. */
  15730. onApplyObservable: Observable<Effect>;
  15731. private _onApplyObserver;
  15732. /**
  15733. * A function that is added to the onApplyObservable
  15734. */
  15735. onApply: (effect: Effect) => void;
  15736. /**
  15737. * An event triggered before rendering the postprocess
  15738. */
  15739. onBeforeRenderObservable: Observable<Effect>;
  15740. private _onBeforeRenderObserver;
  15741. /**
  15742. * A function that is added to the onBeforeRenderObservable
  15743. */
  15744. onBeforeRender: (effect: Effect) => void;
  15745. /**
  15746. * An event triggered after rendering the postprocess
  15747. */
  15748. onAfterRenderObservable: Observable<Effect>;
  15749. private _onAfterRenderObserver;
  15750. /**
  15751. * A function that is added to the onAfterRenderObservable
  15752. */
  15753. onAfterRender: (efect: Effect) => void;
  15754. /**
  15755. * 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
  15756. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15757. */
  15758. inputTexture: InternalTexture;
  15759. /**
  15760. * Gets the camera which post process is applied to.
  15761. * @returns The camera the post process is applied to.
  15762. */
  15763. getCamera(): Camera;
  15764. /**
  15765. * Gets the texel size of the postprocess.
  15766. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15767. */
  15768. readonly texelSize: Vector2;
  15769. /**
  15770. * Creates a new instance PostProcess
  15771. * @param name The name of the PostProcess.
  15772. * @param fragmentUrl The url of the fragment shader to be used.
  15773. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15774. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15775. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15776. * @param camera The camera to apply the render pass to.
  15777. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15778. * @param engine The engine which the post process will be applied. (default: current engine)
  15779. * @param reusable If the post process can be reused on the same frame. (default: false)
  15780. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15781. * @param textureType Type of textures used when performing the post process. (default: 0)
  15782. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15783. * @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
  15784. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15785. */
  15786. constructor(
  15787. /** Name of the PostProcess. */
  15788. 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);
  15789. /**
  15790. * Gets a string idenfifying the name of the class
  15791. * @returns "PostProcess" string
  15792. */
  15793. getClassName(): string;
  15794. /**
  15795. * Gets the engine which this post process belongs to.
  15796. * @returns The engine the post process was enabled with.
  15797. */
  15798. getEngine(): Engine;
  15799. /**
  15800. * The effect that is created when initializing the post process.
  15801. * @returns The created effect corresponding the the postprocess.
  15802. */
  15803. getEffect(): Effect;
  15804. /**
  15805. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15806. * @param postProcess The post process to share the output with.
  15807. * @returns This post process.
  15808. */
  15809. shareOutputWith(postProcess: PostProcess): PostProcess;
  15810. /**
  15811. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15812. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15813. */
  15814. useOwnOutput(): void;
  15815. /**
  15816. * Updates the effect with the current post process compile time values and recompiles the shader.
  15817. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15818. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15819. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15820. * @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
  15821. * @param onCompiled Called when the shader has been compiled.
  15822. * @param onError Called if there is an error when compiling a shader.
  15823. */
  15824. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15825. /**
  15826. * The post process is reusable if it can be used multiple times within one frame.
  15827. * @returns If the post process is reusable
  15828. */
  15829. isReusable(): boolean;
  15830. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15831. markTextureDirty(): void;
  15832. /**
  15833. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15834. * 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.
  15835. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15836. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15837. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15838. * @returns The target texture that was bound to be written to.
  15839. */
  15840. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15841. /**
  15842. * If the post process is supported.
  15843. */
  15844. readonly isSupported: boolean;
  15845. /**
  15846. * The aspect ratio of the output texture.
  15847. */
  15848. readonly aspectRatio: number;
  15849. /**
  15850. * Get a value indicating if the post-process is ready to be used
  15851. * @returns true if the post-process is ready (shader is compiled)
  15852. */
  15853. isReady(): boolean;
  15854. /**
  15855. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15856. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15857. */
  15858. apply(): Nullable<Effect>;
  15859. private _disposeTextures;
  15860. /**
  15861. * Disposes the post process.
  15862. * @param camera The camera to dispose the post process on.
  15863. */
  15864. dispose(camera?: Camera): void;
  15865. }
  15866. }
  15867. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15868. /** @hidden */
  15869. export var kernelBlurVaryingDeclaration: {
  15870. name: string;
  15871. shader: string;
  15872. };
  15873. }
  15874. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15875. /** @hidden */
  15876. export var kernelBlurFragment: {
  15877. name: string;
  15878. shader: string;
  15879. };
  15880. }
  15881. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15882. /** @hidden */
  15883. export var kernelBlurFragment2: {
  15884. name: string;
  15885. shader: string;
  15886. };
  15887. }
  15888. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15889. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15890. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15891. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15892. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15893. /** @hidden */
  15894. export var kernelBlurPixelShader: {
  15895. name: string;
  15896. shader: string;
  15897. };
  15898. }
  15899. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15900. /** @hidden */
  15901. export var kernelBlurVertex: {
  15902. name: string;
  15903. shader: string;
  15904. };
  15905. }
  15906. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15907. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15908. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15909. /** @hidden */
  15910. export var kernelBlurVertexShader: {
  15911. name: string;
  15912. shader: string;
  15913. };
  15914. }
  15915. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15916. import { Vector2 } from "babylonjs/Maths/math.vector";
  15917. import { Nullable } from "babylonjs/types";
  15918. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15919. import { Camera } from "babylonjs/Cameras/camera";
  15920. import { Effect } from "babylonjs/Materials/effect";
  15921. import { Engine } from "babylonjs/Engines/engine";
  15922. import "babylonjs/Shaders/kernelBlur.fragment";
  15923. import "babylonjs/Shaders/kernelBlur.vertex";
  15924. /**
  15925. * The Blur Post Process which blurs an image based on a kernel and direction.
  15926. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15927. */
  15928. export class BlurPostProcess extends PostProcess {
  15929. /** The direction in which to blur the image. */
  15930. direction: Vector2;
  15931. private blockCompilation;
  15932. protected _kernel: number;
  15933. protected _idealKernel: number;
  15934. protected _packedFloat: boolean;
  15935. private _staticDefines;
  15936. /**
  15937. * Sets the length in pixels of the blur sample region
  15938. */
  15939. /**
  15940. * Gets the length in pixels of the blur sample region
  15941. */
  15942. kernel: number;
  15943. /**
  15944. * Sets wether or not the blur needs to unpack/repack floats
  15945. */
  15946. /**
  15947. * Gets wether or not the blur is unpacking/repacking floats
  15948. */
  15949. packedFloat: boolean;
  15950. /**
  15951. * Creates a new instance BlurPostProcess
  15952. * @param name The name of the effect.
  15953. * @param direction The direction in which to blur the image.
  15954. * @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.
  15955. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15956. * @param camera The camera to apply the render pass to.
  15957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15958. * @param engine The engine which the post process will be applied. (default: current engine)
  15959. * @param reusable If the post process can be reused on the same frame. (default: false)
  15960. * @param textureType Type of textures used when performing the post process. (default: 0)
  15961. * @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)
  15962. */
  15963. constructor(name: string,
  15964. /** The direction in which to blur the image. */
  15965. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15966. /**
  15967. * Updates the effect with the current post process compile time values and recompiles the shader.
  15968. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15969. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15970. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15971. * @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
  15972. * @param onCompiled Called when the shader has been compiled.
  15973. * @param onError Called if there is an error when compiling a shader.
  15974. */
  15975. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15976. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15977. /**
  15978. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15979. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15980. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15981. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15982. * The gaps between physical kernels are compensated for in the weighting of the samples
  15983. * @param idealKernel Ideal blur kernel.
  15984. * @return Nearest best kernel.
  15985. */
  15986. protected _nearestBestKernel(idealKernel: number): number;
  15987. /**
  15988. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15989. * @param x The point on the Gaussian distribution to sample.
  15990. * @return the value of the Gaussian function at x.
  15991. */
  15992. protected _gaussianWeight(x: number): number;
  15993. /**
  15994. * Generates a string that can be used as a floating point number in GLSL.
  15995. * @param x Value to print.
  15996. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15997. * @return GLSL float string.
  15998. */
  15999. protected _glslFloat(x: number, decimalFigures?: number): string;
  16000. }
  16001. }
  16002. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16003. import { Scene } from "babylonjs/scene";
  16004. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16005. import { Plane } from "babylonjs/Maths/math.plane";
  16006. /**
  16007. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16008. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16009. * You can then easily use it as a reflectionTexture on a flat surface.
  16010. * In case the surface is not a plane, please consider relying on reflection probes.
  16011. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16012. */
  16013. export class MirrorTexture extends RenderTargetTexture {
  16014. private scene;
  16015. /**
  16016. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16017. * 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.
  16018. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16019. */
  16020. mirrorPlane: Plane;
  16021. /**
  16022. * Define the blur ratio used to blur the reflection if needed.
  16023. */
  16024. blurRatio: number;
  16025. /**
  16026. * Define the adaptive blur kernel used to blur the reflection if needed.
  16027. * This will autocompute the closest best match for the `blurKernel`
  16028. */
  16029. adaptiveBlurKernel: number;
  16030. /**
  16031. * Define the blur kernel used to blur the reflection if needed.
  16032. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16033. */
  16034. blurKernel: number;
  16035. /**
  16036. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16037. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16038. */
  16039. blurKernelX: number;
  16040. /**
  16041. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16042. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16043. */
  16044. blurKernelY: number;
  16045. private _autoComputeBlurKernel;
  16046. protected _onRatioRescale(): void;
  16047. private _updateGammaSpace;
  16048. private _imageProcessingConfigChangeObserver;
  16049. private _transformMatrix;
  16050. private _mirrorMatrix;
  16051. private _savedViewMatrix;
  16052. private _blurX;
  16053. private _blurY;
  16054. private _adaptiveBlurKernel;
  16055. private _blurKernelX;
  16056. private _blurKernelY;
  16057. private _blurRatio;
  16058. /**
  16059. * Instantiates a Mirror Texture.
  16060. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16061. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16062. * You can then easily use it as a reflectionTexture on a flat surface.
  16063. * In case the surface is not a plane, please consider relying on reflection probes.
  16064. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16065. * @param name
  16066. * @param size
  16067. * @param scene
  16068. * @param generateMipMaps
  16069. * @param type
  16070. * @param samplingMode
  16071. * @param generateDepthBuffer
  16072. */
  16073. constructor(name: string, size: number | {
  16074. width: number;
  16075. height: number;
  16076. } | {
  16077. ratio: number;
  16078. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16079. private _preparePostProcesses;
  16080. /**
  16081. * Clone the mirror texture.
  16082. * @returns the cloned texture
  16083. */
  16084. clone(): MirrorTexture;
  16085. /**
  16086. * Serialize the texture to a JSON representation you could use in Parse later on
  16087. * @returns the serialized JSON representation
  16088. */
  16089. serialize(): any;
  16090. /**
  16091. * Dispose the texture and release its associated resources.
  16092. */
  16093. dispose(): void;
  16094. }
  16095. }
  16096. declare module "babylonjs/Materials/Textures/texture" {
  16097. import { Observable } from "babylonjs/Misc/observable";
  16098. import { Nullable } from "babylonjs/types";
  16099. import { Matrix } from "babylonjs/Maths/math.vector";
  16100. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16101. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16102. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16103. import { Scene } from "babylonjs/scene";
  16104. /**
  16105. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16106. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16107. */
  16108. export class Texture extends BaseTexture {
  16109. /**
  16110. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16111. */
  16112. static SerializeBuffers: boolean;
  16113. /** @hidden */
  16114. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16115. /** @hidden */
  16116. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16117. /** @hidden */
  16118. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16119. /** nearest is mag = nearest and min = nearest and mip = linear */
  16120. static readonly NEAREST_SAMPLINGMODE: number;
  16121. /** nearest is mag = nearest and min = nearest and mip = linear */
  16122. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16123. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16124. static readonly BILINEAR_SAMPLINGMODE: number;
  16125. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16126. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16127. /** Trilinear is mag = linear and min = linear and mip = linear */
  16128. static readonly TRILINEAR_SAMPLINGMODE: number;
  16129. /** Trilinear is mag = linear and min = linear and mip = linear */
  16130. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16131. /** mag = nearest and min = nearest and mip = nearest */
  16132. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16133. /** mag = nearest and min = linear and mip = nearest */
  16134. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16135. /** mag = nearest and min = linear and mip = linear */
  16136. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16137. /** mag = nearest and min = linear and mip = none */
  16138. static readonly NEAREST_LINEAR: number;
  16139. /** mag = nearest and min = nearest and mip = none */
  16140. static readonly NEAREST_NEAREST: number;
  16141. /** mag = linear and min = nearest and mip = nearest */
  16142. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16143. /** mag = linear and min = nearest and mip = linear */
  16144. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16145. /** mag = linear and min = linear and mip = none */
  16146. static readonly LINEAR_LINEAR: number;
  16147. /** mag = linear and min = nearest and mip = none */
  16148. static readonly LINEAR_NEAREST: number;
  16149. /** Explicit coordinates mode */
  16150. static readonly EXPLICIT_MODE: number;
  16151. /** Spherical coordinates mode */
  16152. static readonly SPHERICAL_MODE: number;
  16153. /** Planar coordinates mode */
  16154. static readonly PLANAR_MODE: number;
  16155. /** Cubic coordinates mode */
  16156. static readonly CUBIC_MODE: number;
  16157. /** Projection coordinates mode */
  16158. static readonly PROJECTION_MODE: number;
  16159. /** Inverse Cubic coordinates mode */
  16160. static readonly SKYBOX_MODE: number;
  16161. /** Inverse Cubic coordinates mode */
  16162. static readonly INVCUBIC_MODE: number;
  16163. /** Equirectangular coordinates mode */
  16164. static readonly EQUIRECTANGULAR_MODE: number;
  16165. /** Equirectangular Fixed coordinates mode */
  16166. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16167. /** Equirectangular Fixed Mirrored coordinates mode */
  16168. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16169. /** Texture is not repeating outside of 0..1 UVs */
  16170. static readonly CLAMP_ADDRESSMODE: number;
  16171. /** Texture is repeating outside of 0..1 UVs */
  16172. static readonly WRAP_ADDRESSMODE: number;
  16173. /** Texture is repeating and mirrored */
  16174. static readonly MIRROR_ADDRESSMODE: number;
  16175. /**
  16176. * 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
  16177. */
  16178. static UseSerializedUrlIfAny: boolean;
  16179. /**
  16180. * Define the url of the texture.
  16181. */
  16182. url: Nullable<string>;
  16183. /**
  16184. * Define an offset on the texture to offset the u coordinates of the UVs
  16185. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16186. */
  16187. uOffset: number;
  16188. /**
  16189. * Define an offset on the texture to offset the v coordinates of the UVs
  16190. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16191. */
  16192. vOffset: number;
  16193. /**
  16194. * Define an offset on the texture to scale the u coordinates of the UVs
  16195. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16196. */
  16197. uScale: number;
  16198. /**
  16199. * Define an offset on the texture to scale the v coordinates of the UVs
  16200. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16201. */
  16202. vScale: number;
  16203. /**
  16204. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16205. * @see http://doc.babylonjs.com/how_to/more_materials
  16206. */
  16207. uAng: number;
  16208. /**
  16209. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16210. * @see http://doc.babylonjs.com/how_to/more_materials
  16211. */
  16212. vAng: number;
  16213. /**
  16214. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16215. * @see http://doc.babylonjs.com/how_to/more_materials
  16216. */
  16217. wAng: number;
  16218. /**
  16219. * Defines the center of rotation (U)
  16220. */
  16221. uRotationCenter: number;
  16222. /**
  16223. * Defines the center of rotation (V)
  16224. */
  16225. vRotationCenter: number;
  16226. /**
  16227. * Defines the center of rotation (W)
  16228. */
  16229. wRotationCenter: number;
  16230. /**
  16231. * Are mip maps generated for this texture or not.
  16232. */
  16233. readonly noMipmap: boolean;
  16234. /**
  16235. * List of inspectable custom properties (used by the Inspector)
  16236. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16237. */
  16238. inspectableCustomProperties: Nullable<IInspectable[]>;
  16239. private _noMipmap;
  16240. /** @hidden */
  16241. _invertY: boolean;
  16242. private _rowGenerationMatrix;
  16243. private _cachedTextureMatrix;
  16244. private _projectionModeMatrix;
  16245. private _t0;
  16246. private _t1;
  16247. private _t2;
  16248. private _cachedUOffset;
  16249. private _cachedVOffset;
  16250. private _cachedUScale;
  16251. private _cachedVScale;
  16252. private _cachedUAng;
  16253. private _cachedVAng;
  16254. private _cachedWAng;
  16255. private _cachedProjectionMatrixId;
  16256. private _cachedCoordinatesMode;
  16257. /** @hidden */
  16258. protected _initialSamplingMode: number;
  16259. /** @hidden */
  16260. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16261. private _deleteBuffer;
  16262. protected _format: Nullable<number>;
  16263. private _delayedOnLoad;
  16264. private _delayedOnError;
  16265. private _mimeType?;
  16266. /**
  16267. * Observable triggered once the texture has been loaded.
  16268. */
  16269. onLoadObservable: Observable<Texture>;
  16270. protected _isBlocking: boolean;
  16271. /**
  16272. * Is the texture preventing material to render while loading.
  16273. * If false, a default texture will be used instead of the loading one during the preparation step.
  16274. */
  16275. isBlocking: boolean;
  16276. /**
  16277. * Get the current sampling mode associated with the texture.
  16278. */
  16279. readonly samplingMode: number;
  16280. /**
  16281. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16282. */
  16283. readonly invertY: boolean;
  16284. /**
  16285. * Instantiates a new texture.
  16286. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16287. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16288. * @param url defines the url of the picture to load as a texture
  16289. * @param scene defines the scene or engine the texture will belong to
  16290. * @param noMipmap defines if the texture will require mip maps or not
  16291. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16292. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16293. * @param onLoad defines a callback triggered when the texture has been loaded
  16294. * @param onError defines a callback triggered when an error occurred during the loading session
  16295. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16296. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16297. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16298. * @param mimeType defines an optional mime type information
  16299. */
  16300. 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);
  16301. /**
  16302. * Update the url (and optional buffer) of this texture if url was null during construction.
  16303. * @param url the url of the texture
  16304. * @param buffer the buffer of the texture (defaults to null)
  16305. * @param onLoad callback called when the texture is loaded (defaults to null)
  16306. */
  16307. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16308. /**
  16309. * Finish the loading sequence of a texture flagged as delayed load.
  16310. * @hidden
  16311. */
  16312. delayLoad(): void;
  16313. private _prepareRowForTextureGeneration;
  16314. /**
  16315. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16316. * @returns the transform matrix of the texture.
  16317. */
  16318. getTextureMatrix(): Matrix;
  16319. /**
  16320. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16321. * @returns The reflection texture transform
  16322. */
  16323. getReflectionTextureMatrix(): Matrix;
  16324. /**
  16325. * Clones the texture.
  16326. * @returns the cloned texture
  16327. */
  16328. clone(): Texture;
  16329. /**
  16330. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16331. * @returns The JSON representation of the texture
  16332. */
  16333. serialize(): any;
  16334. /**
  16335. * Get the current class name of the texture useful for serialization or dynamic coding.
  16336. * @returns "Texture"
  16337. */
  16338. getClassName(): string;
  16339. /**
  16340. * Dispose the texture and release its associated resources.
  16341. */
  16342. dispose(): void;
  16343. /**
  16344. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16345. * @param parsedTexture Define the JSON representation of the texture
  16346. * @param scene Define the scene the parsed texture should be instantiated in
  16347. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16348. * @returns The parsed texture if successful
  16349. */
  16350. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16351. /**
  16352. * Creates a texture from its base 64 representation.
  16353. * @param data Define the base64 payload without the data: prefix
  16354. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16355. * @param scene Define the scene the texture should belong to
  16356. * @param noMipmap Forces the texture to not create mip map information if true
  16357. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16358. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16359. * @param onLoad define a callback triggered when the texture has been loaded
  16360. * @param onError define a callback triggered when an error occurred during the loading session
  16361. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16362. * @returns the created texture
  16363. */
  16364. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16365. /**
  16366. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16367. * @param data Define the base64 payload without the data: prefix
  16368. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16369. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16370. * @param scene Define the scene the texture should belong to
  16371. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16372. * @param noMipmap Forces the texture to not create mip map information if true
  16373. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16374. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16375. * @param onLoad define a callback triggered when the texture has been loaded
  16376. * @param onError define a callback triggered when an error occurred during the loading session
  16377. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16378. * @returns the created texture
  16379. */
  16380. 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;
  16381. }
  16382. }
  16383. declare module "babylonjs/PostProcesses/postProcessManager" {
  16384. import { Nullable } from "babylonjs/types";
  16385. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16386. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16387. import { Scene } from "babylonjs/scene";
  16388. /**
  16389. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16390. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16391. */
  16392. export class PostProcessManager {
  16393. private _scene;
  16394. private _indexBuffer;
  16395. private _vertexBuffers;
  16396. /**
  16397. * Creates a new instance PostProcess
  16398. * @param scene The scene that the post process is associated with.
  16399. */
  16400. constructor(scene: Scene);
  16401. private _prepareBuffers;
  16402. private _buildIndexBuffer;
  16403. /**
  16404. * Rebuilds the vertex buffers of the manager.
  16405. * @hidden
  16406. */
  16407. _rebuild(): void;
  16408. /**
  16409. * Prepares a frame to be run through a post process.
  16410. * @param sourceTexture The input texture to the post procesess. (default: null)
  16411. * @param postProcesses An array of post processes to be run. (default: null)
  16412. * @returns True if the post processes were able to be run.
  16413. * @hidden
  16414. */
  16415. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16416. /**
  16417. * Manually render a set of post processes to a texture.
  16418. * @param postProcesses An array of post processes to be run.
  16419. * @param targetTexture The target texture to render to.
  16420. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16421. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16422. * @param lodLevel defines which lod of the texture to render to
  16423. */
  16424. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16425. /**
  16426. * Finalize the result of the output of the postprocesses.
  16427. * @param doNotPresent If true the result will not be displayed to the screen.
  16428. * @param targetTexture The target texture to render to.
  16429. * @param faceIndex The index of the face to bind the target texture to.
  16430. * @param postProcesses The array of post processes to render.
  16431. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16432. * @hidden
  16433. */
  16434. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16435. /**
  16436. * Disposes of the post process manager.
  16437. */
  16438. dispose(): void;
  16439. }
  16440. }
  16441. declare module "babylonjs/Misc/gradients" {
  16442. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16443. /** Interface used by value gradients (color, factor, ...) */
  16444. export interface IValueGradient {
  16445. /**
  16446. * Gets or sets the gradient value (between 0 and 1)
  16447. */
  16448. gradient: number;
  16449. }
  16450. /** Class used to store color4 gradient */
  16451. export class ColorGradient implements IValueGradient {
  16452. /**
  16453. * Gets or sets the gradient value (between 0 and 1)
  16454. */
  16455. gradient: number;
  16456. /**
  16457. * Gets or sets first associated color
  16458. */
  16459. color1: Color4;
  16460. /**
  16461. * Gets or sets second associated color
  16462. */
  16463. color2?: Color4;
  16464. /**
  16465. * Will get a color picked randomly between color1 and color2.
  16466. * If color2 is undefined then color1 will be used
  16467. * @param result defines the target Color4 to store the result in
  16468. */
  16469. getColorToRef(result: Color4): void;
  16470. }
  16471. /** Class used to store color 3 gradient */
  16472. export class Color3Gradient implements IValueGradient {
  16473. /**
  16474. * Gets or sets the gradient value (between 0 and 1)
  16475. */
  16476. gradient: number;
  16477. /**
  16478. * Gets or sets the associated color
  16479. */
  16480. color: Color3;
  16481. }
  16482. /** Class used to store factor gradient */
  16483. export class FactorGradient implements IValueGradient {
  16484. /**
  16485. * Gets or sets the gradient value (between 0 and 1)
  16486. */
  16487. gradient: number;
  16488. /**
  16489. * Gets or sets first associated factor
  16490. */
  16491. factor1: number;
  16492. /**
  16493. * Gets or sets second associated factor
  16494. */
  16495. factor2?: number;
  16496. /**
  16497. * Will get a number picked randomly between factor1 and factor2.
  16498. * If factor2 is undefined then factor1 will be used
  16499. * @returns the picked number
  16500. */
  16501. getFactor(): number;
  16502. }
  16503. /**
  16504. * Helper used to simplify some generic gradient tasks
  16505. */
  16506. export class GradientHelper {
  16507. /**
  16508. * Gets the current gradient from an array of IValueGradient
  16509. * @param ratio defines the current ratio to get
  16510. * @param gradients defines the array of IValueGradient
  16511. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16512. */
  16513. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16514. }
  16515. }
  16516. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16517. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16518. import { Nullable } from "babylonjs/types";
  16519. module "babylonjs/Engines/thinEngine" {
  16520. interface ThinEngine {
  16521. /**
  16522. * Creates a dynamic texture
  16523. * @param width defines the width of the texture
  16524. * @param height defines the height of the texture
  16525. * @param generateMipMaps defines if the engine should generate the mip levels
  16526. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16527. * @returns the dynamic texture inside an InternalTexture
  16528. */
  16529. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16530. /**
  16531. * Update the content of a dynamic texture
  16532. * @param texture defines the texture to update
  16533. * @param canvas defines the canvas containing the source
  16534. * @param invertY defines if data must be stored with Y axis inverted
  16535. * @param premulAlpha defines if alpha is stored as premultiplied
  16536. * @param format defines the format of the data
  16537. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16538. */
  16539. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16540. }
  16541. }
  16542. }
  16543. declare module "babylonjs/Misc/canvasGenerator" {
  16544. /**
  16545. * Helper class used to generate a canvas to manipulate images
  16546. */
  16547. export class CanvasGenerator {
  16548. /**
  16549. * Create a new canvas (or offscreen canvas depending on the context)
  16550. * @param width defines the expected width
  16551. * @param height defines the expected height
  16552. * @return a new canvas or offscreen canvas
  16553. */
  16554. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16555. }
  16556. }
  16557. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16558. import { Scene } from "babylonjs/scene";
  16559. import { Texture } from "babylonjs/Materials/Textures/texture";
  16560. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16561. /**
  16562. * A class extending Texture allowing drawing on a texture
  16563. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16564. */
  16565. export class DynamicTexture extends Texture {
  16566. private _generateMipMaps;
  16567. private _canvas;
  16568. private _context;
  16569. private _engine;
  16570. /**
  16571. * Creates a DynamicTexture
  16572. * @param name defines the name of the texture
  16573. * @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
  16574. * @param scene defines the scene where you want the texture
  16575. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16576. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16577. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16578. */
  16579. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16580. /**
  16581. * Get the current class name of the texture useful for serialization or dynamic coding.
  16582. * @returns "DynamicTexture"
  16583. */
  16584. getClassName(): string;
  16585. /**
  16586. * Gets the current state of canRescale
  16587. */
  16588. readonly canRescale: boolean;
  16589. private _recreate;
  16590. /**
  16591. * Scales the texture
  16592. * @param ratio the scale factor to apply to both width and height
  16593. */
  16594. scale(ratio: number): void;
  16595. /**
  16596. * Resizes the texture
  16597. * @param width the new width
  16598. * @param height the new height
  16599. */
  16600. scaleTo(width: number, height: number): void;
  16601. /**
  16602. * Gets the context of the canvas used by the texture
  16603. * @returns the canvas context of the dynamic texture
  16604. */
  16605. getContext(): CanvasRenderingContext2D;
  16606. /**
  16607. * Clears the texture
  16608. */
  16609. clear(): void;
  16610. /**
  16611. * Updates the texture
  16612. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16613. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16614. */
  16615. update(invertY?: boolean, premulAlpha?: boolean): void;
  16616. /**
  16617. * Draws text onto the texture
  16618. * @param text defines the text to be drawn
  16619. * @param x defines the placement of the text from the left
  16620. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16621. * @param font defines the font to be used with font-style, font-size, font-name
  16622. * @param color defines the color used for the text
  16623. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16624. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16625. * @param update defines whether texture is immediately update (default is true)
  16626. */
  16627. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16628. /**
  16629. * Clones the texture
  16630. * @returns the clone of the texture.
  16631. */
  16632. clone(): DynamicTexture;
  16633. /**
  16634. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16635. * @returns a serialized dynamic texture object
  16636. */
  16637. serialize(): any;
  16638. /** @hidden */
  16639. _rebuild(): void;
  16640. }
  16641. }
  16642. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16643. import { Scene } from "babylonjs/scene";
  16644. import { ISceneComponent } from "babylonjs/sceneComponent";
  16645. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16646. module "babylonjs/abstractScene" {
  16647. interface AbstractScene {
  16648. /**
  16649. * The list of procedural textures added to the scene
  16650. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16651. */
  16652. proceduralTextures: Array<ProceduralTexture>;
  16653. }
  16654. }
  16655. /**
  16656. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16657. * in a given scene.
  16658. */
  16659. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16660. /**
  16661. * The component name helpfull to identify the component in the list of scene components.
  16662. */
  16663. readonly name: string;
  16664. /**
  16665. * The scene the component belongs to.
  16666. */
  16667. scene: Scene;
  16668. /**
  16669. * Creates a new instance of the component for the given scene
  16670. * @param scene Defines the scene to register the component in
  16671. */
  16672. constructor(scene: Scene);
  16673. /**
  16674. * Registers the component in a given scene
  16675. */
  16676. register(): void;
  16677. /**
  16678. * Rebuilds the elements related to this component in case of
  16679. * context lost for instance.
  16680. */
  16681. rebuild(): void;
  16682. /**
  16683. * Disposes the component and the associated ressources.
  16684. */
  16685. dispose(): void;
  16686. private _beforeClear;
  16687. }
  16688. }
  16689. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16690. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16691. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16692. module "babylonjs/Engines/thinEngine" {
  16693. interface ThinEngine {
  16694. /**
  16695. * Creates a new render target cube texture
  16696. * @param size defines the size of the texture
  16697. * @param options defines the options used to create the texture
  16698. * @returns a new render target cube texture stored in an InternalTexture
  16699. */
  16700. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16701. }
  16702. }
  16703. }
  16704. declare module "babylonjs/Shaders/procedural.vertex" {
  16705. /** @hidden */
  16706. export var proceduralVertexShader: {
  16707. name: string;
  16708. shader: string;
  16709. };
  16710. }
  16711. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16712. import { Observable } from "babylonjs/Misc/observable";
  16713. import { Nullable } from "babylonjs/types";
  16714. import { Scene } from "babylonjs/scene";
  16715. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16716. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16717. import { Effect } from "babylonjs/Materials/effect";
  16718. import { Texture } from "babylonjs/Materials/Textures/texture";
  16719. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16720. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16721. import "babylonjs/Shaders/procedural.vertex";
  16722. /**
  16723. * 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.
  16724. * This is the base class of any Procedural texture and contains most of the shareable code.
  16725. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16726. */
  16727. export class ProceduralTexture extends Texture {
  16728. isCube: boolean;
  16729. /**
  16730. * Define if the texture is enabled or not (disabled texture will not render)
  16731. */
  16732. isEnabled: boolean;
  16733. /**
  16734. * Define if the texture must be cleared before rendering (default is true)
  16735. */
  16736. autoClear: boolean;
  16737. /**
  16738. * Callback called when the texture is generated
  16739. */
  16740. onGenerated: () => void;
  16741. /**
  16742. * Event raised when the texture is generated
  16743. */
  16744. onGeneratedObservable: Observable<ProceduralTexture>;
  16745. /** @hidden */
  16746. _generateMipMaps: boolean;
  16747. /** @hidden **/
  16748. _effect: Effect;
  16749. /** @hidden */
  16750. _textures: {
  16751. [key: string]: Texture;
  16752. };
  16753. private _size;
  16754. private _currentRefreshId;
  16755. private _refreshRate;
  16756. private _vertexBuffers;
  16757. private _indexBuffer;
  16758. private _uniforms;
  16759. private _samplers;
  16760. private _fragment;
  16761. private _floats;
  16762. private _ints;
  16763. private _floatsArrays;
  16764. private _colors3;
  16765. private _colors4;
  16766. private _vectors2;
  16767. private _vectors3;
  16768. private _matrices;
  16769. private _fallbackTexture;
  16770. private _fallbackTextureUsed;
  16771. private _engine;
  16772. private _cachedDefines;
  16773. private _contentUpdateId;
  16774. private _contentData;
  16775. /**
  16776. * Instantiates a new procedural texture.
  16777. * 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.
  16778. * This is the base class of any Procedural texture and contains most of the shareable code.
  16779. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16780. * @param name Define the name of the texture
  16781. * @param size Define the size of the texture to create
  16782. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16783. * @param scene Define the scene the texture belongs to
  16784. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16785. * @param generateMipMaps Define if the texture should creates mip maps or not
  16786. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16787. */
  16788. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16789. /**
  16790. * The effect that is created when initializing the post process.
  16791. * @returns The created effect corresponding the the postprocess.
  16792. */
  16793. getEffect(): Effect;
  16794. /**
  16795. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16796. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16797. */
  16798. getContent(): Nullable<ArrayBufferView>;
  16799. private _createIndexBuffer;
  16800. /** @hidden */
  16801. _rebuild(): void;
  16802. /**
  16803. * Resets the texture in order to recreate its associated resources.
  16804. * This can be called in case of context loss
  16805. */
  16806. reset(): void;
  16807. protected _getDefines(): string;
  16808. /**
  16809. * Is the texture ready to be used ? (rendered at least once)
  16810. * @returns true if ready, otherwise, false.
  16811. */
  16812. isReady(): boolean;
  16813. /**
  16814. * Resets the refresh counter of the texture and start bak from scratch.
  16815. * Could be useful to regenerate the texture if it is setup to render only once.
  16816. */
  16817. resetRefreshCounter(): void;
  16818. /**
  16819. * Set the fragment shader to use in order to render the texture.
  16820. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16821. */
  16822. setFragment(fragment: any): void;
  16823. /**
  16824. * Define the refresh rate of the texture or the rendering frequency.
  16825. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16826. */
  16827. refreshRate: number;
  16828. /** @hidden */
  16829. _shouldRender(): boolean;
  16830. /**
  16831. * Get the size the texture is rendering at.
  16832. * @returns the size (texture is always squared)
  16833. */
  16834. getRenderSize(): number;
  16835. /**
  16836. * Resize the texture to new value.
  16837. * @param size Define the new size the texture should have
  16838. * @param generateMipMaps Define whether the new texture should create mip maps
  16839. */
  16840. resize(size: number, generateMipMaps: boolean): void;
  16841. private _checkUniform;
  16842. /**
  16843. * Set a texture in the shader program used to render.
  16844. * @param name Define the name of the uniform samplers as defined in the shader
  16845. * @param texture Define the texture to bind to this sampler
  16846. * @return the texture itself allowing "fluent" like uniform updates
  16847. */
  16848. setTexture(name: string, texture: Texture): ProceduralTexture;
  16849. /**
  16850. * Set a float in the shader.
  16851. * @param name Define the name of the uniform as defined in the shader
  16852. * @param value Define the value to give to the uniform
  16853. * @return the texture itself allowing "fluent" like uniform updates
  16854. */
  16855. setFloat(name: string, value: number): ProceduralTexture;
  16856. /**
  16857. * Set a int in the shader.
  16858. * @param name Define the name of the uniform as defined in the shader
  16859. * @param value Define the value to give to the uniform
  16860. * @return the texture itself allowing "fluent" like uniform updates
  16861. */
  16862. setInt(name: string, value: number): ProceduralTexture;
  16863. /**
  16864. * Set an array of floats in the shader.
  16865. * @param name Define the name of the uniform as defined in the shader
  16866. * @param value Define the value to give to the uniform
  16867. * @return the texture itself allowing "fluent" like uniform updates
  16868. */
  16869. setFloats(name: string, value: number[]): ProceduralTexture;
  16870. /**
  16871. * Set a vec3 in the shader from a Color3.
  16872. * @param name Define the name of the uniform as defined in the shader
  16873. * @param value Define the value to give to the uniform
  16874. * @return the texture itself allowing "fluent" like uniform updates
  16875. */
  16876. setColor3(name: string, value: Color3): ProceduralTexture;
  16877. /**
  16878. * Set a vec4 in the shader from a Color4.
  16879. * @param name Define the name of the uniform as defined in the shader
  16880. * @param value Define the value to give to the uniform
  16881. * @return the texture itself allowing "fluent" like uniform updates
  16882. */
  16883. setColor4(name: string, value: Color4): ProceduralTexture;
  16884. /**
  16885. * Set a vec2 in the shader from a Vector2.
  16886. * @param name Define the name of the uniform as defined in the shader
  16887. * @param value Define the value to give to the uniform
  16888. * @return the texture itself allowing "fluent" like uniform updates
  16889. */
  16890. setVector2(name: string, value: Vector2): ProceduralTexture;
  16891. /**
  16892. * Set a vec3 in the shader from a Vector3.
  16893. * @param name Define the name of the uniform as defined in the shader
  16894. * @param value Define the value to give to the uniform
  16895. * @return the texture itself allowing "fluent" like uniform updates
  16896. */
  16897. setVector3(name: string, value: Vector3): ProceduralTexture;
  16898. /**
  16899. * Set a mat4 in the shader from a MAtrix.
  16900. * @param name Define the name of the uniform as defined in the shader
  16901. * @param value Define the value to give to the uniform
  16902. * @return the texture itself allowing "fluent" like uniform updates
  16903. */
  16904. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16905. /**
  16906. * Render the texture to its associated render target.
  16907. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16908. */
  16909. render(useCameraPostProcess?: boolean): void;
  16910. /**
  16911. * Clone the texture.
  16912. * @returns the cloned texture
  16913. */
  16914. clone(): ProceduralTexture;
  16915. /**
  16916. * Dispose the texture and release its asoociated resources.
  16917. */
  16918. dispose(): void;
  16919. }
  16920. }
  16921. declare module "babylonjs/Particles/baseParticleSystem" {
  16922. import { Nullable } from "babylonjs/types";
  16923. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16925. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16926. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16927. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16928. import { Scene } from "babylonjs/scene";
  16929. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16930. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16931. import { Texture } from "babylonjs/Materials/Textures/texture";
  16932. import { Color4 } from "babylonjs/Maths/math.color";
  16933. import { Animation } from "babylonjs/Animations/animation";
  16934. /**
  16935. * This represents the base class for particle system in Babylon.
  16936. * 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.
  16937. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16938. * @example https://doc.babylonjs.com/babylon101/particles
  16939. */
  16940. export class BaseParticleSystem {
  16941. /**
  16942. * Source color is added to the destination color without alpha affecting the result
  16943. */
  16944. static BLENDMODE_ONEONE: number;
  16945. /**
  16946. * Blend current color and particle color using particle’s alpha
  16947. */
  16948. static BLENDMODE_STANDARD: number;
  16949. /**
  16950. * Add current color and particle color multiplied by particle’s alpha
  16951. */
  16952. static BLENDMODE_ADD: number;
  16953. /**
  16954. * Multiply current color with particle color
  16955. */
  16956. static BLENDMODE_MULTIPLY: number;
  16957. /**
  16958. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16959. */
  16960. static BLENDMODE_MULTIPLYADD: number;
  16961. /**
  16962. * List of animations used by the particle system.
  16963. */
  16964. animations: Animation[];
  16965. /**
  16966. * The id of the Particle system.
  16967. */
  16968. id: string;
  16969. /**
  16970. * The friendly name of the Particle system.
  16971. */
  16972. name: string;
  16973. /**
  16974. * The rendering group used by the Particle system to chose when to render.
  16975. */
  16976. renderingGroupId: number;
  16977. /**
  16978. * The emitter represents the Mesh or position we are attaching the particle system to.
  16979. */
  16980. emitter: Nullable<AbstractMesh | Vector3>;
  16981. /**
  16982. * The maximum number of particles to emit per frame
  16983. */
  16984. emitRate: number;
  16985. /**
  16986. * If you want to launch only a few particles at once, that can be done, as well.
  16987. */
  16988. manualEmitCount: number;
  16989. /**
  16990. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16991. */
  16992. updateSpeed: number;
  16993. /**
  16994. * The amount of time the particle system is running (depends of the overall update speed).
  16995. */
  16996. targetStopDuration: number;
  16997. /**
  16998. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16999. */
  17000. disposeOnStop: boolean;
  17001. /**
  17002. * Minimum power of emitting particles.
  17003. */
  17004. minEmitPower: number;
  17005. /**
  17006. * Maximum power of emitting particles.
  17007. */
  17008. maxEmitPower: number;
  17009. /**
  17010. * Minimum life time of emitting particles.
  17011. */
  17012. minLifeTime: number;
  17013. /**
  17014. * Maximum life time of emitting particles.
  17015. */
  17016. maxLifeTime: number;
  17017. /**
  17018. * Minimum Size of emitting particles.
  17019. */
  17020. minSize: number;
  17021. /**
  17022. * Maximum Size of emitting particles.
  17023. */
  17024. maxSize: number;
  17025. /**
  17026. * Minimum scale of emitting particles on X axis.
  17027. */
  17028. minScaleX: number;
  17029. /**
  17030. * Maximum scale of emitting particles on X axis.
  17031. */
  17032. maxScaleX: number;
  17033. /**
  17034. * Minimum scale of emitting particles on Y axis.
  17035. */
  17036. minScaleY: number;
  17037. /**
  17038. * Maximum scale of emitting particles on Y axis.
  17039. */
  17040. maxScaleY: number;
  17041. /**
  17042. * Gets or sets the minimal initial rotation in radians.
  17043. */
  17044. minInitialRotation: number;
  17045. /**
  17046. * Gets or sets the maximal initial rotation in radians.
  17047. */
  17048. maxInitialRotation: number;
  17049. /**
  17050. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17051. */
  17052. minAngularSpeed: number;
  17053. /**
  17054. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17055. */
  17056. maxAngularSpeed: number;
  17057. /**
  17058. * The texture used to render each particle. (this can be a spritesheet)
  17059. */
  17060. particleTexture: Nullable<Texture>;
  17061. /**
  17062. * The layer mask we are rendering the particles through.
  17063. */
  17064. layerMask: number;
  17065. /**
  17066. * This can help using your own shader to render the particle system.
  17067. * The according effect will be created
  17068. */
  17069. customShader: any;
  17070. /**
  17071. * By default particle system starts as soon as they are created. This prevents the
  17072. * automatic start to happen and let you decide when to start emitting particles.
  17073. */
  17074. preventAutoStart: boolean;
  17075. private _noiseTexture;
  17076. /**
  17077. * Gets or sets a texture used to add random noise to particle positions
  17078. */
  17079. noiseTexture: Nullable<ProceduralTexture>;
  17080. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17081. noiseStrength: Vector3;
  17082. /**
  17083. * Callback triggered when the particle animation is ending.
  17084. */
  17085. onAnimationEnd: Nullable<() => void>;
  17086. /**
  17087. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17088. */
  17089. blendMode: number;
  17090. /**
  17091. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17092. * to override the particles.
  17093. */
  17094. forceDepthWrite: boolean;
  17095. /** 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 */
  17096. preWarmCycles: number;
  17097. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17098. preWarmStepOffset: number;
  17099. /**
  17100. * 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)
  17101. */
  17102. spriteCellChangeSpeed: number;
  17103. /**
  17104. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17105. */
  17106. startSpriteCellID: number;
  17107. /**
  17108. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17109. */
  17110. endSpriteCellID: number;
  17111. /**
  17112. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17113. */
  17114. spriteCellWidth: number;
  17115. /**
  17116. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17117. */
  17118. spriteCellHeight: number;
  17119. /**
  17120. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17121. */
  17122. spriteRandomStartCell: boolean;
  17123. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17124. translationPivot: Vector2;
  17125. /** @hidden */
  17126. protected _isAnimationSheetEnabled: boolean;
  17127. /**
  17128. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17129. */
  17130. beginAnimationOnStart: boolean;
  17131. /**
  17132. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17133. */
  17134. beginAnimationFrom: number;
  17135. /**
  17136. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17137. */
  17138. beginAnimationTo: number;
  17139. /**
  17140. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17141. */
  17142. beginAnimationLoop: boolean;
  17143. /**
  17144. * Gets or sets a world offset applied to all particles
  17145. */
  17146. worldOffset: Vector3;
  17147. /**
  17148. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17149. */
  17150. isAnimationSheetEnabled: boolean;
  17151. /**
  17152. * Get hosting scene
  17153. * @returns the scene
  17154. */
  17155. getScene(): Scene;
  17156. /**
  17157. * You can use gravity if you want to give an orientation to your particles.
  17158. */
  17159. gravity: Vector3;
  17160. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17161. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17162. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17163. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17164. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17165. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17166. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17167. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17168. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17169. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17170. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17171. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17172. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17173. /**
  17174. * Defines the delay in milliseconds before starting the system (0 by default)
  17175. */
  17176. startDelay: number;
  17177. /**
  17178. * Gets the current list of drag gradients.
  17179. * You must use addDragGradient and removeDragGradient to udpate this list
  17180. * @returns the list of drag gradients
  17181. */
  17182. getDragGradients(): Nullable<Array<FactorGradient>>;
  17183. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17184. limitVelocityDamping: number;
  17185. /**
  17186. * Gets the current list of limit velocity gradients.
  17187. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17188. * @returns the list of limit velocity gradients
  17189. */
  17190. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17191. /**
  17192. * Gets the current list of color gradients.
  17193. * You must use addColorGradient and removeColorGradient to udpate this list
  17194. * @returns the list of color gradients
  17195. */
  17196. getColorGradients(): Nullable<Array<ColorGradient>>;
  17197. /**
  17198. * Gets the current list of size gradients.
  17199. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17200. * @returns the list of size gradients
  17201. */
  17202. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17203. /**
  17204. * Gets the current list of color remap gradients.
  17205. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17206. * @returns the list of color remap gradients
  17207. */
  17208. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17209. /**
  17210. * Gets the current list of alpha remap gradients.
  17211. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17212. * @returns the list of alpha remap gradients
  17213. */
  17214. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17215. /**
  17216. * Gets the current list of life time gradients.
  17217. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17218. * @returns the list of life time gradients
  17219. */
  17220. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17221. /**
  17222. * Gets the current list of angular speed gradients.
  17223. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17224. * @returns the list of angular speed gradients
  17225. */
  17226. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17227. /**
  17228. * Gets the current list of velocity gradients.
  17229. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17230. * @returns the list of velocity gradients
  17231. */
  17232. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17233. /**
  17234. * Gets the current list of start size gradients.
  17235. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17236. * @returns the list of start size gradients
  17237. */
  17238. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17239. /**
  17240. * Gets the current list of emit rate gradients.
  17241. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17242. * @returns the list of emit rate gradients
  17243. */
  17244. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17245. /**
  17246. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17247. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17248. */
  17249. direction1: Vector3;
  17250. /**
  17251. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17252. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17253. */
  17254. direction2: Vector3;
  17255. /**
  17256. * 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.
  17257. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17258. */
  17259. minEmitBox: Vector3;
  17260. /**
  17261. * 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.
  17262. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17263. */
  17264. maxEmitBox: Vector3;
  17265. /**
  17266. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17267. */
  17268. color1: Color4;
  17269. /**
  17270. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17271. */
  17272. color2: Color4;
  17273. /**
  17274. * Color the particle will have at the end of its lifetime
  17275. */
  17276. colorDead: Color4;
  17277. /**
  17278. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17279. */
  17280. textureMask: Color4;
  17281. /**
  17282. * The particle emitter type defines the emitter used by the particle system.
  17283. * It can be for example box, sphere, or cone...
  17284. */
  17285. particleEmitterType: IParticleEmitterType;
  17286. /** @hidden */
  17287. _isSubEmitter: boolean;
  17288. /**
  17289. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17290. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17291. */
  17292. billboardMode: number;
  17293. protected _isBillboardBased: boolean;
  17294. /**
  17295. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17296. */
  17297. isBillboardBased: boolean;
  17298. /**
  17299. * The scene the particle system belongs to.
  17300. */
  17301. protected _scene: Scene;
  17302. /**
  17303. * Local cache of defines for image processing.
  17304. */
  17305. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17306. /**
  17307. * Default configuration related to image processing available in the standard Material.
  17308. */
  17309. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17310. /**
  17311. * Gets the image processing configuration used either in this material.
  17312. */
  17313. /**
  17314. * Sets the Default image processing configuration used either in the this material.
  17315. *
  17316. * If sets to null, the scene one is in use.
  17317. */
  17318. imageProcessingConfiguration: ImageProcessingConfiguration;
  17319. /**
  17320. * Attaches a new image processing configuration to the Standard Material.
  17321. * @param configuration
  17322. */
  17323. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17324. /** @hidden */
  17325. protected _reset(): void;
  17326. /** @hidden */
  17327. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17328. /**
  17329. * Instantiates a particle system.
  17330. * 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.
  17331. * @param name The name of the particle system
  17332. */
  17333. constructor(name: string);
  17334. /**
  17335. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17336. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17337. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17338. * @returns the emitter
  17339. */
  17340. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17341. /**
  17342. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17343. * @param radius The radius of the hemisphere to emit from
  17344. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17345. * @returns the emitter
  17346. */
  17347. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17348. /**
  17349. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17350. * @param radius The radius of the sphere to emit from
  17351. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17352. * @returns the emitter
  17353. */
  17354. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17355. /**
  17356. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17357. * @param radius The radius of the sphere to emit from
  17358. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17359. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17360. * @returns the emitter
  17361. */
  17362. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17363. /**
  17364. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17365. * @param radius The radius of the emission cylinder
  17366. * @param height The height of the emission cylinder
  17367. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17368. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17369. * @returns the emitter
  17370. */
  17371. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17372. /**
  17373. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17374. * @param radius The radius of the cylinder to emit from
  17375. * @param height The height of the emission cylinder
  17376. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17377. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17378. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17379. * @returns the emitter
  17380. */
  17381. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17382. /**
  17383. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17384. * @param radius The radius of the cone to emit from
  17385. * @param angle The base angle of the cone
  17386. * @returns the emitter
  17387. */
  17388. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17389. /**
  17390. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17391. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17392. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17393. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17394. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17395. * @returns the emitter
  17396. */
  17397. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17398. }
  17399. }
  17400. declare module "babylonjs/Particles/subEmitter" {
  17401. import { Scene } from "babylonjs/scene";
  17402. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17403. /**
  17404. * Type of sub emitter
  17405. */
  17406. export enum SubEmitterType {
  17407. /**
  17408. * Attached to the particle over it's lifetime
  17409. */
  17410. ATTACHED = 0,
  17411. /**
  17412. * Created when the particle dies
  17413. */
  17414. END = 1
  17415. }
  17416. /**
  17417. * Sub emitter class used to emit particles from an existing particle
  17418. */
  17419. export class SubEmitter {
  17420. /**
  17421. * the particle system to be used by the sub emitter
  17422. */
  17423. particleSystem: ParticleSystem;
  17424. /**
  17425. * Type of the submitter (Default: END)
  17426. */
  17427. type: SubEmitterType;
  17428. /**
  17429. * 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)
  17430. * Note: This only is supported when using an emitter of type Mesh
  17431. */
  17432. inheritDirection: boolean;
  17433. /**
  17434. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17435. */
  17436. inheritedVelocityAmount: number;
  17437. /**
  17438. * Creates a sub emitter
  17439. * @param particleSystem the particle system to be used by the sub emitter
  17440. */
  17441. constructor(
  17442. /**
  17443. * the particle system to be used by the sub emitter
  17444. */
  17445. particleSystem: ParticleSystem);
  17446. /**
  17447. * Clones the sub emitter
  17448. * @returns the cloned sub emitter
  17449. */
  17450. clone(): SubEmitter;
  17451. /**
  17452. * Serialize current object to a JSON object
  17453. * @returns the serialized object
  17454. */
  17455. serialize(): any;
  17456. /** @hidden */
  17457. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17458. /**
  17459. * Creates a new SubEmitter from a serialized JSON version
  17460. * @param serializationObject defines the JSON object to read from
  17461. * @param scene defines the hosting scene
  17462. * @param rootUrl defines the rootUrl for data loading
  17463. * @returns a new SubEmitter
  17464. */
  17465. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17466. /** Release associated resources */
  17467. dispose(): void;
  17468. }
  17469. }
  17470. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17471. /** @hidden */
  17472. export var clipPlaneFragmentDeclaration: {
  17473. name: string;
  17474. shader: string;
  17475. };
  17476. }
  17477. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17478. /** @hidden */
  17479. export var imageProcessingDeclaration: {
  17480. name: string;
  17481. shader: string;
  17482. };
  17483. }
  17484. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17485. /** @hidden */
  17486. export var imageProcessingFunctions: {
  17487. name: string;
  17488. shader: string;
  17489. };
  17490. }
  17491. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17492. /** @hidden */
  17493. export var clipPlaneFragment: {
  17494. name: string;
  17495. shader: string;
  17496. };
  17497. }
  17498. declare module "babylonjs/Shaders/particles.fragment" {
  17499. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17500. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17501. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17502. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17503. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17504. /** @hidden */
  17505. export var particlesPixelShader: {
  17506. name: string;
  17507. shader: string;
  17508. };
  17509. }
  17510. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17511. /** @hidden */
  17512. export var clipPlaneVertexDeclaration: {
  17513. name: string;
  17514. shader: string;
  17515. };
  17516. }
  17517. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17518. /** @hidden */
  17519. export var clipPlaneVertex: {
  17520. name: string;
  17521. shader: string;
  17522. };
  17523. }
  17524. declare module "babylonjs/Shaders/particles.vertex" {
  17525. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17526. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17527. /** @hidden */
  17528. export var particlesVertexShader: {
  17529. name: string;
  17530. shader: string;
  17531. };
  17532. }
  17533. declare module "babylonjs/Particles/particleSystem" {
  17534. import { Nullable } from "babylonjs/types";
  17535. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17536. import { Observable } from "babylonjs/Misc/observable";
  17537. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17538. import { Effect } from "babylonjs/Materials/effect";
  17539. import { Scene, IDisposable } from "babylonjs/scene";
  17540. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17541. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17542. import { Particle } from "babylonjs/Particles/particle";
  17543. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17544. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17545. import "babylonjs/Shaders/particles.fragment";
  17546. import "babylonjs/Shaders/particles.vertex";
  17547. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17548. /**
  17549. * This represents a particle system in Babylon.
  17550. * 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.
  17551. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17552. * @example https://doc.babylonjs.com/babylon101/particles
  17553. */
  17554. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17555. /**
  17556. * Billboard mode will only apply to Y axis
  17557. */
  17558. static readonly BILLBOARDMODE_Y: number;
  17559. /**
  17560. * Billboard mode will apply to all axes
  17561. */
  17562. static readonly BILLBOARDMODE_ALL: number;
  17563. /**
  17564. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17565. */
  17566. static readonly BILLBOARDMODE_STRETCHED: number;
  17567. /**
  17568. * This function can be defined to provide custom update for active particles.
  17569. * This function will be called instead of regular update (age, position, color, etc.).
  17570. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17571. */
  17572. updateFunction: (particles: Particle[]) => void;
  17573. private _emitterWorldMatrix;
  17574. /**
  17575. * This function can be defined to specify initial direction for every new particle.
  17576. * It by default use the emitterType defined function
  17577. */
  17578. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17579. /**
  17580. * This function can be defined to specify initial position for every new particle.
  17581. * It by default use the emitterType defined function
  17582. */
  17583. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17584. /**
  17585. * @hidden
  17586. */
  17587. _inheritedVelocityOffset: Vector3;
  17588. /**
  17589. * An event triggered when the system is disposed
  17590. */
  17591. onDisposeObservable: Observable<ParticleSystem>;
  17592. private _onDisposeObserver;
  17593. /**
  17594. * Sets a callback that will be triggered when the system is disposed
  17595. */
  17596. onDispose: () => void;
  17597. private _particles;
  17598. private _epsilon;
  17599. private _capacity;
  17600. private _stockParticles;
  17601. private _newPartsExcess;
  17602. private _vertexData;
  17603. private _vertexBuffer;
  17604. private _vertexBuffers;
  17605. private _spriteBuffer;
  17606. private _indexBuffer;
  17607. private _effect;
  17608. private _customEffect;
  17609. private _cachedDefines;
  17610. private _scaledColorStep;
  17611. private _colorDiff;
  17612. private _scaledDirection;
  17613. private _scaledGravity;
  17614. private _currentRenderId;
  17615. private _alive;
  17616. private _useInstancing;
  17617. private _started;
  17618. private _stopped;
  17619. private _actualFrame;
  17620. private _scaledUpdateSpeed;
  17621. private _vertexBufferSize;
  17622. /** @hidden */
  17623. _currentEmitRateGradient: Nullable<FactorGradient>;
  17624. /** @hidden */
  17625. _currentEmitRate1: number;
  17626. /** @hidden */
  17627. _currentEmitRate2: number;
  17628. /** @hidden */
  17629. _currentStartSizeGradient: Nullable<FactorGradient>;
  17630. /** @hidden */
  17631. _currentStartSize1: number;
  17632. /** @hidden */
  17633. _currentStartSize2: number;
  17634. private readonly _rawTextureWidth;
  17635. private _rampGradientsTexture;
  17636. private _useRampGradients;
  17637. /** Gets or sets a boolean indicating that ramp gradients must be used
  17638. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17639. */
  17640. useRampGradients: boolean;
  17641. /**
  17642. * 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.
  17643. * 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: [])
  17644. */
  17645. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17646. private _subEmitters;
  17647. /**
  17648. * @hidden
  17649. * If the particle systems emitter should be disposed when the particle system is disposed
  17650. */
  17651. _disposeEmitterOnDispose: boolean;
  17652. /**
  17653. * The current active Sub-systems, this property is used by the root particle system only.
  17654. */
  17655. activeSubSystems: Array<ParticleSystem>;
  17656. private _rootParticleSystem;
  17657. /**
  17658. * Gets the current list of active particles
  17659. */
  17660. readonly particles: Particle[];
  17661. /**
  17662. * Returns the string "ParticleSystem"
  17663. * @returns a string containing the class name
  17664. */
  17665. getClassName(): string;
  17666. /**
  17667. * Instantiates a particle system.
  17668. * 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.
  17669. * @param name The name of the particle system
  17670. * @param capacity The max number of particles alive at the same time
  17671. * @param scene The scene the particle system belongs to
  17672. * @param customEffect a custom effect used to change the way particles are rendered by default
  17673. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17674. * @param epsilon Offset used to render the particles
  17675. */
  17676. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17677. private _addFactorGradient;
  17678. private _removeFactorGradient;
  17679. /**
  17680. * Adds a new life time gradient
  17681. * @param gradient defines the gradient to use (between 0 and 1)
  17682. * @param factor defines the life time factor to affect to the specified gradient
  17683. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17684. * @returns the current particle system
  17685. */
  17686. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17687. /**
  17688. * Remove a specific life time gradient
  17689. * @param gradient defines the gradient to remove
  17690. * @returns the current particle system
  17691. */
  17692. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17693. /**
  17694. * Adds a new size gradient
  17695. * @param gradient defines the gradient to use (between 0 and 1)
  17696. * @param factor defines the size factor to affect to the specified gradient
  17697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17698. * @returns the current particle system
  17699. */
  17700. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17701. /**
  17702. * Remove a specific size gradient
  17703. * @param gradient defines the gradient to remove
  17704. * @returns the current particle system
  17705. */
  17706. removeSizeGradient(gradient: number): IParticleSystem;
  17707. /**
  17708. * Adds a new color remap gradient
  17709. * @param gradient defines the gradient to use (between 0 and 1)
  17710. * @param min defines the color remap minimal range
  17711. * @param max defines the color remap maximal range
  17712. * @returns the current particle system
  17713. */
  17714. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17715. /**
  17716. * Remove a specific color remap gradient
  17717. * @param gradient defines the gradient to remove
  17718. * @returns the current particle system
  17719. */
  17720. removeColorRemapGradient(gradient: number): IParticleSystem;
  17721. /**
  17722. * Adds a new alpha remap gradient
  17723. * @param gradient defines the gradient to use (between 0 and 1)
  17724. * @param min defines the alpha remap minimal range
  17725. * @param max defines the alpha remap maximal range
  17726. * @returns the current particle system
  17727. */
  17728. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17729. /**
  17730. * Remove a specific alpha remap gradient
  17731. * @param gradient defines the gradient to remove
  17732. * @returns the current particle system
  17733. */
  17734. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17735. /**
  17736. * Adds a new angular speed gradient
  17737. * @param gradient defines the gradient to use (between 0 and 1)
  17738. * @param factor defines the angular speed to affect to the specified gradient
  17739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17740. * @returns the current particle system
  17741. */
  17742. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17743. /**
  17744. * Remove a specific angular speed gradient
  17745. * @param gradient defines the gradient to remove
  17746. * @returns the current particle system
  17747. */
  17748. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17749. /**
  17750. * Adds a new velocity gradient
  17751. * @param gradient defines the gradient to use (between 0 and 1)
  17752. * @param factor defines the velocity to affect to the specified gradient
  17753. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17754. * @returns the current particle system
  17755. */
  17756. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17757. /**
  17758. * Remove a specific velocity gradient
  17759. * @param gradient defines the gradient to remove
  17760. * @returns the current particle system
  17761. */
  17762. removeVelocityGradient(gradient: number): IParticleSystem;
  17763. /**
  17764. * Adds a new limit velocity gradient
  17765. * @param gradient defines the gradient to use (between 0 and 1)
  17766. * @param factor defines the limit velocity value to affect to the specified gradient
  17767. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17768. * @returns the current particle system
  17769. */
  17770. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17771. /**
  17772. * Remove a specific limit velocity gradient
  17773. * @param gradient defines the gradient to remove
  17774. * @returns the current particle system
  17775. */
  17776. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17777. /**
  17778. * Adds a new drag gradient
  17779. * @param gradient defines the gradient to use (between 0 and 1)
  17780. * @param factor defines the drag value to affect to the specified gradient
  17781. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17782. * @returns the current particle system
  17783. */
  17784. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17785. /**
  17786. * Remove a specific drag gradient
  17787. * @param gradient defines the gradient to remove
  17788. * @returns the current particle system
  17789. */
  17790. removeDragGradient(gradient: number): IParticleSystem;
  17791. /**
  17792. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17793. * @param gradient defines the gradient to use (between 0 and 1)
  17794. * @param factor defines the emit rate value to affect to the specified gradient
  17795. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17796. * @returns the current particle system
  17797. */
  17798. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17799. /**
  17800. * Remove a specific emit rate gradient
  17801. * @param gradient defines the gradient to remove
  17802. * @returns the current particle system
  17803. */
  17804. removeEmitRateGradient(gradient: number): IParticleSystem;
  17805. /**
  17806. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17807. * @param gradient defines the gradient to use (between 0 and 1)
  17808. * @param factor defines the start size value to affect to the specified gradient
  17809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17810. * @returns the current particle system
  17811. */
  17812. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17813. /**
  17814. * Remove a specific start size gradient
  17815. * @param gradient defines the gradient to remove
  17816. * @returns the current particle system
  17817. */
  17818. removeStartSizeGradient(gradient: number): IParticleSystem;
  17819. private _createRampGradientTexture;
  17820. /**
  17821. * Gets the current list of ramp gradients.
  17822. * You must use addRampGradient and removeRampGradient to udpate this list
  17823. * @returns the list of ramp gradients
  17824. */
  17825. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17826. /**
  17827. * Adds a new ramp gradient used to remap particle colors
  17828. * @param gradient defines the gradient to use (between 0 and 1)
  17829. * @param color defines the color to affect to the specified gradient
  17830. * @returns the current particle system
  17831. */
  17832. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17833. /**
  17834. * Remove a specific ramp gradient
  17835. * @param gradient defines the gradient to remove
  17836. * @returns the current particle system
  17837. */
  17838. removeRampGradient(gradient: number): ParticleSystem;
  17839. /**
  17840. * Adds a new color gradient
  17841. * @param gradient defines the gradient to use (between 0 and 1)
  17842. * @param color1 defines the color to affect to the specified gradient
  17843. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17844. * @returns this particle system
  17845. */
  17846. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17847. /**
  17848. * Remove a specific color gradient
  17849. * @param gradient defines the gradient to remove
  17850. * @returns this particle system
  17851. */
  17852. removeColorGradient(gradient: number): IParticleSystem;
  17853. private _fetchR;
  17854. protected _reset(): void;
  17855. private _resetEffect;
  17856. private _createVertexBuffers;
  17857. private _createIndexBuffer;
  17858. /**
  17859. * Gets the maximum number of particles active at the same time.
  17860. * @returns The max number of active particles.
  17861. */
  17862. getCapacity(): number;
  17863. /**
  17864. * Gets whether there are still active particles in the system.
  17865. * @returns True if it is alive, otherwise false.
  17866. */
  17867. isAlive(): boolean;
  17868. /**
  17869. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17870. * @returns True if it has been started, otherwise false.
  17871. */
  17872. isStarted(): boolean;
  17873. private _prepareSubEmitterInternalArray;
  17874. /**
  17875. * Starts the particle system and begins to emit
  17876. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17877. */
  17878. start(delay?: number): void;
  17879. /**
  17880. * Stops the particle system.
  17881. * @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.
  17882. */
  17883. stop(stopSubEmitters?: boolean): void;
  17884. /**
  17885. * Remove all active particles
  17886. */
  17887. reset(): void;
  17888. /**
  17889. * @hidden (for internal use only)
  17890. */
  17891. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17892. /**
  17893. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17894. * Its lifetime will start back at 0.
  17895. */
  17896. recycleParticle: (particle: Particle) => void;
  17897. private _stopSubEmitters;
  17898. private _createParticle;
  17899. private _removeFromRoot;
  17900. private _emitFromParticle;
  17901. private _update;
  17902. /** @hidden */
  17903. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17904. /** @hidden */
  17905. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17906. /** @hidden */
  17907. private _getEffect;
  17908. /**
  17909. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17910. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17911. */
  17912. animate(preWarmOnly?: boolean): void;
  17913. private _appendParticleVertices;
  17914. /**
  17915. * Rebuilds the particle system.
  17916. */
  17917. rebuild(): void;
  17918. /**
  17919. * Is this system ready to be used/rendered
  17920. * @return true if the system is ready
  17921. */
  17922. isReady(): boolean;
  17923. private _render;
  17924. /**
  17925. * Renders the particle system in its current state.
  17926. * @returns the current number of particles
  17927. */
  17928. render(): number;
  17929. /**
  17930. * Disposes the particle system and free the associated resources
  17931. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17932. */
  17933. dispose(disposeTexture?: boolean): void;
  17934. /**
  17935. * Clones the particle system.
  17936. * @param name The name of the cloned object
  17937. * @param newEmitter The new emitter to use
  17938. * @returns the cloned particle system
  17939. */
  17940. clone(name: string, newEmitter: any): ParticleSystem;
  17941. /**
  17942. * Serializes the particle system to a JSON object.
  17943. * @returns the JSON object
  17944. */
  17945. serialize(): any;
  17946. /** @hidden */
  17947. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17948. /** @hidden */
  17949. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17950. /**
  17951. * Parses a JSON object to create a particle system.
  17952. * @param parsedParticleSystem The JSON object to parse
  17953. * @param scene The scene to create the particle system in
  17954. * @param rootUrl The root url to use to load external dependencies like texture
  17955. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17956. * @returns the Parsed particle system
  17957. */
  17958. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17959. }
  17960. }
  17961. declare module "babylonjs/Particles/particle" {
  17962. import { Nullable } from "babylonjs/types";
  17963. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17964. import { Color4 } from "babylonjs/Maths/math.color";
  17965. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17966. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17967. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17968. /**
  17969. * A particle represents one of the element emitted by a particle system.
  17970. * This is mainly define by its coordinates, direction, velocity and age.
  17971. */
  17972. export class Particle {
  17973. /**
  17974. * The particle system the particle belongs to.
  17975. */
  17976. particleSystem: ParticleSystem;
  17977. private static _Count;
  17978. /**
  17979. * Unique ID of the particle
  17980. */
  17981. id: number;
  17982. /**
  17983. * The world position of the particle in the scene.
  17984. */
  17985. position: Vector3;
  17986. /**
  17987. * The world direction of the particle in the scene.
  17988. */
  17989. direction: Vector3;
  17990. /**
  17991. * The color of the particle.
  17992. */
  17993. color: Color4;
  17994. /**
  17995. * The color change of the particle per step.
  17996. */
  17997. colorStep: Color4;
  17998. /**
  17999. * Defines how long will the life of the particle be.
  18000. */
  18001. lifeTime: number;
  18002. /**
  18003. * The current age of the particle.
  18004. */
  18005. age: number;
  18006. /**
  18007. * The current size of the particle.
  18008. */
  18009. size: number;
  18010. /**
  18011. * The current scale of the particle.
  18012. */
  18013. scale: Vector2;
  18014. /**
  18015. * The current angle of the particle.
  18016. */
  18017. angle: number;
  18018. /**
  18019. * Defines how fast is the angle changing.
  18020. */
  18021. angularSpeed: number;
  18022. /**
  18023. * Defines the cell index used by the particle to be rendered from a sprite.
  18024. */
  18025. cellIndex: number;
  18026. /**
  18027. * The information required to support color remapping
  18028. */
  18029. remapData: Vector4;
  18030. /** @hidden */
  18031. _randomCellOffset?: number;
  18032. /** @hidden */
  18033. _initialDirection: Nullable<Vector3>;
  18034. /** @hidden */
  18035. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18036. /** @hidden */
  18037. _initialStartSpriteCellID: number;
  18038. /** @hidden */
  18039. _initialEndSpriteCellID: number;
  18040. /** @hidden */
  18041. _currentColorGradient: Nullable<ColorGradient>;
  18042. /** @hidden */
  18043. _currentColor1: Color4;
  18044. /** @hidden */
  18045. _currentColor2: Color4;
  18046. /** @hidden */
  18047. _currentSizeGradient: Nullable<FactorGradient>;
  18048. /** @hidden */
  18049. _currentSize1: number;
  18050. /** @hidden */
  18051. _currentSize2: number;
  18052. /** @hidden */
  18053. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18054. /** @hidden */
  18055. _currentAngularSpeed1: number;
  18056. /** @hidden */
  18057. _currentAngularSpeed2: number;
  18058. /** @hidden */
  18059. _currentVelocityGradient: Nullable<FactorGradient>;
  18060. /** @hidden */
  18061. _currentVelocity1: number;
  18062. /** @hidden */
  18063. _currentVelocity2: number;
  18064. /** @hidden */
  18065. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18066. /** @hidden */
  18067. _currentLimitVelocity1: number;
  18068. /** @hidden */
  18069. _currentLimitVelocity2: number;
  18070. /** @hidden */
  18071. _currentDragGradient: Nullable<FactorGradient>;
  18072. /** @hidden */
  18073. _currentDrag1: number;
  18074. /** @hidden */
  18075. _currentDrag2: number;
  18076. /** @hidden */
  18077. _randomNoiseCoordinates1: Vector3;
  18078. /** @hidden */
  18079. _randomNoiseCoordinates2: Vector3;
  18080. /**
  18081. * Creates a new instance Particle
  18082. * @param particleSystem the particle system the particle belongs to
  18083. */
  18084. constructor(
  18085. /**
  18086. * The particle system the particle belongs to.
  18087. */
  18088. particleSystem: ParticleSystem);
  18089. private updateCellInfoFromSystem;
  18090. /**
  18091. * Defines how the sprite cell index is updated for the particle
  18092. */
  18093. updateCellIndex(): void;
  18094. /** @hidden */
  18095. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18096. /** @hidden */
  18097. _inheritParticleInfoToSubEmitters(): void;
  18098. /** @hidden */
  18099. _reset(): void;
  18100. /**
  18101. * Copy the properties of particle to another one.
  18102. * @param other the particle to copy the information to.
  18103. */
  18104. copyTo(other: Particle): void;
  18105. }
  18106. }
  18107. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18108. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18109. import { Effect } from "babylonjs/Materials/effect";
  18110. import { Particle } from "babylonjs/Particles/particle";
  18111. /**
  18112. * Particle emitter represents a volume emitting particles.
  18113. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18114. */
  18115. export interface IParticleEmitterType {
  18116. /**
  18117. * Called by the particle System when the direction is computed for the created particle.
  18118. * @param worldMatrix is the world matrix of the particle system
  18119. * @param directionToUpdate is the direction vector to update with the result
  18120. * @param particle is the particle we are computed the direction for
  18121. */
  18122. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18123. /**
  18124. * Called by the particle System when the position is computed for the created particle.
  18125. * @param worldMatrix is the world matrix of the particle system
  18126. * @param positionToUpdate is the position vector to update with the result
  18127. * @param particle is the particle we are computed the position for
  18128. */
  18129. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18130. /**
  18131. * Clones the current emitter and returns a copy of it
  18132. * @returns the new emitter
  18133. */
  18134. clone(): IParticleEmitterType;
  18135. /**
  18136. * Called by the GPUParticleSystem to setup the update shader
  18137. * @param effect defines the update shader
  18138. */
  18139. applyToShader(effect: Effect): void;
  18140. /**
  18141. * Returns a string to use to update the GPU particles update shader
  18142. * @returns the effect defines string
  18143. */
  18144. getEffectDefines(): string;
  18145. /**
  18146. * Returns a string representing the class name
  18147. * @returns a string containing the class name
  18148. */
  18149. getClassName(): string;
  18150. /**
  18151. * Serializes the particle system to a JSON object.
  18152. * @returns the JSON object
  18153. */
  18154. serialize(): any;
  18155. /**
  18156. * Parse properties from a JSON object
  18157. * @param serializationObject defines the JSON object
  18158. */
  18159. parse(serializationObject: any): void;
  18160. }
  18161. }
  18162. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18163. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18164. import { Effect } from "babylonjs/Materials/effect";
  18165. import { Particle } from "babylonjs/Particles/particle";
  18166. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18167. /**
  18168. * Particle emitter emitting particles from the inside of a box.
  18169. * It emits the particles randomly between 2 given directions.
  18170. */
  18171. export class BoxParticleEmitter implements IParticleEmitterType {
  18172. /**
  18173. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18174. */
  18175. direction1: Vector3;
  18176. /**
  18177. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18178. */
  18179. direction2: Vector3;
  18180. /**
  18181. * 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.
  18182. */
  18183. minEmitBox: Vector3;
  18184. /**
  18185. * 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.
  18186. */
  18187. maxEmitBox: Vector3;
  18188. /**
  18189. * Creates a new instance BoxParticleEmitter
  18190. */
  18191. constructor();
  18192. /**
  18193. * Called by the particle System when the direction is computed for the created particle.
  18194. * @param worldMatrix is the world matrix of the particle system
  18195. * @param directionToUpdate is the direction vector to update with the result
  18196. * @param particle is the particle we are computed the direction for
  18197. */
  18198. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18199. /**
  18200. * Called by the particle System when the position is computed for the created particle.
  18201. * @param worldMatrix is the world matrix of the particle system
  18202. * @param positionToUpdate is the position vector to update with the result
  18203. * @param particle is the particle we are computed the position for
  18204. */
  18205. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18206. /**
  18207. * Clones the current emitter and returns a copy of it
  18208. * @returns the new emitter
  18209. */
  18210. clone(): BoxParticleEmitter;
  18211. /**
  18212. * Called by the GPUParticleSystem to setup the update shader
  18213. * @param effect defines the update shader
  18214. */
  18215. applyToShader(effect: Effect): void;
  18216. /**
  18217. * Returns a string to use to update the GPU particles update shader
  18218. * @returns a string containng the defines string
  18219. */
  18220. getEffectDefines(): string;
  18221. /**
  18222. * Returns the string "BoxParticleEmitter"
  18223. * @returns a string containing the class name
  18224. */
  18225. getClassName(): string;
  18226. /**
  18227. * Serializes the particle system to a JSON object.
  18228. * @returns the JSON object
  18229. */
  18230. serialize(): any;
  18231. /**
  18232. * Parse properties from a JSON object
  18233. * @param serializationObject defines the JSON object
  18234. */
  18235. parse(serializationObject: any): void;
  18236. }
  18237. }
  18238. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18239. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18240. import { Effect } from "babylonjs/Materials/effect";
  18241. import { Particle } from "babylonjs/Particles/particle";
  18242. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18243. /**
  18244. * Particle emitter emitting particles from the inside of a cone.
  18245. * It emits the particles alongside the cone volume from the base to the particle.
  18246. * The emission direction might be randomized.
  18247. */
  18248. export class ConeParticleEmitter implements IParticleEmitterType {
  18249. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18250. directionRandomizer: number;
  18251. private _radius;
  18252. private _angle;
  18253. private _height;
  18254. /**
  18255. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18256. */
  18257. radiusRange: number;
  18258. /**
  18259. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18260. */
  18261. heightRange: number;
  18262. /**
  18263. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18264. */
  18265. emitFromSpawnPointOnly: boolean;
  18266. /**
  18267. * Gets or sets the radius of the emission cone
  18268. */
  18269. radius: number;
  18270. /**
  18271. * Gets or sets the angle of the emission cone
  18272. */
  18273. angle: number;
  18274. private _buildHeight;
  18275. /**
  18276. * Creates a new instance ConeParticleEmitter
  18277. * @param radius the radius of the emission cone (1 by default)
  18278. * @param angle the cone base angle (PI by default)
  18279. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18280. */
  18281. constructor(radius?: number, angle?: number,
  18282. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18283. directionRandomizer?: number);
  18284. /**
  18285. * Called by the particle System when the direction is computed for the created particle.
  18286. * @param worldMatrix is the world matrix of the particle system
  18287. * @param directionToUpdate is the direction vector to update with the result
  18288. * @param particle is the particle we are computed the direction for
  18289. */
  18290. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18291. /**
  18292. * Called by the particle System when the position is computed for the created particle.
  18293. * @param worldMatrix is the world matrix of the particle system
  18294. * @param positionToUpdate is the position vector to update with the result
  18295. * @param particle is the particle we are computed the position for
  18296. */
  18297. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18298. /**
  18299. * Clones the current emitter and returns a copy of it
  18300. * @returns the new emitter
  18301. */
  18302. clone(): ConeParticleEmitter;
  18303. /**
  18304. * Called by the GPUParticleSystem to setup the update shader
  18305. * @param effect defines the update shader
  18306. */
  18307. applyToShader(effect: Effect): void;
  18308. /**
  18309. * Returns a string to use to update the GPU particles update shader
  18310. * @returns a string containng the defines string
  18311. */
  18312. getEffectDefines(): string;
  18313. /**
  18314. * Returns the string "ConeParticleEmitter"
  18315. * @returns a string containing the class name
  18316. */
  18317. getClassName(): string;
  18318. /**
  18319. * Serializes the particle system to a JSON object.
  18320. * @returns the JSON object
  18321. */
  18322. serialize(): any;
  18323. /**
  18324. * Parse properties from a JSON object
  18325. * @param serializationObject defines the JSON object
  18326. */
  18327. parse(serializationObject: any): void;
  18328. }
  18329. }
  18330. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18331. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18332. import { Effect } from "babylonjs/Materials/effect";
  18333. import { Particle } from "babylonjs/Particles/particle";
  18334. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18335. /**
  18336. * Particle emitter emitting particles from the inside of a cylinder.
  18337. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18338. */
  18339. export class CylinderParticleEmitter implements IParticleEmitterType {
  18340. /**
  18341. * The radius of the emission cylinder.
  18342. */
  18343. radius: number;
  18344. /**
  18345. * The height of the emission cylinder.
  18346. */
  18347. height: number;
  18348. /**
  18349. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18350. */
  18351. radiusRange: number;
  18352. /**
  18353. * How much to randomize the particle direction [0-1].
  18354. */
  18355. directionRandomizer: number;
  18356. /**
  18357. * Creates a new instance CylinderParticleEmitter
  18358. * @param radius the radius of the emission cylinder (1 by default)
  18359. * @param height the height of the emission cylinder (1 by default)
  18360. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18361. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18362. */
  18363. constructor(
  18364. /**
  18365. * The radius of the emission cylinder.
  18366. */
  18367. radius?: number,
  18368. /**
  18369. * The height of the emission cylinder.
  18370. */
  18371. height?: number,
  18372. /**
  18373. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18374. */
  18375. radiusRange?: number,
  18376. /**
  18377. * How much to randomize the particle direction [0-1].
  18378. */
  18379. directionRandomizer?: number);
  18380. /**
  18381. * Called by the particle System when the direction is computed for the created particle.
  18382. * @param worldMatrix is the world matrix of the particle system
  18383. * @param directionToUpdate is the direction vector to update with the result
  18384. * @param particle is the particle we are computed the direction for
  18385. */
  18386. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18387. /**
  18388. * Called by the particle System when the position is computed for the created particle.
  18389. * @param worldMatrix is the world matrix of the particle system
  18390. * @param positionToUpdate is the position vector to update with the result
  18391. * @param particle is the particle we are computed the position for
  18392. */
  18393. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18394. /**
  18395. * Clones the current emitter and returns a copy of it
  18396. * @returns the new emitter
  18397. */
  18398. clone(): CylinderParticleEmitter;
  18399. /**
  18400. * Called by the GPUParticleSystem to setup the update shader
  18401. * @param effect defines the update shader
  18402. */
  18403. applyToShader(effect: Effect): void;
  18404. /**
  18405. * Returns a string to use to update the GPU particles update shader
  18406. * @returns a string containng the defines string
  18407. */
  18408. getEffectDefines(): string;
  18409. /**
  18410. * Returns the string "CylinderParticleEmitter"
  18411. * @returns a string containing the class name
  18412. */
  18413. getClassName(): string;
  18414. /**
  18415. * Serializes the particle system to a JSON object.
  18416. * @returns the JSON object
  18417. */
  18418. serialize(): any;
  18419. /**
  18420. * Parse properties from a JSON object
  18421. * @param serializationObject defines the JSON object
  18422. */
  18423. parse(serializationObject: any): void;
  18424. }
  18425. /**
  18426. * Particle emitter emitting particles from the inside of a cylinder.
  18427. * It emits the particles randomly between two vectors.
  18428. */
  18429. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18430. /**
  18431. * The min limit of the emission direction.
  18432. */
  18433. direction1: Vector3;
  18434. /**
  18435. * The max limit of the emission direction.
  18436. */
  18437. direction2: Vector3;
  18438. /**
  18439. * Creates a new instance CylinderDirectedParticleEmitter
  18440. * @param radius the radius of the emission cylinder (1 by default)
  18441. * @param height the height of the emission cylinder (1 by default)
  18442. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18443. * @param direction1 the min limit of the emission direction (up vector by default)
  18444. * @param direction2 the max limit of the emission direction (up vector by default)
  18445. */
  18446. constructor(radius?: number, height?: number, radiusRange?: number,
  18447. /**
  18448. * The min limit of the emission direction.
  18449. */
  18450. direction1?: Vector3,
  18451. /**
  18452. * The max limit of the emission direction.
  18453. */
  18454. direction2?: Vector3);
  18455. /**
  18456. * Called by the particle System when the direction is computed for the created particle.
  18457. * @param worldMatrix is the world matrix of the particle system
  18458. * @param directionToUpdate is the direction vector to update with the result
  18459. * @param particle is the particle we are computed the direction for
  18460. */
  18461. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18462. /**
  18463. * Clones the current emitter and returns a copy of it
  18464. * @returns the new emitter
  18465. */
  18466. clone(): CylinderDirectedParticleEmitter;
  18467. /**
  18468. * Called by the GPUParticleSystem to setup the update shader
  18469. * @param effect defines the update shader
  18470. */
  18471. applyToShader(effect: Effect): void;
  18472. /**
  18473. * Returns a string to use to update the GPU particles update shader
  18474. * @returns a string containng the defines string
  18475. */
  18476. getEffectDefines(): string;
  18477. /**
  18478. * Returns the string "CylinderDirectedParticleEmitter"
  18479. * @returns a string containing the class name
  18480. */
  18481. getClassName(): string;
  18482. /**
  18483. * Serializes the particle system to a JSON object.
  18484. * @returns the JSON object
  18485. */
  18486. serialize(): any;
  18487. /**
  18488. * Parse properties from a JSON object
  18489. * @param serializationObject defines the JSON object
  18490. */
  18491. parse(serializationObject: any): void;
  18492. }
  18493. }
  18494. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18495. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18496. import { Effect } from "babylonjs/Materials/effect";
  18497. import { Particle } from "babylonjs/Particles/particle";
  18498. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18499. /**
  18500. * Particle emitter emitting particles from the inside of a hemisphere.
  18501. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18502. */
  18503. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18504. /**
  18505. * The radius of the emission hemisphere.
  18506. */
  18507. radius: number;
  18508. /**
  18509. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18510. */
  18511. radiusRange: number;
  18512. /**
  18513. * How much to randomize the particle direction [0-1].
  18514. */
  18515. directionRandomizer: number;
  18516. /**
  18517. * Creates a new instance HemisphericParticleEmitter
  18518. * @param radius the radius of the emission hemisphere (1 by default)
  18519. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18520. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18521. */
  18522. constructor(
  18523. /**
  18524. * The radius of the emission hemisphere.
  18525. */
  18526. radius?: number,
  18527. /**
  18528. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18529. */
  18530. radiusRange?: number,
  18531. /**
  18532. * How much to randomize the particle direction [0-1].
  18533. */
  18534. directionRandomizer?: number);
  18535. /**
  18536. * Called by the particle System when the direction is computed for the created particle.
  18537. * @param worldMatrix is the world matrix of the particle system
  18538. * @param directionToUpdate is the direction vector to update with the result
  18539. * @param particle is the particle we are computed the direction for
  18540. */
  18541. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18542. /**
  18543. * Called by the particle System when the position is computed for the created particle.
  18544. * @param worldMatrix is the world matrix of the particle system
  18545. * @param positionToUpdate is the position vector to update with the result
  18546. * @param particle is the particle we are computed the position for
  18547. */
  18548. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18549. /**
  18550. * Clones the current emitter and returns a copy of it
  18551. * @returns the new emitter
  18552. */
  18553. clone(): HemisphericParticleEmitter;
  18554. /**
  18555. * Called by the GPUParticleSystem to setup the update shader
  18556. * @param effect defines the update shader
  18557. */
  18558. applyToShader(effect: Effect): void;
  18559. /**
  18560. * Returns a string to use to update the GPU particles update shader
  18561. * @returns a string containng the defines string
  18562. */
  18563. getEffectDefines(): string;
  18564. /**
  18565. * Returns the string "HemisphericParticleEmitter"
  18566. * @returns a string containing the class name
  18567. */
  18568. getClassName(): string;
  18569. /**
  18570. * Serializes the particle system to a JSON object.
  18571. * @returns the JSON object
  18572. */
  18573. serialize(): any;
  18574. /**
  18575. * Parse properties from a JSON object
  18576. * @param serializationObject defines the JSON object
  18577. */
  18578. parse(serializationObject: any): void;
  18579. }
  18580. }
  18581. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18582. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18583. import { Effect } from "babylonjs/Materials/effect";
  18584. import { Particle } from "babylonjs/Particles/particle";
  18585. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18586. /**
  18587. * Particle emitter emitting particles from a point.
  18588. * It emits the particles randomly between 2 given directions.
  18589. */
  18590. export class PointParticleEmitter implements IParticleEmitterType {
  18591. /**
  18592. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18593. */
  18594. direction1: Vector3;
  18595. /**
  18596. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18597. */
  18598. direction2: Vector3;
  18599. /**
  18600. * Creates a new instance PointParticleEmitter
  18601. */
  18602. constructor();
  18603. /**
  18604. * Called by the particle System when the direction is computed for the created particle.
  18605. * @param worldMatrix is the world matrix of the particle system
  18606. * @param directionToUpdate is the direction vector to update with the result
  18607. * @param particle is the particle we are computed the direction for
  18608. */
  18609. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18610. /**
  18611. * Called by the particle System when the position is computed for the created particle.
  18612. * @param worldMatrix is the world matrix of the particle system
  18613. * @param positionToUpdate is the position vector to update with the result
  18614. * @param particle is the particle we are computed the position for
  18615. */
  18616. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18617. /**
  18618. * Clones the current emitter and returns a copy of it
  18619. * @returns the new emitter
  18620. */
  18621. clone(): PointParticleEmitter;
  18622. /**
  18623. * Called by the GPUParticleSystem to setup the update shader
  18624. * @param effect defines the update shader
  18625. */
  18626. applyToShader(effect: Effect): void;
  18627. /**
  18628. * Returns a string to use to update the GPU particles update shader
  18629. * @returns a string containng the defines string
  18630. */
  18631. getEffectDefines(): string;
  18632. /**
  18633. * Returns the string "PointParticleEmitter"
  18634. * @returns a string containing the class name
  18635. */
  18636. getClassName(): string;
  18637. /**
  18638. * Serializes the particle system to a JSON object.
  18639. * @returns the JSON object
  18640. */
  18641. serialize(): any;
  18642. /**
  18643. * Parse properties from a JSON object
  18644. * @param serializationObject defines the JSON object
  18645. */
  18646. parse(serializationObject: any): void;
  18647. }
  18648. }
  18649. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18650. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18651. import { Effect } from "babylonjs/Materials/effect";
  18652. import { Particle } from "babylonjs/Particles/particle";
  18653. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18654. /**
  18655. * Particle emitter emitting particles from the inside of a sphere.
  18656. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18657. */
  18658. export class SphereParticleEmitter implements IParticleEmitterType {
  18659. /**
  18660. * The radius of the emission sphere.
  18661. */
  18662. radius: number;
  18663. /**
  18664. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18665. */
  18666. radiusRange: number;
  18667. /**
  18668. * How much to randomize the particle direction [0-1].
  18669. */
  18670. directionRandomizer: number;
  18671. /**
  18672. * Creates a new instance SphereParticleEmitter
  18673. * @param radius the radius of the emission sphere (1 by default)
  18674. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18675. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18676. */
  18677. constructor(
  18678. /**
  18679. * The radius of the emission sphere.
  18680. */
  18681. radius?: number,
  18682. /**
  18683. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18684. */
  18685. radiusRange?: number,
  18686. /**
  18687. * How much to randomize the particle direction [0-1].
  18688. */
  18689. directionRandomizer?: number);
  18690. /**
  18691. * Called by the particle System when the direction is computed for the created particle.
  18692. * @param worldMatrix is the world matrix of the particle system
  18693. * @param directionToUpdate is the direction vector to update with the result
  18694. * @param particle is the particle we are computed the direction for
  18695. */
  18696. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18697. /**
  18698. * Called by the particle System when the position is computed for the created particle.
  18699. * @param worldMatrix is the world matrix of the particle system
  18700. * @param positionToUpdate is the position vector to update with the result
  18701. * @param particle is the particle we are computed the position for
  18702. */
  18703. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18704. /**
  18705. * Clones the current emitter and returns a copy of it
  18706. * @returns the new emitter
  18707. */
  18708. clone(): SphereParticleEmitter;
  18709. /**
  18710. * Called by the GPUParticleSystem to setup the update shader
  18711. * @param effect defines the update shader
  18712. */
  18713. applyToShader(effect: Effect): void;
  18714. /**
  18715. * Returns a string to use to update the GPU particles update shader
  18716. * @returns a string containng the defines string
  18717. */
  18718. getEffectDefines(): string;
  18719. /**
  18720. * Returns the string "SphereParticleEmitter"
  18721. * @returns a string containing the class name
  18722. */
  18723. getClassName(): string;
  18724. /**
  18725. * Serializes the particle system to a JSON object.
  18726. * @returns the JSON object
  18727. */
  18728. serialize(): any;
  18729. /**
  18730. * Parse properties from a JSON object
  18731. * @param serializationObject defines the JSON object
  18732. */
  18733. parse(serializationObject: any): void;
  18734. }
  18735. /**
  18736. * Particle emitter emitting particles from the inside of a sphere.
  18737. * It emits the particles randomly between two vectors.
  18738. */
  18739. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18740. /**
  18741. * The min limit of the emission direction.
  18742. */
  18743. direction1: Vector3;
  18744. /**
  18745. * The max limit of the emission direction.
  18746. */
  18747. direction2: Vector3;
  18748. /**
  18749. * Creates a new instance SphereDirectedParticleEmitter
  18750. * @param radius the radius of the emission sphere (1 by default)
  18751. * @param direction1 the min limit of the emission direction (up vector by default)
  18752. * @param direction2 the max limit of the emission direction (up vector by default)
  18753. */
  18754. constructor(radius?: number,
  18755. /**
  18756. * The min limit of the emission direction.
  18757. */
  18758. direction1?: Vector3,
  18759. /**
  18760. * The max limit of the emission direction.
  18761. */
  18762. direction2?: Vector3);
  18763. /**
  18764. * Called by the particle System when the direction is computed for the created particle.
  18765. * @param worldMatrix is the world matrix of the particle system
  18766. * @param directionToUpdate is the direction vector to update with the result
  18767. * @param particle is the particle we are computed the direction for
  18768. */
  18769. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18770. /**
  18771. * Clones the current emitter and returns a copy of it
  18772. * @returns the new emitter
  18773. */
  18774. clone(): SphereDirectedParticleEmitter;
  18775. /**
  18776. * Called by the GPUParticleSystem to setup the update shader
  18777. * @param effect defines the update shader
  18778. */
  18779. applyToShader(effect: Effect): void;
  18780. /**
  18781. * Returns a string to use to update the GPU particles update shader
  18782. * @returns a string containng the defines string
  18783. */
  18784. getEffectDefines(): string;
  18785. /**
  18786. * Returns the string "SphereDirectedParticleEmitter"
  18787. * @returns a string containing the class name
  18788. */
  18789. getClassName(): string;
  18790. /**
  18791. * Serializes the particle system to a JSON object.
  18792. * @returns the JSON object
  18793. */
  18794. serialize(): any;
  18795. /**
  18796. * Parse properties from a JSON object
  18797. * @param serializationObject defines the JSON object
  18798. */
  18799. parse(serializationObject: any): void;
  18800. }
  18801. }
  18802. declare module "babylonjs/Particles/EmitterTypes/index" {
  18803. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18804. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18805. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18806. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18807. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18808. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18809. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18810. }
  18811. declare module "babylonjs/Particles/IParticleSystem" {
  18812. import { Nullable } from "babylonjs/types";
  18813. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18814. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18816. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18817. import { Texture } from "babylonjs/Materials/Textures/texture";
  18818. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18819. import { Scene } from "babylonjs/scene";
  18820. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18821. import { Animation } from "babylonjs/Animations/animation";
  18822. /**
  18823. * Interface representing a particle system in Babylon.js.
  18824. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18825. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18826. */
  18827. export interface IParticleSystem {
  18828. /**
  18829. * List of animations used by the particle system.
  18830. */
  18831. animations: Animation[];
  18832. /**
  18833. * The id of the Particle system.
  18834. */
  18835. id: string;
  18836. /**
  18837. * The name of the Particle system.
  18838. */
  18839. name: string;
  18840. /**
  18841. * The emitter represents the Mesh or position we are attaching the particle system to.
  18842. */
  18843. emitter: Nullable<AbstractMesh | Vector3>;
  18844. /**
  18845. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18846. */
  18847. isBillboardBased: boolean;
  18848. /**
  18849. * The rendering group used by the Particle system to chose when to render.
  18850. */
  18851. renderingGroupId: number;
  18852. /**
  18853. * The layer mask we are rendering the particles through.
  18854. */
  18855. layerMask: number;
  18856. /**
  18857. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18858. */
  18859. updateSpeed: number;
  18860. /**
  18861. * The amount of time the particle system is running (depends of the overall update speed).
  18862. */
  18863. targetStopDuration: number;
  18864. /**
  18865. * The texture used to render each particle. (this can be a spritesheet)
  18866. */
  18867. particleTexture: Nullable<Texture>;
  18868. /**
  18869. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18870. */
  18871. blendMode: number;
  18872. /**
  18873. * Minimum life time of emitting particles.
  18874. */
  18875. minLifeTime: number;
  18876. /**
  18877. * Maximum life time of emitting particles.
  18878. */
  18879. maxLifeTime: number;
  18880. /**
  18881. * Minimum Size of emitting particles.
  18882. */
  18883. minSize: number;
  18884. /**
  18885. * Maximum Size of emitting particles.
  18886. */
  18887. maxSize: number;
  18888. /**
  18889. * Minimum scale of emitting particles on X axis.
  18890. */
  18891. minScaleX: number;
  18892. /**
  18893. * Maximum scale of emitting particles on X axis.
  18894. */
  18895. maxScaleX: number;
  18896. /**
  18897. * Minimum scale of emitting particles on Y axis.
  18898. */
  18899. minScaleY: number;
  18900. /**
  18901. * Maximum scale of emitting particles on Y axis.
  18902. */
  18903. maxScaleY: number;
  18904. /**
  18905. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18906. */
  18907. color1: Color4;
  18908. /**
  18909. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18910. */
  18911. color2: Color4;
  18912. /**
  18913. * Color the particle will have at the end of its lifetime.
  18914. */
  18915. colorDead: Color4;
  18916. /**
  18917. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18918. */
  18919. emitRate: number;
  18920. /**
  18921. * You can use gravity if you want to give an orientation to your particles.
  18922. */
  18923. gravity: Vector3;
  18924. /**
  18925. * Minimum power of emitting particles.
  18926. */
  18927. minEmitPower: number;
  18928. /**
  18929. * Maximum power of emitting particles.
  18930. */
  18931. maxEmitPower: number;
  18932. /**
  18933. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18934. */
  18935. minAngularSpeed: number;
  18936. /**
  18937. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18938. */
  18939. maxAngularSpeed: number;
  18940. /**
  18941. * Gets or sets the minimal initial rotation in radians.
  18942. */
  18943. minInitialRotation: number;
  18944. /**
  18945. * Gets or sets the maximal initial rotation in radians.
  18946. */
  18947. maxInitialRotation: number;
  18948. /**
  18949. * The particle emitter type defines the emitter used by the particle system.
  18950. * It can be for example box, sphere, or cone...
  18951. */
  18952. particleEmitterType: Nullable<IParticleEmitterType>;
  18953. /**
  18954. * Defines the delay in milliseconds before starting the system (0 by default)
  18955. */
  18956. startDelay: number;
  18957. /**
  18958. * 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
  18959. */
  18960. preWarmCycles: number;
  18961. /**
  18962. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18963. */
  18964. preWarmStepOffset: number;
  18965. /**
  18966. * 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)
  18967. */
  18968. spriteCellChangeSpeed: number;
  18969. /**
  18970. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18971. */
  18972. startSpriteCellID: number;
  18973. /**
  18974. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18975. */
  18976. endSpriteCellID: number;
  18977. /**
  18978. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18979. */
  18980. spriteCellWidth: number;
  18981. /**
  18982. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18983. */
  18984. spriteCellHeight: number;
  18985. /**
  18986. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18987. */
  18988. spriteRandomStartCell: boolean;
  18989. /**
  18990. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18991. */
  18992. isAnimationSheetEnabled: boolean;
  18993. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18994. translationPivot: Vector2;
  18995. /**
  18996. * Gets or sets a texture used to add random noise to particle positions
  18997. */
  18998. noiseTexture: Nullable<BaseTexture>;
  18999. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19000. noiseStrength: Vector3;
  19001. /**
  19002. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19003. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19004. */
  19005. billboardMode: number;
  19006. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19007. limitVelocityDamping: number;
  19008. /**
  19009. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19010. */
  19011. beginAnimationOnStart: boolean;
  19012. /**
  19013. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19014. */
  19015. beginAnimationFrom: number;
  19016. /**
  19017. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19018. */
  19019. beginAnimationTo: number;
  19020. /**
  19021. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19022. */
  19023. beginAnimationLoop: boolean;
  19024. /**
  19025. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19026. */
  19027. disposeOnStop: boolean;
  19028. /**
  19029. * Gets the maximum number of particles active at the same time.
  19030. * @returns The max number of active particles.
  19031. */
  19032. getCapacity(): number;
  19033. /**
  19034. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19035. * @returns True if it has been started, otherwise false.
  19036. */
  19037. isStarted(): boolean;
  19038. /**
  19039. * Animates the particle system for this frame.
  19040. */
  19041. animate(): void;
  19042. /**
  19043. * Renders the particle system in its current state.
  19044. * @returns the current number of particles
  19045. */
  19046. render(): number;
  19047. /**
  19048. * Dispose the particle system and frees its associated resources.
  19049. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19050. */
  19051. dispose(disposeTexture?: boolean): void;
  19052. /**
  19053. * Clones the particle system.
  19054. * @param name The name of the cloned object
  19055. * @param newEmitter The new emitter to use
  19056. * @returns the cloned particle system
  19057. */
  19058. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19059. /**
  19060. * Serializes the particle system to a JSON object.
  19061. * @returns the JSON object
  19062. */
  19063. serialize(): any;
  19064. /**
  19065. * Rebuild the particle system
  19066. */
  19067. rebuild(): void;
  19068. /**
  19069. * Starts the particle system and begins to emit
  19070. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19071. */
  19072. start(delay?: number): void;
  19073. /**
  19074. * Stops the particle system.
  19075. */
  19076. stop(): void;
  19077. /**
  19078. * Remove all active particles
  19079. */
  19080. reset(): void;
  19081. /**
  19082. * Is this system ready to be used/rendered
  19083. * @return true if the system is ready
  19084. */
  19085. isReady(): boolean;
  19086. /**
  19087. * Adds a new color gradient
  19088. * @param gradient defines the gradient to use (between 0 and 1)
  19089. * @param color1 defines the color to affect to the specified gradient
  19090. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19091. * @returns the current particle system
  19092. */
  19093. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19094. /**
  19095. * Remove a specific color gradient
  19096. * @param gradient defines the gradient to remove
  19097. * @returns the current particle system
  19098. */
  19099. removeColorGradient(gradient: number): IParticleSystem;
  19100. /**
  19101. * Adds a new size gradient
  19102. * @param gradient defines the gradient to use (between 0 and 1)
  19103. * @param factor defines the size factor to affect to the specified gradient
  19104. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19105. * @returns the current particle system
  19106. */
  19107. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19108. /**
  19109. * Remove a specific size gradient
  19110. * @param gradient defines the gradient to remove
  19111. * @returns the current particle system
  19112. */
  19113. removeSizeGradient(gradient: number): IParticleSystem;
  19114. /**
  19115. * Gets the current list of color gradients.
  19116. * You must use addColorGradient and removeColorGradient to udpate this list
  19117. * @returns the list of color gradients
  19118. */
  19119. getColorGradients(): Nullable<Array<ColorGradient>>;
  19120. /**
  19121. * Gets the current list of size gradients.
  19122. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19123. * @returns the list of size gradients
  19124. */
  19125. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19126. /**
  19127. * Gets the current list of angular speed gradients.
  19128. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19129. * @returns the list of angular speed gradients
  19130. */
  19131. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19132. /**
  19133. * Adds a new angular speed gradient
  19134. * @param gradient defines the gradient to use (between 0 and 1)
  19135. * @param factor defines the angular speed to affect to the specified gradient
  19136. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19137. * @returns the current particle system
  19138. */
  19139. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19140. /**
  19141. * Remove a specific angular speed gradient
  19142. * @param gradient defines the gradient to remove
  19143. * @returns the current particle system
  19144. */
  19145. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19146. /**
  19147. * Gets the current list of velocity gradients.
  19148. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19149. * @returns the list of velocity gradients
  19150. */
  19151. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19152. /**
  19153. * Adds a new velocity gradient
  19154. * @param gradient defines the gradient to use (between 0 and 1)
  19155. * @param factor defines the velocity to affect to the specified gradient
  19156. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19157. * @returns the current particle system
  19158. */
  19159. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19160. /**
  19161. * Remove a specific velocity gradient
  19162. * @param gradient defines the gradient to remove
  19163. * @returns the current particle system
  19164. */
  19165. removeVelocityGradient(gradient: number): IParticleSystem;
  19166. /**
  19167. * Gets the current list of limit velocity gradients.
  19168. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19169. * @returns the list of limit velocity gradients
  19170. */
  19171. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19172. /**
  19173. * Adds a new limit velocity gradient
  19174. * @param gradient defines the gradient to use (between 0 and 1)
  19175. * @param factor defines the limit velocity to affect to the specified gradient
  19176. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19177. * @returns the current particle system
  19178. */
  19179. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19180. /**
  19181. * Remove a specific limit velocity gradient
  19182. * @param gradient defines the gradient to remove
  19183. * @returns the current particle system
  19184. */
  19185. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19186. /**
  19187. * Adds a new drag gradient
  19188. * @param gradient defines the gradient to use (between 0 and 1)
  19189. * @param factor defines the drag to affect to the specified gradient
  19190. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19191. * @returns the current particle system
  19192. */
  19193. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19194. /**
  19195. * Remove a specific drag gradient
  19196. * @param gradient defines the gradient to remove
  19197. * @returns the current particle system
  19198. */
  19199. removeDragGradient(gradient: number): IParticleSystem;
  19200. /**
  19201. * Gets the current list of drag gradients.
  19202. * You must use addDragGradient and removeDragGradient to udpate this list
  19203. * @returns the list of drag gradients
  19204. */
  19205. getDragGradients(): Nullable<Array<FactorGradient>>;
  19206. /**
  19207. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19208. * @param gradient defines the gradient to use (between 0 and 1)
  19209. * @param factor defines the emit rate to affect to the specified gradient
  19210. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19211. * @returns the current particle system
  19212. */
  19213. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19214. /**
  19215. * Remove a specific emit rate gradient
  19216. * @param gradient defines the gradient to remove
  19217. * @returns the current particle system
  19218. */
  19219. removeEmitRateGradient(gradient: number): IParticleSystem;
  19220. /**
  19221. * Gets the current list of emit rate gradients.
  19222. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19223. * @returns the list of emit rate gradients
  19224. */
  19225. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19226. /**
  19227. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19228. * @param gradient defines the gradient to use (between 0 and 1)
  19229. * @param factor defines the start size to affect to the specified gradient
  19230. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19231. * @returns the current particle system
  19232. */
  19233. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19234. /**
  19235. * Remove a specific start size gradient
  19236. * @param gradient defines the gradient to remove
  19237. * @returns the current particle system
  19238. */
  19239. removeStartSizeGradient(gradient: number): IParticleSystem;
  19240. /**
  19241. * Gets the current list of start size gradients.
  19242. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19243. * @returns the list of start size gradients
  19244. */
  19245. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19246. /**
  19247. * Adds a new life time gradient
  19248. * @param gradient defines the gradient to use (between 0 and 1)
  19249. * @param factor defines the life time factor to affect to the specified gradient
  19250. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19251. * @returns the current particle system
  19252. */
  19253. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19254. /**
  19255. * Remove a specific life time gradient
  19256. * @param gradient defines the gradient to remove
  19257. * @returns the current particle system
  19258. */
  19259. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19260. /**
  19261. * Gets the current list of life time gradients.
  19262. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19263. * @returns the list of life time gradients
  19264. */
  19265. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19266. /**
  19267. * Gets the current list of color gradients.
  19268. * You must use addColorGradient and removeColorGradient to udpate this list
  19269. * @returns the list of color gradients
  19270. */
  19271. getColorGradients(): Nullable<Array<ColorGradient>>;
  19272. /**
  19273. * Adds a new ramp gradient used to remap particle colors
  19274. * @param gradient defines the gradient to use (between 0 and 1)
  19275. * @param color defines the color to affect to the specified gradient
  19276. * @returns the current particle system
  19277. */
  19278. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19279. /**
  19280. * Gets the current list of ramp gradients.
  19281. * You must use addRampGradient and removeRampGradient to udpate this list
  19282. * @returns the list of ramp gradients
  19283. */
  19284. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19285. /** Gets or sets a boolean indicating that ramp gradients must be used
  19286. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19287. */
  19288. useRampGradients: boolean;
  19289. /**
  19290. * Adds a new color remap gradient
  19291. * @param gradient defines the gradient to use (between 0 and 1)
  19292. * @param min defines the color remap minimal range
  19293. * @param max defines the color remap maximal range
  19294. * @returns the current particle system
  19295. */
  19296. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19297. /**
  19298. * Gets the current list of color remap gradients.
  19299. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19300. * @returns the list of color remap gradients
  19301. */
  19302. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19303. /**
  19304. * Adds a new alpha remap gradient
  19305. * @param gradient defines the gradient to use (between 0 and 1)
  19306. * @param min defines the alpha remap minimal range
  19307. * @param max defines the alpha remap maximal range
  19308. * @returns the current particle system
  19309. */
  19310. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19311. /**
  19312. * Gets the current list of alpha remap gradients.
  19313. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19314. * @returns the list of alpha remap gradients
  19315. */
  19316. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19317. /**
  19318. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19319. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19320. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19321. * @returns the emitter
  19322. */
  19323. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19324. /**
  19325. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19326. * @param radius The radius of the hemisphere to emit from
  19327. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19328. * @returns the emitter
  19329. */
  19330. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19331. /**
  19332. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19333. * @param radius The radius of the sphere to emit from
  19334. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19335. * @returns the emitter
  19336. */
  19337. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19338. /**
  19339. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19340. * @param radius The radius of the sphere to emit from
  19341. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19342. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19343. * @returns the emitter
  19344. */
  19345. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19346. /**
  19347. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19348. * @param radius The radius of the emission cylinder
  19349. * @param height The height of the emission cylinder
  19350. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19351. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19352. * @returns the emitter
  19353. */
  19354. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19355. /**
  19356. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19357. * @param radius The radius of the cylinder to emit from
  19358. * @param height The height of the emission cylinder
  19359. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19360. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19361. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19362. * @returns the emitter
  19363. */
  19364. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19365. /**
  19366. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19367. * @param radius The radius of the cone to emit from
  19368. * @param angle The base angle of the cone
  19369. * @returns the emitter
  19370. */
  19371. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19372. /**
  19373. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19374. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19375. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19376. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19377. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19378. * @returns the emitter
  19379. */
  19380. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19381. /**
  19382. * Get hosting scene
  19383. * @returns the scene
  19384. */
  19385. getScene(): Scene;
  19386. }
  19387. }
  19388. declare module "babylonjs/Meshes/instancedMesh" {
  19389. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19390. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19391. import { Camera } from "babylonjs/Cameras/camera";
  19392. import { Node } from "babylonjs/node";
  19393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19394. import { Mesh } from "babylonjs/Meshes/mesh";
  19395. import { Material } from "babylonjs/Materials/material";
  19396. import { Skeleton } from "babylonjs/Bones/skeleton";
  19397. import { Light } from "babylonjs/Lights/light";
  19398. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19399. /**
  19400. * Creates an instance based on a source mesh.
  19401. */
  19402. export class InstancedMesh extends AbstractMesh {
  19403. private _sourceMesh;
  19404. private _currentLOD;
  19405. /** @hidden */
  19406. _indexInSourceMeshInstanceArray: number;
  19407. constructor(name: string, source: Mesh);
  19408. /**
  19409. * Returns the string "InstancedMesh".
  19410. */
  19411. getClassName(): string;
  19412. /** Gets the list of lights affecting that mesh */
  19413. readonly lightSources: Light[];
  19414. _resyncLightSources(): void;
  19415. _resyncLighSource(light: Light): void;
  19416. _removeLightSource(light: Light, dispose: boolean): void;
  19417. /**
  19418. * If the source mesh receives shadows
  19419. */
  19420. readonly receiveShadows: boolean;
  19421. /**
  19422. * The material of the source mesh
  19423. */
  19424. readonly material: Nullable<Material>;
  19425. /**
  19426. * Visibility of the source mesh
  19427. */
  19428. readonly visibility: number;
  19429. /**
  19430. * Skeleton of the source mesh
  19431. */
  19432. readonly skeleton: Nullable<Skeleton>;
  19433. /**
  19434. * Rendering ground id of the source mesh
  19435. */
  19436. renderingGroupId: number;
  19437. /**
  19438. * Returns the total number of vertices (integer).
  19439. */
  19440. getTotalVertices(): number;
  19441. /**
  19442. * Returns a positive integer : the total number of indices in this mesh geometry.
  19443. * @returns the numner of indices or zero if the mesh has no geometry.
  19444. */
  19445. getTotalIndices(): number;
  19446. /**
  19447. * The source mesh of the instance
  19448. */
  19449. readonly sourceMesh: Mesh;
  19450. /**
  19451. * Is this node ready to be used/rendered
  19452. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19453. * @return {boolean} is it ready
  19454. */
  19455. isReady(completeCheck?: boolean): boolean;
  19456. /**
  19457. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19458. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19459. * @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.
  19460. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19461. */
  19462. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19463. /**
  19464. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19465. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19466. * The `data` are either a numeric array either a Float32Array.
  19467. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19468. * 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).
  19469. * Note that a new underlying VertexBuffer object is created each call.
  19470. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19471. *
  19472. * Possible `kind` values :
  19473. * - VertexBuffer.PositionKind
  19474. * - VertexBuffer.UVKind
  19475. * - VertexBuffer.UV2Kind
  19476. * - VertexBuffer.UV3Kind
  19477. * - VertexBuffer.UV4Kind
  19478. * - VertexBuffer.UV5Kind
  19479. * - VertexBuffer.UV6Kind
  19480. * - VertexBuffer.ColorKind
  19481. * - VertexBuffer.MatricesIndicesKind
  19482. * - VertexBuffer.MatricesIndicesExtraKind
  19483. * - VertexBuffer.MatricesWeightsKind
  19484. * - VertexBuffer.MatricesWeightsExtraKind
  19485. *
  19486. * Returns the Mesh.
  19487. */
  19488. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19489. /**
  19490. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19491. * If the mesh has no geometry, it is simply returned as it is.
  19492. * The `data` are either a numeric array either a Float32Array.
  19493. * No new underlying VertexBuffer object is created.
  19494. * 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.
  19495. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19496. *
  19497. * Possible `kind` values :
  19498. * - VertexBuffer.PositionKind
  19499. * - VertexBuffer.UVKind
  19500. * - VertexBuffer.UV2Kind
  19501. * - VertexBuffer.UV3Kind
  19502. * - VertexBuffer.UV4Kind
  19503. * - VertexBuffer.UV5Kind
  19504. * - VertexBuffer.UV6Kind
  19505. * - VertexBuffer.ColorKind
  19506. * - VertexBuffer.MatricesIndicesKind
  19507. * - VertexBuffer.MatricesIndicesExtraKind
  19508. * - VertexBuffer.MatricesWeightsKind
  19509. * - VertexBuffer.MatricesWeightsExtraKind
  19510. *
  19511. * Returns the Mesh.
  19512. */
  19513. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19514. /**
  19515. * Sets the mesh indices.
  19516. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19517. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19518. * This method creates a new index buffer each call.
  19519. * Returns the Mesh.
  19520. */
  19521. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19522. /**
  19523. * Boolean : True if the mesh owns the requested kind of data.
  19524. */
  19525. isVerticesDataPresent(kind: string): boolean;
  19526. /**
  19527. * Returns an array of indices (IndicesArray).
  19528. */
  19529. getIndices(): Nullable<IndicesArray>;
  19530. readonly _positions: Nullable<Vector3[]>;
  19531. /**
  19532. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19533. * This means the mesh underlying bounding box and sphere are recomputed.
  19534. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19535. * @returns the current mesh
  19536. */
  19537. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19538. /** @hidden */
  19539. _preActivate(): InstancedMesh;
  19540. /** @hidden */
  19541. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19542. /** @hidden */
  19543. _postActivate(): void;
  19544. getWorldMatrix(): Matrix;
  19545. readonly isAnInstance: boolean;
  19546. /**
  19547. * Returns the current associated LOD AbstractMesh.
  19548. */
  19549. getLOD(camera: Camera): AbstractMesh;
  19550. /** @hidden */
  19551. _syncSubMeshes(): InstancedMesh;
  19552. /** @hidden */
  19553. _generatePointsArray(): boolean;
  19554. /**
  19555. * Creates a new InstancedMesh from the current mesh.
  19556. * - name (string) : the cloned mesh name
  19557. * - newParent (optional Node) : the optional Node to parent the clone to.
  19558. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19559. *
  19560. * Returns the clone.
  19561. */
  19562. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19563. /**
  19564. * Disposes the InstancedMesh.
  19565. * Returns nothing.
  19566. */
  19567. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19568. }
  19569. module "babylonjs/Meshes/mesh" {
  19570. interface Mesh {
  19571. /**
  19572. * Register a custom buffer that will be instanced
  19573. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19574. * @param kind defines the buffer kind
  19575. * @param stride defines the stride in floats
  19576. */
  19577. registerInstancedBuffer(kind: string, stride: number): void;
  19578. /** @hidden */
  19579. _userInstancedBuffersStorage: {
  19580. data: {
  19581. [key: string]: Float32Array;
  19582. };
  19583. sizes: {
  19584. [key: string]: number;
  19585. };
  19586. vertexBuffers: {
  19587. [key: string]: Nullable<VertexBuffer>;
  19588. };
  19589. strides: {
  19590. [key: string]: number;
  19591. };
  19592. };
  19593. }
  19594. }
  19595. module "babylonjs/Meshes/abstractMesh" {
  19596. interface AbstractMesh {
  19597. /**
  19598. * Object used to store instanced buffers defined by user
  19599. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19600. */
  19601. instancedBuffers: {
  19602. [key: string]: any;
  19603. };
  19604. }
  19605. }
  19606. }
  19607. declare module "babylonjs/Materials/shaderMaterial" {
  19608. import { Scene } from "babylonjs/scene";
  19609. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19611. import { Mesh } from "babylonjs/Meshes/mesh";
  19612. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19613. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19614. import { Texture } from "babylonjs/Materials/Textures/texture";
  19615. import { Material } from "babylonjs/Materials/material";
  19616. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19617. /**
  19618. * Defines the options associated with the creation of a shader material.
  19619. */
  19620. export interface IShaderMaterialOptions {
  19621. /**
  19622. * Does the material work in alpha blend mode
  19623. */
  19624. needAlphaBlending: boolean;
  19625. /**
  19626. * Does the material work in alpha test mode
  19627. */
  19628. needAlphaTesting: boolean;
  19629. /**
  19630. * The list of attribute names used in the shader
  19631. */
  19632. attributes: string[];
  19633. /**
  19634. * The list of unifrom names used in the shader
  19635. */
  19636. uniforms: string[];
  19637. /**
  19638. * The list of UBO names used in the shader
  19639. */
  19640. uniformBuffers: string[];
  19641. /**
  19642. * The list of sampler names used in the shader
  19643. */
  19644. samplers: string[];
  19645. /**
  19646. * The list of defines used in the shader
  19647. */
  19648. defines: string[];
  19649. }
  19650. /**
  19651. * 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.
  19652. *
  19653. * This returned material effects how the mesh will look based on the code in the shaders.
  19654. *
  19655. * @see http://doc.babylonjs.com/how_to/shader_material
  19656. */
  19657. export class ShaderMaterial extends Material {
  19658. private _shaderPath;
  19659. private _options;
  19660. private _textures;
  19661. private _textureArrays;
  19662. private _floats;
  19663. private _ints;
  19664. private _floatsArrays;
  19665. private _colors3;
  19666. private _colors3Arrays;
  19667. private _colors4;
  19668. private _colors4Arrays;
  19669. private _vectors2;
  19670. private _vectors3;
  19671. private _vectors4;
  19672. private _matrices;
  19673. private _matrixArrays;
  19674. private _matrices3x3;
  19675. private _matrices2x2;
  19676. private _vectors2Arrays;
  19677. private _vectors3Arrays;
  19678. private _vectors4Arrays;
  19679. private _cachedWorldViewMatrix;
  19680. private _cachedWorldViewProjectionMatrix;
  19681. private _renderId;
  19682. /**
  19683. * Instantiate a new shader material.
  19684. * 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.
  19685. * This returned material effects how the mesh will look based on the code in the shaders.
  19686. * @see http://doc.babylonjs.com/how_to/shader_material
  19687. * @param name Define the name of the material in the scene
  19688. * @param scene Define the scene the material belongs to
  19689. * @param shaderPath Defines the route to the shader code in one of three ways:
  19690. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19691. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19692. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19693. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19694. * @param options Define the options used to create the shader
  19695. */
  19696. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19697. /**
  19698. * Gets the shader path used to define the shader code
  19699. * It can be modified to trigger a new compilation
  19700. */
  19701. /**
  19702. * Sets the shader path used to define the shader code
  19703. * It can be modified to trigger a new compilation
  19704. */
  19705. shaderPath: any;
  19706. /**
  19707. * Gets the options used to compile the shader.
  19708. * They can be modified to trigger a new compilation
  19709. */
  19710. readonly options: IShaderMaterialOptions;
  19711. /**
  19712. * Gets the current class name of the material e.g. "ShaderMaterial"
  19713. * Mainly use in serialization.
  19714. * @returns the class name
  19715. */
  19716. getClassName(): string;
  19717. /**
  19718. * Specifies if the material will require alpha blending
  19719. * @returns a boolean specifying if alpha blending is needed
  19720. */
  19721. needAlphaBlending(): boolean;
  19722. /**
  19723. * Specifies if this material should be rendered in alpha test mode
  19724. * @returns a boolean specifying if an alpha test is needed.
  19725. */
  19726. needAlphaTesting(): boolean;
  19727. private _checkUniform;
  19728. /**
  19729. * Set a texture in the shader.
  19730. * @param name Define the name of the uniform samplers as defined in the shader
  19731. * @param texture Define the texture to bind to this sampler
  19732. * @return the material itself allowing "fluent" like uniform updates
  19733. */
  19734. setTexture(name: string, texture: Texture): ShaderMaterial;
  19735. /**
  19736. * Set a texture array in the shader.
  19737. * @param name Define the name of the uniform sampler array as defined in the shader
  19738. * @param textures Define the list of textures to bind to this sampler
  19739. * @return the material itself allowing "fluent" like uniform updates
  19740. */
  19741. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19742. /**
  19743. * Set a float in the shader.
  19744. * @param name Define the name of the uniform as defined in the shader
  19745. * @param value Define the value to give to the uniform
  19746. * @return the material itself allowing "fluent" like uniform updates
  19747. */
  19748. setFloat(name: string, value: number): ShaderMaterial;
  19749. /**
  19750. * Set a int in the shader.
  19751. * @param name Define the name of the uniform as defined in the shader
  19752. * @param value Define the value to give to the uniform
  19753. * @return the material itself allowing "fluent" like uniform updates
  19754. */
  19755. setInt(name: string, value: number): ShaderMaterial;
  19756. /**
  19757. * Set an array of floats in the shader.
  19758. * @param name Define the name of the uniform as defined in the shader
  19759. * @param value Define the value to give to the uniform
  19760. * @return the material itself allowing "fluent" like uniform updates
  19761. */
  19762. setFloats(name: string, value: number[]): ShaderMaterial;
  19763. /**
  19764. * Set a vec3 in the shader from a Color3.
  19765. * @param name Define the name of the uniform as defined in the shader
  19766. * @param value Define the value to give to the uniform
  19767. * @return the material itself allowing "fluent" like uniform updates
  19768. */
  19769. setColor3(name: string, value: Color3): ShaderMaterial;
  19770. /**
  19771. * Set a vec3 array in the shader from a Color3 array.
  19772. * @param name Define the name of the uniform as defined in the shader
  19773. * @param value Define the value to give to the uniform
  19774. * @return the material itself allowing "fluent" like uniform updates
  19775. */
  19776. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19777. /**
  19778. * Set a vec4 in the shader from a Color4.
  19779. * @param name Define the name of the uniform as defined in the shader
  19780. * @param value Define the value to give to the uniform
  19781. * @return the material itself allowing "fluent" like uniform updates
  19782. */
  19783. setColor4(name: string, value: Color4): ShaderMaterial;
  19784. /**
  19785. * Set a vec4 array in the shader from a Color4 array.
  19786. * @param name Define the name of the uniform as defined in the shader
  19787. * @param value Define the value to give to the uniform
  19788. * @return the material itself allowing "fluent" like uniform updates
  19789. */
  19790. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19791. /**
  19792. * Set a vec2 in the shader from a Vector2.
  19793. * @param name Define the name of the uniform as defined in the shader
  19794. * @param value Define the value to give to the uniform
  19795. * @return the material itself allowing "fluent" like uniform updates
  19796. */
  19797. setVector2(name: string, value: Vector2): ShaderMaterial;
  19798. /**
  19799. * Set a vec3 in the shader from a Vector3.
  19800. * @param name Define the name of the uniform as defined in the shader
  19801. * @param value Define the value to give to the uniform
  19802. * @return the material itself allowing "fluent" like uniform updates
  19803. */
  19804. setVector3(name: string, value: Vector3): ShaderMaterial;
  19805. /**
  19806. * Set a vec4 in the shader from a Vector4.
  19807. * @param name Define the name of the uniform as defined in the shader
  19808. * @param value Define the value to give to the uniform
  19809. * @return the material itself allowing "fluent" like uniform updates
  19810. */
  19811. setVector4(name: string, value: Vector4): ShaderMaterial;
  19812. /**
  19813. * Set a mat4 in the shader from a Matrix.
  19814. * @param name Define the name of the uniform as defined in the shader
  19815. * @param value Define the value to give to the uniform
  19816. * @return the material itself allowing "fluent" like uniform updates
  19817. */
  19818. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19819. /**
  19820. * Set a float32Array in the shader from a matrix array.
  19821. * @param name Define the name of the uniform as defined in the shader
  19822. * @param value Define the value to give to the uniform
  19823. * @return the material itself allowing "fluent" like uniform updates
  19824. */
  19825. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19826. /**
  19827. * Set a mat3 in the shader from a Float32Array.
  19828. * @param name Define the name of the uniform as defined in the shader
  19829. * @param value Define the value to give to the uniform
  19830. * @return the material itself allowing "fluent" like uniform updates
  19831. */
  19832. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19833. /**
  19834. * Set a mat2 in the shader from a Float32Array.
  19835. * @param name Define the name of the uniform as defined in the shader
  19836. * @param value Define the value to give to the uniform
  19837. * @return the material itself allowing "fluent" like uniform updates
  19838. */
  19839. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19840. /**
  19841. * Set a vec2 array in the shader from a number array.
  19842. * @param name Define the name of the uniform as defined in the shader
  19843. * @param value Define the value to give to the uniform
  19844. * @return the material itself allowing "fluent" like uniform updates
  19845. */
  19846. setArray2(name: string, value: number[]): ShaderMaterial;
  19847. /**
  19848. * Set a vec3 array in the shader from a number array.
  19849. * @param name Define the name of the uniform as defined in the shader
  19850. * @param value Define the value to give to the uniform
  19851. * @return the material itself allowing "fluent" like uniform updates
  19852. */
  19853. setArray3(name: string, value: number[]): ShaderMaterial;
  19854. /**
  19855. * Set a vec4 array in the shader from a number array.
  19856. * @param name Define the name of the uniform as defined in the shader
  19857. * @param value Define the value to give to the uniform
  19858. * @return the material itself allowing "fluent" like uniform updates
  19859. */
  19860. setArray4(name: string, value: number[]): ShaderMaterial;
  19861. private _checkCache;
  19862. /**
  19863. * Specifies that the submesh is ready to be used
  19864. * @param mesh defines the mesh to check
  19865. * @param subMesh defines which submesh to check
  19866. * @param useInstances specifies that instances should be used
  19867. * @returns a boolean indicating that the submesh is ready or not
  19868. */
  19869. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19870. /**
  19871. * Checks if the material is ready to render the requested mesh
  19872. * @param mesh Define the mesh to render
  19873. * @param useInstances Define whether or not the material is used with instances
  19874. * @returns true if ready, otherwise false
  19875. */
  19876. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19877. /**
  19878. * Binds the world matrix to the material
  19879. * @param world defines the world transformation matrix
  19880. */
  19881. bindOnlyWorldMatrix(world: Matrix): void;
  19882. /**
  19883. * Binds the material to the mesh
  19884. * @param world defines the world transformation matrix
  19885. * @param mesh defines the mesh to bind the material to
  19886. */
  19887. bind(world: Matrix, mesh?: Mesh): void;
  19888. /**
  19889. * Gets the active textures from the material
  19890. * @returns an array of textures
  19891. */
  19892. getActiveTextures(): BaseTexture[];
  19893. /**
  19894. * Specifies if the material uses a texture
  19895. * @param texture defines the texture to check against the material
  19896. * @returns a boolean specifying if the material uses the texture
  19897. */
  19898. hasTexture(texture: BaseTexture): boolean;
  19899. /**
  19900. * Makes a duplicate of the material, and gives it a new name
  19901. * @param name defines the new name for the duplicated material
  19902. * @returns the cloned material
  19903. */
  19904. clone(name: string): ShaderMaterial;
  19905. /**
  19906. * Disposes the material
  19907. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19908. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19909. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19910. */
  19911. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19912. /**
  19913. * Serializes this material in a JSON representation
  19914. * @returns the serialized material object
  19915. */
  19916. serialize(): any;
  19917. /**
  19918. * Creates a shader material from parsed shader material data
  19919. * @param source defines the JSON represnetation of the material
  19920. * @param scene defines the hosting scene
  19921. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19922. * @returns a new material
  19923. */
  19924. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19925. }
  19926. }
  19927. declare module "babylonjs/Shaders/color.fragment" {
  19928. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19929. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19930. /** @hidden */
  19931. export var colorPixelShader: {
  19932. name: string;
  19933. shader: string;
  19934. };
  19935. }
  19936. declare module "babylonjs/Shaders/color.vertex" {
  19937. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19938. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19939. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19940. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19941. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19942. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19943. /** @hidden */
  19944. export var colorVertexShader: {
  19945. name: string;
  19946. shader: string;
  19947. };
  19948. }
  19949. declare module "babylonjs/Meshes/linesMesh" {
  19950. import { Nullable } from "babylonjs/types";
  19951. import { Scene } from "babylonjs/scene";
  19952. import { Color3 } from "babylonjs/Maths/math.color";
  19953. import { Node } from "babylonjs/node";
  19954. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19955. import { Mesh } from "babylonjs/Meshes/mesh";
  19956. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19957. import { Effect } from "babylonjs/Materials/effect";
  19958. import { Material } from "babylonjs/Materials/material";
  19959. import "babylonjs/Shaders/color.fragment";
  19960. import "babylonjs/Shaders/color.vertex";
  19961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19962. /**
  19963. * Line mesh
  19964. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19965. */
  19966. export class LinesMesh extends Mesh {
  19967. /**
  19968. * If vertex color should be applied to the mesh
  19969. */
  19970. readonly useVertexColor?: boolean | undefined;
  19971. /**
  19972. * If vertex alpha should be applied to the mesh
  19973. */
  19974. readonly useVertexAlpha?: boolean | undefined;
  19975. /**
  19976. * Color of the line (Default: White)
  19977. */
  19978. color: Color3;
  19979. /**
  19980. * Alpha of the line (Default: 1)
  19981. */
  19982. alpha: number;
  19983. /**
  19984. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19985. * This margin is expressed in world space coordinates, so its value may vary.
  19986. * Default value is 0.1
  19987. */
  19988. intersectionThreshold: number;
  19989. private _colorShader;
  19990. private color4;
  19991. /**
  19992. * Creates a new LinesMesh
  19993. * @param name defines the name
  19994. * @param scene defines the hosting scene
  19995. * @param parent defines the parent mesh if any
  19996. * @param source defines the optional source LinesMesh used to clone data from
  19997. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19998. * When false, achieved by calling a clone(), also passing False.
  19999. * This will make creation of children, recursive.
  20000. * @param useVertexColor defines if this LinesMesh supports vertex color
  20001. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20002. */
  20003. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20004. /**
  20005. * If vertex color should be applied to the mesh
  20006. */
  20007. useVertexColor?: boolean | undefined,
  20008. /**
  20009. * If vertex alpha should be applied to the mesh
  20010. */
  20011. useVertexAlpha?: boolean | undefined);
  20012. private _addClipPlaneDefine;
  20013. private _removeClipPlaneDefine;
  20014. isReady(): boolean;
  20015. /**
  20016. * Returns the string "LineMesh"
  20017. */
  20018. getClassName(): string;
  20019. /**
  20020. * @hidden
  20021. */
  20022. /**
  20023. * @hidden
  20024. */
  20025. material: Material;
  20026. /**
  20027. * @hidden
  20028. */
  20029. readonly checkCollisions: boolean;
  20030. /** @hidden */
  20031. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20032. /** @hidden */
  20033. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20034. /**
  20035. * Disposes of the line mesh
  20036. * @param doNotRecurse If children should be disposed
  20037. */
  20038. dispose(doNotRecurse?: boolean): void;
  20039. /**
  20040. * Returns a new LineMesh object cloned from the current one.
  20041. */
  20042. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20043. /**
  20044. * Creates a new InstancedLinesMesh object from the mesh model.
  20045. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20046. * @param name defines the name of the new instance
  20047. * @returns a new InstancedLinesMesh
  20048. */
  20049. createInstance(name: string): InstancedLinesMesh;
  20050. }
  20051. /**
  20052. * Creates an instance based on a source LinesMesh
  20053. */
  20054. export class InstancedLinesMesh extends InstancedMesh {
  20055. /**
  20056. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20057. * This margin is expressed in world space coordinates, so its value may vary.
  20058. * Initilized with the intersectionThreshold value of the source LinesMesh
  20059. */
  20060. intersectionThreshold: number;
  20061. constructor(name: string, source: LinesMesh);
  20062. /**
  20063. * Returns the string "InstancedLinesMesh".
  20064. */
  20065. getClassName(): string;
  20066. }
  20067. }
  20068. declare module "babylonjs/Shaders/line.fragment" {
  20069. /** @hidden */
  20070. export var linePixelShader: {
  20071. name: string;
  20072. shader: string;
  20073. };
  20074. }
  20075. declare module "babylonjs/Shaders/line.vertex" {
  20076. /** @hidden */
  20077. export var lineVertexShader: {
  20078. name: string;
  20079. shader: string;
  20080. };
  20081. }
  20082. declare module "babylonjs/Rendering/edgesRenderer" {
  20083. import { Nullable } from "babylonjs/types";
  20084. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20086. import { Vector3 } from "babylonjs/Maths/math.vector";
  20087. import { IDisposable } from "babylonjs/scene";
  20088. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20089. import "babylonjs/Shaders/line.fragment";
  20090. import "babylonjs/Shaders/line.vertex";
  20091. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20092. module "babylonjs/Meshes/abstractMesh" {
  20093. interface AbstractMesh {
  20094. /**
  20095. * Gets the edgesRenderer associated with the mesh
  20096. */
  20097. edgesRenderer: Nullable<EdgesRenderer>;
  20098. }
  20099. }
  20100. module "babylonjs/Meshes/linesMesh" {
  20101. interface LinesMesh {
  20102. /**
  20103. * Enables the edge rendering mode on the mesh.
  20104. * This mode makes the mesh edges visible
  20105. * @param epsilon defines the maximal distance between two angles to detect a face
  20106. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20107. * @returns the currentAbstractMesh
  20108. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20109. */
  20110. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20111. }
  20112. }
  20113. module "babylonjs/Meshes/linesMesh" {
  20114. interface InstancedLinesMesh {
  20115. /**
  20116. * Enables the edge rendering mode on the mesh.
  20117. * This mode makes the mesh edges visible
  20118. * @param epsilon defines the maximal distance between two angles to detect a face
  20119. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20120. * @returns the current InstancedLinesMesh
  20121. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20122. */
  20123. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20124. }
  20125. }
  20126. /**
  20127. * Defines the minimum contract an Edges renderer should follow.
  20128. */
  20129. export interface IEdgesRenderer extends IDisposable {
  20130. /**
  20131. * Gets or sets a boolean indicating if the edgesRenderer is active
  20132. */
  20133. isEnabled: boolean;
  20134. /**
  20135. * Renders the edges of the attached mesh,
  20136. */
  20137. render(): void;
  20138. /**
  20139. * Checks wether or not the edges renderer is ready to render.
  20140. * @return true if ready, otherwise false.
  20141. */
  20142. isReady(): boolean;
  20143. }
  20144. /**
  20145. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20146. */
  20147. export class EdgesRenderer implements IEdgesRenderer {
  20148. /**
  20149. * Define the size of the edges with an orthographic camera
  20150. */
  20151. edgesWidthScalerForOrthographic: number;
  20152. /**
  20153. * Define the size of the edges with a perspective camera
  20154. */
  20155. edgesWidthScalerForPerspective: number;
  20156. protected _source: AbstractMesh;
  20157. protected _linesPositions: number[];
  20158. protected _linesNormals: number[];
  20159. protected _linesIndices: number[];
  20160. protected _epsilon: number;
  20161. protected _indicesCount: number;
  20162. protected _lineShader: ShaderMaterial;
  20163. protected _ib: DataBuffer;
  20164. protected _buffers: {
  20165. [key: string]: Nullable<VertexBuffer>;
  20166. };
  20167. protected _checkVerticesInsteadOfIndices: boolean;
  20168. private _meshRebuildObserver;
  20169. private _meshDisposeObserver;
  20170. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20171. isEnabled: boolean;
  20172. /**
  20173. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20174. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20175. * @param source Mesh used to create edges
  20176. * @param epsilon sum of angles in adjacency to check for edge
  20177. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20178. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20179. */
  20180. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20181. protected _prepareRessources(): void;
  20182. /** @hidden */
  20183. _rebuild(): void;
  20184. /**
  20185. * Releases the required resources for the edges renderer
  20186. */
  20187. dispose(): void;
  20188. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20189. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20190. /**
  20191. * Checks if the pair of p0 and p1 is en edge
  20192. * @param faceIndex
  20193. * @param edge
  20194. * @param faceNormals
  20195. * @param p0
  20196. * @param p1
  20197. * @private
  20198. */
  20199. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20200. /**
  20201. * push line into the position, normal and index buffer
  20202. * @protected
  20203. */
  20204. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20205. /**
  20206. * Generates lines edges from adjacencjes
  20207. * @private
  20208. */
  20209. _generateEdgesLines(): void;
  20210. /**
  20211. * Checks wether or not the edges renderer is ready to render.
  20212. * @return true if ready, otherwise false.
  20213. */
  20214. isReady(): boolean;
  20215. /**
  20216. * Renders the edges of the attached mesh,
  20217. */
  20218. render(): void;
  20219. }
  20220. /**
  20221. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20222. */
  20223. export class LineEdgesRenderer extends EdgesRenderer {
  20224. /**
  20225. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20226. * @param source LineMesh used to generate edges
  20227. * @param epsilon not important (specified angle for edge detection)
  20228. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20229. */
  20230. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20231. /**
  20232. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20233. */
  20234. _generateEdgesLines(): void;
  20235. }
  20236. }
  20237. declare module "babylonjs/Rendering/renderingGroup" {
  20238. import { SmartArray } from "babylonjs/Misc/smartArray";
  20239. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20241. import { Nullable } from "babylonjs/types";
  20242. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20243. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20244. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20245. import { Material } from "babylonjs/Materials/material";
  20246. import { Scene } from "babylonjs/scene";
  20247. /**
  20248. * This represents the object necessary to create a rendering group.
  20249. * This is exclusively used and created by the rendering manager.
  20250. * To modify the behavior, you use the available helpers in your scene or meshes.
  20251. * @hidden
  20252. */
  20253. export class RenderingGroup {
  20254. index: number;
  20255. private static _zeroVector;
  20256. private _scene;
  20257. private _opaqueSubMeshes;
  20258. private _transparentSubMeshes;
  20259. private _alphaTestSubMeshes;
  20260. private _depthOnlySubMeshes;
  20261. private _particleSystems;
  20262. private _spriteManagers;
  20263. private _opaqueSortCompareFn;
  20264. private _alphaTestSortCompareFn;
  20265. private _transparentSortCompareFn;
  20266. private _renderOpaque;
  20267. private _renderAlphaTest;
  20268. private _renderTransparent;
  20269. /** @hidden */
  20270. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20271. onBeforeTransparentRendering: () => void;
  20272. /**
  20273. * Set the opaque sort comparison function.
  20274. * If null the sub meshes will be render in the order they were created
  20275. */
  20276. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20277. /**
  20278. * Set the alpha test sort comparison function.
  20279. * If null the sub meshes will be render in the order they were created
  20280. */
  20281. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20282. /**
  20283. * Set the transparent sort comparison function.
  20284. * If null the sub meshes will be render in the order they were created
  20285. */
  20286. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20287. /**
  20288. * Creates a new rendering group.
  20289. * @param index The rendering group index
  20290. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20291. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20292. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20293. */
  20294. 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>);
  20295. /**
  20296. * Render all the sub meshes contained in the group.
  20297. * @param customRenderFunction Used to override the default render behaviour of the group.
  20298. * @returns true if rendered some submeshes.
  20299. */
  20300. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20301. /**
  20302. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20303. * @param subMeshes The submeshes to render
  20304. */
  20305. private renderOpaqueSorted;
  20306. /**
  20307. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20308. * @param subMeshes The submeshes to render
  20309. */
  20310. private renderAlphaTestSorted;
  20311. /**
  20312. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20313. * @param subMeshes The submeshes to render
  20314. */
  20315. private renderTransparentSorted;
  20316. /**
  20317. * Renders the submeshes in a specified order.
  20318. * @param subMeshes The submeshes to sort before render
  20319. * @param sortCompareFn The comparison function use to sort
  20320. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20321. * @param transparent Specifies to activate blending if true
  20322. */
  20323. private static renderSorted;
  20324. /**
  20325. * Renders the submeshes in the order they were dispatched (no sort applied).
  20326. * @param subMeshes The submeshes to render
  20327. */
  20328. private static renderUnsorted;
  20329. /**
  20330. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20331. * are rendered back to front if in the same alpha index.
  20332. *
  20333. * @param a The first submesh
  20334. * @param b The second submesh
  20335. * @returns The result of the comparison
  20336. */
  20337. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20338. /**
  20339. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20340. * are rendered back to front.
  20341. *
  20342. * @param a The first submesh
  20343. * @param b The second submesh
  20344. * @returns The result of the comparison
  20345. */
  20346. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20347. /**
  20348. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20349. * are rendered front to back (prevent overdraw).
  20350. *
  20351. * @param a The first submesh
  20352. * @param b The second submesh
  20353. * @returns The result of the comparison
  20354. */
  20355. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20356. /**
  20357. * Resets the different lists of submeshes to prepare a new frame.
  20358. */
  20359. prepare(): void;
  20360. dispose(): void;
  20361. /**
  20362. * Inserts the submesh in its correct queue depending on its material.
  20363. * @param subMesh The submesh to dispatch
  20364. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20365. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20366. */
  20367. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20368. dispatchSprites(spriteManager: ISpriteManager): void;
  20369. dispatchParticles(particleSystem: IParticleSystem): void;
  20370. private _renderParticles;
  20371. private _renderSprites;
  20372. }
  20373. }
  20374. declare module "babylonjs/Rendering/renderingManager" {
  20375. import { Nullable } from "babylonjs/types";
  20376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20377. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20378. import { SmartArray } from "babylonjs/Misc/smartArray";
  20379. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20380. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20381. import { Material } from "babylonjs/Materials/material";
  20382. import { Scene } from "babylonjs/scene";
  20383. import { Camera } from "babylonjs/Cameras/camera";
  20384. /**
  20385. * Interface describing the different options available in the rendering manager
  20386. * regarding Auto Clear between groups.
  20387. */
  20388. export interface IRenderingManagerAutoClearSetup {
  20389. /**
  20390. * Defines whether or not autoclear is enable.
  20391. */
  20392. autoClear: boolean;
  20393. /**
  20394. * Defines whether or not to autoclear the depth buffer.
  20395. */
  20396. depth: boolean;
  20397. /**
  20398. * Defines whether or not to autoclear the stencil buffer.
  20399. */
  20400. stencil: boolean;
  20401. }
  20402. /**
  20403. * This class is used by the onRenderingGroupObservable
  20404. */
  20405. export class RenderingGroupInfo {
  20406. /**
  20407. * The Scene that being rendered
  20408. */
  20409. scene: Scene;
  20410. /**
  20411. * The camera currently used for the rendering pass
  20412. */
  20413. camera: Nullable<Camera>;
  20414. /**
  20415. * The ID of the renderingGroup being processed
  20416. */
  20417. renderingGroupId: number;
  20418. }
  20419. /**
  20420. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20421. * It is enable to manage the different groups as well as the different necessary sort functions.
  20422. * This should not be used directly aside of the few static configurations
  20423. */
  20424. export class RenderingManager {
  20425. /**
  20426. * The max id used for rendering groups (not included)
  20427. */
  20428. static MAX_RENDERINGGROUPS: number;
  20429. /**
  20430. * The min id used for rendering groups (included)
  20431. */
  20432. static MIN_RENDERINGGROUPS: number;
  20433. /**
  20434. * Used to globally prevent autoclearing scenes.
  20435. */
  20436. static AUTOCLEAR: boolean;
  20437. /**
  20438. * @hidden
  20439. */
  20440. _useSceneAutoClearSetup: boolean;
  20441. private _scene;
  20442. private _renderingGroups;
  20443. private _depthStencilBufferAlreadyCleaned;
  20444. private _autoClearDepthStencil;
  20445. private _customOpaqueSortCompareFn;
  20446. private _customAlphaTestSortCompareFn;
  20447. private _customTransparentSortCompareFn;
  20448. private _renderingGroupInfo;
  20449. /**
  20450. * Instantiates a new rendering group for a particular scene
  20451. * @param scene Defines the scene the groups belongs to
  20452. */
  20453. constructor(scene: Scene);
  20454. private _clearDepthStencilBuffer;
  20455. /**
  20456. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20457. * @hidden
  20458. */
  20459. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20460. /**
  20461. * Resets the different information of the group to prepare a new frame
  20462. * @hidden
  20463. */
  20464. reset(): void;
  20465. /**
  20466. * Dispose and release the group and its associated resources.
  20467. * @hidden
  20468. */
  20469. dispose(): void;
  20470. /**
  20471. * Clear the info related to rendering groups preventing retention points during dispose.
  20472. */
  20473. freeRenderingGroups(): void;
  20474. private _prepareRenderingGroup;
  20475. /**
  20476. * Add a sprite manager to the rendering manager in order to render it this frame.
  20477. * @param spriteManager Define the sprite manager to render
  20478. */
  20479. dispatchSprites(spriteManager: ISpriteManager): void;
  20480. /**
  20481. * Add a particle system to the rendering manager in order to render it this frame.
  20482. * @param particleSystem Define the particle system to render
  20483. */
  20484. dispatchParticles(particleSystem: IParticleSystem): void;
  20485. /**
  20486. * Add a submesh to the manager in order to render it this frame
  20487. * @param subMesh The submesh to dispatch
  20488. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20489. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20490. */
  20491. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20492. /**
  20493. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20494. * This allowed control for front to back rendering or reversly depending of the special needs.
  20495. *
  20496. * @param renderingGroupId The rendering group id corresponding to its index
  20497. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20498. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20499. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20500. */
  20501. 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;
  20502. /**
  20503. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20504. *
  20505. * @param renderingGroupId The rendering group id corresponding to its index
  20506. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20507. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20508. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20509. */
  20510. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20511. /**
  20512. * Gets the current auto clear configuration for one rendering group of the rendering
  20513. * manager.
  20514. * @param index the rendering group index to get the information for
  20515. * @returns The auto clear setup for the requested rendering group
  20516. */
  20517. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20518. }
  20519. }
  20520. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20521. import { Observable } from "babylonjs/Misc/observable";
  20522. import { SmartArray } from "babylonjs/Misc/smartArray";
  20523. import { Nullable } from "babylonjs/types";
  20524. import { Camera } from "babylonjs/Cameras/camera";
  20525. import { Scene } from "babylonjs/scene";
  20526. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20527. import { Color4 } from "babylonjs/Maths/math.color";
  20528. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20530. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20531. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20532. import { Texture } from "babylonjs/Materials/Textures/texture";
  20533. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20534. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20535. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20536. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20537. import { Engine } from "babylonjs/Engines/engine";
  20538. /**
  20539. * This Helps creating a texture that will be created from a camera in your scene.
  20540. * It is basically a dynamic texture that could be used to create special effects for instance.
  20541. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20542. */
  20543. export class RenderTargetTexture extends Texture {
  20544. isCube: boolean;
  20545. /**
  20546. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20547. */
  20548. static readonly REFRESHRATE_RENDER_ONCE: number;
  20549. /**
  20550. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20551. */
  20552. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20553. /**
  20554. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20555. * the central point of your effect and can save a lot of performances.
  20556. */
  20557. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20558. /**
  20559. * Use this predicate to dynamically define the list of mesh you want to render.
  20560. * If set, the renderList property will be overwritten.
  20561. */
  20562. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20563. private _renderList;
  20564. /**
  20565. * Use this list to define the list of mesh you want to render.
  20566. */
  20567. renderList: Nullable<Array<AbstractMesh>>;
  20568. private _hookArray;
  20569. /**
  20570. * Define if particles should be rendered in your texture.
  20571. */
  20572. renderParticles: boolean;
  20573. /**
  20574. * Define if sprites should be rendered in your texture.
  20575. */
  20576. renderSprites: boolean;
  20577. /**
  20578. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20579. */
  20580. coordinatesMode: number;
  20581. /**
  20582. * Define the camera used to render the texture.
  20583. */
  20584. activeCamera: Nullable<Camera>;
  20585. /**
  20586. * Override the render function of the texture with your own one.
  20587. */
  20588. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20589. /**
  20590. * Define if camera post processes should be use while rendering the texture.
  20591. */
  20592. useCameraPostProcesses: boolean;
  20593. /**
  20594. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20595. */
  20596. ignoreCameraViewport: boolean;
  20597. private _postProcessManager;
  20598. private _postProcesses;
  20599. private _resizeObserver;
  20600. /**
  20601. * An event triggered when the texture is unbind.
  20602. */
  20603. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20604. /**
  20605. * An event triggered when the texture is unbind.
  20606. */
  20607. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20608. private _onAfterUnbindObserver;
  20609. /**
  20610. * Set a after unbind callback in the texture.
  20611. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20612. */
  20613. onAfterUnbind: () => void;
  20614. /**
  20615. * An event triggered before rendering the texture
  20616. */
  20617. onBeforeRenderObservable: Observable<number>;
  20618. private _onBeforeRenderObserver;
  20619. /**
  20620. * Set a before render callback in the texture.
  20621. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20622. */
  20623. onBeforeRender: (faceIndex: number) => void;
  20624. /**
  20625. * An event triggered after rendering the texture
  20626. */
  20627. onAfterRenderObservable: Observable<number>;
  20628. private _onAfterRenderObserver;
  20629. /**
  20630. * Set a after render callback in the texture.
  20631. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20632. */
  20633. onAfterRender: (faceIndex: number) => void;
  20634. /**
  20635. * An event triggered after the texture clear
  20636. */
  20637. onClearObservable: Observable<Engine>;
  20638. private _onClearObserver;
  20639. /**
  20640. * Set a clear callback in the texture.
  20641. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20642. */
  20643. onClear: (Engine: Engine) => void;
  20644. /**
  20645. * An event triggered when the texture is resized.
  20646. */
  20647. onResizeObservable: Observable<RenderTargetTexture>;
  20648. /**
  20649. * Define the clear color of the Render Target if it should be different from the scene.
  20650. */
  20651. clearColor: Color4;
  20652. protected _size: number | {
  20653. width: number;
  20654. height: number;
  20655. };
  20656. protected _initialSizeParameter: number | {
  20657. width: number;
  20658. height: number;
  20659. } | {
  20660. ratio: number;
  20661. };
  20662. protected _sizeRatio: Nullable<number>;
  20663. /** @hidden */
  20664. _generateMipMaps: boolean;
  20665. protected _renderingManager: RenderingManager;
  20666. /** @hidden */
  20667. _waitingRenderList: string[];
  20668. protected _doNotChangeAspectRatio: boolean;
  20669. protected _currentRefreshId: number;
  20670. protected _refreshRate: number;
  20671. protected _textureMatrix: Matrix;
  20672. protected _samples: number;
  20673. protected _renderTargetOptions: RenderTargetCreationOptions;
  20674. /**
  20675. * Gets render target creation options that were used.
  20676. */
  20677. readonly renderTargetOptions: RenderTargetCreationOptions;
  20678. protected _engine: Engine;
  20679. protected _onRatioRescale(): void;
  20680. /**
  20681. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20682. * It must define where the camera used to render the texture is set
  20683. */
  20684. boundingBoxPosition: Vector3;
  20685. private _boundingBoxSize;
  20686. /**
  20687. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20688. * When defined, the cubemap will switch to local mode
  20689. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20690. * @example https://www.babylonjs-playground.com/#RNASML
  20691. */
  20692. boundingBoxSize: Vector3;
  20693. /**
  20694. * In case the RTT has been created with a depth texture, get the associated
  20695. * depth texture.
  20696. * Otherwise, return null.
  20697. */
  20698. depthStencilTexture: Nullable<InternalTexture>;
  20699. /**
  20700. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20701. * or used a shadow, depth texture...
  20702. * @param name The friendly name of the texture
  20703. * @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)
  20704. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20705. * @param generateMipMaps True if mip maps need to be generated after render.
  20706. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20707. * @param type The type of the buffer in the RTT (int, half float, float...)
  20708. * @param isCube True if a cube texture needs to be created
  20709. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20710. * @param generateDepthBuffer True to generate a depth buffer
  20711. * @param generateStencilBuffer True to generate a stencil buffer
  20712. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20713. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20714. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20715. */
  20716. constructor(name: string, size: number | {
  20717. width: number;
  20718. height: number;
  20719. } | {
  20720. ratio: number;
  20721. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20722. /**
  20723. * Creates a depth stencil texture.
  20724. * This is only available in WebGL 2 or with the depth texture extension available.
  20725. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20726. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20727. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20728. */
  20729. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20730. private _processSizeParameter;
  20731. /**
  20732. * Define the number of samples to use in case of MSAA.
  20733. * It defaults to one meaning no MSAA has been enabled.
  20734. */
  20735. samples: number;
  20736. /**
  20737. * Resets the refresh counter of the texture and start bak from scratch.
  20738. * Could be useful to regenerate the texture if it is setup to render only once.
  20739. */
  20740. resetRefreshCounter(): void;
  20741. /**
  20742. * Define the refresh rate of the texture or the rendering frequency.
  20743. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20744. */
  20745. refreshRate: number;
  20746. /**
  20747. * Adds a post process to the render target rendering passes.
  20748. * @param postProcess define the post process to add
  20749. */
  20750. addPostProcess(postProcess: PostProcess): void;
  20751. /**
  20752. * Clear all the post processes attached to the render target
  20753. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20754. */
  20755. clearPostProcesses(dispose?: boolean): void;
  20756. /**
  20757. * Remove one of the post process from the list of attached post processes to the texture
  20758. * @param postProcess define the post process to remove from the list
  20759. */
  20760. removePostProcess(postProcess: PostProcess): void;
  20761. /** @hidden */
  20762. _shouldRender(): boolean;
  20763. /**
  20764. * Gets the actual render size of the texture.
  20765. * @returns the width of the render size
  20766. */
  20767. getRenderSize(): number;
  20768. /**
  20769. * Gets the actual render width of the texture.
  20770. * @returns the width of the render size
  20771. */
  20772. getRenderWidth(): number;
  20773. /**
  20774. * Gets the actual render height of the texture.
  20775. * @returns the height of the render size
  20776. */
  20777. getRenderHeight(): number;
  20778. /**
  20779. * Get if the texture can be rescaled or not.
  20780. */
  20781. readonly canRescale: boolean;
  20782. /**
  20783. * Resize the texture using a ratio.
  20784. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20785. */
  20786. scale(ratio: number): void;
  20787. /**
  20788. * Get the texture reflection matrix used to rotate/transform the reflection.
  20789. * @returns the reflection matrix
  20790. */
  20791. getReflectionTextureMatrix(): Matrix;
  20792. /**
  20793. * Resize the texture to a new desired size.
  20794. * Be carrefull as it will recreate all the data in the new texture.
  20795. * @param size Define the new size. It can be:
  20796. * - a number for squared texture,
  20797. * - an object containing { width: number, height: number }
  20798. * - or an object containing a ratio { ratio: number }
  20799. */
  20800. resize(size: number | {
  20801. width: number;
  20802. height: number;
  20803. } | {
  20804. ratio: number;
  20805. }): void;
  20806. /**
  20807. * Renders all the objects from the render list into the texture.
  20808. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20809. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20810. */
  20811. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20812. private _bestReflectionRenderTargetDimension;
  20813. /**
  20814. * @hidden
  20815. * @param faceIndex face index to bind to if this is a cubetexture
  20816. */
  20817. _bindFrameBuffer(faceIndex?: number): void;
  20818. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20819. private renderToTarget;
  20820. /**
  20821. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20822. * This allowed control for front to back rendering or reversly depending of the special needs.
  20823. *
  20824. * @param renderingGroupId The rendering group id corresponding to its index
  20825. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20826. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20827. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20828. */
  20829. 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;
  20830. /**
  20831. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20832. *
  20833. * @param renderingGroupId The rendering group id corresponding to its index
  20834. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20835. */
  20836. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20837. /**
  20838. * Clones the texture.
  20839. * @returns the cloned texture
  20840. */
  20841. clone(): RenderTargetTexture;
  20842. /**
  20843. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20844. * @returns The JSON representation of the texture
  20845. */
  20846. serialize(): any;
  20847. /**
  20848. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20849. */
  20850. disposeFramebufferObjects(): void;
  20851. /**
  20852. * Dispose the texture and release its associated resources.
  20853. */
  20854. dispose(): void;
  20855. /** @hidden */
  20856. _rebuild(): void;
  20857. /**
  20858. * Clear the info related to rendering groups preventing retention point in material dispose.
  20859. */
  20860. freeRenderingGroups(): void;
  20861. /**
  20862. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20863. * @returns the view count
  20864. */
  20865. getViewCount(): number;
  20866. }
  20867. }
  20868. declare module "babylonjs/Materials/material" {
  20869. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20870. import { SmartArray } from "babylonjs/Misc/smartArray";
  20871. import { Observable } from "babylonjs/Misc/observable";
  20872. import { Nullable } from "babylonjs/types";
  20873. import { Scene } from "babylonjs/scene";
  20874. import { Matrix } from "babylonjs/Maths/math.vector";
  20875. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20877. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20878. import { Effect } from "babylonjs/Materials/effect";
  20879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20880. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20881. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20882. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20883. import { Mesh } from "babylonjs/Meshes/mesh";
  20884. import { Animation } from "babylonjs/Animations/animation";
  20885. /**
  20886. * Options for compiling materials.
  20887. */
  20888. export interface IMaterialCompilationOptions {
  20889. /**
  20890. * Defines whether clip planes are enabled.
  20891. */
  20892. clipPlane: boolean;
  20893. /**
  20894. * Defines whether instances are enabled.
  20895. */
  20896. useInstances: boolean;
  20897. }
  20898. /**
  20899. * Base class for the main features of a material in Babylon.js
  20900. */
  20901. export class Material implements IAnimatable {
  20902. /**
  20903. * Returns the triangle fill mode
  20904. */
  20905. static readonly TriangleFillMode: number;
  20906. /**
  20907. * Returns the wireframe mode
  20908. */
  20909. static readonly WireFrameFillMode: number;
  20910. /**
  20911. * Returns the point fill mode
  20912. */
  20913. static readonly PointFillMode: number;
  20914. /**
  20915. * Returns the point list draw mode
  20916. */
  20917. static readonly PointListDrawMode: number;
  20918. /**
  20919. * Returns the line list draw mode
  20920. */
  20921. static readonly LineListDrawMode: number;
  20922. /**
  20923. * Returns the line loop draw mode
  20924. */
  20925. static readonly LineLoopDrawMode: number;
  20926. /**
  20927. * Returns the line strip draw mode
  20928. */
  20929. static readonly LineStripDrawMode: number;
  20930. /**
  20931. * Returns the triangle strip draw mode
  20932. */
  20933. static readonly TriangleStripDrawMode: number;
  20934. /**
  20935. * Returns the triangle fan draw mode
  20936. */
  20937. static readonly TriangleFanDrawMode: number;
  20938. /**
  20939. * Stores the clock-wise side orientation
  20940. */
  20941. static readonly ClockWiseSideOrientation: number;
  20942. /**
  20943. * Stores the counter clock-wise side orientation
  20944. */
  20945. static readonly CounterClockWiseSideOrientation: number;
  20946. /**
  20947. * The dirty texture flag value
  20948. */
  20949. static readonly TextureDirtyFlag: number;
  20950. /**
  20951. * The dirty light flag value
  20952. */
  20953. static readonly LightDirtyFlag: number;
  20954. /**
  20955. * The dirty fresnel flag value
  20956. */
  20957. static readonly FresnelDirtyFlag: number;
  20958. /**
  20959. * The dirty attribute flag value
  20960. */
  20961. static readonly AttributesDirtyFlag: number;
  20962. /**
  20963. * The dirty misc flag value
  20964. */
  20965. static readonly MiscDirtyFlag: number;
  20966. /**
  20967. * The all dirty flag value
  20968. */
  20969. static readonly AllDirtyFlag: number;
  20970. /**
  20971. * The ID of the material
  20972. */
  20973. id: string;
  20974. /**
  20975. * Gets or sets the unique id of the material
  20976. */
  20977. uniqueId: number;
  20978. /**
  20979. * The name of the material
  20980. */
  20981. name: string;
  20982. /**
  20983. * Gets or sets user defined metadata
  20984. */
  20985. metadata: any;
  20986. /**
  20987. * For internal use only. Please do not use.
  20988. */
  20989. reservedDataStore: any;
  20990. /**
  20991. * Specifies if the ready state should be checked on each call
  20992. */
  20993. checkReadyOnEveryCall: boolean;
  20994. /**
  20995. * Specifies if the ready state should be checked once
  20996. */
  20997. checkReadyOnlyOnce: boolean;
  20998. /**
  20999. * The state of the material
  21000. */
  21001. state: string;
  21002. /**
  21003. * The alpha value of the material
  21004. */
  21005. protected _alpha: number;
  21006. /**
  21007. * List of inspectable custom properties (used by the Inspector)
  21008. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21009. */
  21010. inspectableCustomProperties: IInspectable[];
  21011. /**
  21012. * Sets the alpha value of the material
  21013. */
  21014. /**
  21015. * Gets the alpha value of the material
  21016. */
  21017. alpha: number;
  21018. /**
  21019. * Specifies if back face culling is enabled
  21020. */
  21021. protected _backFaceCulling: boolean;
  21022. /**
  21023. * Sets the back-face culling state
  21024. */
  21025. /**
  21026. * Gets the back-face culling state
  21027. */
  21028. backFaceCulling: boolean;
  21029. /**
  21030. * Stores the value for side orientation
  21031. */
  21032. sideOrientation: number;
  21033. /**
  21034. * Callback triggered when the material is compiled
  21035. */
  21036. onCompiled: Nullable<(effect: Effect) => void>;
  21037. /**
  21038. * Callback triggered when an error occurs
  21039. */
  21040. onError: Nullable<(effect: Effect, errors: string) => void>;
  21041. /**
  21042. * Callback triggered to get the render target textures
  21043. */
  21044. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21045. /**
  21046. * Gets a boolean indicating that current material needs to register RTT
  21047. */
  21048. readonly hasRenderTargetTextures: boolean;
  21049. /**
  21050. * Specifies if the material should be serialized
  21051. */
  21052. doNotSerialize: boolean;
  21053. /**
  21054. * @hidden
  21055. */
  21056. _storeEffectOnSubMeshes: boolean;
  21057. /**
  21058. * Stores the animations for the material
  21059. */
  21060. animations: Nullable<Array<Animation>>;
  21061. /**
  21062. * An event triggered when the material is disposed
  21063. */
  21064. onDisposeObservable: Observable<Material>;
  21065. /**
  21066. * An observer which watches for dispose events
  21067. */
  21068. private _onDisposeObserver;
  21069. private _onUnBindObservable;
  21070. /**
  21071. * Called during a dispose event
  21072. */
  21073. onDispose: () => void;
  21074. private _onBindObservable;
  21075. /**
  21076. * An event triggered when the material is bound
  21077. */
  21078. readonly onBindObservable: Observable<AbstractMesh>;
  21079. /**
  21080. * An observer which watches for bind events
  21081. */
  21082. private _onBindObserver;
  21083. /**
  21084. * Called during a bind event
  21085. */
  21086. onBind: (Mesh: AbstractMesh) => void;
  21087. /**
  21088. * An event triggered when the material is unbound
  21089. */
  21090. readonly onUnBindObservable: Observable<Material>;
  21091. /**
  21092. * Stores the value of the alpha mode
  21093. */
  21094. private _alphaMode;
  21095. /**
  21096. * Sets the value of the alpha mode.
  21097. *
  21098. * | Value | Type | Description |
  21099. * | --- | --- | --- |
  21100. * | 0 | ALPHA_DISABLE | |
  21101. * | 1 | ALPHA_ADD | |
  21102. * | 2 | ALPHA_COMBINE | |
  21103. * | 3 | ALPHA_SUBTRACT | |
  21104. * | 4 | ALPHA_MULTIPLY | |
  21105. * | 5 | ALPHA_MAXIMIZED | |
  21106. * | 6 | ALPHA_ONEONE | |
  21107. * | 7 | ALPHA_PREMULTIPLIED | |
  21108. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21109. * | 9 | ALPHA_INTERPOLATE | |
  21110. * | 10 | ALPHA_SCREENMODE | |
  21111. *
  21112. */
  21113. /**
  21114. * Gets the value of the alpha mode
  21115. */
  21116. alphaMode: number;
  21117. /**
  21118. * Stores the state of the need depth pre-pass value
  21119. */
  21120. private _needDepthPrePass;
  21121. /**
  21122. * Sets the need depth pre-pass value
  21123. */
  21124. /**
  21125. * Gets the depth pre-pass value
  21126. */
  21127. needDepthPrePass: boolean;
  21128. /**
  21129. * Specifies if depth writing should be disabled
  21130. */
  21131. disableDepthWrite: boolean;
  21132. /**
  21133. * Specifies if depth writing should be forced
  21134. */
  21135. forceDepthWrite: boolean;
  21136. /**
  21137. * Specifies if there should be a separate pass for culling
  21138. */
  21139. separateCullingPass: boolean;
  21140. /**
  21141. * Stores the state specifing if fog should be enabled
  21142. */
  21143. private _fogEnabled;
  21144. /**
  21145. * Sets the state for enabling fog
  21146. */
  21147. /**
  21148. * Gets the value of the fog enabled state
  21149. */
  21150. fogEnabled: boolean;
  21151. /**
  21152. * Stores the size of points
  21153. */
  21154. pointSize: number;
  21155. /**
  21156. * Stores the z offset value
  21157. */
  21158. zOffset: number;
  21159. /**
  21160. * Gets a value specifying if wireframe mode is enabled
  21161. */
  21162. /**
  21163. * Sets the state of wireframe mode
  21164. */
  21165. wireframe: boolean;
  21166. /**
  21167. * Gets the value specifying if point clouds are enabled
  21168. */
  21169. /**
  21170. * Sets the state of point cloud mode
  21171. */
  21172. pointsCloud: boolean;
  21173. /**
  21174. * Gets the material fill mode
  21175. */
  21176. /**
  21177. * Sets the material fill mode
  21178. */
  21179. fillMode: number;
  21180. /**
  21181. * @hidden
  21182. * Stores the effects for the material
  21183. */
  21184. _effect: Nullable<Effect>;
  21185. /**
  21186. * @hidden
  21187. * Specifies if the material was previously ready
  21188. */
  21189. _wasPreviouslyReady: boolean;
  21190. /**
  21191. * Specifies if uniform buffers should be used
  21192. */
  21193. private _useUBO;
  21194. /**
  21195. * Stores a reference to the scene
  21196. */
  21197. private _scene;
  21198. /**
  21199. * Stores the fill mode state
  21200. */
  21201. private _fillMode;
  21202. /**
  21203. * Specifies if the depth write state should be cached
  21204. */
  21205. private _cachedDepthWriteState;
  21206. /**
  21207. * Stores the uniform buffer
  21208. */
  21209. protected _uniformBuffer: UniformBuffer;
  21210. /** @hidden */
  21211. _indexInSceneMaterialArray: number;
  21212. /** @hidden */
  21213. meshMap: Nullable<{
  21214. [id: string]: AbstractMesh | undefined;
  21215. }>;
  21216. /**
  21217. * Creates a material instance
  21218. * @param name defines the name of the material
  21219. * @param scene defines the scene to reference
  21220. * @param doNotAdd specifies if the material should be added to the scene
  21221. */
  21222. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21223. /**
  21224. * Returns a string representation of the current material
  21225. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21226. * @returns a string with material information
  21227. */
  21228. toString(fullDetails?: boolean): string;
  21229. /**
  21230. * Gets the class name of the material
  21231. * @returns a string with the class name of the material
  21232. */
  21233. getClassName(): string;
  21234. /**
  21235. * Specifies if updates for the material been locked
  21236. */
  21237. readonly isFrozen: boolean;
  21238. /**
  21239. * Locks updates for the material
  21240. */
  21241. freeze(): void;
  21242. /**
  21243. * Unlocks updates for the material
  21244. */
  21245. unfreeze(): void;
  21246. /**
  21247. * Specifies if the material is ready to be used
  21248. * @param mesh defines the mesh to check
  21249. * @param useInstances specifies if instances should be used
  21250. * @returns a boolean indicating if the material is ready to be used
  21251. */
  21252. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21253. /**
  21254. * Specifies that the submesh is ready to be used
  21255. * @param mesh defines the mesh to check
  21256. * @param subMesh defines which submesh to check
  21257. * @param useInstances specifies that instances should be used
  21258. * @returns a boolean indicating that the submesh is ready or not
  21259. */
  21260. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21261. /**
  21262. * Returns the material effect
  21263. * @returns the effect associated with the material
  21264. */
  21265. getEffect(): Nullable<Effect>;
  21266. /**
  21267. * Returns the current scene
  21268. * @returns a Scene
  21269. */
  21270. getScene(): Scene;
  21271. /**
  21272. * Specifies if the material will require alpha blending
  21273. * @returns a boolean specifying if alpha blending is needed
  21274. */
  21275. needAlphaBlending(): boolean;
  21276. /**
  21277. * Specifies if the mesh will require alpha blending
  21278. * @param mesh defines the mesh to check
  21279. * @returns a boolean specifying if alpha blending is needed for the mesh
  21280. */
  21281. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21282. /**
  21283. * Specifies if this material should be rendered in alpha test mode
  21284. * @returns a boolean specifying if an alpha test is needed.
  21285. */
  21286. needAlphaTesting(): boolean;
  21287. /**
  21288. * Gets the texture used for the alpha test
  21289. * @returns the texture to use for alpha testing
  21290. */
  21291. getAlphaTestTexture(): Nullable<BaseTexture>;
  21292. /**
  21293. * Marks the material to indicate that it needs to be re-calculated
  21294. */
  21295. markDirty(): void;
  21296. /** @hidden */
  21297. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21298. /**
  21299. * Binds the material to the mesh
  21300. * @param world defines the world transformation matrix
  21301. * @param mesh defines the mesh to bind the material to
  21302. */
  21303. bind(world: Matrix, mesh?: Mesh): void;
  21304. /**
  21305. * Binds the submesh to the material
  21306. * @param world defines the world transformation matrix
  21307. * @param mesh defines the mesh containing the submesh
  21308. * @param subMesh defines the submesh to bind the material to
  21309. */
  21310. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21311. /**
  21312. * Binds the world matrix to the material
  21313. * @param world defines the world transformation matrix
  21314. */
  21315. bindOnlyWorldMatrix(world: Matrix): void;
  21316. /**
  21317. * Binds the scene's uniform buffer to the effect.
  21318. * @param effect defines the effect to bind to the scene uniform buffer
  21319. * @param sceneUbo defines the uniform buffer storing scene data
  21320. */
  21321. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21322. /**
  21323. * Binds the view matrix to the effect
  21324. * @param effect defines the effect to bind the view matrix to
  21325. */
  21326. bindView(effect: Effect): void;
  21327. /**
  21328. * Binds the view projection matrix to the effect
  21329. * @param effect defines the effect to bind the view projection matrix to
  21330. */
  21331. bindViewProjection(effect: Effect): void;
  21332. /**
  21333. * Specifies if material alpha testing should be turned on for the mesh
  21334. * @param mesh defines the mesh to check
  21335. */
  21336. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21337. /**
  21338. * Processes to execute after binding the material to a mesh
  21339. * @param mesh defines the rendered mesh
  21340. */
  21341. protected _afterBind(mesh?: Mesh): void;
  21342. /**
  21343. * Unbinds the material from the mesh
  21344. */
  21345. unbind(): void;
  21346. /**
  21347. * Gets the active textures from the material
  21348. * @returns an array of textures
  21349. */
  21350. getActiveTextures(): BaseTexture[];
  21351. /**
  21352. * Specifies if the material uses a texture
  21353. * @param texture defines the texture to check against the material
  21354. * @returns a boolean specifying if the material uses the texture
  21355. */
  21356. hasTexture(texture: BaseTexture): boolean;
  21357. /**
  21358. * Makes a duplicate of the material, and gives it a new name
  21359. * @param name defines the new name for the duplicated material
  21360. * @returns the cloned material
  21361. */
  21362. clone(name: string): Nullable<Material>;
  21363. /**
  21364. * Gets the meshes bound to the material
  21365. * @returns an array of meshes bound to the material
  21366. */
  21367. getBindedMeshes(): AbstractMesh[];
  21368. /**
  21369. * Force shader compilation
  21370. * @param mesh defines the mesh associated with this material
  21371. * @param onCompiled defines a function to execute once the material is compiled
  21372. * @param options defines the options to configure the compilation
  21373. * @param onError defines a function to execute if the material fails compiling
  21374. */
  21375. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21376. /**
  21377. * Force shader compilation
  21378. * @param mesh defines the mesh that will use this material
  21379. * @param options defines additional options for compiling the shaders
  21380. * @returns a promise that resolves when the compilation completes
  21381. */
  21382. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21383. private static readonly _AllDirtyCallBack;
  21384. private static readonly _ImageProcessingDirtyCallBack;
  21385. private static readonly _TextureDirtyCallBack;
  21386. private static readonly _FresnelDirtyCallBack;
  21387. private static readonly _MiscDirtyCallBack;
  21388. private static readonly _LightsDirtyCallBack;
  21389. private static readonly _AttributeDirtyCallBack;
  21390. private static _FresnelAndMiscDirtyCallBack;
  21391. private static _TextureAndMiscDirtyCallBack;
  21392. private static readonly _DirtyCallbackArray;
  21393. private static readonly _RunDirtyCallBacks;
  21394. /**
  21395. * Marks a define in the material to indicate that it needs to be re-computed
  21396. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21397. */
  21398. markAsDirty(flag: number): void;
  21399. /**
  21400. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21401. * @param func defines a function which checks material defines against the submeshes
  21402. */
  21403. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21404. /**
  21405. * Indicates that we need to re-calculated for all submeshes
  21406. */
  21407. protected _markAllSubMeshesAsAllDirty(): void;
  21408. /**
  21409. * Indicates that image processing needs to be re-calculated for all submeshes
  21410. */
  21411. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21412. /**
  21413. * Indicates that textures need to be re-calculated for all submeshes
  21414. */
  21415. protected _markAllSubMeshesAsTexturesDirty(): void;
  21416. /**
  21417. * Indicates that fresnel needs to be re-calculated for all submeshes
  21418. */
  21419. protected _markAllSubMeshesAsFresnelDirty(): void;
  21420. /**
  21421. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21422. */
  21423. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21424. /**
  21425. * Indicates that lights need to be re-calculated for all submeshes
  21426. */
  21427. protected _markAllSubMeshesAsLightsDirty(): void;
  21428. /**
  21429. * Indicates that attributes need to be re-calculated for all submeshes
  21430. */
  21431. protected _markAllSubMeshesAsAttributesDirty(): void;
  21432. /**
  21433. * Indicates that misc needs to be re-calculated for all submeshes
  21434. */
  21435. protected _markAllSubMeshesAsMiscDirty(): void;
  21436. /**
  21437. * Indicates that textures and misc need to be re-calculated for all submeshes
  21438. */
  21439. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21440. /**
  21441. * Disposes the material
  21442. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21443. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21444. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21445. */
  21446. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21447. /** @hidden */
  21448. private releaseVertexArrayObject;
  21449. /**
  21450. * Serializes this material
  21451. * @returns the serialized material object
  21452. */
  21453. serialize(): any;
  21454. /**
  21455. * Creates a material from parsed material data
  21456. * @param parsedMaterial defines parsed material data
  21457. * @param scene defines the hosting scene
  21458. * @param rootUrl defines the root URL to use to load textures
  21459. * @returns a new material
  21460. */
  21461. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21462. }
  21463. }
  21464. declare module "babylonjs/Materials/multiMaterial" {
  21465. import { Nullable } from "babylonjs/types";
  21466. import { Scene } from "babylonjs/scene";
  21467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21468. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21469. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21470. import { Material } from "babylonjs/Materials/material";
  21471. /**
  21472. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21473. * separate meshes. This can be use to improve performances.
  21474. * @see http://doc.babylonjs.com/how_to/multi_materials
  21475. */
  21476. export class MultiMaterial extends Material {
  21477. private _subMaterials;
  21478. /**
  21479. * Gets or Sets the list of Materials used within the multi material.
  21480. * They need to be ordered according to the submeshes order in the associated mesh
  21481. */
  21482. subMaterials: Nullable<Material>[];
  21483. /**
  21484. * Function used to align with Node.getChildren()
  21485. * @returns the list of Materials used within the multi material
  21486. */
  21487. getChildren(): Nullable<Material>[];
  21488. /**
  21489. * Instantiates a new Multi Material
  21490. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21491. * separate meshes. This can be use to improve performances.
  21492. * @see http://doc.babylonjs.com/how_to/multi_materials
  21493. * @param name Define the name in the scene
  21494. * @param scene Define the scene the material belongs to
  21495. */
  21496. constructor(name: string, scene: Scene);
  21497. private _hookArray;
  21498. /**
  21499. * Get one of the submaterial by its index in the submaterials array
  21500. * @param index The index to look the sub material at
  21501. * @returns The Material if the index has been defined
  21502. */
  21503. getSubMaterial(index: number): Nullable<Material>;
  21504. /**
  21505. * Get the list of active textures for the whole sub materials list.
  21506. * @returns All the textures that will be used during the rendering
  21507. */
  21508. getActiveTextures(): BaseTexture[];
  21509. /**
  21510. * Gets the current class name of the material e.g. "MultiMaterial"
  21511. * Mainly use in serialization.
  21512. * @returns the class name
  21513. */
  21514. getClassName(): string;
  21515. /**
  21516. * Checks if the material is ready to render the requested sub mesh
  21517. * @param mesh Define the mesh the submesh belongs to
  21518. * @param subMesh Define the sub mesh to look readyness for
  21519. * @param useInstances Define whether or not the material is used with instances
  21520. * @returns true if ready, otherwise false
  21521. */
  21522. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21523. /**
  21524. * Clones the current material and its related sub materials
  21525. * @param name Define the name of the newly cloned material
  21526. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21527. * @returns the cloned material
  21528. */
  21529. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21530. /**
  21531. * Serializes the materials into a JSON representation.
  21532. * @returns the JSON representation
  21533. */
  21534. serialize(): any;
  21535. /**
  21536. * Dispose the material and release its associated resources
  21537. * @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)
  21538. * @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)
  21539. * @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)
  21540. */
  21541. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21542. /**
  21543. * Creates a MultiMaterial from parsed MultiMaterial data.
  21544. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21545. * @param scene defines the hosting scene
  21546. * @returns a new MultiMaterial
  21547. */
  21548. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21549. }
  21550. }
  21551. declare module "babylonjs/Meshes/subMesh" {
  21552. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21553. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21554. import { Engine } from "babylonjs/Engines/engine";
  21555. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21556. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21557. import { Effect } from "babylonjs/Materials/effect";
  21558. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21559. import { Plane } from "babylonjs/Maths/math.plane";
  21560. import { Collider } from "babylonjs/Collisions/collider";
  21561. import { Material } from "babylonjs/Materials/material";
  21562. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21564. import { Mesh } from "babylonjs/Meshes/mesh";
  21565. import { Ray } from "babylonjs/Culling/ray";
  21566. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21567. /**
  21568. * Base class for submeshes
  21569. */
  21570. export class BaseSubMesh {
  21571. /** @hidden */
  21572. _materialDefines: Nullable<MaterialDefines>;
  21573. /** @hidden */
  21574. _materialEffect: Nullable<Effect>;
  21575. /**
  21576. * Gets associated effect
  21577. */
  21578. readonly effect: Nullable<Effect>;
  21579. /**
  21580. * Sets associated effect (effect used to render this submesh)
  21581. * @param effect defines the effect to associate with
  21582. * @param defines defines the set of defines used to compile this effect
  21583. */
  21584. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21585. }
  21586. /**
  21587. * Defines a subdivision inside a mesh
  21588. */
  21589. export class SubMesh extends BaseSubMesh implements ICullable {
  21590. /** the material index to use */
  21591. materialIndex: number;
  21592. /** vertex index start */
  21593. verticesStart: number;
  21594. /** vertices count */
  21595. verticesCount: number;
  21596. /** index start */
  21597. indexStart: number;
  21598. /** indices count */
  21599. indexCount: number;
  21600. /** @hidden */
  21601. _linesIndexCount: number;
  21602. private _mesh;
  21603. private _renderingMesh;
  21604. private _boundingInfo;
  21605. private _linesIndexBuffer;
  21606. /** @hidden */
  21607. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21608. /** @hidden */
  21609. _trianglePlanes: Plane[];
  21610. /** @hidden */
  21611. _lastColliderTransformMatrix: Nullable<Matrix>;
  21612. /** @hidden */
  21613. _renderId: number;
  21614. /** @hidden */
  21615. _alphaIndex: number;
  21616. /** @hidden */
  21617. _distanceToCamera: number;
  21618. /** @hidden */
  21619. _id: number;
  21620. private _currentMaterial;
  21621. /**
  21622. * Add a new submesh to a mesh
  21623. * @param materialIndex defines the material index to use
  21624. * @param verticesStart defines vertex index start
  21625. * @param verticesCount defines vertices count
  21626. * @param indexStart defines index start
  21627. * @param indexCount defines indices count
  21628. * @param mesh defines the parent mesh
  21629. * @param renderingMesh defines an optional rendering mesh
  21630. * @param createBoundingBox defines if bounding box should be created for this submesh
  21631. * @returns the new submesh
  21632. */
  21633. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21634. /**
  21635. * Creates a new submesh
  21636. * @param materialIndex defines the material index to use
  21637. * @param verticesStart defines vertex index start
  21638. * @param verticesCount defines vertices count
  21639. * @param indexStart defines index start
  21640. * @param indexCount defines indices count
  21641. * @param mesh defines the parent mesh
  21642. * @param renderingMesh defines an optional rendering mesh
  21643. * @param createBoundingBox defines if bounding box should be created for this submesh
  21644. */
  21645. constructor(
  21646. /** the material index to use */
  21647. materialIndex: number,
  21648. /** vertex index start */
  21649. verticesStart: number,
  21650. /** vertices count */
  21651. verticesCount: number,
  21652. /** index start */
  21653. indexStart: number,
  21654. /** indices count */
  21655. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21656. /**
  21657. * Returns true if this submesh covers the entire parent mesh
  21658. * @ignorenaming
  21659. */
  21660. readonly IsGlobal: boolean;
  21661. /**
  21662. * Returns the submesh BoudingInfo object
  21663. * @returns current bounding info (or mesh's one if the submesh is global)
  21664. */
  21665. getBoundingInfo(): BoundingInfo;
  21666. /**
  21667. * Sets the submesh BoundingInfo
  21668. * @param boundingInfo defines the new bounding info to use
  21669. * @returns the SubMesh
  21670. */
  21671. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21672. /**
  21673. * Returns the mesh of the current submesh
  21674. * @return the parent mesh
  21675. */
  21676. getMesh(): AbstractMesh;
  21677. /**
  21678. * Returns the rendering mesh of the submesh
  21679. * @returns the rendering mesh (could be different from parent mesh)
  21680. */
  21681. getRenderingMesh(): Mesh;
  21682. /**
  21683. * Returns the submesh material
  21684. * @returns null or the current material
  21685. */
  21686. getMaterial(): Nullable<Material>;
  21687. /**
  21688. * Sets a new updated BoundingInfo object to the submesh
  21689. * @param data defines an optional position array to use to determine the bounding info
  21690. * @returns the SubMesh
  21691. */
  21692. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21693. /** @hidden */
  21694. _checkCollision(collider: Collider): boolean;
  21695. /**
  21696. * Updates the submesh BoundingInfo
  21697. * @param world defines the world matrix to use to update the bounding info
  21698. * @returns the submesh
  21699. */
  21700. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21701. /**
  21702. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21703. * @param frustumPlanes defines the frustum planes
  21704. * @returns true if the submesh is intersecting with the frustum
  21705. */
  21706. isInFrustum(frustumPlanes: Plane[]): boolean;
  21707. /**
  21708. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21709. * @param frustumPlanes defines the frustum planes
  21710. * @returns true if the submesh is inside the frustum
  21711. */
  21712. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21713. /**
  21714. * Renders the submesh
  21715. * @param enableAlphaMode defines if alpha needs to be used
  21716. * @returns the submesh
  21717. */
  21718. render(enableAlphaMode: boolean): SubMesh;
  21719. /**
  21720. * @hidden
  21721. */
  21722. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21723. /**
  21724. * Checks if the submesh intersects with a ray
  21725. * @param ray defines the ray to test
  21726. * @returns true is the passed ray intersects the submesh bounding box
  21727. */
  21728. canIntersects(ray: Ray): boolean;
  21729. /**
  21730. * Intersects current submesh with a ray
  21731. * @param ray defines the ray to test
  21732. * @param positions defines mesh's positions array
  21733. * @param indices defines mesh's indices array
  21734. * @param fastCheck defines if only bounding info should be used
  21735. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21736. * @returns intersection info or null if no intersection
  21737. */
  21738. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21739. /** @hidden */
  21740. private _intersectLines;
  21741. /** @hidden */
  21742. private _intersectUnIndexedLines;
  21743. /** @hidden */
  21744. private _intersectTriangles;
  21745. /** @hidden */
  21746. private _intersectUnIndexedTriangles;
  21747. /** @hidden */
  21748. _rebuild(): void;
  21749. /**
  21750. * Creates a new submesh from the passed mesh
  21751. * @param newMesh defines the new hosting mesh
  21752. * @param newRenderingMesh defines an optional rendering mesh
  21753. * @returns the new submesh
  21754. */
  21755. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21756. /**
  21757. * Release associated resources
  21758. */
  21759. dispose(): void;
  21760. /**
  21761. * Gets the class name
  21762. * @returns the string "SubMesh".
  21763. */
  21764. getClassName(): string;
  21765. /**
  21766. * Creates a new submesh from indices data
  21767. * @param materialIndex the index of the main mesh material
  21768. * @param startIndex the index where to start the copy in the mesh indices array
  21769. * @param indexCount the number of indices to copy then from the startIndex
  21770. * @param mesh the main mesh to create the submesh from
  21771. * @param renderingMesh the optional rendering mesh
  21772. * @returns a new submesh
  21773. */
  21774. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21775. }
  21776. }
  21777. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21778. /**
  21779. * Class used to represent data loading progression
  21780. */
  21781. export class SceneLoaderFlags {
  21782. private static _ForceFullSceneLoadingForIncremental;
  21783. private static _ShowLoadingScreen;
  21784. private static _CleanBoneMatrixWeights;
  21785. private static _loggingLevel;
  21786. /**
  21787. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21788. */
  21789. static ForceFullSceneLoadingForIncremental: boolean;
  21790. /**
  21791. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21792. */
  21793. static ShowLoadingScreen: boolean;
  21794. /**
  21795. * Defines the current logging level (while loading the scene)
  21796. * @ignorenaming
  21797. */
  21798. static loggingLevel: number;
  21799. /**
  21800. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21801. */
  21802. static CleanBoneMatrixWeights: boolean;
  21803. }
  21804. }
  21805. declare module "babylonjs/Meshes/geometry" {
  21806. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21807. import { Scene } from "babylonjs/scene";
  21808. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21809. import { Engine } from "babylonjs/Engines/engine";
  21810. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21811. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21812. import { Effect } from "babylonjs/Materials/effect";
  21813. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21814. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21815. import { Mesh } from "babylonjs/Meshes/mesh";
  21816. /**
  21817. * Class used to store geometry data (vertex buffers + index buffer)
  21818. */
  21819. export class Geometry implements IGetSetVerticesData {
  21820. /**
  21821. * Gets or sets the ID of the geometry
  21822. */
  21823. id: string;
  21824. /**
  21825. * Gets or sets the unique ID of the geometry
  21826. */
  21827. uniqueId: number;
  21828. /**
  21829. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21830. */
  21831. delayLoadState: number;
  21832. /**
  21833. * Gets the file containing the data to load when running in delay load state
  21834. */
  21835. delayLoadingFile: Nullable<string>;
  21836. /**
  21837. * Callback called when the geometry is updated
  21838. */
  21839. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21840. private _scene;
  21841. private _engine;
  21842. private _meshes;
  21843. private _totalVertices;
  21844. /** @hidden */
  21845. _indices: IndicesArray;
  21846. /** @hidden */
  21847. _vertexBuffers: {
  21848. [key: string]: VertexBuffer;
  21849. };
  21850. private _isDisposed;
  21851. private _extend;
  21852. private _boundingBias;
  21853. /** @hidden */
  21854. _delayInfo: Array<string>;
  21855. private _indexBuffer;
  21856. private _indexBufferIsUpdatable;
  21857. /** @hidden */
  21858. _boundingInfo: Nullable<BoundingInfo>;
  21859. /** @hidden */
  21860. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21861. /** @hidden */
  21862. _softwareSkinningFrameId: number;
  21863. private _vertexArrayObjects;
  21864. private _updatable;
  21865. /** @hidden */
  21866. _positions: Nullable<Vector3[]>;
  21867. /**
  21868. * 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
  21869. */
  21870. /**
  21871. * 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
  21872. */
  21873. boundingBias: Vector2;
  21874. /**
  21875. * Static function used to attach a new empty geometry to a mesh
  21876. * @param mesh defines the mesh to attach the geometry to
  21877. * @returns the new Geometry
  21878. */
  21879. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21880. /**
  21881. * Creates a new geometry
  21882. * @param id defines the unique ID
  21883. * @param scene defines the hosting scene
  21884. * @param vertexData defines the VertexData used to get geometry data
  21885. * @param updatable defines if geometry must be updatable (false by default)
  21886. * @param mesh defines the mesh that will be associated with the geometry
  21887. */
  21888. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21889. /**
  21890. * Gets the current extend of the geometry
  21891. */
  21892. readonly extend: {
  21893. minimum: Vector3;
  21894. maximum: Vector3;
  21895. };
  21896. /**
  21897. * Gets the hosting scene
  21898. * @returns the hosting Scene
  21899. */
  21900. getScene(): Scene;
  21901. /**
  21902. * Gets the hosting engine
  21903. * @returns the hosting Engine
  21904. */
  21905. getEngine(): Engine;
  21906. /**
  21907. * Defines if the geometry is ready to use
  21908. * @returns true if the geometry is ready to be used
  21909. */
  21910. isReady(): boolean;
  21911. /**
  21912. * Gets a value indicating that the geometry should not be serialized
  21913. */
  21914. readonly doNotSerialize: boolean;
  21915. /** @hidden */
  21916. _rebuild(): void;
  21917. /**
  21918. * Affects all geometry data in one call
  21919. * @param vertexData defines the geometry data
  21920. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21921. */
  21922. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21923. /**
  21924. * Set specific vertex data
  21925. * @param kind defines the data kind (Position, normal, etc...)
  21926. * @param data defines the vertex data to use
  21927. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21928. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21929. */
  21930. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21931. /**
  21932. * Removes a specific vertex data
  21933. * @param kind defines the data kind (Position, normal, etc...)
  21934. */
  21935. removeVerticesData(kind: string): void;
  21936. /**
  21937. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21938. * @param buffer defines the vertex buffer to use
  21939. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21940. */
  21941. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21942. /**
  21943. * Update a specific vertex buffer
  21944. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21945. * It will do nothing if the buffer is not updatable
  21946. * @param kind defines the data kind (Position, normal, etc...)
  21947. * @param data defines the data to use
  21948. * @param offset defines the offset in the target buffer where to store the data
  21949. * @param useBytes set to true if the offset is in bytes
  21950. */
  21951. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21952. /**
  21953. * Update a specific vertex buffer
  21954. * This function will create a new buffer if the current one is not updatable
  21955. * @param kind defines the data kind (Position, normal, etc...)
  21956. * @param data defines the data to use
  21957. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21958. */
  21959. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21960. private _updateBoundingInfo;
  21961. /** @hidden */
  21962. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21963. /**
  21964. * Gets total number of vertices
  21965. * @returns the total number of vertices
  21966. */
  21967. getTotalVertices(): number;
  21968. /**
  21969. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21970. * @param kind defines the data kind (Position, normal, etc...)
  21971. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21972. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21973. * @returns a float array containing vertex data
  21974. */
  21975. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21976. /**
  21977. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21978. * @param kind defines the data kind (Position, normal, etc...)
  21979. * @returns true if the vertex buffer with the specified kind is updatable
  21980. */
  21981. isVertexBufferUpdatable(kind: string): boolean;
  21982. /**
  21983. * Gets a specific vertex buffer
  21984. * @param kind defines the data kind (Position, normal, etc...)
  21985. * @returns a VertexBuffer
  21986. */
  21987. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21988. /**
  21989. * Returns all vertex buffers
  21990. * @return an object holding all vertex buffers indexed by kind
  21991. */
  21992. getVertexBuffers(): Nullable<{
  21993. [key: string]: VertexBuffer;
  21994. }>;
  21995. /**
  21996. * Gets a boolean indicating if specific vertex buffer is present
  21997. * @param kind defines the data kind (Position, normal, etc...)
  21998. * @returns true if data is present
  21999. */
  22000. isVerticesDataPresent(kind: string): boolean;
  22001. /**
  22002. * Gets a list of all attached data kinds (Position, normal, etc...)
  22003. * @returns a list of string containing all kinds
  22004. */
  22005. getVerticesDataKinds(): string[];
  22006. /**
  22007. * Update index buffer
  22008. * @param indices defines the indices to store in the index buffer
  22009. * @param offset defines the offset in the target buffer where to store the data
  22010. * @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)
  22011. */
  22012. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22013. /**
  22014. * Creates a new index buffer
  22015. * @param indices defines the indices to store in the index buffer
  22016. * @param totalVertices defines the total number of vertices (could be null)
  22017. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22018. */
  22019. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22020. /**
  22021. * Return the total number of indices
  22022. * @returns the total number of indices
  22023. */
  22024. getTotalIndices(): number;
  22025. /**
  22026. * Gets the index buffer array
  22027. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22028. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22029. * @returns the index buffer array
  22030. */
  22031. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22032. /**
  22033. * Gets the index buffer
  22034. * @return the index buffer
  22035. */
  22036. getIndexBuffer(): Nullable<DataBuffer>;
  22037. /** @hidden */
  22038. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22039. /**
  22040. * Release the associated resources for a specific mesh
  22041. * @param mesh defines the source mesh
  22042. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22043. */
  22044. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22045. /**
  22046. * Apply current geometry to a given mesh
  22047. * @param mesh defines the mesh to apply geometry to
  22048. */
  22049. applyToMesh(mesh: Mesh): void;
  22050. private _updateExtend;
  22051. private _applyToMesh;
  22052. private notifyUpdate;
  22053. /**
  22054. * Load the geometry if it was flagged as delay loaded
  22055. * @param scene defines the hosting scene
  22056. * @param onLoaded defines a callback called when the geometry is loaded
  22057. */
  22058. load(scene: Scene, onLoaded?: () => void): void;
  22059. private _queueLoad;
  22060. /**
  22061. * Invert the geometry to move from a right handed system to a left handed one.
  22062. */
  22063. toLeftHanded(): void;
  22064. /** @hidden */
  22065. _resetPointsArrayCache(): void;
  22066. /** @hidden */
  22067. _generatePointsArray(): boolean;
  22068. /**
  22069. * Gets a value indicating if the geometry is disposed
  22070. * @returns true if the geometry was disposed
  22071. */
  22072. isDisposed(): boolean;
  22073. private _disposeVertexArrayObjects;
  22074. /**
  22075. * Free all associated resources
  22076. */
  22077. dispose(): void;
  22078. /**
  22079. * Clone the current geometry into a new geometry
  22080. * @param id defines the unique ID of the new geometry
  22081. * @returns a new geometry object
  22082. */
  22083. copy(id: string): Geometry;
  22084. /**
  22085. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22086. * @return a JSON representation of the current geometry data (without the vertices data)
  22087. */
  22088. serialize(): any;
  22089. private toNumberArray;
  22090. /**
  22091. * Serialize all vertices data into a JSON oject
  22092. * @returns a JSON representation of the current geometry data
  22093. */
  22094. serializeVerticeData(): any;
  22095. /**
  22096. * Extracts a clone of a mesh geometry
  22097. * @param mesh defines the source mesh
  22098. * @param id defines the unique ID of the new geometry object
  22099. * @returns the new geometry object
  22100. */
  22101. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22102. /**
  22103. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22104. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22105. * Be aware Math.random() could cause collisions, but:
  22106. * "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"
  22107. * @returns a string containing a new GUID
  22108. */
  22109. static RandomId(): string;
  22110. /** @hidden */
  22111. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22112. private static _CleanMatricesWeights;
  22113. /**
  22114. * Create a new geometry from persisted data (Using .babylon file format)
  22115. * @param parsedVertexData defines the persisted data
  22116. * @param scene defines the hosting scene
  22117. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22118. * @returns the new geometry object
  22119. */
  22120. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22121. }
  22122. }
  22123. declare module "babylonjs/Meshes/mesh.vertexData" {
  22124. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22125. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22126. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22127. import { Geometry } from "babylonjs/Meshes/geometry";
  22128. import { Mesh } from "babylonjs/Meshes/mesh";
  22129. /**
  22130. * Define an interface for all classes that will get and set the data on vertices
  22131. */
  22132. export interface IGetSetVerticesData {
  22133. /**
  22134. * Gets a boolean indicating if specific vertex data is present
  22135. * @param kind defines the vertex data kind to use
  22136. * @returns true is data kind is present
  22137. */
  22138. isVerticesDataPresent(kind: string): boolean;
  22139. /**
  22140. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22141. * @param kind defines the data kind (Position, normal, etc...)
  22142. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22143. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22144. * @returns a float array containing vertex data
  22145. */
  22146. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22147. /**
  22148. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22149. * @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.
  22150. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22151. * @returns the indices array or an empty array if the mesh has no geometry
  22152. */
  22153. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22154. /**
  22155. * Set specific vertex data
  22156. * @param kind defines the data kind (Position, normal, etc...)
  22157. * @param data defines the vertex data to use
  22158. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22159. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22160. */
  22161. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22162. /**
  22163. * Update a specific associated vertex buffer
  22164. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22165. * - VertexBuffer.PositionKind
  22166. * - VertexBuffer.UVKind
  22167. * - VertexBuffer.UV2Kind
  22168. * - VertexBuffer.UV3Kind
  22169. * - VertexBuffer.UV4Kind
  22170. * - VertexBuffer.UV5Kind
  22171. * - VertexBuffer.UV6Kind
  22172. * - VertexBuffer.ColorKind
  22173. * - VertexBuffer.MatricesIndicesKind
  22174. * - VertexBuffer.MatricesIndicesExtraKind
  22175. * - VertexBuffer.MatricesWeightsKind
  22176. * - VertexBuffer.MatricesWeightsExtraKind
  22177. * @param data defines the data source
  22178. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22179. * @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)
  22180. */
  22181. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22182. /**
  22183. * Creates a new index buffer
  22184. * @param indices defines the indices to store in the index buffer
  22185. * @param totalVertices defines the total number of vertices (could be null)
  22186. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22187. */
  22188. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22189. }
  22190. /**
  22191. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22192. */
  22193. export class VertexData {
  22194. /**
  22195. * Mesh side orientation : usually the external or front surface
  22196. */
  22197. static readonly FRONTSIDE: number;
  22198. /**
  22199. * Mesh side orientation : usually the internal or back surface
  22200. */
  22201. static readonly BACKSIDE: number;
  22202. /**
  22203. * Mesh side orientation : both internal and external or front and back surfaces
  22204. */
  22205. static readonly DOUBLESIDE: number;
  22206. /**
  22207. * Mesh side orientation : by default, `FRONTSIDE`
  22208. */
  22209. static readonly DEFAULTSIDE: number;
  22210. /**
  22211. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22212. */
  22213. positions: Nullable<FloatArray>;
  22214. /**
  22215. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22216. */
  22217. normals: Nullable<FloatArray>;
  22218. /**
  22219. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22220. */
  22221. tangents: Nullable<FloatArray>;
  22222. /**
  22223. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22224. */
  22225. uvs: Nullable<FloatArray>;
  22226. /**
  22227. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22228. */
  22229. uvs2: Nullable<FloatArray>;
  22230. /**
  22231. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22232. */
  22233. uvs3: Nullable<FloatArray>;
  22234. /**
  22235. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22236. */
  22237. uvs4: Nullable<FloatArray>;
  22238. /**
  22239. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22240. */
  22241. uvs5: Nullable<FloatArray>;
  22242. /**
  22243. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22244. */
  22245. uvs6: Nullable<FloatArray>;
  22246. /**
  22247. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22248. */
  22249. colors: Nullable<FloatArray>;
  22250. /**
  22251. * 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).
  22252. */
  22253. matricesIndices: Nullable<FloatArray>;
  22254. /**
  22255. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22256. */
  22257. matricesWeights: Nullable<FloatArray>;
  22258. /**
  22259. * An array extending the number of possible indices
  22260. */
  22261. matricesIndicesExtra: Nullable<FloatArray>;
  22262. /**
  22263. * An array extending the number of possible weights when the number of indices is extended
  22264. */
  22265. matricesWeightsExtra: Nullable<FloatArray>;
  22266. /**
  22267. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22268. */
  22269. indices: Nullable<IndicesArray>;
  22270. /**
  22271. * Uses the passed data array to set the set the values for the specified kind of data
  22272. * @param data a linear array of floating numbers
  22273. * @param kind the type of data that is being set, eg positions, colors etc
  22274. */
  22275. set(data: FloatArray, kind: string): void;
  22276. /**
  22277. * Associates the vertexData to the passed Mesh.
  22278. * Sets it as updatable or not (default `false`)
  22279. * @param mesh the mesh the vertexData is applied to
  22280. * @param updatable when used and having the value true allows new data to update the vertexData
  22281. * @returns the VertexData
  22282. */
  22283. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22284. /**
  22285. * Associates the vertexData to the passed Geometry.
  22286. * Sets it as updatable or not (default `false`)
  22287. * @param geometry the geometry the vertexData is applied to
  22288. * @param updatable when used and having the value true allows new data to update the vertexData
  22289. * @returns VertexData
  22290. */
  22291. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22292. /**
  22293. * Updates the associated mesh
  22294. * @param mesh the mesh to be updated
  22295. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22296. * @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
  22297. * @returns VertexData
  22298. */
  22299. updateMesh(mesh: Mesh): VertexData;
  22300. /**
  22301. * Updates the associated geometry
  22302. * @param geometry the geometry to be updated
  22303. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22304. * @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
  22305. * @returns VertexData.
  22306. */
  22307. updateGeometry(geometry: Geometry): VertexData;
  22308. private _applyTo;
  22309. private _update;
  22310. /**
  22311. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22312. * @param matrix the transforming matrix
  22313. * @returns the VertexData
  22314. */
  22315. transform(matrix: Matrix): VertexData;
  22316. /**
  22317. * Merges the passed VertexData into the current one
  22318. * @param other the VertexData to be merged into the current one
  22319. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22320. * @returns the modified VertexData
  22321. */
  22322. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22323. private _mergeElement;
  22324. private _validate;
  22325. /**
  22326. * Serializes the VertexData
  22327. * @returns a serialized object
  22328. */
  22329. serialize(): any;
  22330. /**
  22331. * Extracts the vertexData from a mesh
  22332. * @param mesh the mesh from which to extract the VertexData
  22333. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22334. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22335. * @returns the object VertexData associated to the passed mesh
  22336. */
  22337. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22338. /**
  22339. * Extracts the vertexData from the geometry
  22340. * @param geometry the geometry from which to extract the VertexData
  22341. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22342. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22343. * @returns the object VertexData associated to the passed mesh
  22344. */
  22345. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22346. private static _ExtractFrom;
  22347. /**
  22348. * Creates the VertexData for a Ribbon
  22349. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22350. * * pathArray array of paths, each of which an array of successive Vector3
  22351. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22352. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22353. * * 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
  22354. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22355. * * 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)
  22356. * * 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)
  22357. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22358. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22359. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22360. * @returns the VertexData of the ribbon
  22361. */
  22362. static CreateRibbon(options: {
  22363. pathArray: Vector3[][];
  22364. closeArray?: boolean;
  22365. closePath?: boolean;
  22366. offset?: number;
  22367. sideOrientation?: number;
  22368. frontUVs?: Vector4;
  22369. backUVs?: Vector4;
  22370. invertUV?: boolean;
  22371. uvs?: Vector2[];
  22372. colors?: Color4[];
  22373. }): VertexData;
  22374. /**
  22375. * Creates the VertexData for a box
  22376. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22377. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22378. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22379. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22380. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22381. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22382. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22383. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22384. * * 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)
  22385. * * 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)
  22386. * @returns the VertexData of the box
  22387. */
  22388. static CreateBox(options: {
  22389. size?: number;
  22390. width?: number;
  22391. height?: number;
  22392. depth?: number;
  22393. faceUV?: Vector4[];
  22394. faceColors?: Color4[];
  22395. sideOrientation?: number;
  22396. frontUVs?: Vector4;
  22397. backUVs?: Vector4;
  22398. }): VertexData;
  22399. /**
  22400. * Creates the VertexData for a tiled box
  22401. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22402. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22403. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22404. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22405. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22406. * @returns the VertexData of the box
  22407. */
  22408. static CreateTiledBox(options: {
  22409. pattern?: number;
  22410. width?: number;
  22411. height?: number;
  22412. depth?: number;
  22413. tileSize?: number;
  22414. tileWidth?: number;
  22415. tileHeight?: number;
  22416. alignHorizontal?: number;
  22417. alignVertical?: number;
  22418. faceUV?: Vector4[];
  22419. faceColors?: Color4[];
  22420. sideOrientation?: number;
  22421. }): VertexData;
  22422. /**
  22423. * Creates the VertexData for a tiled plane
  22424. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22425. * * pattern a limited pattern arrangement depending on the number
  22426. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22427. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22428. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22429. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22430. * * 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)
  22431. * * 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)
  22432. * @returns the VertexData of the tiled plane
  22433. */
  22434. static CreateTiledPlane(options: {
  22435. pattern?: number;
  22436. tileSize?: number;
  22437. tileWidth?: number;
  22438. tileHeight?: number;
  22439. size?: number;
  22440. width?: number;
  22441. height?: number;
  22442. alignHorizontal?: number;
  22443. alignVertical?: number;
  22444. sideOrientation?: number;
  22445. frontUVs?: Vector4;
  22446. backUVs?: Vector4;
  22447. }): VertexData;
  22448. /**
  22449. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22450. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22451. * * segments sets the number of horizontal strips optional, default 32
  22452. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22453. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22454. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22455. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22456. * * 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
  22457. * * 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
  22458. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22459. * * 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)
  22460. * * 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)
  22461. * @returns the VertexData of the ellipsoid
  22462. */
  22463. static CreateSphere(options: {
  22464. segments?: number;
  22465. diameter?: number;
  22466. diameterX?: number;
  22467. diameterY?: number;
  22468. diameterZ?: number;
  22469. arc?: number;
  22470. slice?: number;
  22471. sideOrientation?: number;
  22472. frontUVs?: Vector4;
  22473. backUVs?: Vector4;
  22474. }): VertexData;
  22475. /**
  22476. * Creates the VertexData for a cylinder, cone or prism
  22477. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22478. * * height sets the height (y direction) of the cylinder, optional, default 2
  22479. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22480. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22481. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22482. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22483. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22484. * * 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
  22485. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22486. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22487. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22488. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22489. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22490. * * 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)
  22491. * * 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)
  22492. * @returns the VertexData of the cylinder, cone or prism
  22493. */
  22494. static CreateCylinder(options: {
  22495. height?: number;
  22496. diameterTop?: number;
  22497. diameterBottom?: number;
  22498. diameter?: number;
  22499. tessellation?: number;
  22500. subdivisions?: number;
  22501. arc?: number;
  22502. faceColors?: Color4[];
  22503. faceUV?: Vector4[];
  22504. hasRings?: boolean;
  22505. enclose?: boolean;
  22506. sideOrientation?: number;
  22507. frontUVs?: Vector4;
  22508. backUVs?: Vector4;
  22509. }): VertexData;
  22510. /**
  22511. * Creates the VertexData for a torus
  22512. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22513. * * diameter the diameter of the torus, optional default 1
  22514. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22515. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22516. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22517. * * 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)
  22518. * * 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)
  22519. * @returns the VertexData of the torus
  22520. */
  22521. static CreateTorus(options: {
  22522. diameter?: number;
  22523. thickness?: number;
  22524. tessellation?: number;
  22525. sideOrientation?: number;
  22526. frontUVs?: Vector4;
  22527. backUVs?: Vector4;
  22528. }): VertexData;
  22529. /**
  22530. * Creates the VertexData of the LineSystem
  22531. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22532. * - lines an array of lines, each line being an array of successive Vector3
  22533. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22534. * @returns the VertexData of the LineSystem
  22535. */
  22536. static CreateLineSystem(options: {
  22537. lines: Vector3[][];
  22538. colors?: Nullable<Color4[][]>;
  22539. }): VertexData;
  22540. /**
  22541. * Create the VertexData for a DashedLines
  22542. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22543. * - points an array successive Vector3
  22544. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22545. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22546. * - dashNb the intended total number of dashes, optional, default 200
  22547. * @returns the VertexData for the DashedLines
  22548. */
  22549. static CreateDashedLines(options: {
  22550. points: Vector3[];
  22551. dashSize?: number;
  22552. gapSize?: number;
  22553. dashNb?: number;
  22554. }): VertexData;
  22555. /**
  22556. * Creates the VertexData for a Ground
  22557. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22558. * - width the width (x direction) of the ground, optional, default 1
  22559. * - height the height (z direction) of the ground, optional, default 1
  22560. * - subdivisions the number of subdivisions per side, optional, default 1
  22561. * @returns the VertexData of the Ground
  22562. */
  22563. static CreateGround(options: {
  22564. width?: number;
  22565. height?: number;
  22566. subdivisions?: number;
  22567. subdivisionsX?: number;
  22568. subdivisionsY?: number;
  22569. }): VertexData;
  22570. /**
  22571. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22572. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22573. * * xmin the ground minimum X coordinate, optional, default -1
  22574. * * zmin the ground minimum Z coordinate, optional, default -1
  22575. * * xmax the ground maximum X coordinate, optional, default 1
  22576. * * zmax the ground maximum Z coordinate, optional, default 1
  22577. * * 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}
  22578. * * 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}
  22579. * @returns the VertexData of the TiledGround
  22580. */
  22581. static CreateTiledGround(options: {
  22582. xmin: number;
  22583. zmin: number;
  22584. xmax: number;
  22585. zmax: number;
  22586. subdivisions?: {
  22587. w: number;
  22588. h: number;
  22589. };
  22590. precision?: {
  22591. w: number;
  22592. h: number;
  22593. };
  22594. }): VertexData;
  22595. /**
  22596. * Creates the VertexData of the Ground designed from a heightmap
  22597. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22598. * * width the width (x direction) of the ground
  22599. * * height the height (z direction) of the ground
  22600. * * subdivisions the number of subdivisions per side
  22601. * * minHeight the minimum altitude on the ground, optional, default 0
  22602. * * maxHeight the maximum altitude on the ground, optional default 1
  22603. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22604. * * buffer the array holding the image color data
  22605. * * bufferWidth the width of image
  22606. * * bufferHeight the height of image
  22607. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22608. * @returns the VertexData of the Ground designed from a heightmap
  22609. */
  22610. static CreateGroundFromHeightMap(options: {
  22611. width: number;
  22612. height: number;
  22613. subdivisions: number;
  22614. minHeight: number;
  22615. maxHeight: number;
  22616. colorFilter: Color3;
  22617. buffer: Uint8Array;
  22618. bufferWidth: number;
  22619. bufferHeight: number;
  22620. alphaFilter: number;
  22621. }): VertexData;
  22622. /**
  22623. * Creates the VertexData for a Plane
  22624. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22625. * * size sets the width and height of the plane to the value of size, optional default 1
  22626. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22627. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22628. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22629. * * 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)
  22630. * * 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)
  22631. * @returns the VertexData of the box
  22632. */
  22633. static CreatePlane(options: {
  22634. size?: number;
  22635. width?: number;
  22636. height?: number;
  22637. sideOrientation?: number;
  22638. frontUVs?: Vector4;
  22639. backUVs?: Vector4;
  22640. }): VertexData;
  22641. /**
  22642. * Creates the VertexData of the Disc or regular Polygon
  22643. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22644. * * radius the radius of the disc, optional default 0.5
  22645. * * tessellation the number of polygon sides, optional, default 64
  22646. * * 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
  22647. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22648. * * 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)
  22649. * * 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)
  22650. * @returns the VertexData of the box
  22651. */
  22652. static CreateDisc(options: {
  22653. radius?: number;
  22654. tessellation?: number;
  22655. arc?: number;
  22656. sideOrientation?: number;
  22657. frontUVs?: Vector4;
  22658. backUVs?: Vector4;
  22659. }): VertexData;
  22660. /**
  22661. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22662. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22663. * @param polygon a mesh built from polygonTriangulation.build()
  22664. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22665. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22666. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22667. * @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)
  22668. * @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)
  22669. * @returns the VertexData of the Polygon
  22670. */
  22671. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22672. /**
  22673. * Creates the VertexData of the IcoSphere
  22674. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22675. * * radius the radius of the IcoSphere, optional default 1
  22676. * * radiusX allows stretching in the x direction, optional, default radius
  22677. * * radiusY allows stretching in the y direction, optional, default radius
  22678. * * radiusZ allows stretching in the z direction, optional, default radius
  22679. * * flat when true creates a flat shaded mesh, optional, default true
  22680. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22681. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22682. * * 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)
  22683. * * 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)
  22684. * @returns the VertexData of the IcoSphere
  22685. */
  22686. static CreateIcoSphere(options: {
  22687. radius?: number;
  22688. radiusX?: number;
  22689. radiusY?: number;
  22690. radiusZ?: number;
  22691. flat?: boolean;
  22692. subdivisions?: number;
  22693. sideOrientation?: number;
  22694. frontUVs?: Vector4;
  22695. backUVs?: Vector4;
  22696. }): VertexData;
  22697. /**
  22698. * Creates the VertexData for a Polyhedron
  22699. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22700. * * type provided types are:
  22701. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22702. * * 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)
  22703. * * size the size of the IcoSphere, optional default 1
  22704. * * sizeX allows stretching in the x direction, optional, default size
  22705. * * sizeY allows stretching in the y direction, optional, default size
  22706. * * sizeZ allows stretching in the z direction, optional, default size
  22707. * * 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
  22708. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22709. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22710. * * flat when true creates a flat shaded mesh, optional, default true
  22711. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22712. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22713. * * 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)
  22714. * * 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)
  22715. * @returns the VertexData of the Polyhedron
  22716. */
  22717. static CreatePolyhedron(options: {
  22718. type?: number;
  22719. size?: number;
  22720. sizeX?: number;
  22721. sizeY?: number;
  22722. sizeZ?: number;
  22723. custom?: any;
  22724. faceUV?: Vector4[];
  22725. faceColors?: Color4[];
  22726. flat?: boolean;
  22727. sideOrientation?: number;
  22728. frontUVs?: Vector4;
  22729. backUVs?: Vector4;
  22730. }): VertexData;
  22731. /**
  22732. * Creates the VertexData for a TorusKnot
  22733. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22734. * * radius the radius of the torus knot, optional, default 2
  22735. * * tube the thickness of the tube, optional, default 0.5
  22736. * * radialSegments the number of sides on each tube segments, optional, default 32
  22737. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22738. * * p the number of windings around the z axis, optional, default 2
  22739. * * q the number of windings around the x axis, optional, default 3
  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 Torus Knot
  22744. */
  22745. static CreateTorusKnot(options: {
  22746. radius?: number;
  22747. tube?: number;
  22748. radialSegments?: number;
  22749. tubularSegments?: number;
  22750. p?: number;
  22751. q?: number;
  22752. sideOrientation?: number;
  22753. frontUVs?: Vector4;
  22754. backUVs?: Vector4;
  22755. }): VertexData;
  22756. /**
  22757. * Compute normals for given positions and indices
  22758. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22759. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22760. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22761. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22762. * * facetNormals : optional array of facet normals (vector3)
  22763. * * facetPositions : optional array of facet positions (vector3)
  22764. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22765. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22766. * * bInfo : optional bounding info, required for facetPartitioning computation
  22767. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22768. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22769. * * useRightHandedSystem: optional boolean to for right handed system computation
  22770. * * depthSort : optional boolean to enable the facet depth sort computation
  22771. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22772. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22773. */
  22774. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22775. facetNormals?: any;
  22776. facetPositions?: any;
  22777. facetPartitioning?: any;
  22778. ratio?: number;
  22779. bInfo?: any;
  22780. bbSize?: Vector3;
  22781. subDiv?: any;
  22782. useRightHandedSystem?: boolean;
  22783. depthSort?: boolean;
  22784. distanceTo?: Vector3;
  22785. depthSortedFacets?: any;
  22786. }): void;
  22787. /** @hidden */
  22788. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22789. /**
  22790. * Applies VertexData created from the imported parameters to the geometry
  22791. * @param parsedVertexData the parsed data from an imported file
  22792. * @param geometry the geometry to apply the VertexData to
  22793. */
  22794. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22795. }
  22796. }
  22797. declare module "babylonjs/Morph/morphTarget" {
  22798. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22799. import { Observable } from "babylonjs/Misc/observable";
  22800. import { Nullable, FloatArray } from "babylonjs/types";
  22801. import { Scene } from "babylonjs/scene";
  22802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22803. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22804. /**
  22805. * Defines a target to use with MorphTargetManager
  22806. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22807. */
  22808. export class MorphTarget implements IAnimatable {
  22809. /** defines the name of the target */
  22810. name: string;
  22811. /**
  22812. * Gets or sets the list of animations
  22813. */
  22814. animations: import("babylonjs/Animations/animation").Animation[];
  22815. private _scene;
  22816. private _positions;
  22817. private _normals;
  22818. private _tangents;
  22819. private _uvs;
  22820. private _influence;
  22821. private _uniqueId;
  22822. /**
  22823. * Observable raised when the influence changes
  22824. */
  22825. onInfluenceChanged: Observable<boolean>;
  22826. /** @hidden */
  22827. _onDataLayoutChanged: Observable<void>;
  22828. /**
  22829. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22830. */
  22831. influence: number;
  22832. /**
  22833. * Gets or sets the id of the morph Target
  22834. */
  22835. id: string;
  22836. private _animationPropertiesOverride;
  22837. /**
  22838. * Gets or sets the animation properties override
  22839. */
  22840. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22841. /**
  22842. * Creates a new MorphTarget
  22843. * @param name defines the name of the target
  22844. * @param influence defines the influence to use
  22845. * @param scene defines the scene the morphtarget belongs to
  22846. */
  22847. constructor(
  22848. /** defines the name of the target */
  22849. name: string, influence?: number, scene?: Nullable<Scene>);
  22850. /**
  22851. * Gets the unique ID of this manager
  22852. */
  22853. readonly uniqueId: number;
  22854. /**
  22855. * Gets a boolean defining if the target contains position data
  22856. */
  22857. readonly hasPositions: boolean;
  22858. /**
  22859. * Gets a boolean defining if the target contains normal data
  22860. */
  22861. readonly hasNormals: boolean;
  22862. /**
  22863. * Gets a boolean defining if the target contains tangent data
  22864. */
  22865. readonly hasTangents: boolean;
  22866. /**
  22867. * Gets a boolean defining if the target contains texture coordinates data
  22868. */
  22869. readonly hasUVs: boolean;
  22870. /**
  22871. * Affects position data to this target
  22872. * @param data defines the position data to use
  22873. */
  22874. setPositions(data: Nullable<FloatArray>): void;
  22875. /**
  22876. * Gets the position data stored in this target
  22877. * @returns a FloatArray containing the position data (or null if not present)
  22878. */
  22879. getPositions(): Nullable<FloatArray>;
  22880. /**
  22881. * Affects normal data to this target
  22882. * @param data defines the normal data to use
  22883. */
  22884. setNormals(data: Nullable<FloatArray>): void;
  22885. /**
  22886. * Gets the normal data stored in this target
  22887. * @returns a FloatArray containing the normal data (or null if not present)
  22888. */
  22889. getNormals(): Nullable<FloatArray>;
  22890. /**
  22891. * Affects tangent data to this target
  22892. * @param data defines the tangent data to use
  22893. */
  22894. setTangents(data: Nullable<FloatArray>): void;
  22895. /**
  22896. * Gets the tangent data stored in this target
  22897. * @returns a FloatArray containing the tangent data (or null if not present)
  22898. */
  22899. getTangents(): Nullable<FloatArray>;
  22900. /**
  22901. * Affects texture coordinates data to this target
  22902. * @param data defines the texture coordinates data to use
  22903. */
  22904. setUVs(data: Nullable<FloatArray>): void;
  22905. /**
  22906. * Gets the texture coordinates data stored in this target
  22907. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22908. */
  22909. getUVs(): Nullable<FloatArray>;
  22910. /**
  22911. * Clone the current target
  22912. * @returns a new MorphTarget
  22913. */
  22914. clone(): MorphTarget;
  22915. /**
  22916. * Serializes the current target into a Serialization object
  22917. * @returns the serialized object
  22918. */
  22919. serialize(): any;
  22920. /**
  22921. * Returns the string "MorphTarget"
  22922. * @returns "MorphTarget"
  22923. */
  22924. getClassName(): string;
  22925. /**
  22926. * Creates a new target from serialized data
  22927. * @param serializationObject defines the serialized data to use
  22928. * @returns a new MorphTarget
  22929. */
  22930. static Parse(serializationObject: any): MorphTarget;
  22931. /**
  22932. * Creates a MorphTarget from mesh data
  22933. * @param mesh defines the source mesh
  22934. * @param name defines the name to use for the new target
  22935. * @param influence defines the influence to attach to the target
  22936. * @returns a new MorphTarget
  22937. */
  22938. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22939. }
  22940. }
  22941. declare module "babylonjs/Morph/morphTargetManager" {
  22942. import { Nullable } from "babylonjs/types";
  22943. import { Scene } from "babylonjs/scene";
  22944. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22945. /**
  22946. * This class is used to deform meshes using morphing between different targets
  22947. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22948. */
  22949. export class MorphTargetManager {
  22950. private _targets;
  22951. private _targetInfluenceChangedObservers;
  22952. private _targetDataLayoutChangedObservers;
  22953. private _activeTargets;
  22954. private _scene;
  22955. private _influences;
  22956. private _supportsNormals;
  22957. private _supportsTangents;
  22958. private _supportsUVs;
  22959. private _vertexCount;
  22960. private _uniqueId;
  22961. private _tempInfluences;
  22962. /**
  22963. * Gets or sets a boolean indicating if normals must be morphed
  22964. */
  22965. enableNormalMorphing: boolean;
  22966. /**
  22967. * Gets or sets a boolean indicating if tangents must be morphed
  22968. */
  22969. enableTangentMorphing: boolean;
  22970. /**
  22971. * Gets or sets a boolean indicating if UV must be morphed
  22972. */
  22973. enableUVMorphing: boolean;
  22974. /**
  22975. * Creates a new MorphTargetManager
  22976. * @param scene defines the current scene
  22977. */
  22978. constructor(scene?: Nullable<Scene>);
  22979. /**
  22980. * Gets the unique ID of this manager
  22981. */
  22982. readonly uniqueId: number;
  22983. /**
  22984. * Gets the number of vertices handled by this manager
  22985. */
  22986. readonly vertexCount: number;
  22987. /**
  22988. * Gets a boolean indicating if this manager supports morphing of normals
  22989. */
  22990. readonly supportsNormals: boolean;
  22991. /**
  22992. * Gets a boolean indicating if this manager supports morphing of tangents
  22993. */
  22994. readonly supportsTangents: boolean;
  22995. /**
  22996. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22997. */
  22998. readonly supportsUVs: boolean;
  22999. /**
  23000. * Gets the number of targets stored in this manager
  23001. */
  23002. readonly numTargets: number;
  23003. /**
  23004. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23005. */
  23006. readonly numInfluencers: number;
  23007. /**
  23008. * Gets the list of influences (one per target)
  23009. */
  23010. readonly influences: Float32Array;
  23011. /**
  23012. * Gets the active target at specified index. An active target is a target with an influence > 0
  23013. * @param index defines the index to check
  23014. * @returns the requested target
  23015. */
  23016. getActiveTarget(index: number): MorphTarget;
  23017. /**
  23018. * Gets the target at specified index
  23019. * @param index defines the index to check
  23020. * @returns the requested target
  23021. */
  23022. getTarget(index: number): MorphTarget;
  23023. /**
  23024. * Add a new target to this manager
  23025. * @param target defines the target to add
  23026. */
  23027. addTarget(target: MorphTarget): void;
  23028. /**
  23029. * Removes a target from the manager
  23030. * @param target defines the target to remove
  23031. */
  23032. removeTarget(target: MorphTarget): void;
  23033. /**
  23034. * Clone the current manager
  23035. * @returns a new MorphTargetManager
  23036. */
  23037. clone(): MorphTargetManager;
  23038. /**
  23039. * Serializes the current manager into a Serialization object
  23040. * @returns the serialized object
  23041. */
  23042. serialize(): any;
  23043. private _syncActiveTargets;
  23044. /**
  23045. * Syncrhonize the targets with all the meshes using this morph target manager
  23046. */
  23047. synchronize(): void;
  23048. /**
  23049. * Creates a new MorphTargetManager from serialized data
  23050. * @param serializationObject defines the serialized data
  23051. * @param scene defines the hosting scene
  23052. * @returns the new MorphTargetManager
  23053. */
  23054. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23055. }
  23056. }
  23057. declare module "babylonjs/Meshes/meshLODLevel" {
  23058. import { Mesh } from "babylonjs/Meshes/mesh";
  23059. import { Nullable } from "babylonjs/types";
  23060. /**
  23061. * Class used to represent a specific level of detail of a mesh
  23062. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23063. */
  23064. export class MeshLODLevel {
  23065. /** Defines the distance where this level should start being displayed */
  23066. distance: number;
  23067. /** Defines the mesh to use to render this level */
  23068. mesh: Nullable<Mesh>;
  23069. /**
  23070. * Creates a new LOD level
  23071. * @param distance defines the distance where this level should star being displayed
  23072. * @param mesh defines the mesh to use to render this level
  23073. */
  23074. constructor(
  23075. /** Defines the distance where this level should start being displayed */
  23076. distance: number,
  23077. /** Defines the mesh to use to render this level */
  23078. mesh: Nullable<Mesh>);
  23079. }
  23080. }
  23081. declare module "babylonjs/Meshes/groundMesh" {
  23082. import { Scene } from "babylonjs/scene";
  23083. import { Vector3 } from "babylonjs/Maths/math.vector";
  23084. import { Mesh } from "babylonjs/Meshes/mesh";
  23085. /**
  23086. * Mesh representing the gorund
  23087. */
  23088. export class GroundMesh extends Mesh {
  23089. /** If octree should be generated */
  23090. generateOctree: boolean;
  23091. private _heightQuads;
  23092. /** @hidden */
  23093. _subdivisionsX: number;
  23094. /** @hidden */
  23095. _subdivisionsY: number;
  23096. /** @hidden */
  23097. _width: number;
  23098. /** @hidden */
  23099. _height: number;
  23100. /** @hidden */
  23101. _minX: number;
  23102. /** @hidden */
  23103. _maxX: number;
  23104. /** @hidden */
  23105. _minZ: number;
  23106. /** @hidden */
  23107. _maxZ: number;
  23108. constructor(name: string, scene: Scene);
  23109. /**
  23110. * "GroundMesh"
  23111. * @returns "GroundMesh"
  23112. */
  23113. getClassName(): string;
  23114. /**
  23115. * The minimum of x and y subdivisions
  23116. */
  23117. readonly subdivisions: number;
  23118. /**
  23119. * X subdivisions
  23120. */
  23121. readonly subdivisionsX: number;
  23122. /**
  23123. * Y subdivisions
  23124. */
  23125. readonly subdivisionsY: number;
  23126. /**
  23127. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23128. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23129. * @param chunksCount the number of subdivisions for x and y
  23130. * @param octreeBlocksSize (Default: 32)
  23131. */
  23132. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23133. /**
  23134. * Returns a height (y) value in the Worl system :
  23135. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23136. * @param x x coordinate
  23137. * @param z z coordinate
  23138. * @returns the ground y position if (x, z) are outside the ground surface.
  23139. */
  23140. getHeightAtCoordinates(x: number, z: number): number;
  23141. /**
  23142. * Returns a normalized vector (Vector3) orthogonal to the ground
  23143. * at the ground coordinates (x, z) expressed in the World system.
  23144. * @param x x coordinate
  23145. * @param z z coordinate
  23146. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23147. */
  23148. getNormalAtCoordinates(x: number, z: number): Vector3;
  23149. /**
  23150. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23151. * at the ground coordinates (x, z) expressed in the World system.
  23152. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23153. * @param x x coordinate
  23154. * @param z z coordinate
  23155. * @param ref vector to store the result
  23156. * @returns the GroundMesh.
  23157. */
  23158. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23159. /**
  23160. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23161. * if the ground has been updated.
  23162. * This can be used in the render loop.
  23163. * @returns the GroundMesh.
  23164. */
  23165. updateCoordinateHeights(): GroundMesh;
  23166. private _getFacetAt;
  23167. private _initHeightQuads;
  23168. private _computeHeightQuads;
  23169. /**
  23170. * Serializes this ground mesh
  23171. * @param serializationObject object to write serialization to
  23172. */
  23173. serialize(serializationObject: any): void;
  23174. /**
  23175. * Parses a serialized ground mesh
  23176. * @param parsedMesh the serialized mesh
  23177. * @param scene the scene to create the ground mesh in
  23178. * @returns the created ground mesh
  23179. */
  23180. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23181. }
  23182. }
  23183. declare module "babylonjs/Physics/physicsJoint" {
  23184. import { Vector3 } from "babylonjs/Maths/math.vector";
  23185. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23186. /**
  23187. * Interface for Physics-Joint data
  23188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23189. */
  23190. export interface PhysicsJointData {
  23191. /**
  23192. * The main pivot of the joint
  23193. */
  23194. mainPivot?: Vector3;
  23195. /**
  23196. * The connected pivot of the joint
  23197. */
  23198. connectedPivot?: Vector3;
  23199. /**
  23200. * The main axis of the joint
  23201. */
  23202. mainAxis?: Vector3;
  23203. /**
  23204. * The connected axis of the joint
  23205. */
  23206. connectedAxis?: Vector3;
  23207. /**
  23208. * The collision of the joint
  23209. */
  23210. collision?: boolean;
  23211. /**
  23212. * Native Oimo/Cannon/Energy data
  23213. */
  23214. nativeParams?: any;
  23215. }
  23216. /**
  23217. * This is a holder class for the physics joint created by the physics plugin
  23218. * It holds a set of functions to control the underlying joint
  23219. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23220. */
  23221. export class PhysicsJoint {
  23222. /**
  23223. * The type of the physics joint
  23224. */
  23225. type: number;
  23226. /**
  23227. * The data for the physics joint
  23228. */
  23229. jointData: PhysicsJointData;
  23230. private _physicsJoint;
  23231. protected _physicsPlugin: IPhysicsEnginePlugin;
  23232. /**
  23233. * Initializes the physics joint
  23234. * @param type The type of the physics joint
  23235. * @param jointData The data for the physics joint
  23236. */
  23237. constructor(
  23238. /**
  23239. * The type of the physics joint
  23240. */
  23241. type: number,
  23242. /**
  23243. * The data for the physics joint
  23244. */
  23245. jointData: PhysicsJointData);
  23246. /**
  23247. * Gets the physics joint
  23248. */
  23249. /**
  23250. * Sets the physics joint
  23251. */
  23252. physicsJoint: any;
  23253. /**
  23254. * Sets the physics plugin
  23255. */
  23256. physicsPlugin: IPhysicsEnginePlugin;
  23257. /**
  23258. * Execute a function that is physics-plugin specific.
  23259. * @param {Function} func the function that will be executed.
  23260. * It accepts two parameters: the physics world and the physics joint
  23261. */
  23262. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23263. /**
  23264. * Distance-Joint type
  23265. */
  23266. static DistanceJoint: number;
  23267. /**
  23268. * Hinge-Joint type
  23269. */
  23270. static HingeJoint: number;
  23271. /**
  23272. * Ball-and-Socket joint type
  23273. */
  23274. static BallAndSocketJoint: number;
  23275. /**
  23276. * Wheel-Joint type
  23277. */
  23278. static WheelJoint: number;
  23279. /**
  23280. * Slider-Joint type
  23281. */
  23282. static SliderJoint: number;
  23283. /**
  23284. * Prismatic-Joint type
  23285. */
  23286. static PrismaticJoint: number;
  23287. /**
  23288. * Universal-Joint type
  23289. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23290. */
  23291. static UniversalJoint: number;
  23292. /**
  23293. * Hinge-Joint 2 type
  23294. */
  23295. static Hinge2Joint: number;
  23296. /**
  23297. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23298. */
  23299. static PointToPointJoint: number;
  23300. /**
  23301. * Spring-Joint type
  23302. */
  23303. static SpringJoint: number;
  23304. /**
  23305. * Lock-Joint type
  23306. */
  23307. static LockJoint: number;
  23308. }
  23309. /**
  23310. * A class representing a physics distance joint
  23311. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23312. */
  23313. export class DistanceJoint extends PhysicsJoint {
  23314. /**
  23315. *
  23316. * @param jointData The data for the Distance-Joint
  23317. */
  23318. constructor(jointData: DistanceJointData);
  23319. /**
  23320. * Update the predefined distance.
  23321. * @param maxDistance The maximum preferred distance
  23322. * @param minDistance The minimum preferred distance
  23323. */
  23324. updateDistance(maxDistance: number, minDistance?: number): void;
  23325. }
  23326. /**
  23327. * Represents a Motor-Enabled Joint
  23328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23329. */
  23330. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23331. /**
  23332. * Initializes the Motor-Enabled Joint
  23333. * @param type The type of the joint
  23334. * @param jointData The physica joint data for the joint
  23335. */
  23336. constructor(type: number, jointData: PhysicsJointData);
  23337. /**
  23338. * Set the motor values.
  23339. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23340. * @param force the force to apply
  23341. * @param maxForce max force for this motor.
  23342. */
  23343. setMotor(force?: number, maxForce?: number): void;
  23344. /**
  23345. * Set the motor's limits.
  23346. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23347. * @param upperLimit The upper limit of the motor
  23348. * @param lowerLimit The lower limit of the motor
  23349. */
  23350. setLimit(upperLimit: number, lowerLimit?: number): void;
  23351. }
  23352. /**
  23353. * This class represents a single physics Hinge-Joint
  23354. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23355. */
  23356. export class HingeJoint extends MotorEnabledJoint {
  23357. /**
  23358. * Initializes the Hinge-Joint
  23359. * @param jointData The joint data for the Hinge-Joint
  23360. */
  23361. constructor(jointData: PhysicsJointData);
  23362. /**
  23363. * Set the motor values.
  23364. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23365. * @param {number} force the force to apply
  23366. * @param {number} maxForce max force for this motor.
  23367. */
  23368. setMotor(force?: number, maxForce?: number): void;
  23369. /**
  23370. * Set the motor's limits.
  23371. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23372. * @param upperLimit The upper limit of the motor
  23373. * @param lowerLimit The lower limit of the motor
  23374. */
  23375. setLimit(upperLimit: number, lowerLimit?: number): void;
  23376. }
  23377. /**
  23378. * This class represents a dual hinge physics joint (same as wheel joint)
  23379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23380. */
  23381. export class Hinge2Joint extends MotorEnabledJoint {
  23382. /**
  23383. * Initializes the Hinge2-Joint
  23384. * @param jointData The joint data for the Hinge2-Joint
  23385. */
  23386. constructor(jointData: PhysicsJointData);
  23387. /**
  23388. * Set the motor values.
  23389. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23390. * @param {number} targetSpeed the speed the motor is to reach
  23391. * @param {number} maxForce max force for this motor.
  23392. * @param {motorIndex} the motor's index, 0 or 1.
  23393. */
  23394. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23395. /**
  23396. * Set the motor limits.
  23397. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23398. * @param {number} upperLimit the upper limit
  23399. * @param {number} lowerLimit lower limit
  23400. * @param {motorIndex} the motor's index, 0 or 1.
  23401. */
  23402. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23403. }
  23404. /**
  23405. * Interface for a motor enabled joint
  23406. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23407. */
  23408. export interface IMotorEnabledJoint {
  23409. /**
  23410. * Physics joint
  23411. */
  23412. physicsJoint: any;
  23413. /**
  23414. * Sets the motor of the motor-enabled joint
  23415. * @param force The force of the motor
  23416. * @param maxForce The maximum force of the motor
  23417. * @param motorIndex The index of the motor
  23418. */
  23419. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23420. /**
  23421. * Sets the limit of the motor
  23422. * @param upperLimit The upper limit of the motor
  23423. * @param lowerLimit The lower limit of the motor
  23424. * @param motorIndex The index of the motor
  23425. */
  23426. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23427. }
  23428. /**
  23429. * Joint data for a Distance-Joint
  23430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23431. */
  23432. export interface DistanceJointData extends PhysicsJointData {
  23433. /**
  23434. * Max distance the 2 joint objects can be apart
  23435. */
  23436. maxDistance: number;
  23437. }
  23438. /**
  23439. * Joint data from a spring joint
  23440. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23441. */
  23442. export interface SpringJointData extends PhysicsJointData {
  23443. /**
  23444. * Length of the spring
  23445. */
  23446. length: number;
  23447. /**
  23448. * Stiffness of the spring
  23449. */
  23450. stiffness: number;
  23451. /**
  23452. * Damping of the spring
  23453. */
  23454. damping: number;
  23455. /** this callback will be called when applying the force to the impostors. */
  23456. forceApplicationCallback: () => void;
  23457. }
  23458. }
  23459. declare module "babylonjs/Physics/physicsRaycastResult" {
  23460. import { Vector3 } from "babylonjs/Maths/math.vector";
  23461. /**
  23462. * Holds the data for the raycast result
  23463. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23464. */
  23465. export class PhysicsRaycastResult {
  23466. private _hasHit;
  23467. private _hitDistance;
  23468. private _hitNormalWorld;
  23469. private _hitPointWorld;
  23470. private _rayFromWorld;
  23471. private _rayToWorld;
  23472. /**
  23473. * Gets if there was a hit
  23474. */
  23475. readonly hasHit: boolean;
  23476. /**
  23477. * Gets the distance from the hit
  23478. */
  23479. readonly hitDistance: number;
  23480. /**
  23481. * Gets the hit normal/direction in the world
  23482. */
  23483. readonly hitNormalWorld: Vector3;
  23484. /**
  23485. * Gets the hit point in the world
  23486. */
  23487. readonly hitPointWorld: Vector3;
  23488. /**
  23489. * Gets the ray "start point" of the ray in the world
  23490. */
  23491. readonly rayFromWorld: Vector3;
  23492. /**
  23493. * Gets the ray "end point" of the ray in the world
  23494. */
  23495. readonly rayToWorld: Vector3;
  23496. /**
  23497. * Sets the hit data (normal & point in world space)
  23498. * @param hitNormalWorld defines the normal in world space
  23499. * @param hitPointWorld defines the point in world space
  23500. */
  23501. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23502. /**
  23503. * Sets the distance from the start point to the hit point
  23504. * @param distance
  23505. */
  23506. setHitDistance(distance: number): void;
  23507. /**
  23508. * Calculates the distance manually
  23509. */
  23510. calculateHitDistance(): void;
  23511. /**
  23512. * Resets all the values to default
  23513. * @param from The from point on world space
  23514. * @param to The to point on world space
  23515. */
  23516. reset(from?: Vector3, to?: Vector3): void;
  23517. }
  23518. /**
  23519. * Interface for the size containing width and height
  23520. */
  23521. interface IXYZ {
  23522. /**
  23523. * X
  23524. */
  23525. x: number;
  23526. /**
  23527. * Y
  23528. */
  23529. y: number;
  23530. /**
  23531. * Z
  23532. */
  23533. z: number;
  23534. }
  23535. }
  23536. declare module "babylonjs/Physics/IPhysicsEngine" {
  23537. import { Nullable } from "babylonjs/types";
  23538. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23540. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23541. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23542. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23543. /**
  23544. * Interface used to describe a physics joint
  23545. */
  23546. export interface PhysicsImpostorJoint {
  23547. /** Defines the main impostor to which the joint is linked */
  23548. mainImpostor: PhysicsImpostor;
  23549. /** Defines the impostor that is connected to the main impostor using this joint */
  23550. connectedImpostor: PhysicsImpostor;
  23551. /** Defines the joint itself */
  23552. joint: PhysicsJoint;
  23553. }
  23554. /** @hidden */
  23555. export interface IPhysicsEnginePlugin {
  23556. world: any;
  23557. name: string;
  23558. setGravity(gravity: Vector3): void;
  23559. setTimeStep(timeStep: number): void;
  23560. getTimeStep(): number;
  23561. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23562. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23563. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23564. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23565. removePhysicsBody(impostor: PhysicsImpostor): void;
  23566. generateJoint(joint: PhysicsImpostorJoint): void;
  23567. removeJoint(joint: PhysicsImpostorJoint): void;
  23568. isSupported(): boolean;
  23569. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23570. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23571. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23572. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23573. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23574. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23575. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23576. getBodyMass(impostor: PhysicsImpostor): number;
  23577. getBodyFriction(impostor: PhysicsImpostor): number;
  23578. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23579. getBodyRestitution(impostor: PhysicsImpostor): number;
  23580. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23581. getBodyPressure?(impostor: PhysicsImpostor): number;
  23582. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23583. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23584. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23585. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23586. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23587. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23588. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23589. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23590. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23591. sleepBody(impostor: PhysicsImpostor): void;
  23592. wakeUpBody(impostor: PhysicsImpostor): void;
  23593. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23594. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23595. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23596. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23597. getRadius(impostor: PhysicsImpostor): number;
  23598. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23599. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23600. dispose(): void;
  23601. }
  23602. /**
  23603. * Interface used to define a physics engine
  23604. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23605. */
  23606. export interface IPhysicsEngine {
  23607. /**
  23608. * Gets the gravity vector used by the simulation
  23609. */
  23610. gravity: Vector3;
  23611. /**
  23612. * Sets the gravity vector used by the simulation
  23613. * @param gravity defines the gravity vector to use
  23614. */
  23615. setGravity(gravity: Vector3): void;
  23616. /**
  23617. * Set the time step of the physics engine.
  23618. * Default is 1/60.
  23619. * To slow it down, enter 1/600 for example.
  23620. * To speed it up, 1/30
  23621. * @param newTimeStep the new timestep to apply to this world.
  23622. */
  23623. setTimeStep(newTimeStep: number): void;
  23624. /**
  23625. * Get the time step of the physics engine.
  23626. * @returns the current time step
  23627. */
  23628. getTimeStep(): number;
  23629. /**
  23630. * Release all resources
  23631. */
  23632. dispose(): void;
  23633. /**
  23634. * Gets the name of the current physics plugin
  23635. * @returns the name of the plugin
  23636. */
  23637. getPhysicsPluginName(): string;
  23638. /**
  23639. * Adding a new impostor for the impostor tracking.
  23640. * This will be done by the impostor itself.
  23641. * @param impostor the impostor to add
  23642. */
  23643. addImpostor(impostor: PhysicsImpostor): void;
  23644. /**
  23645. * Remove an impostor from the engine.
  23646. * This impostor and its mesh will not longer be updated by the physics engine.
  23647. * @param impostor the impostor to remove
  23648. */
  23649. removeImpostor(impostor: PhysicsImpostor): void;
  23650. /**
  23651. * Add a joint to the physics engine
  23652. * @param mainImpostor defines the main impostor to which the joint is added.
  23653. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23654. * @param joint defines the joint that will connect both impostors.
  23655. */
  23656. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23657. /**
  23658. * Removes a joint from the simulation
  23659. * @param mainImpostor defines the impostor used with the joint
  23660. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23661. * @param joint defines the joint to remove
  23662. */
  23663. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23664. /**
  23665. * Gets the current plugin used to run the simulation
  23666. * @returns current plugin
  23667. */
  23668. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23669. /**
  23670. * Gets the list of physic impostors
  23671. * @returns an array of PhysicsImpostor
  23672. */
  23673. getImpostors(): Array<PhysicsImpostor>;
  23674. /**
  23675. * Gets the impostor for a physics enabled object
  23676. * @param object defines the object impersonated by the impostor
  23677. * @returns the PhysicsImpostor or null if not found
  23678. */
  23679. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23680. /**
  23681. * Gets the impostor for a physics body object
  23682. * @param body defines physics body used by the impostor
  23683. * @returns the PhysicsImpostor or null if not found
  23684. */
  23685. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23686. /**
  23687. * Does a raycast in the physics world
  23688. * @param from when should the ray start?
  23689. * @param to when should the ray end?
  23690. * @returns PhysicsRaycastResult
  23691. */
  23692. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23693. /**
  23694. * Called by the scene. No need to call it.
  23695. * @param delta defines the timespam between frames
  23696. */
  23697. _step(delta: number): void;
  23698. }
  23699. }
  23700. declare module "babylonjs/Physics/physicsImpostor" {
  23701. import { Nullable, IndicesArray } from "babylonjs/types";
  23702. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23703. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23705. import { Scene } from "babylonjs/scene";
  23706. import { Bone } from "babylonjs/Bones/bone";
  23707. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23708. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23709. import { Space } from "babylonjs/Maths/math.axis";
  23710. /**
  23711. * The interface for the physics imposter parameters
  23712. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23713. */
  23714. export interface PhysicsImpostorParameters {
  23715. /**
  23716. * The mass of the physics imposter
  23717. */
  23718. mass: number;
  23719. /**
  23720. * The friction of the physics imposter
  23721. */
  23722. friction?: number;
  23723. /**
  23724. * The coefficient of restitution of the physics imposter
  23725. */
  23726. restitution?: number;
  23727. /**
  23728. * The native options of the physics imposter
  23729. */
  23730. nativeOptions?: any;
  23731. /**
  23732. * Specifies if the parent should be ignored
  23733. */
  23734. ignoreParent?: boolean;
  23735. /**
  23736. * Specifies if bi-directional transformations should be disabled
  23737. */
  23738. disableBidirectionalTransformation?: boolean;
  23739. /**
  23740. * The pressure inside the physics imposter, soft object only
  23741. */
  23742. pressure?: number;
  23743. /**
  23744. * The stiffness the physics imposter, soft object only
  23745. */
  23746. stiffness?: number;
  23747. /**
  23748. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23749. */
  23750. velocityIterations?: number;
  23751. /**
  23752. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23753. */
  23754. positionIterations?: number;
  23755. /**
  23756. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23757. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23758. * Add to fix multiple points
  23759. */
  23760. fixedPoints?: number;
  23761. /**
  23762. * The collision margin around a soft object
  23763. */
  23764. margin?: number;
  23765. /**
  23766. * The collision margin around a soft object
  23767. */
  23768. damping?: number;
  23769. /**
  23770. * The path for a rope based on an extrusion
  23771. */
  23772. path?: any;
  23773. /**
  23774. * The shape of an extrusion used for a rope based on an extrusion
  23775. */
  23776. shape?: any;
  23777. }
  23778. /**
  23779. * Interface for a physics-enabled object
  23780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23781. */
  23782. export interface IPhysicsEnabledObject {
  23783. /**
  23784. * The position of the physics-enabled object
  23785. */
  23786. position: Vector3;
  23787. /**
  23788. * The rotation of the physics-enabled object
  23789. */
  23790. rotationQuaternion: Nullable<Quaternion>;
  23791. /**
  23792. * The scale of the physics-enabled object
  23793. */
  23794. scaling: Vector3;
  23795. /**
  23796. * The rotation of the physics-enabled object
  23797. */
  23798. rotation?: Vector3;
  23799. /**
  23800. * The parent of the physics-enabled object
  23801. */
  23802. parent?: any;
  23803. /**
  23804. * The bounding info of the physics-enabled object
  23805. * @returns The bounding info of the physics-enabled object
  23806. */
  23807. getBoundingInfo(): BoundingInfo;
  23808. /**
  23809. * Computes the world matrix
  23810. * @param force Specifies if the world matrix should be computed by force
  23811. * @returns A world matrix
  23812. */
  23813. computeWorldMatrix(force: boolean): Matrix;
  23814. /**
  23815. * Gets the world matrix
  23816. * @returns A world matrix
  23817. */
  23818. getWorldMatrix?(): Matrix;
  23819. /**
  23820. * Gets the child meshes
  23821. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23822. * @returns An array of abstract meshes
  23823. */
  23824. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23825. /**
  23826. * Gets the vertex data
  23827. * @param kind The type of vertex data
  23828. * @returns A nullable array of numbers, or a float32 array
  23829. */
  23830. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23831. /**
  23832. * Gets the indices from the mesh
  23833. * @returns A nullable array of index arrays
  23834. */
  23835. getIndices?(): Nullable<IndicesArray>;
  23836. /**
  23837. * Gets the scene from the mesh
  23838. * @returns the indices array or null
  23839. */
  23840. getScene?(): Scene;
  23841. /**
  23842. * Gets the absolute position from the mesh
  23843. * @returns the absolute position
  23844. */
  23845. getAbsolutePosition(): Vector3;
  23846. /**
  23847. * Gets the absolute pivot point from the mesh
  23848. * @returns the absolute pivot point
  23849. */
  23850. getAbsolutePivotPoint(): Vector3;
  23851. /**
  23852. * Rotates the mesh
  23853. * @param axis The axis of rotation
  23854. * @param amount The amount of rotation
  23855. * @param space The space of the rotation
  23856. * @returns The rotation transform node
  23857. */
  23858. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23859. /**
  23860. * Translates the mesh
  23861. * @param axis The axis of translation
  23862. * @param distance The distance of translation
  23863. * @param space The space of the translation
  23864. * @returns The transform node
  23865. */
  23866. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23867. /**
  23868. * Sets the absolute position of the mesh
  23869. * @param absolutePosition The absolute position of the mesh
  23870. * @returns The transform node
  23871. */
  23872. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23873. /**
  23874. * Gets the class name of the mesh
  23875. * @returns The class name
  23876. */
  23877. getClassName(): string;
  23878. }
  23879. /**
  23880. * Represents a physics imposter
  23881. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23882. */
  23883. export class PhysicsImpostor {
  23884. /**
  23885. * The physics-enabled object used as the physics imposter
  23886. */
  23887. object: IPhysicsEnabledObject;
  23888. /**
  23889. * The type of the physics imposter
  23890. */
  23891. type: number;
  23892. private _options;
  23893. private _scene?;
  23894. /**
  23895. * The default object size of the imposter
  23896. */
  23897. static DEFAULT_OBJECT_SIZE: Vector3;
  23898. /**
  23899. * The identity quaternion of the imposter
  23900. */
  23901. static IDENTITY_QUATERNION: Quaternion;
  23902. /** @hidden */
  23903. _pluginData: any;
  23904. private _physicsEngine;
  23905. private _physicsBody;
  23906. private _bodyUpdateRequired;
  23907. private _onBeforePhysicsStepCallbacks;
  23908. private _onAfterPhysicsStepCallbacks;
  23909. /** @hidden */
  23910. _onPhysicsCollideCallbacks: Array<{
  23911. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23912. otherImpostors: Array<PhysicsImpostor>;
  23913. }>;
  23914. private _deltaPosition;
  23915. private _deltaRotation;
  23916. private _deltaRotationConjugated;
  23917. /** @hidden */
  23918. _isFromLine: boolean;
  23919. private _parent;
  23920. private _isDisposed;
  23921. private static _tmpVecs;
  23922. private static _tmpQuat;
  23923. /**
  23924. * Specifies if the physics imposter is disposed
  23925. */
  23926. readonly isDisposed: boolean;
  23927. /**
  23928. * Gets the mass of the physics imposter
  23929. */
  23930. mass: number;
  23931. /**
  23932. * Gets the coefficient of friction
  23933. */
  23934. /**
  23935. * Sets the coefficient of friction
  23936. */
  23937. friction: number;
  23938. /**
  23939. * Gets the coefficient of restitution
  23940. */
  23941. /**
  23942. * Sets the coefficient of restitution
  23943. */
  23944. restitution: number;
  23945. /**
  23946. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23947. */
  23948. /**
  23949. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23950. */
  23951. pressure: number;
  23952. /**
  23953. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23954. */
  23955. /**
  23956. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23957. */
  23958. stiffness: number;
  23959. /**
  23960. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23961. */
  23962. /**
  23963. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23964. */
  23965. velocityIterations: number;
  23966. /**
  23967. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23968. */
  23969. /**
  23970. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23971. */
  23972. positionIterations: number;
  23973. /**
  23974. * The unique id of the physics imposter
  23975. * set by the physics engine when adding this impostor to the array
  23976. */
  23977. uniqueId: number;
  23978. /**
  23979. * @hidden
  23980. */
  23981. soft: boolean;
  23982. /**
  23983. * @hidden
  23984. */
  23985. segments: number;
  23986. private _joints;
  23987. /**
  23988. * Initializes the physics imposter
  23989. * @param object The physics-enabled object used as the physics imposter
  23990. * @param type The type of the physics imposter
  23991. * @param _options The options for the physics imposter
  23992. * @param _scene The Babylon scene
  23993. */
  23994. constructor(
  23995. /**
  23996. * The physics-enabled object used as the physics imposter
  23997. */
  23998. object: IPhysicsEnabledObject,
  23999. /**
  24000. * The type of the physics imposter
  24001. */
  24002. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24003. /**
  24004. * This function will completly initialize this impostor.
  24005. * It will create a new body - but only if this mesh has no parent.
  24006. * If it has, this impostor will not be used other than to define the impostor
  24007. * of the child mesh.
  24008. * @hidden
  24009. */
  24010. _init(): void;
  24011. private _getPhysicsParent;
  24012. /**
  24013. * Should a new body be generated.
  24014. * @returns boolean specifying if body initialization is required
  24015. */
  24016. isBodyInitRequired(): boolean;
  24017. /**
  24018. * Sets the updated scaling
  24019. * @param updated Specifies if the scaling is updated
  24020. */
  24021. setScalingUpdated(): void;
  24022. /**
  24023. * Force a regeneration of this or the parent's impostor's body.
  24024. * Use under cautious - This will remove all joints already implemented.
  24025. */
  24026. forceUpdate(): void;
  24027. /**
  24028. * Gets the body that holds this impostor. Either its own, or its parent.
  24029. */
  24030. /**
  24031. * Set the physics body. Used mainly by the physics engine/plugin
  24032. */
  24033. physicsBody: any;
  24034. /**
  24035. * Get the parent of the physics imposter
  24036. * @returns Physics imposter or null
  24037. */
  24038. /**
  24039. * Sets the parent of the physics imposter
  24040. */
  24041. parent: Nullable<PhysicsImpostor>;
  24042. /**
  24043. * Resets the update flags
  24044. */
  24045. resetUpdateFlags(): void;
  24046. /**
  24047. * Gets the object extend size
  24048. * @returns the object extend size
  24049. */
  24050. getObjectExtendSize(): Vector3;
  24051. /**
  24052. * Gets the object center
  24053. * @returns The object center
  24054. */
  24055. getObjectCenter(): Vector3;
  24056. /**
  24057. * Get a specific parametes from the options parameter
  24058. * @param paramName The object parameter name
  24059. * @returns The object parameter
  24060. */
  24061. getParam(paramName: string): any;
  24062. /**
  24063. * Sets a specific parameter in the options given to the physics plugin
  24064. * @param paramName The parameter name
  24065. * @param value The value of the parameter
  24066. */
  24067. setParam(paramName: string, value: number): void;
  24068. /**
  24069. * Specifically change the body's mass option. Won't recreate the physics body object
  24070. * @param mass The mass of the physics imposter
  24071. */
  24072. setMass(mass: number): void;
  24073. /**
  24074. * Gets the linear velocity
  24075. * @returns linear velocity or null
  24076. */
  24077. getLinearVelocity(): Nullable<Vector3>;
  24078. /**
  24079. * Sets the linear velocity
  24080. * @param velocity linear velocity or null
  24081. */
  24082. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24083. /**
  24084. * Gets the angular velocity
  24085. * @returns angular velocity or null
  24086. */
  24087. getAngularVelocity(): Nullable<Vector3>;
  24088. /**
  24089. * Sets the angular velocity
  24090. * @param velocity The velocity or null
  24091. */
  24092. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24093. /**
  24094. * Execute a function with the physics plugin native code
  24095. * Provide a function the will have two variables - the world object and the physics body object
  24096. * @param func The function to execute with the physics plugin native code
  24097. */
  24098. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24099. /**
  24100. * Register a function that will be executed before the physics world is stepping forward
  24101. * @param func The function to execute before the physics world is stepped forward
  24102. */
  24103. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24104. /**
  24105. * Unregister a function that will be executed before the physics world is stepping forward
  24106. * @param func The function to execute before the physics world is stepped forward
  24107. */
  24108. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24109. /**
  24110. * Register a function that will be executed after the physics step
  24111. * @param func The function to execute after physics step
  24112. */
  24113. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24114. /**
  24115. * Unregisters a function that will be executed after the physics step
  24116. * @param func The function to execute after physics step
  24117. */
  24118. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24119. /**
  24120. * register a function that will be executed when this impostor collides against a different body
  24121. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24122. * @param func Callback that is executed on collision
  24123. */
  24124. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24125. /**
  24126. * Unregisters the physics imposter on contact
  24127. * @param collideAgainst The physics object to collide against
  24128. * @param func Callback to execute on collision
  24129. */
  24130. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24131. private _tmpQuat;
  24132. private _tmpQuat2;
  24133. /**
  24134. * Get the parent rotation
  24135. * @returns The parent rotation
  24136. */
  24137. getParentsRotation(): Quaternion;
  24138. /**
  24139. * this function is executed by the physics engine.
  24140. */
  24141. beforeStep: () => void;
  24142. /**
  24143. * this function is executed by the physics engine
  24144. */
  24145. afterStep: () => void;
  24146. /**
  24147. * Legacy collision detection event support
  24148. */
  24149. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24150. /**
  24151. * event and body object due to cannon's event-based architecture.
  24152. */
  24153. onCollide: (e: {
  24154. body: any;
  24155. }) => void;
  24156. /**
  24157. * Apply a force
  24158. * @param force The force to apply
  24159. * @param contactPoint The contact point for the force
  24160. * @returns The physics imposter
  24161. */
  24162. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24163. /**
  24164. * Apply an impulse
  24165. * @param force The impulse force
  24166. * @param contactPoint The contact point for the impulse force
  24167. * @returns The physics imposter
  24168. */
  24169. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24170. /**
  24171. * A help function to create a joint
  24172. * @param otherImpostor A physics imposter used to create a joint
  24173. * @param jointType The type of joint
  24174. * @param jointData The data for the joint
  24175. * @returns The physics imposter
  24176. */
  24177. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24178. /**
  24179. * Add a joint to this impostor with a different impostor
  24180. * @param otherImpostor A physics imposter used to add a joint
  24181. * @param joint The joint to add
  24182. * @returns The physics imposter
  24183. */
  24184. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24185. /**
  24186. * Add an anchor to a cloth impostor
  24187. * @param otherImpostor rigid impostor to anchor to
  24188. * @param width ratio across width from 0 to 1
  24189. * @param height ratio up height from 0 to 1
  24190. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24191. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24192. * @returns impostor the soft imposter
  24193. */
  24194. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24195. /**
  24196. * Add a hook to a rope impostor
  24197. * @param otherImpostor rigid impostor to anchor to
  24198. * @param length ratio across rope from 0 to 1
  24199. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24200. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24201. * @returns impostor the rope imposter
  24202. */
  24203. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24204. /**
  24205. * Will keep this body still, in a sleep mode.
  24206. * @returns the physics imposter
  24207. */
  24208. sleep(): PhysicsImpostor;
  24209. /**
  24210. * Wake the body up.
  24211. * @returns The physics imposter
  24212. */
  24213. wakeUp(): PhysicsImpostor;
  24214. /**
  24215. * Clones the physics imposter
  24216. * @param newObject The physics imposter clones to this physics-enabled object
  24217. * @returns A nullable physics imposter
  24218. */
  24219. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24220. /**
  24221. * Disposes the physics imposter
  24222. */
  24223. dispose(): void;
  24224. /**
  24225. * Sets the delta position
  24226. * @param position The delta position amount
  24227. */
  24228. setDeltaPosition(position: Vector3): void;
  24229. /**
  24230. * Sets the delta rotation
  24231. * @param rotation The delta rotation amount
  24232. */
  24233. setDeltaRotation(rotation: Quaternion): void;
  24234. /**
  24235. * Gets the box size of the physics imposter and stores the result in the input parameter
  24236. * @param result Stores the box size
  24237. * @returns The physics imposter
  24238. */
  24239. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24240. /**
  24241. * Gets the radius of the physics imposter
  24242. * @returns Radius of the physics imposter
  24243. */
  24244. getRadius(): number;
  24245. /**
  24246. * Sync a bone with this impostor
  24247. * @param bone The bone to sync to the impostor.
  24248. * @param boneMesh The mesh that the bone is influencing.
  24249. * @param jointPivot The pivot of the joint / bone in local space.
  24250. * @param distToJoint Optional distance from the impostor to the joint.
  24251. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24252. */
  24253. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24254. /**
  24255. * Sync impostor to a bone
  24256. * @param bone The bone that the impostor will be synced to.
  24257. * @param boneMesh The mesh that the bone is influencing.
  24258. * @param jointPivot The pivot of the joint / bone in local space.
  24259. * @param distToJoint Optional distance from the impostor to the joint.
  24260. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24261. * @param boneAxis Optional vector3 axis the bone is aligned with
  24262. */
  24263. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24264. /**
  24265. * No-Imposter type
  24266. */
  24267. static NoImpostor: number;
  24268. /**
  24269. * Sphere-Imposter type
  24270. */
  24271. static SphereImpostor: number;
  24272. /**
  24273. * Box-Imposter type
  24274. */
  24275. static BoxImpostor: number;
  24276. /**
  24277. * Plane-Imposter type
  24278. */
  24279. static PlaneImpostor: number;
  24280. /**
  24281. * Mesh-imposter type
  24282. */
  24283. static MeshImpostor: number;
  24284. /**
  24285. * Capsule-Impostor type (Ammo.js plugin only)
  24286. */
  24287. static CapsuleImpostor: number;
  24288. /**
  24289. * Cylinder-Imposter type
  24290. */
  24291. static CylinderImpostor: number;
  24292. /**
  24293. * Particle-Imposter type
  24294. */
  24295. static ParticleImpostor: number;
  24296. /**
  24297. * Heightmap-Imposter type
  24298. */
  24299. static HeightmapImpostor: number;
  24300. /**
  24301. * ConvexHull-Impostor type (Ammo.js plugin only)
  24302. */
  24303. static ConvexHullImpostor: number;
  24304. /**
  24305. * Rope-Imposter type
  24306. */
  24307. static RopeImpostor: number;
  24308. /**
  24309. * Cloth-Imposter type
  24310. */
  24311. static ClothImpostor: number;
  24312. /**
  24313. * Softbody-Imposter type
  24314. */
  24315. static SoftbodyImpostor: number;
  24316. }
  24317. }
  24318. declare module "babylonjs/Meshes/mesh" {
  24319. import { Observable } from "babylonjs/Misc/observable";
  24320. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24321. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24322. import { Camera } from "babylonjs/Cameras/camera";
  24323. import { Scene } from "babylonjs/scene";
  24324. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24325. import { Color4 } from "babylonjs/Maths/math.color";
  24326. import { Engine } from "babylonjs/Engines/engine";
  24327. import { Node } from "babylonjs/node";
  24328. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24329. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24330. import { Buffer } from "babylonjs/Meshes/buffer";
  24331. import { Geometry } from "babylonjs/Meshes/geometry";
  24332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24333. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24334. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24335. import { Effect } from "babylonjs/Materials/effect";
  24336. import { Material } from "babylonjs/Materials/material";
  24337. import { Skeleton } from "babylonjs/Bones/skeleton";
  24338. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24339. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24340. import { Path3D } from "babylonjs/Maths/math.path";
  24341. import { Plane } from "babylonjs/Maths/math.plane";
  24342. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24343. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24344. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24345. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24346. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24347. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24348. /**
  24349. * @hidden
  24350. **/
  24351. export class _CreationDataStorage {
  24352. closePath?: boolean;
  24353. closeArray?: boolean;
  24354. idx: number[];
  24355. dashSize: number;
  24356. gapSize: number;
  24357. path3D: Path3D;
  24358. pathArray: Vector3[][];
  24359. arc: number;
  24360. radius: number;
  24361. cap: number;
  24362. tessellation: number;
  24363. }
  24364. /**
  24365. * @hidden
  24366. **/
  24367. class _InstanceDataStorage {
  24368. visibleInstances: any;
  24369. batchCache: _InstancesBatch;
  24370. instancesBufferSize: number;
  24371. instancesBuffer: Nullable<Buffer>;
  24372. instancesData: Float32Array;
  24373. overridenInstanceCount: number;
  24374. isFrozen: boolean;
  24375. previousBatch: Nullable<_InstancesBatch>;
  24376. hardwareInstancedRendering: boolean;
  24377. sideOrientation: number;
  24378. manualUpdate: boolean;
  24379. }
  24380. /**
  24381. * @hidden
  24382. **/
  24383. export class _InstancesBatch {
  24384. mustReturn: boolean;
  24385. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24386. renderSelf: boolean[];
  24387. hardwareInstancedRendering: boolean[];
  24388. }
  24389. /**
  24390. * Class used to represent renderable models
  24391. */
  24392. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24393. /**
  24394. * Mesh side orientation : usually the external or front surface
  24395. */
  24396. static readonly FRONTSIDE: number;
  24397. /**
  24398. * Mesh side orientation : usually the internal or back surface
  24399. */
  24400. static readonly BACKSIDE: number;
  24401. /**
  24402. * Mesh side orientation : both internal and external or front and back surfaces
  24403. */
  24404. static readonly DOUBLESIDE: number;
  24405. /**
  24406. * Mesh side orientation : by default, `FRONTSIDE`
  24407. */
  24408. static readonly DEFAULTSIDE: number;
  24409. /**
  24410. * Mesh cap setting : no cap
  24411. */
  24412. static readonly NO_CAP: number;
  24413. /**
  24414. * Mesh cap setting : one cap at the beginning of the mesh
  24415. */
  24416. static readonly CAP_START: number;
  24417. /**
  24418. * Mesh cap setting : one cap at the end of the mesh
  24419. */
  24420. static readonly CAP_END: number;
  24421. /**
  24422. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24423. */
  24424. static readonly CAP_ALL: number;
  24425. /**
  24426. * Mesh pattern setting : no flip or rotate
  24427. */
  24428. static readonly NO_FLIP: number;
  24429. /**
  24430. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24431. */
  24432. static readonly FLIP_TILE: number;
  24433. /**
  24434. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24435. */
  24436. static readonly ROTATE_TILE: number;
  24437. /**
  24438. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24439. */
  24440. static readonly FLIP_ROW: number;
  24441. /**
  24442. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24443. */
  24444. static readonly ROTATE_ROW: number;
  24445. /**
  24446. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24447. */
  24448. static readonly FLIP_N_ROTATE_TILE: number;
  24449. /**
  24450. * Mesh pattern setting : rotate pattern and rotate
  24451. */
  24452. static readonly FLIP_N_ROTATE_ROW: number;
  24453. /**
  24454. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24455. */
  24456. static readonly CENTER: number;
  24457. /**
  24458. * Mesh tile positioning : part tiles on left
  24459. */
  24460. static readonly LEFT: number;
  24461. /**
  24462. * Mesh tile positioning : part tiles on right
  24463. */
  24464. static readonly RIGHT: number;
  24465. /**
  24466. * Mesh tile positioning : part tiles on top
  24467. */
  24468. static readonly TOP: number;
  24469. /**
  24470. * Mesh tile positioning : part tiles on bottom
  24471. */
  24472. static readonly BOTTOM: number;
  24473. /**
  24474. * Gets the default side orientation.
  24475. * @param orientation the orientation to value to attempt to get
  24476. * @returns the default orientation
  24477. * @hidden
  24478. */
  24479. static _GetDefaultSideOrientation(orientation?: number): number;
  24480. private _internalMeshDataInfo;
  24481. /**
  24482. * An event triggered before rendering the mesh
  24483. */
  24484. readonly onBeforeRenderObservable: Observable<Mesh>;
  24485. /**
  24486. * An event triggered before binding the mesh
  24487. */
  24488. readonly onBeforeBindObservable: Observable<Mesh>;
  24489. /**
  24490. * An event triggered after rendering the mesh
  24491. */
  24492. readonly onAfterRenderObservable: Observable<Mesh>;
  24493. /**
  24494. * An event triggered before drawing the mesh
  24495. */
  24496. readonly onBeforeDrawObservable: Observable<Mesh>;
  24497. private _onBeforeDrawObserver;
  24498. /**
  24499. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24500. */
  24501. onBeforeDraw: () => void;
  24502. readonly hasInstances: boolean;
  24503. /**
  24504. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24505. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24506. */
  24507. delayLoadState: number;
  24508. /**
  24509. * Gets the list of instances created from this mesh
  24510. * it is not supposed to be modified manually.
  24511. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24512. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24513. */
  24514. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24515. /**
  24516. * Gets the file containing delay loading data for this mesh
  24517. */
  24518. delayLoadingFile: string;
  24519. /** @hidden */
  24520. _binaryInfo: any;
  24521. /**
  24522. * User defined function used to change how LOD level selection is done
  24523. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24524. */
  24525. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24526. /**
  24527. * Gets or sets the morph target manager
  24528. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24529. */
  24530. morphTargetManager: Nullable<MorphTargetManager>;
  24531. /** @hidden */
  24532. _creationDataStorage: Nullable<_CreationDataStorage>;
  24533. /** @hidden */
  24534. _geometry: Nullable<Geometry>;
  24535. /** @hidden */
  24536. _delayInfo: Array<string>;
  24537. /** @hidden */
  24538. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24539. /** @hidden */
  24540. _instanceDataStorage: _InstanceDataStorage;
  24541. private _effectiveMaterial;
  24542. /** @hidden */
  24543. _shouldGenerateFlatShading: boolean;
  24544. /** @hidden */
  24545. _originalBuilderSideOrientation: number;
  24546. /**
  24547. * Use this property to change the original side orientation defined at construction time
  24548. */
  24549. overrideMaterialSideOrientation: Nullable<number>;
  24550. /**
  24551. * Gets the source mesh (the one used to clone this one from)
  24552. */
  24553. readonly source: Nullable<Mesh>;
  24554. /**
  24555. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24556. */
  24557. isUnIndexed: boolean;
  24558. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24559. readonly worldMatrixInstancedBuffer: Float32Array;
  24560. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24561. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  24562. /**
  24563. * @constructor
  24564. * @param name The value used by scene.getMeshByName() to do a lookup.
  24565. * @param scene The scene to add this mesh to.
  24566. * @param parent The parent of this mesh, if it has one
  24567. * @param source An optional Mesh from which geometry is shared, cloned.
  24568. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24569. * When false, achieved by calling a clone(), also passing False.
  24570. * This will make creation of children, recursive.
  24571. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24572. */
  24573. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24574. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24575. doNotInstantiate: boolean;
  24576. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24577. /**
  24578. * Gets the class name
  24579. * @returns the string "Mesh".
  24580. */
  24581. getClassName(): string;
  24582. /** @hidden */
  24583. readonly _isMesh: boolean;
  24584. /**
  24585. * Returns a description of this mesh
  24586. * @param fullDetails define if full details about this mesh must be used
  24587. * @returns a descriptive string representing this mesh
  24588. */
  24589. toString(fullDetails?: boolean): string;
  24590. /** @hidden */
  24591. _unBindEffect(): void;
  24592. /**
  24593. * Gets a boolean indicating if this mesh has LOD
  24594. */
  24595. readonly hasLODLevels: boolean;
  24596. /**
  24597. * Gets the list of MeshLODLevel associated with the current mesh
  24598. * @returns an array of MeshLODLevel
  24599. */
  24600. getLODLevels(): MeshLODLevel[];
  24601. private _sortLODLevels;
  24602. /**
  24603. * Add a mesh as LOD level triggered at the given distance.
  24604. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24605. * @param distance The distance from the center of the object to show this level
  24606. * @param mesh The mesh to be added as LOD level (can be null)
  24607. * @return This mesh (for chaining)
  24608. */
  24609. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24610. /**
  24611. * Returns the LOD level mesh at the passed distance or null if not found.
  24612. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24613. * @param distance The distance from the center of the object to show this level
  24614. * @returns a Mesh or `null`
  24615. */
  24616. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24617. /**
  24618. * Remove a mesh from the LOD array
  24619. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24620. * @param mesh defines the mesh to be removed
  24621. * @return This mesh (for chaining)
  24622. */
  24623. removeLODLevel(mesh: Mesh): Mesh;
  24624. /**
  24625. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24626. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24627. * @param camera defines the camera to use to compute distance
  24628. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24629. * @return This mesh (for chaining)
  24630. */
  24631. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24632. /**
  24633. * Gets the mesh internal Geometry object
  24634. */
  24635. readonly geometry: Nullable<Geometry>;
  24636. /**
  24637. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24638. * @returns the total number of vertices
  24639. */
  24640. getTotalVertices(): number;
  24641. /**
  24642. * Returns the content of an associated vertex buffer
  24643. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24644. * - VertexBuffer.PositionKind
  24645. * - VertexBuffer.UVKind
  24646. * - VertexBuffer.UV2Kind
  24647. * - VertexBuffer.UV3Kind
  24648. * - VertexBuffer.UV4Kind
  24649. * - VertexBuffer.UV5Kind
  24650. * - VertexBuffer.UV6Kind
  24651. * - VertexBuffer.ColorKind
  24652. * - VertexBuffer.MatricesIndicesKind
  24653. * - VertexBuffer.MatricesIndicesExtraKind
  24654. * - VertexBuffer.MatricesWeightsKind
  24655. * - VertexBuffer.MatricesWeightsExtraKind
  24656. * @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
  24657. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24658. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24659. */
  24660. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24661. /**
  24662. * Returns the mesh VertexBuffer object from the requested `kind`
  24663. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24664. * - VertexBuffer.PositionKind
  24665. * - VertexBuffer.NormalKind
  24666. * - VertexBuffer.UVKind
  24667. * - VertexBuffer.UV2Kind
  24668. * - VertexBuffer.UV3Kind
  24669. * - VertexBuffer.UV4Kind
  24670. * - VertexBuffer.UV5Kind
  24671. * - VertexBuffer.UV6Kind
  24672. * - VertexBuffer.ColorKind
  24673. * - VertexBuffer.MatricesIndicesKind
  24674. * - VertexBuffer.MatricesIndicesExtraKind
  24675. * - VertexBuffer.MatricesWeightsKind
  24676. * - VertexBuffer.MatricesWeightsExtraKind
  24677. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24678. */
  24679. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24680. /**
  24681. * Tests if a specific vertex buffer is associated with this mesh
  24682. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24683. * - VertexBuffer.PositionKind
  24684. * - VertexBuffer.NormalKind
  24685. * - VertexBuffer.UVKind
  24686. * - VertexBuffer.UV2Kind
  24687. * - VertexBuffer.UV3Kind
  24688. * - VertexBuffer.UV4Kind
  24689. * - VertexBuffer.UV5Kind
  24690. * - VertexBuffer.UV6Kind
  24691. * - VertexBuffer.ColorKind
  24692. * - VertexBuffer.MatricesIndicesKind
  24693. * - VertexBuffer.MatricesIndicesExtraKind
  24694. * - VertexBuffer.MatricesWeightsKind
  24695. * - VertexBuffer.MatricesWeightsExtraKind
  24696. * @returns a boolean
  24697. */
  24698. isVerticesDataPresent(kind: string): boolean;
  24699. /**
  24700. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24701. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24702. * - VertexBuffer.PositionKind
  24703. * - VertexBuffer.UVKind
  24704. * - VertexBuffer.UV2Kind
  24705. * - VertexBuffer.UV3Kind
  24706. * - VertexBuffer.UV4Kind
  24707. * - VertexBuffer.UV5Kind
  24708. * - VertexBuffer.UV6Kind
  24709. * - VertexBuffer.ColorKind
  24710. * - VertexBuffer.MatricesIndicesKind
  24711. * - VertexBuffer.MatricesIndicesExtraKind
  24712. * - VertexBuffer.MatricesWeightsKind
  24713. * - VertexBuffer.MatricesWeightsExtraKind
  24714. * @returns a boolean
  24715. */
  24716. isVertexBufferUpdatable(kind: string): boolean;
  24717. /**
  24718. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24719. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24720. * - VertexBuffer.PositionKind
  24721. * - VertexBuffer.NormalKind
  24722. * - VertexBuffer.UVKind
  24723. * - VertexBuffer.UV2Kind
  24724. * - VertexBuffer.UV3Kind
  24725. * - VertexBuffer.UV4Kind
  24726. * - VertexBuffer.UV5Kind
  24727. * - VertexBuffer.UV6Kind
  24728. * - VertexBuffer.ColorKind
  24729. * - VertexBuffer.MatricesIndicesKind
  24730. * - VertexBuffer.MatricesIndicesExtraKind
  24731. * - VertexBuffer.MatricesWeightsKind
  24732. * - VertexBuffer.MatricesWeightsExtraKind
  24733. * @returns an array of strings
  24734. */
  24735. getVerticesDataKinds(): string[];
  24736. /**
  24737. * Returns a positive integer : the total number of indices in this mesh geometry.
  24738. * @returns the numner of indices or zero if the mesh has no geometry.
  24739. */
  24740. getTotalIndices(): number;
  24741. /**
  24742. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24743. * @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.
  24744. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24745. * @returns the indices array or an empty array if the mesh has no geometry
  24746. */
  24747. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24748. readonly isBlocked: boolean;
  24749. /**
  24750. * Determine if the current mesh is ready to be rendered
  24751. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24752. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24753. * @returns true if all associated assets are ready (material, textures, shaders)
  24754. */
  24755. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24756. /**
  24757. * 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.
  24758. */
  24759. readonly areNormalsFrozen: boolean;
  24760. /**
  24761. * 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.
  24762. * @returns the current mesh
  24763. */
  24764. freezeNormals(): Mesh;
  24765. /**
  24766. * 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
  24767. * @returns the current mesh
  24768. */
  24769. unfreezeNormals(): Mesh;
  24770. /**
  24771. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24772. */
  24773. overridenInstanceCount: number;
  24774. /** @hidden */
  24775. _preActivate(): Mesh;
  24776. /** @hidden */
  24777. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24778. /** @hidden */
  24779. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24780. /**
  24781. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24782. * This means the mesh underlying bounding box and sphere are recomputed.
  24783. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24784. * @returns the current mesh
  24785. */
  24786. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24787. /** @hidden */
  24788. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24789. /**
  24790. * This function will subdivide the mesh into multiple submeshes
  24791. * @param count defines the expected number of submeshes
  24792. */
  24793. subdivide(count: number): void;
  24794. /**
  24795. * Copy a FloatArray into a specific associated vertex buffer
  24796. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24797. * - VertexBuffer.PositionKind
  24798. * - VertexBuffer.UVKind
  24799. * - VertexBuffer.UV2Kind
  24800. * - VertexBuffer.UV3Kind
  24801. * - VertexBuffer.UV4Kind
  24802. * - VertexBuffer.UV5Kind
  24803. * - VertexBuffer.UV6Kind
  24804. * - VertexBuffer.ColorKind
  24805. * - VertexBuffer.MatricesIndicesKind
  24806. * - VertexBuffer.MatricesIndicesExtraKind
  24807. * - VertexBuffer.MatricesWeightsKind
  24808. * - VertexBuffer.MatricesWeightsExtraKind
  24809. * @param data defines the data source
  24810. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24811. * @param stride defines the data stride size (can be null)
  24812. * @returns the current mesh
  24813. */
  24814. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24815. /**
  24816. * Delete a vertex buffer associated with this mesh
  24817. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24818. * - VertexBuffer.PositionKind
  24819. * - VertexBuffer.UVKind
  24820. * - VertexBuffer.UV2Kind
  24821. * - VertexBuffer.UV3Kind
  24822. * - VertexBuffer.UV4Kind
  24823. * - VertexBuffer.UV5Kind
  24824. * - VertexBuffer.UV6Kind
  24825. * - VertexBuffer.ColorKind
  24826. * - VertexBuffer.MatricesIndicesKind
  24827. * - VertexBuffer.MatricesIndicesExtraKind
  24828. * - VertexBuffer.MatricesWeightsKind
  24829. * - VertexBuffer.MatricesWeightsExtraKind
  24830. */
  24831. removeVerticesData(kind: string): void;
  24832. /**
  24833. * Flags an associated vertex buffer as updatable
  24834. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24835. * - VertexBuffer.PositionKind
  24836. * - VertexBuffer.UVKind
  24837. * - VertexBuffer.UV2Kind
  24838. * - VertexBuffer.UV3Kind
  24839. * - VertexBuffer.UV4Kind
  24840. * - VertexBuffer.UV5Kind
  24841. * - VertexBuffer.UV6Kind
  24842. * - VertexBuffer.ColorKind
  24843. * - VertexBuffer.MatricesIndicesKind
  24844. * - VertexBuffer.MatricesIndicesExtraKind
  24845. * - VertexBuffer.MatricesWeightsKind
  24846. * - VertexBuffer.MatricesWeightsExtraKind
  24847. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24848. */
  24849. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24850. /**
  24851. * Sets the mesh global Vertex Buffer
  24852. * @param buffer defines the buffer to use
  24853. * @returns the current mesh
  24854. */
  24855. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24856. /**
  24857. * Update a specific associated vertex buffer
  24858. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24859. * - VertexBuffer.PositionKind
  24860. * - VertexBuffer.UVKind
  24861. * - VertexBuffer.UV2Kind
  24862. * - VertexBuffer.UV3Kind
  24863. * - VertexBuffer.UV4Kind
  24864. * - VertexBuffer.UV5Kind
  24865. * - VertexBuffer.UV6Kind
  24866. * - VertexBuffer.ColorKind
  24867. * - VertexBuffer.MatricesIndicesKind
  24868. * - VertexBuffer.MatricesIndicesExtraKind
  24869. * - VertexBuffer.MatricesWeightsKind
  24870. * - VertexBuffer.MatricesWeightsExtraKind
  24871. * @param data defines the data source
  24872. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24873. * @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)
  24874. * @returns the current mesh
  24875. */
  24876. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24877. /**
  24878. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24879. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24880. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24881. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24882. * @returns the current mesh
  24883. */
  24884. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24885. /**
  24886. * Creates a un-shared specific occurence of the geometry for the mesh.
  24887. * @returns the current mesh
  24888. */
  24889. makeGeometryUnique(): Mesh;
  24890. /**
  24891. * Set the index buffer of this mesh
  24892. * @param indices defines the source data
  24893. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24894. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24895. * @returns the current mesh
  24896. */
  24897. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24898. /**
  24899. * Update the current index buffer
  24900. * @param indices defines the source data
  24901. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24902. * @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)
  24903. * @returns the current mesh
  24904. */
  24905. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24906. /**
  24907. * Invert the geometry to move from a right handed system to a left handed one.
  24908. * @returns the current mesh
  24909. */
  24910. toLeftHanded(): Mesh;
  24911. /** @hidden */
  24912. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24913. /** @hidden */
  24914. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24915. /**
  24916. * Registers for this mesh a javascript function called just before the rendering process
  24917. * @param func defines the function to call before rendering this mesh
  24918. * @returns the current mesh
  24919. */
  24920. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24921. /**
  24922. * Disposes a previously registered javascript function called before the rendering
  24923. * @param func defines the function to remove
  24924. * @returns the current mesh
  24925. */
  24926. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24927. /**
  24928. * Registers for this mesh a javascript function called just after the rendering is complete
  24929. * @param func defines the function to call after rendering this mesh
  24930. * @returns the current mesh
  24931. */
  24932. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24933. /**
  24934. * Disposes a previously registered javascript function called after the rendering.
  24935. * @param func defines the function to remove
  24936. * @returns the current mesh
  24937. */
  24938. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24939. /** @hidden */
  24940. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24941. /** @hidden */
  24942. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24943. /** @hidden */
  24944. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24945. /** @hidden */
  24946. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24947. /** @hidden */
  24948. _rebuild(): void;
  24949. /** @hidden */
  24950. _freeze(): void;
  24951. /** @hidden */
  24952. _unFreeze(): void;
  24953. /**
  24954. * 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
  24955. * @param subMesh defines the subMesh to render
  24956. * @param enableAlphaMode defines if alpha mode can be changed
  24957. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24958. * @returns the current mesh
  24959. */
  24960. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24961. private _onBeforeDraw;
  24962. /**
  24963. * Renormalize the mesh and patch it up if there are no weights
  24964. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24965. * However in the case of zero weights then we set just a single influence to 1.
  24966. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24967. */
  24968. cleanMatrixWeights(): void;
  24969. private normalizeSkinFourWeights;
  24970. private normalizeSkinWeightsAndExtra;
  24971. /**
  24972. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24973. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24974. * the user know there was an issue with importing the mesh
  24975. * @returns a validation object with skinned, valid and report string
  24976. */
  24977. validateSkinning(): {
  24978. skinned: boolean;
  24979. valid: boolean;
  24980. report: string;
  24981. };
  24982. /** @hidden */
  24983. _checkDelayState(): Mesh;
  24984. private _queueLoad;
  24985. /**
  24986. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24987. * A mesh is in the frustum if its bounding box intersects the frustum
  24988. * @param frustumPlanes defines the frustum to test
  24989. * @returns true if the mesh is in the frustum planes
  24990. */
  24991. isInFrustum(frustumPlanes: Plane[]): boolean;
  24992. /**
  24993. * Sets the mesh material by the material or multiMaterial `id` property
  24994. * @param id is a string identifying the material or the multiMaterial
  24995. * @returns the current mesh
  24996. */
  24997. setMaterialByID(id: string): Mesh;
  24998. /**
  24999. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25000. * @returns an array of IAnimatable
  25001. */
  25002. getAnimatables(): IAnimatable[];
  25003. /**
  25004. * Modifies the mesh geometry according to the passed transformation matrix.
  25005. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25006. * The mesh normals are modified using the same transformation.
  25007. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25008. * @param transform defines the transform matrix to use
  25009. * @see http://doc.babylonjs.com/resources/baking_transformations
  25010. * @returns the current mesh
  25011. */
  25012. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25013. /**
  25014. * Modifies the mesh geometry according to its own current World Matrix.
  25015. * The mesh World Matrix is then reset.
  25016. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25017. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25018. * @see http://doc.babylonjs.com/resources/baking_transformations
  25019. * @returns the current mesh
  25020. */
  25021. bakeCurrentTransformIntoVertices(): Mesh;
  25022. /** @hidden */
  25023. readonly _positions: Nullable<Vector3[]>;
  25024. /** @hidden */
  25025. _resetPointsArrayCache(): Mesh;
  25026. /** @hidden */
  25027. _generatePointsArray(): boolean;
  25028. /**
  25029. * Returns a new Mesh object generated from the current mesh properties.
  25030. * This method must not get confused with createInstance()
  25031. * @param name is a string, the name given to the new mesh
  25032. * @param newParent can be any Node object (default `null`)
  25033. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25034. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25035. * @returns a new mesh
  25036. */
  25037. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25038. /**
  25039. * Releases resources associated with this mesh.
  25040. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25041. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25042. */
  25043. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25044. /** @hidden */
  25045. _disposeInstanceSpecificData(): void;
  25046. /**
  25047. * Modifies the mesh geometry according to a displacement map.
  25048. * 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.
  25049. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25050. * @param url is a string, the URL from the image file is to be downloaded.
  25051. * @param minHeight is the lower limit of the displacement.
  25052. * @param maxHeight is the upper limit of the displacement.
  25053. * @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.
  25054. * @param uvOffset is an optional vector2 used to offset UV.
  25055. * @param uvScale is an optional vector2 used to scale UV.
  25056. * @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.
  25057. * @returns the Mesh.
  25058. */
  25059. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25060. /**
  25061. * Modifies the mesh geometry according to a displacementMap buffer.
  25062. * 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.
  25063. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25064. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25065. * @param heightMapWidth is the width of the buffer image.
  25066. * @param heightMapHeight is the height of the buffer image.
  25067. * @param minHeight is the lower limit of the displacement.
  25068. * @param maxHeight is the upper limit of the displacement.
  25069. * @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.
  25070. * @param uvOffset is an optional vector2 used to offset UV.
  25071. * @param uvScale is an optional vector2 used to scale UV.
  25072. * @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.
  25073. * @returns the Mesh.
  25074. */
  25075. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25076. /**
  25077. * Modify the mesh to get a flat shading rendering.
  25078. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25079. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25080. * @returns current mesh
  25081. */
  25082. convertToFlatShadedMesh(): Mesh;
  25083. /**
  25084. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25085. * In other words, more vertices, no more indices and a single bigger VBO.
  25086. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25087. * @returns current mesh
  25088. */
  25089. convertToUnIndexedMesh(): Mesh;
  25090. /**
  25091. * Inverses facet orientations.
  25092. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25093. * @param flipNormals will also inverts the normals
  25094. * @returns current mesh
  25095. */
  25096. flipFaces(flipNormals?: boolean): Mesh;
  25097. /**
  25098. * Increase the number of facets and hence vertices in a mesh
  25099. * Vertex normals are interpolated from existing vertex normals
  25100. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25101. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25102. */
  25103. increaseVertices(numberPerEdge: number): void;
  25104. /**
  25105. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25106. * This will undo any application of covertToFlatShadedMesh
  25107. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25108. */
  25109. forceSharedVertices(): void;
  25110. /** @hidden */
  25111. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25112. /** @hidden */
  25113. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25114. /**
  25115. * Creates a new InstancedMesh object from the mesh model.
  25116. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25117. * @param name defines the name of the new instance
  25118. * @returns a new InstancedMesh
  25119. */
  25120. createInstance(name: string): InstancedMesh;
  25121. /**
  25122. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25123. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25124. * @returns the current mesh
  25125. */
  25126. synchronizeInstances(): Mesh;
  25127. /**
  25128. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25129. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25130. * This should be used together with the simplification to avoid disappearing triangles.
  25131. * @param successCallback an optional success callback to be called after the optimization finished.
  25132. * @returns the current mesh
  25133. */
  25134. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25135. /**
  25136. * Serialize current mesh
  25137. * @param serializationObject defines the object which will receive the serialization data
  25138. */
  25139. serialize(serializationObject: any): void;
  25140. /** @hidden */
  25141. _syncGeometryWithMorphTargetManager(): void;
  25142. /** @hidden */
  25143. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25144. /**
  25145. * Returns a new Mesh object parsed from the source provided.
  25146. * @param parsedMesh is the source
  25147. * @param scene defines the hosting scene
  25148. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25149. * @returns a new Mesh
  25150. */
  25151. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25152. /**
  25153. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25154. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25155. * @param name defines the name of the mesh to create
  25156. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25157. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25158. * @param closePath creates a seam between the first and the last points of each path of the path array
  25159. * @param offset is taken in account only if the `pathArray` is containing a single path
  25160. * @param scene defines the hosting scene
  25161. * @param updatable defines if the mesh must be flagged as updatable
  25162. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25163. * @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)
  25164. * @returns a new Mesh
  25165. */
  25166. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25167. /**
  25168. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25169. * @param name defines the name of the mesh to create
  25170. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25171. * @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
  25172. * @param scene defines the hosting scene
  25173. * @param updatable defines if the mesh must be flagged as updatable
  25174. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25175. * @returns a new Mesh
  25176. */
  25177. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25178. /**
  25179. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25180. * @param name defines the name of the mesh to create
  25181. * @param size sets the size (float) of each box side (default 1)
  25182. * @param scene defines the hosting scene
  25183. * @param updatable defines if the mesh must be flagged as updatable
  25184. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25185. * @returns a new Mesh
  25186. */
  25187. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25188. /**
  25189. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25190. * @param name defines the name of the mesh to create
  25191. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25192. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25193. * @param scene defines the hosting scene
  25194. * @param updatable defines if the mesh must be flagged as updatable
  25195. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25196. * @returns a new Mesh
  25197. */
  25198. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25199. /**
  25200. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25201. * @param name defines the name of the mesh to create
  25202. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25203. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25204. * @param scene defines the hosting scene
  25205. * @returns a new Mesh
  25206. */
  25207. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25208. /**
  25209. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25210. * @param name defines the name of the mesh to create
  25211. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25212. * @param diameterTop set the top cap diameter (floats, default 1)
  25213. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25214. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25215. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25216. * @param scene defines the hosting scene
  25217. * @param updatable defines if the mesh must be flagged as updatable
  25218. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25219. * @returns a new Mesh
  25220. */
  25221. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25222. /**
  25223. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25224. * @param name defines the name of the mesh to create
  25225. * @param diameter sets the diameter size (float) of the torus (default 1)
  25226. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25227. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25228. * @param scene defines the hosting scene
  25229. * @param updatable defines if the mesh must be flagged as updatable
  25230. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25231. * @returns a new Mesh
  25232. */
  25233. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25234. /**
  25235. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25236. * @param name defines the name of the mesh to create
  25237. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25238. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25239. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25240. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25241. * @param p the number of windings on X axis (positive integers, default 2)
  25242. * @param q the number of windings on Y axis (positive integers, default 3)
  25243. * @param scene defines the hosting scene
  25244. * @param updatable defines if the mesh must be flagged as updatable
  25245. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25246. * @returns a new Mesh
  25247. */
  25248. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25249. /**
  25250. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25251. * @param name defines the name of the mesh to create
  25252. * @param points is an array successive Vector3
  25253. * @param scene defines the hosting scene
  25254. * @param updatable defines if the mesh must be flagged as updatable
  25255. * @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).
  25256. * @returns a new Mesh
  25257. */
  25258. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25259. /**
  25260. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25261. * @param name defines the name of the mesh to create
  25262. * @param points is an array successive Vector3
  25263. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25264. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25265. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25266. * @param scene defines the hosting scene
  25267. * @param updatable defines if the mesh must be flagged as updatable
  25268. * @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)
  25269. * @returns a new Mesh
  25270. */
  25271. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25272. /**
  25273. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25274. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25275. * 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.
  25276. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25277. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25278. * Remember you can only change the shape positions, not their number when updating a polygon.
  25279. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25280. * @param name defines the name of the mesh to create
  25281. * @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
  25282. * @param scene defines the hosting scene
  25283. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25284. * @param updatable defines if the mesh must be flagged as updatable
  25285. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25286. * @param earcutInjection can be used to inject your own earcut reference
  25287. * @returns a new Mesh
  25288. */
  25289. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25290. /**
  25291. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25292. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25293. * @param name defines the name of the mesh to create
  25294. * @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
  25295. * @param depth defines the height of extrusion
  25296. * @param scene defines the hosting scene
  25297. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25298. * @param updatable defines if the mesh must be flagged as updatable
  25299. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25300. * @param earcutInjection can be used to inject your own earcut reference
  25301. * @returns a new Mesh
  25302. */
  25303. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25304. /**
  25305. * Creates an extruded shape mesh.
  25306. * 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
  25307. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25308. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25309. * @param name defines the name of the mesh to create
  25310. * @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
  25311. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25312. * @param scale is the value to scale the shape
  25313. * @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
  25314. * @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
  25315. * @param scene defines the hosting scene
  25316. * @param updatable defines if the mesh must be flagged as updatable
  25317. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25318. * @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)
  25319. * @returns a new Mesh
  25320. */
  25321. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25322. /**
  25323. * Creates an custom extruded shape mesh.
  25324. * The custom extrusion is a parametric shape.
  25325. * It has no predefined shape. Its final shape will depend on the input parameters.
  25326. * Please consider using the same method from the MeshBuilder class instead
  25327. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25328. * @param name defines the name of the mesh to create
  25329. * @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
  25330. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25331. * @param scaleFunction is a custom Javascript function called on each path point
  25332. * @param rotationFunction is a custom Javascript function called on each path point
  25333. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25334. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25335. * @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
  25336. * @param scene defines the hosting scene
  25337. * @param updatable defines if the mesh must be flagged as updatable
  25338. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25339. * @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)
  25340. * @returns a new Mesh
  25341. */
  25342. 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;
  25343. /**
  25344. * Creates lathe mesh.
  25345. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25346. * Please consider using the same method from the MeshBuilder class instead
  25347. * @param name defines the name of the mesh to create
  25348. * @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
  25349. * @param radius is the radius value of the lathe
  25350. * @param tessellation is the side number of the lathe.
  25351. * @param scene defines the hosting scene
  25352. * @param updatable defines if the mesh must be flagged as updatable
  25353. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25354. * @returns a new Mesh
  25355. */
  25356. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25357. /**
  25358. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25359. * @param name defines the name of the mesh to create
  25360. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25361. * @param scene defines the hosting scene
  25362. * @param updatable defines if the mesh must be flagged as updatable
  25363. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25364. * @returns a new Mesh
  25365. */
  25366. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25367. /**
  25368. * Creates a ground mesh.
  25369. * Please consider using the same method from the MeshBuilder class instead
  25370. * @param name defines the name of the mesh to create
  25371. * @param width set the width of the ground
  25372. * @param height set the height of the ground
  25373. * @param subdivisions sets the number of subdivisions per side
  25374. * @param scene defines the hosting scene
  25375. * @param updatable defines if the mesh must be flagged as updatable
  25376. * @returns a new Mesh
  25377. */
  25378. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25379. /**
  25380. * Creates a tiled ground mesh.
  25381. * Please consider using the same method from the MeshBuilder class instead
  25382. * @param name defines the name of the mesh to create
  25383. * @param xmin set the ground minimum X coordinate
  25384. * @param zmin set the ground minimum Y coordinate
  25385. * @param xmax set the ground maximum X coordinate
  25386. * @param zmax set the ground maximum Z coordinate
  25387. * @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
  25388. * @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
  25389. * @param scene defines the hosting scene
  25390. * @param updatable defines if the mesh must be flagged as updatable
  25391. * @returns a new Mesh
  25392. */
  25393. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25394. w: number;
  25395. h: number;
  25396. }, precision: {
  25397. w: number;
  25398. h: number;
  25399. }, scene: Scene, updatable?: boolean): Mesh;
  25400. /**
  25401. * Creates a ground mesh from a height map.
  25402. * Please consider using the same method from the MeshBuilder class instead
  25403. * @see http://doc.babylonjs.com/babylon101/height_map
  25404. * @param name defines the name of the mesh to create
  25405. * @param url sets the URL of the height map image resource
  25406. * @param width set the ground width size
  25407. * @param height set the ground height size
  25408. * @param subdivisions sets the number of subdivision per side
  25409. * @param minHeight is the minimum altitude on the ground
  25410. * @param maxHeight is the maximum altitude on the ground
  25411. * @param scene defines the hosting scene
  25412. * @param updatable defines if the mesh must be flagged as updatable
  25413. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25414. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25415. * @returns a new Mesh
  25416. */
  25417. 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;
  25418. /**
  25419. * Creates a tube mesh.
  25420. * The tube is a parametric shape.
  25421. * It has no predefined shape. Its final shape will depend on the input parameters.
  25422. * Please consider using the same method from the MeshBuilder class instead
  25423. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25424. * @param name defines the name of the mesh to create
  25425. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25426. * @param radius sets the tube radius size
  25427. * @param tessellation is the number of sides on the tubular surface
  25428. * @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
  25429. * @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
  25430. * @param scene defines the hosting scene
  25431. * @param updatable defines if the mesh must be flagged as updatable
  25432. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25433. * @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)
  25434. * @returns a new Mesh
  25435. */
  25436. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25437. (i: number, distance: number): number;
  25438. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25439. /**
  25440. * Creates a polyhedron mesh.
  25441. * Please consider using the same method from the MeshBuilder class instead.
  25442. * * 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
  25443. * * The parameter `size` (positive float, default 1) sets the polygon size
  25444. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25445. * * 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`
  25446. * * 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
  25447. * * 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)`)
  25448. * * 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
  25449. * * 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
  25450. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25451. * * If you create a double-sided mesh, you can choose what parts of 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
  25452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25453. * @param name defines the name of the mesh to create
  25454. * @param options defines the options used to create the mesh
  25455. * @param scene defines the hosting scene
  25456. * @returns a new Mesh
  25457. */
  25458. static CreatePolyhedron(name: string, options: {
  25459. type?: number;
  25460. size?: number;
  25461. sizeX?: number;
  25462. sizeY?: number;
  25463. sizeZ?: number;
  25464. custom?: any;
  25465. faceUV?: Vector4[];
  25466. faceColors?: Color4[];
  25467. updatable?: boolean;
  25468. sideOrientation?: number;
  25469. }, scene: Scene): Mesh;
  25470. /**
  25471. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25472. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25473. * * 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`)
  25474. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25475. * * 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
  25476. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25477. * * If you create a double-sided mesh, you can choose what parts of 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
  25478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25479. * @param name defines the name of the mesh
  25480. * @param options defines the options used to create the mesh
  25481. * @param scene defines the hosting scene
  25482. * @returns a new Mesh
  25483. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25484. */
  25485. static CreateIcoSphere(name: string, options: {
  25486. radius?: number;
  25487. flat?: boolean;
  25488. subdivisions?: number;
  25489. sideOrientation?: number;
  25490. updatable?: boolean;
  25491. }, scene: Scene): Mesh;
  25492. /**
  25493. * Creates a decal mesh.
  25494. * Please consider using the same method from the MeshBuilder class instead.
  25495. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25496. * @param name defines the name of the mesh
  25497. * @param sourceMesh defines the mesh receiving the decal
  25498. * @param position sets the position of the decal in world coordinates
  25499. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25500. * @param size sets the decal scaling
  25501. * @param angle sets the angle to rotate the decal
  25502. * @returns a new Mesh
  25503. */
  25504. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25505. /**
  25506. * Prepare internal position array for software CPU skinning
  25507. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25508. */
  25509. setPositionsForCPUSkinning(): Float32Array;
  25510. /**
  25511. * Prepare internal normal array for software CPU skinning
  25512. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25513. */
  25514. setNormalsForCPUSkinning(): Float32Array;
  25515. /**
  25516. * Updates the vertex buffer by applying transformation from the bones
  25517. * @param skeleton defines the skeleton to apply to current mesh
  25518. * @returns the current mesh
  25519. */
  25520. applySkeleton(skeleton: Skeleton): Mesh;
  25521. /**
  25522. * 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
  25523. * @param meshes defines the list of meshes to scan
  25524. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25525. */
  25526. static MinMax(meshes: AbstractMesh[]): {
  25527. min: Vector3;
  25528. max: Vector3;
  25529. };
  25530. /**
  25531. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25532. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25533. * @returns a vector3
  25534. */
  25535. static Center(meshesOrMinMaxVector: {
  25536. min: Vector3;
  25537. max: Vector3;
  25538. } | AbstractMesh[]): Vector3;
  25539. /**
  25540. * Merge the array of meshes into a single mesh for performance reasons.
  25541. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25542. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25543. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25544. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25545. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25546. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25547. * @returns a new mesh
  25548. */
  25549. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25550. /** @hidden */
  25551. addInstance(instance: InstancedMesh): void;
  25552. /** @hidden */
  25553. removeInstance(instance: InstancedMesh): void;
  25554. }
  25555. }
  25556. declare module "babylonjs/Cameras/camera" {
  25557. import { SmartArray } from "babylonjs/Misc/smartArray";
  25558. import { Observable } from "babylonjs/Misc/observable";
  25559. import { Nullable } from "babylonjs/types";
  25560. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25561. import { Scene } from "babylonjs/scene";
  25562. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25563. import { Node } from "babylonjs/node";
  25564. import { Mesh } from "babylonjs/Meshes/mesh";
  25565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25566. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25567. import { Viewport } from "babylonjs/Maths/math.viewport";
  25568. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25569. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25570. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25571. import { Ray } from "babylonjs/Culling/ray";
  25572. /**
  25573. * This is the base class of all the camera used in the application.
  25574. * @see http://doc.babylonjs.com/features/cameras
  25575. */
  25576. export class Camera extends Node {
  25577. /** @hidden */
  25578. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25579. /**
  25580. * This is the default projection mode used by the cameras.
  25581. * It helps recreating a feeling of perspective and better appreciate depth.
  25582. * This is the best way to simulate real life cameras.
  25583. */
  25584. static readonly PERSPECTIVE_CAMERA: number;
  25585. /**
  25586. * This helps creating camera with an orthographic mode.
  25587. * 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.
  25588. */
  25589. static readonly ORTHOGRAPHIC_CAMERA: number;
  25590. /**
  25591. * This is the default FOV mode for perspective cameras.
  25592. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25593. */
  25594. static readonly FOVMODE_VERTICAL_FIXED: number;
  25595. /**
  25596. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25597. */
  25598. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25599. /**
  25600. * This specifies ther is no need for a camera rig.
  25601. * Basically only one eye is rendered corresponding to the camera.
  25602. */
  25603. static readonly RIG_MODE_NONE: number;
  25604. /**
  25605. * Simulates a camera Rig with one blue eye and one red eye.
  25606. * This can be use with 3d blue and red glasses.
  25607. */
  25608. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25609. /**
  25610. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25611. */
  25612. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25613. /**
  25614. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25615. */
  25616. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25617. /**
  25618. * Defines that both eyes of the camera will be rendered over under each other.
  25619. */
  25620. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25621. /**
  25622. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25623. */
  25624. static readonly RIG_MODE_VR: number;
  25625. /**
  25626. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25627. */
  25628. static readonly RIG_MODE_WEBVR: number;
  25629. /**
  25630. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25631. */
  25632. static readonly RIG_MODE_CUSTOM: number;
  25633. /**
  25634. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25635. */
  25636. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25637. /**
  25638. * Define the input manager associated with the camera.
  25639. */
  25640. inputs: CameraInputsManager<Camera>;
  25641. /** @hidden */
  25642. _position: Vector3;
  25643. /**
  25644. * Define the current local position of the camera in the scene
  25645. */
  25646. position: Vector3;
  25647. /**
  25648. * The vector the camera should consider as up.
  25649. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25650. */
  25651. upVector: Vector3;
  25652. /**
  25653. * Define the current limit on the left side for an orthographic camera
  25654. * In scene unit
  25655. */
  25656. orthoLeft: Nullable<number>;
  25657. /**
  25658. * Define the current limit on the right side for an orthographic camera
  25659. * In scene unit
  25660. */
  25661. orthoRight: Nullable<number>;
  25662. /**
  25663. * Define the current limit on the bottom side for an orthographic camera
  25664. * In scene unit
  25665. */
  25666. orthoBottom: Nullable<number>;
  25667. /**
  25668. * Define the current limit on the top side for an orthographic camera
  25669. * In scene unit
  25670. */
  25671. orthoTop: Nullable<number>;
  25672. /**
  25673. * Field Of View is set in Radians. (default is 0.8)
  25674. */
  25675. fov: number;
  25676. /**
  25677. * Define the minimum distance the camera can see from.
  25678. * This is important to note that the depth buffer are not infinite and the closer it starts
  25679. * the more your scene might encounter depth fighting issue.
  25680. */
  25681. minZ: number;
  25682. /**
  25683. * Define the maximum distance the camera can see to.
  25684. * This is important to note that the depth buffer are not infinite and the further it end
  25685. * the more your scene might encounter depth fighting issue.
  25686. */
  25687. maxZ: number;
  25688. /**
  25689. * Define the default inertia of the camera.
  25690. * This helps giving a smooth feeling to the camera movement.
  25691. */
  25692. inertia: number;
  25693. /**
  25694. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25695. */
  25696. mode: number;
  25697. /**
  25698. * Define wether the camera is intermediate.
  25699. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25700. */
  25701. isIntermediate: boolean;
  25702. /**
  25703. * Define the viewport of the camera.
  25704. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25705. */
  25706. viewport: Viewport;
  25707. /**
  25708. * Restricts the camera to viewing objects with the same layerMask.
  25709. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25710. */
  25711. layerMask: number;
  25712. /**
  25713. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25714. */
  25715. fovMode: number;
  25716. /**
  25717. * Rig mode of the camera.
  25718. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25719. * This is normally controlled byt the camera themselves as internal use.
  25720. */
  25721. cameraRigMode: number;
  25722. /**
  25723. * Defines the distance between both "eyes" in case of a RIG
  25724. */
  25725. interaxialDistance: number;
  25726. /**
  25727. * Defines if stereoscopic rendering is done side by side or over under.
  25728. */
  25729. isStereoscopicSideBySide: boolean;
  25730. /**
  25731. * 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
  25732. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25733. * else in the scene. (Eg. security camera)
  25734. *
  25735. * 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)
  25736. */
  25737. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25738. /**
  25739. * When set, the camera will render to this render target instead of the default canvas
  25740. *
  25741. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25742. */
  25743. outputRenderTarget: Nullable<RenderTargetTexture>;
  25744. /**
  25745. * Observable triggered when the camera view matrix has changed.
  25746. */
  25747. onViewMatrixChangedObservable: Observable<Camera>;
  25748. /**
  25749. * Observable triggered when the camera Projection matrix has changed.
  25750. */
  25751. onProjectionMatrixChangedObservable: Observable<Camera>;
  25752. /**
  25753. * Observable triggered when the inputs have been processed.
  25754. */
  25755. onAfterCheckInputsObservable: Observable<Camera>;
  25756. /**
  25757. * Observable triggered when reset has been called and applied to the camera.
  25758. */
  25759. onRestoreStateObservable: Observable<Camera>;
  25760. /** @hidden */
  25761. _cameraRigParams: any;
  25762. /** @hidden */
  25763. _rigCameras: Camera[];
  25764. /** @hidden */
  25765. _rigPostProcess: Nullable<PostProcess>;
  25766. protected _webvrViewMatrix: Matrix;
  25767. /** @hidden */
  25768. _skipRendering: boolean;
  25769. /** @hidden */
  25770. _projectionMatrix: Matrix;
  25771. /** @hidden */
  25772. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25773. /** @hidden */
  25774. _activeMeshes: SmartArray<AbstractMesh>;
  25775. protected _globalPosition: Vector3;
  25776. /** @hidden */
  25777. _computedViewMatrix: Matrix;
  25778. private _doNotComputeProjectionMatrix;
  25779. private _transformMatrix;
  25780. private _frustumPlanes;
  25781. private _refreshFrustumPlanes;
  25782. private _storedFov;
  25783. private _stateStored;
  25784. /**
  25785. * Instantiates a new camera object.
  25786. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25787. * @see http://doc.babylonjs.com/features/cameras
  25788. * @param name Defines the name of the camera in the scene
  25789. * @param position Defines the position of the camera
  25790. * @param scene Defines the scene the camera belongs too
  25791. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25792. */
  25793. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25794. /**
  25795. * Store current camera state (fov, position, etc..)
  25796. * @returns the camera
  25797. */
  25798. storeState(): Camera;
  25799. /**
  25800. * Restores the camera state values if it has been stored. You must call storeState() first
  25801. */
  25802. protected _restoreStateValues(): boolean;
  25803. /**
  25804. * Restored camera state. You must call storeState() first.
  25805. * @returns true if restored and false otherwise
  25806. */
  25807. restoreState(): boolean;
  25808. /**
  25809. * Gets the class name of the camera.
  25810. * @returns the class name
  25811. */
  25812. getClassName(): string;
  25813. /** @hidden */
  25814. readonly _isCamera: boolean;
  25815. /**
  25816. * Gets a string representation of the camera useful for debug purpose.
  25817. * @param fullDetails Defines that a more verboe level of logging is required
  25818. * @returns the string representation
  25819. */
  25820. toString(fullDetails?: boolean): string;
  25821. /**
  25822. * Gets the current world space position of the camera.
  25823. */
  25824. readonly globalPosition: Vector3;
  25825. /**
  25826. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25827. * @returns the active meshe list
  25828. */
  25829. getActiveMeshes(): SmartArray<AbstractMesh>;
  25830. /**
  25831. * Check wether a mesh is part of the current active mesh list of the camera
  25832. * @param mesh Defines the mesh to check
  25833. * @returns true if active, false otherwise
  25834. */
  25835. isActiveMesh(mesh: Mesh): boolean;
  25836. /**
  25837. * Is this camera ready to be used/rendered
  25838. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25839. * @return true if the camera is ready
  25840. */
  25841. isReady(completeCheck?: boolean): boolean;
  25842. /** @hidden */
  25843. _initCache(): void;
  25844. /** @hidden */
  25845. _updateCache(ignoreParentClass?: boolean): void;
  25846. /** @hidden */
  25847. _isSynchronized(): boolean;
  25848. /** @hidden */
  25849. _isSynchronizedViewMatrix(): boolean;
  25850. /** @hidden */
  25851. _isSynchronizedProjectionMatrix(): boolean;
  25852. /**
  25853. * Attach the input controls to a specific dom element to get the input from.
  25854. * @param element Defines the element the controls should be listened from
  25855. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25856. */
  25857. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25858. /**
  25859. * Detach the current controls from the specified dom element.
  25860. * @param element Defines the element to stop listening the inputs from
  25861. */
  25862. detachControl(element: HTMLElement): void;
  25863. /**
  25864. * Update the camera state according to the different inputs gathered during the frame.
  25865. */
  25866. update(): void;
  25867. /** @hidden */
  25868. _checkInputs(): void;
  25869. /** @hidden */
  25870. readonly rigCameras: Camera[];
  25871. /**
  25872. * Gets the post process used by the rig cameras
  25873. */
  25874. readonly rigPostProcess: Nullable<PostProcess>;
  25875. /**
  25876. * Internal, gets the first post proces.
  25877. * @returns the first post process to be run on this camera.
  25878. */
  25879. _getFirstPostProcess(): Nullable<PostProcess>;
  25880. private _cascadePostProcessesToRigCams;
  25881. /**
  25882. * Attach a post process to the camera.
  25883. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25884. * @param postProcess The post process to attach to the camera
  25885. * @param insertAt The position of the post process in case several of them are in use in the scene
  25886. * @returns the position the post process has been inserted at
  25887. */
  25888. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25889. /**
  25890. * Detach a post process to the camera.
  25891. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25892. * @param postProcess The post process to detach from the camera
  25893. */
  25894. detachPostProcess(postProcess: PostProcess): void;
  25895. /**
  25896. * Gets the current world matrix of the camera
  25897. */
  25898. getWorldMatrix(): Matrix;
  25899. /** @hidden */
  25900. _getViewMatrix(): Matrix;
  25901. /**
  25902. * Gets the current view matrix of the camera.
  25903. * @param force forces the camera to recompute the matrix without looking at the cached state
  25904. * @returns the view matrix
  25905. */
  25906. getViewMatrix(force?: boolean): Matrix;
  25907. /**
  25908. * Freeze the projection matrix.
  25909. * It will prevent the cache check of the camera projection compute and can speed up perf
  25910. * if no parameter of the camera are meant to change
  25911. * @param projection Defines manually a projection if necessary
  25912. */
  25913. freezeProjectionMatrix(projection?: Matrix): void;
  25914. /**
  25915. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25916. */
  25917. unfreezeProjectionMatrix(): void;
  25918. /**
  25919. * Gets the current projection matrix of the camera.
  25920. * @param force forces the camera to recompute the matrix without looking at the cached state
  25921. * @returns the projection matrix
  25922. */
  25923. getProjectionMatrix(force?: boolean): Matrix;
  25924. /**
  25925. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25926. * @returns a Matrix
  25927. */
  25928. getTransformationMatrix(): Matrix;
  25929. private _updateFrustumPlanes;
  25930. /**
  25931. * Checks if a cullable object (mesh...) is in the camera frustum
  25932. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25933. * @param target The object to check
  25934. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25935. * @returns true if the object is in frustum otherwise false
  25936. */
  25937. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25938. /**
  25939. * Checks if a cullable object (mesh...) is in the camera frustum
  25940. * Unlike isInFrustum this cheks the full bounding box
  25941. * @param target The object to check
  25942. * @returns true if the object is in frustum otherwise false
  25943. */
  25944. isCompletelyInFrustum(target: ICullable): boolean;
  25945. /**
  25946. * Gets a ray in the forward direction from the camera.
  25947. * @param length Defines the length of the ray to create
  25948. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25949. * @param origin Defines the start point of the ray which defaults to the camera position
  25950. * @returns the forward ray
  25951. */
  25952. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25953. /**
  25954. * Releases resources associated with this node.
  25955. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25956. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25957. */
  25958. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25959. /** @hidden */
  25960. _isLeftCamera: boolean;
  25961. /**
  25962. * Gets the left camera of a rig setup in case of Rigged Camera
  25963. */
  25964. readonly isLeftCamera: boolean;
  25965. /** @hidden */
  25966. _isRightCamera: boolean;
  25967. /**
  25968. * Gets the right camera of a rig setup in case of Rigged Camera
  25969. */
  25970. readonly isRightCamera: boolean;
  25971. /**
  25972. * Gets the left camera of a rig setup in case of Rigged Camera
  25973. */
  25974. readonly leftCamera: Nullable<FreeCamera>;
  25975. /**
  25976. * Gets the right camera of a rig setup in case of Rigged Camera
  25977. */
  25978. readonly rightCamera: Nullable<FreeCamera>;
  25979. /**
  25980. * Gets the left camera target of a rig setup in case of Rigged Camera
  25981. * @returns the target position
  25982. */
  25983. getLeftTarget(): Nullable<Vector3>;
  25984. /**
  25985. * Gets the right camera target of a rig setup in case of Rigged Camera
  25986. * @returns the target position
  25987. */
  25988. getRightTarget(): Nullable<Vector3>;
  25989. /**
  25990. * @hidden
  25991. */
  25992. setCameraRigMode(mode: number, rigParams: any): void;
  25993. /** @hidden */
  25994. static _setStereoscopicRigMode(camera: Camera): void;
  25995. /** @hidden */
  25996. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25997. /** @hidden */
  25998. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25999. /** @hidden */
  26000. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26001. /** @hidden */
  26002. _getVRProjectionMatrix(): Matrix;
  26003. protected _updateCameraRotationMatrix(): void;
  26004. protected _updateWebVRCameraRotationMatrix(): void;
  26005. /**
  26006. * This function MUST be overwritten by the different WebVR cameras available.
  26007. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26008. * @hidden
  26009. */
  26010. _getWebVRProjectionMatrix(): Matrix;
  26011. /**
  26012. * This function MUST be overwritten by the different WebVR cameras available.
  26013. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26014. * @hidden
  26015. */
  26016. _getWebVRViewMatrix(): Matrix;
  26017. /** @hidden */
  26018. setCameraRigParameter(name: string, value: any): void;
  26019. /**
  26020. * needs to be overridden by children so sub has required properties to be copied
  26021. * @hidden
  26022. */
  26023. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26024. /**
  26025. * May need to be overridden by children
  26026. * @hidden
  26027. */
  26028. _updateRigCameras(): void;
  26029. /** @hidden */
  26030. _setupInputs(): void;
  26031. /**
  26032. * Serialiaze the camera setup to a json represention
  26033. * @returns the JSON representation
  26034. */
  26035. serialize(): any;
  26036. /**
  26037. * Clones the current camera.
  26038. * @param name The cloned camera name
  26039. * @returns the cloned camera
  26040. */
  26041. clone(name: string): Camera;
  26042. /**
  26043. * Gets the direction of the camera relative to a given local axis.
  26044. * @param localAxis Defines the reference axis to provide a relative direction.
  26045. * @return the direction
  26046. */
  26047. getDirection(localAxis: Vector3): Vector3;
  26048. /**
  26049. * Returns the current camera absolute rotation
  26050. */
  26051. readonly absoluteRotation: Quaternion;
  26052. /**
  26053. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26054. * @param localAxis Defines the reference axis to provide a relative direction.
  26055. * @param result Defines the vector to store the result in
  26056. */
  26057. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26058. /**
  26059. * Gets a camera constructor for a given camera type
  26060. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26061. * @param name The name of the camera the result will be able to instantiate
  26062. * @param scene The scene the result will construct the camera in
  26063. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26064. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26065. * @returns a factory method to construc the camera
  26066. */
  26067. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26068. /**
  26069. * Compute the world matrix of the camera.
  26070. * @returns the camera world matrix
  26071. */
  26072. computeWorldMatrix(): Matrix;
  26073. /**
  26074. * Parse a JSON and creates the camera from the parsed information
  26075. * @param parsedCamera The JSON to parse
  26076. * @param scene The scene to instantiate the camera in
  26077. * @returns the newly constructed camera
  26078. */
  26079. static Parse(parsedCamera: any, scene: Scene): Camera;
  26080. }
  26081. }
  26082. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26083. import { Nullable } from "babylonjs/types";
  26084. import { Scene } from "babylonjs/scene";
  26085. import { Vector4 } from "babylonjs/Maths/math.vector";
  26086. import { Mesh } from "babylonjs/Meshes/mesh";
  26087. /**
  26088. * Class containing static functions to help procedurally build meshes
  26089. */
  26090. export class DiscBuilder {
  26091. /**
  26092. * Creates a plane polygonal mesh. By default, this is a disc
  26093. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26094. * * 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
  26095. * * 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
  26096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26097. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26099. * @param name defines the name of the mesh
  26100. * @param options defines the options used to create the mesh
  26101. * @param scene defines the hosting scene
  26102. * @returns the plane polygonal mesh
  26103. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26104. */
  26105. static CreateDisc(name: string, options: {
  26106. radius?: number;
  26107. tessellation?: number;
  26108. arc?: number;
  26109. updatable?: boolean;
  26110. sideOrientation?: number;
  26111. frontUVs?: Vector4;
  26112. backUVs?: Vector4;
  26113. }, scene?: Nullable<Scene>): Mesh;
  26114. }
  26115. }
  26116. declare module "babylonjs/Particles/solidParticleSystem" {
  26117. import { Nullable } from "babylonjs/types";
  26118. import { Vector3 } from "babylonjs/Maths/math.vector";
  26119. import { Mesh } from "babylonjs/Meshes/mesh";
  26120. import { Scene, IDisposable } from "babylonjs/scene";
  26121. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  26122. /**
  26123. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26124. *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.
  26125. * The SPS is also a particle system. It provides some methods to manage the particles.
  26126. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26127. *
  26128. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26129. */
  26130. export class SolidParticleSystem implements IDisposable {
  26131. /**
  26132. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26133. * Example : var p = SPS.particles[i];
  26134. */
  26135. particles: SolidParticle[];
  26136. /**
  26137. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26138. */
  26139. nbParticles: number;
  26140. /**
  26141. * If the particles must ever face the camera (default false). Useful for planar particles.
  26142. */
  26143. billboard: boolean;
  26144. /**
  26145. * Recompute normals when adding a shape
  26146. */
  26147. recomputeNormals: boolean;
  26148. /**
  26149. * This a counter ofr your own usage. It's not set by any SPS functions.
  26150. */
  26151. counter: number;
  26152. /**
  26153. * The SPS name. This name is also given to the underlying mesh.
  26154. */
  26155. name: string;
  26156. /**
  26157. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26158. */
  26159. mesh: Mesh;
  26160. /**
  26161. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26162. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26163. */
  26164. vars: any;
  26165. /**
  26166. * This array is populated when the SPS is set as 'pickable'.
  26167. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26168. * Each element of this array is an object `{idx: int, faceId: int}`.
  26169. * `idx` is the picked particle index in the `SPS.particles` array
  26170. * `faceId` is the picked face index counted within this particle.
  26171. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26172. */
  26173. pickedParticles: {
  26174. idx: number;
  26175. faceId: number;
  26176. }[];
  26177. /**
  26178. * This array is populated when `enableDepthSort` is set to true.
  26179. * Each element of this array is an instance of the class DepthSortedParticle.
  26180. */
  26181. depthSortedParticles: DepthSortedParticle[];
  26182. /**
  26183. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26184. * @hidden
  26185. */
  26186. _bSphereOnly: boolean;
  26187. /**
  26188. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26189. * @hidden
  26190. */
  26191. _bSphereRadiusFactor: number;
  26192. private _scene;
  26193. private _positions;
  26194. private _indices;
  26195. private _normals;
  26196. private _colors;
  26197. private _uvs;
  26198. private _indices32;
  26199. private _positions32;
  26200. private _normals32;
  26201. private _fixedNormal32;
  26202. private _colors32;
  26203. private _uvs32;
  26204. private _index;
  26205. private _updatable;
  26206. private _pickable;
  26207. private _isVisibilityBoxLocked;
  26208. private _alwaysVisible;
  26209. private _depthSort;
  26210. private _expandable;
  26211. private _shapeCounter;
  26212. private _copy;
  26213. private _color;
  26214. private _computeParticleColor;
  26215. private _computeParticleTexture;
  26216. private _computeParticleRotation;
  26217. private _computeParticleVertex;
  26218. private _computeBoundingBox;
  26219. private _depthSortParticles;
  26220. private _camera;
  26221. private _mustUnrotateFixedNormals;
  26222. private _particlesIntersect;
  26223. private _needs32Bits;
  26224. private _isNotBuilt;
  26225. private _lastParticleId;
  26226. private _idxOfId;
  26227. /**
  26228. * Creates a SPS (Solid Particle System) object.
  26229. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26230. * @param scene (Scene) is the scene in which the SPS is added.
  26231. * @param options defines the options of the sps e.g.
  26232. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26233. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26234. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26235. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26236. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26237. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26238. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26239. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26240. */
  26241. constructor(name: string, scene: Scene, options?: {
  26242. updatable?: boolean;
  26243. isPickable?: boolean;
  26244. enableDepthSort?: boolean;
  26245. particleIntersection?: boolean;
  26246. boundingSphereOnly?: boolean;
  26247. bSphereRadiusFactor?: number;
  26248. expandable?: boolean;
  26249. });
  26250. /**
  26251. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26252. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26253. * @returns the created mesh
  26254. */
  26255. buildMesh(): Mesh;
  26256. /**
  26257. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26258. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26259. * Thus the particles generated from `digest()` have their property `position` set yet.
  26260. * @param mesh ( Mesh ) is the mesh to be digested
  26261. * @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
  26262. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26263. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26264. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26265. * @returns the current SPS
  26266. */
  26267. digest(mesh: Mesh, options?: {
  26268. facetNb?: number;
  26269. number?: number;
  26270. delta?: number;
  26271. storage?: [];
  26272. }): SolidParticleSystem;
  26273. /**
  26274. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26275. * @hidden
  26276. */
  26277. private _unrotateFixedNormals;
  26278. /**
  26279. * Resets the temporary working copy particle
  26280. * @hidden
  26281. */
  26282. private _resetCopy;
  26283. /**
  26284. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26285. * @param p the current index in the positions array to be updated
  26286. * @param shape a Vector3 array, the shape geometry
  26287. * @param positions the positions array to be updated
  26288. * @param meshInd the shape indices array
  26289. * @param indices the indices array to be updated
  26290. * @param meshUV the shape uv array
  26291. * @param uvs the uv array to be updated
  26292. * @param meshCol the shape color array
  26293. * @param colors the color array to be updated
  26294. * @param meshNor the shape normals array
  26295. * @param normals the normals array to be updated
  26296. * @param idx the particle index
  26297. * @param idxInShape the particle index in its shape
  26298. * @param options the addShape() method passed options
  26299. * @hidden
  26300. */
  26301. private _meshBuilder;
  26302. /**
  26303. * Returns a shape Vector3 array from positions float array
  26304. * @param positions float array
  26305. * @returns a vector3 array
  26306. * @hidden
  26307. */
  26308. private _posToShape;
  26309. /**
  26310. * Returns a shapeUV array from a float uvs (array deep copy)
  26311. * @param uvs as a float array
  26312. * @returns a shapeUV array
  26313. * @hidden
  26314. */
  26315. private _uvsToShapeUV;
  26316. /**
  26317. * Adds a new particle object in the particles array
  26318. * @param idx particle index in particles array
  26319. * @param id particle id
  26320. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26321. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26322. * @param model particle ModelShape object
  26323. * @param shapeId model shape identifier
  26324. * @param idxInShape index of the particle in the current model
  26325. * @param bInfo model bounding info object
  26326. * @param storage target storage array, if any
  26327. * @hidden
  26328. */
  26329. private _addParticle;
  26330. /**
  26331. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26332. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26333. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26334. * @param nb (positive integer) the number of particles to be created from this model
  26335. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26336. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26337. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26338. * @returns the number of shapes in the system
  26339. */
  26340. addShape(mesh: Mesh, nb: number, options?: {
  26341. positionFunction?: any;
  26342. vertexFunction?: any;
  26343. storage?: [];
  26344. }): number;
  26345. /**
  26346. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26347. * @hidden
  26348. */
  26349. private _rebuildParticle;
  26350. /**
  26351. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26352. * @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.
  26353. * @returns the SPS.
  26354. */
  26355. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26356. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26357. * Returns an array with the removed particles.
  26358. * 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.
  26359. * The SPS can't be empty so at least one particle needs to remain in place.
  26360. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26361. * @param start index of the first particle to remove
  26362. * @param end index of the last particle to remove (included)
  26363. * @returns an array populated with the removed particles
  26364. */
  26365. removeParticles(start: number, end: number): SolidParticle[];
  26366. /**
  26367. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26368. * @param solidParticleArray an array populated with Solid Particles objects
  26369. * @returns the SPS
  26370. */
  26371. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26372. /**
  26373. * Creates a new particle and modifies the SPS mesh geometry :
  26374. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26375. * - calls _addParticle() to populate the particle array
  26376. * factorized code from addShape() and insertParticlesFromArray()
  26377. * @param idx particle index in the particles array
  26378. * @param i particle index in its shape
  26379. * @param modelShape particle ModelShape object
  26380. * @param shape shape vertex array
  26381. * @param meshInd shape indices array
  26382. * @param meshUV shape uv array
  26383. * @param meshCol shape color array
  26384. * @param meshNor shape normals array
  26385. * @param bbInfo shape bounding info
  26386. * @param storage target particle storage
  26387. * @options addShape() passed options
  26388. * @hidden
  26389. */
  26390. private _insertNewParticle;
  26391. /**
  26392. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26393. * This method calls `updateParticle()` for each particle of the SPS.
  26394. * For an animated SPS, it is usually called within the render loop.
  26395. * 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.
  26396. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26397. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26398. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26399. * @returns the SPS.
  26400. */
  26401. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26402. /**
  26403. * Disposes the SPS.
  26404. */
  26405. dispose(): void;
  26406. /**
  26407. * Returns a SolidParticle object from its identifier : particle.id
  26408. * @param id (integer) the particle Id
  26409. * @returns the searched particle or null if not found in the SPS.
  26410. */
  26411. getParticleById(id: number): Nullable<SolidParticle>;
  26412. /**
  26413. * Returns a new array populated with the particles having the passed shapeId.
  26414. * @param shapeId (integer) the shape identifier
  26415. * @returns a new solid particle array
  26416. */
  26417. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26418. /**
  26419. * Populates the passed array "ref" with the particles having the passed shapeId.
  26420. * @param shapeId the shape identifier
  26421. * @returns the SPS
  26422. * @param ref
  26423. */
  26424. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26425. /**
  26426. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26427. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26428. * @returns the SPS.
  26429. */
  26430. refreshVisibleSize(): SolidParticleSystem;
  26431. /**
  26432. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26433. * @param size the size (float) of the visibility box
  26434. * note : this doesn't lock the SPS mesh bounding box.
  26435. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26436. */
  26437. setVisibilityBox(size: number): void;
  26438. /**
  26439. * Gets whether the SPS as always visible or not
  26440. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26441. */
  26442. /**
  26443. * Sets the SPS as always visible or not
  26444. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26445. */
  26446. isAlwaysVisible: boolean;
  26447. /**
  26448. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26449. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26450. */
  26451. /**
  26452. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26453. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26454. */
  26455. isVisibilityBoxLocked: boolean;
  26456. /**
  26457. * Tells to `setParticles()` to compute the particle rotations or not.
  26458. * Default value : true. The SPS is faster when it's set to false.
  26459. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26460. */
  26461. /**
  26462. * Gets if `setParticles()` computes the particle rotations or not.
  26463. * Default value : true. The SPS is faster when it's set to false.
  26464. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26465. */
  26466. computeParticleRotation: boolean;
  26467. /**
  26468. * Tells to `setParticles()` to compute the particle colors or not.
  26469. * Default value : true. The SPS is faster when it's set to false.
  26470. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26471. */
  26472. /**
  26473. * Gets if `setParticles()` computes the particle colors or not.
  26474. * Default value : true. The SPS is faster when it's set to false.
  26475. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26476. */
  26477. computeParticleColor: boolean;
  26478. /**
  26479. * Gets if `setParticles()` computes the particle textures or not.
  26480. * Default value : true. The SPS is faster when it's set to false.
  26481. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26482. */
  26483. computeParticleTexture: boolean;
  26484. /**
  26485. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26486. * Default value : false. The SPS is faster when it's set to false.
  26487. * Note : the particle custom vertex positions aren't stored values.
  26488. */
  26489. /**
  26490. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26491. * Default value : false. The SPS is faster when it's set to false.
  26492. * Note : the particle custom vertex positions aren't stored values.
  26493. */
  26494. computeParticleVertex: boolean;
  26495. /**
  26496. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26497. */
  26498. /**
  26499. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26500. */
  26501. computeBoundingBox: boolean;
  26502. /**
  26503. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26504. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26505. * Default : `true`
  26506. */
  26507. /**
  26508. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26509. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26510. * Default : `true`
  26511. */
  26512. depthSortParticles: boolean;
  26513. /**
  26514. * Gets if the SPS is created as expandable at construction time.
  26515. * Default : `false`
  26516. */
  26517. readonly expandable: boolean;
  26518. /**
  26519. * This function does nothing. It may be overwritten to set all the particle first values.
  26520. * The SPS doesn't call this function, you may have to call it by your own.
  26521. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26522. */
  26523. initParticles(): void;
  26524. /**
  26525. * This function does nothing. It may be overwritten to recycle a particle.
  26526. * The SPS doesn't call this function, you may have to call it by your own.
  26527. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26528. * @param particle The particle to recycle
  26529. * @returns the recycled particle
  26530. */
  26531. recycleParticle(particle: SolidParticle): SolidParticle;
  26532. /**
  26533. * Updates a particle : this function should be overwritten by the user.
  26534. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26535. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26536. * @example : just set a particle position or velocity and recycle conditions
  26537. * @param particle The particle to update
  26538. * @returns the updated particle
  26539. */
  26540. updateParticle(particle: SolidParticle): SolidParticle;
  26541. /**
  26542. * Updates a vertex of a particle : it can be overwritten by the user.
  26543. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26544. * @param particle the current particle
  26545. * @param vertex the current index of the current particle
  26546. * @param pt the index of the current vertex in the particle shape
  26547. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26548. * @example : just set a vertex particle position
  26549. * @returns the updated vertex
  26550. */
  26551. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26552. /**
  26553. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26554. * This does nothing and may be overwritten by the user.
  26555. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26556. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26557. * @param update the boolean update value actually passed to setParticles()
  26558. */
  26559. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26560. /**
  26561. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26562. * This will be passed three parameters.
  26563. * This does nothing and may be overwritten by the user.
  26564. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26565. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26566. * @param update the boolean update value actually passed to setParticles()
  26567. */
  26568. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26569. }
  26570. }
  26571. declare module "babylonjs/Particles/solidParticle" {
  26572. import { Nullable } from "babylonjs/types";
  26573. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26574. import { Color4 } from "babylonjs/Maths/math.color";
  26575. import { Mesh } from "babylonjs/Meshes/mesh";
  26576. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26577. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26578. import { Plane } from "babylonjs/Maths/math.plane";
  26579. /**
  26580. * Represents one particle of a solid particle system.
  26581. */
  26582. export class SolidParticle {
  26583. /**
  26584. * particle global index
  26585. */
  26586. idx: number;
  26587. /**
  26588. * particle identifier
  26589. */
  26590. id: number;
  26591. /**
  26592. * The color of the particle
  26593. */
  26594. color: Nullable<Color4>;
  26595. /**
  26596. * The world space position of the particle.
  26597. */
  26598. position: Vector3;
  26599. /**
  26600. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26601. */
  26602. rotation: Vector3;
  26603. /**
  26604. * The world space rotation quaternion of the particle.
  26605. */
  26606. rotationQuaternion: Nullable<Quaternion>;
  26607. /**
  26608. * The scaling of the particle.
  26609. */
  26610. scaling: Vector3;
  26611. /**
  26612. * The uvs of the particle.
  26613. */
  26614. uvs: Vector4;
  26615. /**
  26616. * The current speed of the particle.
  26617. */
  26618. velocity: Vector3;
  26619. /**
  26620. * The pivot point in the particle local space.
  26621. */
  26622. pivot: Vector3;
  26623. /**
  26624. * Must the particle be translated from its pivot point in its local space ?
  26625. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26626. * Default : false
  26627. */
  26628. translateFromPivot: boolean;
  26629. /**
  26630. * Is the particle active or not ?
  26631. */
  26632. alive: boolean;
  26633. /**
  26634. * Is the particle visible or not ?
  26635. */
  26636. isVisible: boolean;
  26637. /**
  26638. * Index of this particle in the global "positions" array (Internal use)
  26639. * @hidden
  26640. */
  26641. _pos: number;
  26642. /**
  26643. * @hidden Index of this particle in the global "indices" array (Internal use)
  26644. */
  26645. _ind: number;
  26646. /**
  26647. * @hidden ModelShape of this particle (Internal use)
  26648. */
  26649. _model: ModelShape;
  26650. /**
  26651. * ModelShape id of this particle
  26652. */
  26653. shapeId: number;
  26654. /**
  26655. * Index of the particle in its shape id
  26656. */
  26657. idxInShape: number;
  26658. /**
  26659. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26660. */
  26661. _modelBoundingInfo: BoundingInfo;
  26662. /**
  26663. * @hidden Particle BoundingInfo object (Internal use)
  26664. */
  26665. _boundingInfo: BoundingInfo;
  26666. /**
  26667. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26668. */
  26669. _sps: SolidParticleSystem;
  26670. /**
  26671. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26672. */
  26673. _stillInvisible: boolean;
  26674. /**
  26675. * @hidden Last computed particle rotation matrix
  26676. */
  26677. _rotationMatrix: number[];
  26678. /**
  26679. * Parent particle Id, if any.
  26680. * Default null.
  26681. */
  26682. parentId: Nullable<number>;
  26683. /**
  26684. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26685. * The possible values are :
  26686. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26687. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26688. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26689. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26690. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26691. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26692. * */
  26693. cullingStrategy: number;
  26694. /**
  26695. * @hidden Internal global position in the SPS.
  26696. */
  26697. _globalPosition: Vector3;
  26698. /**
  26699. * Creates a Solid Particle object.
  26700. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26701. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  26702. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  26703. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26704. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26705. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26706. * @param shapeId (integer) is the model shape identifier in the SPS.
  26707. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26708. * @param sps defines the sps it is associated to
  26709. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26710. */
  26711. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26712. /**
  26713. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  26714. * @param target the particle target
  26715. * @returns the current particle
  26716. */
  26717. copyToRef(target: SolidParticle): SolidParticle;
  26718. /**
  26719. * Legacy support, changed scale to scaling
  26720. */
  26721. /**
  26722. * Legacy support, changed scale to scaling
  26723. */
  26724. scale: Vector3;
  26725. /**
  26726. * Legacy support, changed quaternion to rotationQuaternion
  26727. */
  26728. /**
  26729. * Legacy support, changed quaternion to rotationQuaternion
  26730. */
  26731. quaternion: Nullable<Quaternion>;
  26732. /**
  26733. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26734. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26735. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26736. * @returns true if it intersects
  26737. */
  26738. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26739. /**
  26740. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26741. * A particle is in the frustum if its bounding box intersects the frustum
  26742. * @param frustumPlanes defines the frustum to test
  26743. * @returns true if the particle is in the frustum planes
  26744. */
  26745. isInFrustum(frustumPlanes: Plane[]): boolean;
  26746. /**
  26747. * get the rotation matrix of the particle
  26748. * @hidden
  26749. */
  26750. getRotationMatrix(m: Matrix): void;
  26751. }
  26752. /**
  26753. * Represents the shape of the model used by one particle of a solid particle system.
  26754. * SPS internal tool, don't use it manually.
  26755. */
  26756. export class ModelShape {
  26757. /**
  26758. * The shape id
  26759. * @hidden
  26760. */
  26761. shapeID: number;
  26762. /**
  26763. * flat array of model positions (internal use)
  26764. * @hidden
  26765. */
  26766. _shape: Vector3[];
  26767. /**
  26768. * flat array of model UVs (internal use)
  26769. * @hidden
  26770. */
  26771. _shapeUV: number[];
  26772. /**
  26773. * color array of the model
  26774. * @hidden
  26775. */
  26776. _shapeColors: number[];
  26777. /**
  26778. * indices array of the model
  26779. * @hidden
  26780. */
  26781. _indices: number[];
  26782. /**
  26783. * normals array of the model
  26784. * @hidden
  26785. */
  26786. _normals: number[];
  26787. /**
  26788. * length of the shape in the model indices array (internal use)
  26789. * @hidden
  26790. */
  26791. _indicesLength: number;
  26792. /**
  26793. * Custom position function (internal use)
  26794. * @hidden
  26795. */
  26796. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26797. /**
  26798. * Custom vertex function (internal use)
  26799. * @hidden
  26800. */
  26801. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26802. /**
  26803. * 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.
  26804. * SPS internal tool, don't use it manually.
  26805. * @hidden
  26806. */
  26807. 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>);
  26808. }
  26809. /**
  26810. * Represents a Depth Sorted Particle in the solid particle system.
  26811. */
  26812. export class DepthSortedParticle {
  26813. /**
  26814. * Index of the particle in the "indices" array
  26815. */
  26816. ind: number;
  26817. /**
  26818. * Length of the particle shape in the "indices" array
  26819. */
  26820. indicesLength: number;
  26821. /**
  26822. * Squared distance from the particle to the camera
  26823. */
  26824. sqDistance: number;
  26825. }
  26826. }
  26827. declare module "babylonjs/Collisions/meshCollisionData" {
  26828. import { Collider } from "babylonjs/Collisions/collider";
  26829. import { Vector3 } from "babylonjs/Maths/math.vector";
  26830. import { Nullable } from "babylonjs/types";
  26831. import { Observer } from "babylonjs/Misc/observable";
  26832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26833. /**
  26834. * @hidden
  26835. */
  26836. export class _MeshCollisionData {
  26837. _checkCollisions: boolean;
  26838. _collisionMask: number;
  26839. _collisionGroup: number;
  26840. _collider: Nullable<Collider>;
  26841. _oldPositionForCollisions: Vector3;
  26842. _diffPositionForCollisions: Vector3;
  26843. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26844. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26845. }
  26846. }
  26847. declare module "babylonjs/Meshes/abstractMesh" {
  26848. import { Observable } from "babylonjs/Misc/observable";
  26849. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26850. import { Camera } from "babylonjs/Cameras/camera";
  26851. import { Scene, IDisposable } from "babylonjs/scene";
  26852. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26853. import { Node } from "babylonjs/node";
  26854. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26855. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26856. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26857. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26858. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26859. import { Material } from "babylonjs/Materials/material";
  26860. import { Light } from "babylonjs/Lights/light";
  26861. import { Skeleton } from "babylonjs/Bones/skeleton";
  26862. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26863. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26864. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26865. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26866. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26867. import { Plane } from "babylonjs/Maths/math.plane";
  26868. import { Ray } from "babylonjs/Culling/ray";
  26869. import { Collider } from "babylonjs/Collisions/collider";
  26870. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26871. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26872. /** @hidden */
  26873. class _FacetDataStorage {
  26874. facetPositions: Vector3[];
  26875. facetNormals: Vector3[];
  26876. facetPartitioning: number[][];
  26877. facetNb: number;
  26878. partitioningSubdivisions: number;
  26879. partitioningBBoxRatio: number;
  26880. facetDataEnabled: boolean;
  26881. facetParameters: any;
  26882. bbSize: Vector3;
  26883. subDiv: {
  26884. max: number;
  26885. X: number;
  26886. Y: number;
  26887. Z: number;
  26888. };
  26889. facetDepthSort: boolean;
  26890. facetDepthSortEnabled: boolean;
  26891. depthSortedIndices: IndicesArray;
  26892. depthSortedFacets: {
  26893. ind: number;
  26894. sqDistance: number;
  26895. }[];
  26896. facetDepthSortFunction: (f1: {
  26897. ind: number;
  26898. sqDistance: number;
  26899. }, f2: {
  26900. ind: number;
  26901. sqDistance: number;
  26902. }) => number;
  26903. facetDepthSortFrom: Vector3;
  26904. facetDepthSortOrigin: Vector3;
  26905. invertedMatrix: Matrix;
  26906. }
  26907. /**
  26908. * @hidden
  26909. **/
  26910. class _InternalAbstractMeshDataInfo {
  26911. _hasVertexAlpha: boolean;
  26912. _useVertexColors: boolean;
  26913. _numBoneInfluencers: number;
  26914. _applyFog: boolean;
  26915. _receiveShadows: boolean;
  26916. _facetData: _FacetDataStorage;
  26917. _visibility: number;
  26918. _skeleton: Nullable<Skeleton>;
  26919. _layerMask: number;
  26920. _computeBonesUsingShaders: boolean;
  26921. _isActive: boolean;
  26922. _onlyForInstances: boolean;
  26923. _isActiveIntermediate: boolean;
  26924. _onlyForInstancesIntermediate: boolean;
  26925. _actAsRegularMesh: boolean;
  26926. }
  26927. /**
  26928. * Class used to store all common mesh properties
  26929. */
  26930. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26931. /** No occlusion */
  26932. static OCCLUSION_TYPE_NONE: number;
  26933. /** Occlusion set to optimisitic */
  26934. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26935. /** Occlusion set to strict */
  26936. static OCCLUSION_TYPE_STRICT: number;
  26937. /** Use an accurante occlusion algorithm */
  26938. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26939. /** Use a conservative occlusion algorithm */
  26940. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26941. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26942. * Test order :
  26943. * Is the bounding sphere outside the frustum ?
  26944. * If not, are the bounding box vertices outside the frustum ?
  26945. * It not, then the cullable object is in the frustum.
  26946. */
  26947. static readonly CULLINGSTRATEGY_STANDARD: number;
  26948. /** Culling strategy : Bounding Sphere Only.
  26949. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26950. * It's also less accurate than the standard because some not visible objects can still be selected.
  26951. * Test : is the bounding sphere outside the frustum ?
  26952. * If not, then the cullable object is in the frustum.
  26953. */
  26954. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26955. /** Culling strategy : Optimistic Inclusion.
  26956. * This in an inclusion test first, then the standard exclusion test.
  26957. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26958. * 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.
  26959. * Anyway, it's as accurate as the standard strategy.
  26960. * Test :
  26961. * Is the cullable object bounding sphere center in the frustum ?
  26962. * If not, apply the default culling strategy.
  26963. */
  26964. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26965. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26966. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26967. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26968. * 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.
  26969. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26970. * Test :
  26971. * Is the cullable object bounding sphere center in the frustum ?
  26972. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26973. */
  26974. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26975. /**
  26976. * No billboard
  26977. */
  26978. static readonly BILLBOARDMODE_NONE: number;
  26979. /** Billboard on X axis */
  26980. static readonly BILLBOARDMODE_X: number;
  26981. /** Billboard on Y axis */
  26982. static readonly BILLBOARDMODE_Y: number;
  26983. /** Billboard on Z axis */
  26984. static readonly BILLBOARDMODE_Z: number;
  26985. /** Billboard on all axes */
  26986. static readonly BILLBOARDMODE_ALL: number;
  26987. /** Billboard on using position instead of orientation */
  26988. static readonly BILLBOARDMODE_USE_POSITION: number;
  26989. /** @hidden */
  26990. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26991. /**
  26992. * The culling strategy to use to check whether the mesh must be rendered or not.
  26993. * This value can be changed at any time and will be used on the next render mesh selection.
  26994. * The possible values are :
  26995. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26996. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26997. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26998. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26999. * Please read each static variable documentation to get details about the culling process.
  27000. * */
  27001. cullingStrategy: number;
  27002. /**
  27003. * Gets the number of facets in the mesh
  27004. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27005. */
  27006. readonly facetNb: number;
  27007. /**
  27008. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27009. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27010. */
  27011. partitioningSubdivisions: number;
  27012. /**
  27013. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27014. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27015. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27016. */
  27017. partitioningBBoxRatio: number;
  27018. /**
  27019. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27020. * Works only for updatable meshes.
  27021. * Doesn't work with multi-materials
  27022. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27023. */
  27024. mustDepthSortFacets: boolean;
  27025. /**
  27026. * The location (Vector3) where the facet depth sort must be computed from.
  27027. * By default, the active camera position.
  27028. * Used only when facet depth sort is enabled
  27029. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27030. */
  27031. facetDepthSortFrom: Vector3;
  27032. /**
  27033. * gets a boolean indicating if facetData is enabled
  27034. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27035. */
  27036. readonly isFacetDataEnabled: boolean;
  27037. /** @hidden */
  27038. _updateNonUniformScalingState(value: boolean): boolean;
  27039. /**
  27040. * An event triggered when this mesh collides with another one
  27041. */
  27042. onCollideObservable: Observable<AbstractMesh>;
  27043. /** Set a function to call when this mesh collides with another one */
  27044. onCollide: () => void;
  27045. /**
  27046. * An event triggered when the collision's position changes
  27047. */
  27048. onCollisionPositionChangeObservable: Observable<Vector3>;
  27049. /** Set a function to call when the collision's position changes */
  27050. onCollisionPositionChange: () => void;
  27051. /**
  27052. * An event triggered when material is changed
  27053. */
  27054. onMaterialChangedObservable: Observable<AbstractMesh>;
  27055. /**
  27056. * Gets or sets the orientation for POV movement & rotation
  27057. */
  27058. definedFacingForward: boolean;
  27059. /** @hidden */
  27060. _occlusionQuery: Nullable<WebGLQuery>;
  27061. /** @hidden */
  27062. _renderingGroup: Nullable<RenderingGroup>;
  27063. /**
  27064. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27065. */
  27066. /**
  27067. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27068. */
  27069. visibility: number;
  27070. /** Gets or sets the alpha index used to sort transparent meshes
  27071. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27072. */
  27073. alphaIndex: number;
  27074. /**
  27075. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27076. */
  27077. isVisible: boolean;
  27078. /**
  27079. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27080. */
  27081. isPickable: boolean;
  27082. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27083. showSubMeshesBoundingBox: boolean;
  27084. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27085. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27086. */
  27087. isBlocker: boolean;
  27088. /**
  27089. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27090. */
  27091. enablePointerMoveEvents: boolean;
  27092. /**
  27093. * Specifies the rendering group id for this mesh (0 by default)
  27094. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27095. */
  27096. renderingGroupId: number;
  27097. private _material;
  27098. /** Gets or sets current material */
  27099. material: Nullable<Material>;
  27100. /**
  27101. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27102. * @see http://doc.babylonjs.com/babylon101/shadows
  27103. */
  27104. receiveShadows: boolean;
  27105. /** Defines color to use when rendering outline */
  27106. outlineColor: Color3;
  27107. /** Define width to use when rendering outline */
  27108. outlineWidth: number;
  27109. /** Defines color to use when rendering overlay */
  27110. overlayColor: Color3;
  27111. /** Defines alpha to use when rendering overlay */
  27112. overlayAlpha: number;
  27113. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27114. hasVertexAlpha: boolean;
  27115. /** 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) */
  27116. useVertexColors: boolean;
  27117. /**
  27118. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27119. */
  27120. computeBonesUsingShaders: boolean;
  27121. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27122. numBoneInfluencers: number;
  27123. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27124. applyFog: boolean;
  27125. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27126. useOctreeForRenderingSelection: boolean;
  27127. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27128. useOctreeForPicking: boolean;
  27129. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27130. useOctreeForCollisions: boolean;
  27131. /**
  27132. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27133. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27134. */
  27135. layerMask: number;
  27136. /**
  27137. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27138. */
  27139. alwaysSelectAsActiveMesh: boolean;
  27140. /**
  27141. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27142. */
  27143. doNotSyncBoundingInfo: boolean;
  27144. /**
  27145. * Gets or sets the current action manager
  27146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27147. */
  27148. actionManager: Nullable<AbstractActionManager>;
  27149. private _meshCollisionData;
  27150. /**
  27151. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27152. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27153. */
  27154. ellipsoid: Vector3;
  27155. /**
  27156. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27157. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27158. */
  27159. ellipsoidOffset: Vector3;
  27160. /**
  27161. * Gets or sets a collision mask used to mask collisions (default is -1).
  27162. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27163. */
  27164. collisionMask: number;
  27165. /**
  27166. * Gets or sets the current collision group mask (-1 by default).
  27167. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27168. */
  27169. collisionGroup: number;
  27170. /**
  27171. * Defines edge width used when edgesRenderer is enabled
  27172. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27173. */
  27174. edgesWidth: number;
  27175. /**
  27176. * Defines edge color used when edgesRenderer is enabled
  27177. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27178. */
  27179. edgesColor: Color4;
  27180. /** @hidden */
  27181. _edgesRenderer: Nullable<IEdgesRenderer>;
  27182. /** @hidden */
  27183. _masterMesh: Nullable<AbstractMesh>;
  27184. /** @hidden */
  27185. _boundingInfo: Nullable<BoundingInfo>;
  27186. /** @hidden */
  27187. _renderId: number;
  27188. /**
  27189. * Gets or sets the list of subMeshes
  27190. * @see http://doc.babylonjs.com/how_to/multi_materials
  27191. */
  27192. subMeshes: SubMesh[];
  27193. /** @hidden */
  27194. _intersectionsInProgress: AbstractMesh[];
  27195. /** @hidden */
  27196. _unIndexed: boolean;
  27197. /** @hidden */
  27198. _lightSources: Light[];
  27199. /** Gets the list of lights affecting that mesh */
  27200. readonly lightSources: Light[];
  27201. /** @hidden */
  27202. readonly _positions: Nullable<Vector3[]>;
  27203. /** @hidden */
  27204. _waitingData: {
  27205. lods: Nullable<any>;
  27206. actions: Nullable<any>;
  27207. freezeWorldMatrix: Nullable<boolean>;
  27208. };
  27209. /** @hidden */
  27210. _bonesTransformMatrices: Nullable<Float32Array>;
  27211. /** @hidden */
  27212. _transformMatrixTexture: Nullable<RawTexture>;
  27213. /**
  27214. * Gets or sets a skeleton to apply skining transformations
  27215. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27216. */
  27217. skeleton: Nullable<Skeleton>;
  27218. /**
  27219. * An event triggered when the mesh is rebuilt.
  27220. */
  27221. onRebuildObservable: Observable<AbstractMesh>;
  27222. /**
  27223. * Creates a new AbstractMesh
  27224. * @param name defines the name of the mesh
  27225. * @param scene defines the hosting scene
  27226. */
  27227. constructor(name: string, scene?: Nullable<Scene>);
  27228. /**
  27229. * Returns the string "AbstractMesh"
  27230. * @returns "AbstractMesh"
  27231. */
  27232. getClassName(): string;
  27233. /**
  27234. * Gets a string representation of the current mesh
  27235. * @param fullDetails defines a boolean indicating if full details must be included
  27236. * @returns a string representation of the current mesh
  27237. */
  27238. toString(fullDetails?: boolean): string;
  27239. /**
  27240. * @hidden
  27241. */
  27242. protected _getEffectiveParent(): Nullable<Node>;
  27243. /** @hidden */
  27244. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27245. /** @hidden */
  27246. _rebuild(): void;
  27247. /** @hidden */
  27248. _resyncLightSources(): void;
  27249. /** @hidden */
  27250. _resyncLighSource(light: Light): void;
  27251. /** @hidden */
  27252. _unBindEffect(): void;
  27253. /** @hidden */
  27254. _removeLightSource(light: Light, dispose: boolean): void;
  27255. private _markSubMeshesAsDirty;
  27256. /** @hidden */
  27257. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27258. /** @hidden */
  27259. _markSubMeshesAsAttributesDirty(): void;
  27260. /** @hidden */
  27261. _markSubMeshesAsMiscDirty(): void;
  27262. /**
  27263. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27264. */
  27265. scaling: Vector3;
  27266. /**
  27267. * Returns true if the mesh is blocked. Implemented by child classes
  27268. */
  27269. readonly isBlocked: boolean;
  27270. /**
  27271. * Returns the mesh itself by default. Implemented by child classes
  27272. * @param camera defines the camera to use to pick the right LOD level
  27273. * @returns the currentAbstractMesh
  27274. */
  27275. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27276. /**
  27277. * Returns 0 by default. Implemented by child classes
  27278. * @returns an integer
  27279. */
  27280. getTotalVertices(): number;
  27281. /**
  27282. * Returns a positive integer : the total number of indices in this mesh geometry.
  27283. * @returns the numner of indices or zero if the mesh has no geometry.
  27284. */
  27285. getTotalIndices(): number;
  27286. /**
  27287. * Returns null by default. Implemented by child classes
  27288. * @returns null
  27289. */
  27290. getIndices(): Nullable<IndicesArray>;
  27291. /**
  27292. * Returns the array of the requested vertex data kind. Implemented by child classes
  27293. * @param kind defines the vertex data kind to use
  27294. * @returns null
  27295. */
  27296. getVerticesData(kind: string): Nullable<FloatArray>;
  27297. /**
  27298. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27299. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27300. * Note that a new underlying VertexBuffer object is created each call.
  27301. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27302. * @param kind defines vertex data kind:
  27303. * * VertexBuffer.PositionKind
  27304. * * VertexBuffer.UVKind
  27305. * * VertexBuffer.UV2Kind
  27306. * * VertexBuffer.UV3Kind
  27307. * * VertexBuffer.UV4Kind
  27308. * * VertexBuffer.UV5Kind
  27309. * * VertexBuffer.UV6Kind
  27310. * * VertexBuffer.ColorKind
  27311. * * VertexBuffer.MatricesIndicesKind
  27312. * * VertexBuffer.MatricesIndicesExtraKind
  27313. * * VertexBuffer.MatricesWeightsKind
  27314. * * VertexBuffer.MatricesWeightsExtraKind
  27315. * @param data defines the data source
  27316. * @param updatable defines if the data must be flagged as updatable (or static)
  27317. * @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
  27318. * @returns the current mesh
  27319. */
  27320. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27321. /**
  27322. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27323. * If the mesh has no geometry, it is simply returned as it is.
  27324. * @param kind defines vertex data kind:
  27325. * * VertexBuffer.PositionKind
  27326. * * VertexBuffer.UVKind
  27327. * * VertexBuffer.UV2Kind
  27328. * * VertexBuffer.UV3Kind
  27329. * * VertexBuffer.UV4Kind
  27330. * * VertexBuffer.UV5Kind
  27331. * * VertexBuffer.UV6Kind
  27332. * * VertexBuffer.ColorKind
  27333. * * VertexBuffer.MatricesIndicesKind
  27334. * * VertexBuffer.MatricesIndicesExtraKind
  27335. * * VertexBuffer.MatricesWeightsKind
  27336. * * VertexBuffer.MatricesWeightsExtraKind
  27337. * @param data defines the data source
  27338. * @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
  27339. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27340. * @returns the current mesh
  27341. */
  27342. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27343. /**
  27344. * Sets the mesh indices,
  27345. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27346. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27347. * @param totalVertices Defines the total number of vertices
  27348. * @returns the current mesh
  27349. */
  27350. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27351. /**
  27352. * Gets a boolean indicating if specific vertex data is present
  27353. * @param kind defines the vertex data kind to use
  27354. * @returns true is data kind is present
  27355. */
  27356. isVerticesDataPresent(kind: string): boolean;
  27357. /**
  27358. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27359. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27360. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27361. * @returns a BoundingInfo
  27362. */
  27363. getBoundingInfo(): BoundingInfo;
  27364. /**
  27365. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27366. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27367. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27368. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27369. * @returns the current mesh
  27370. */
  27371. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27372. /**
  27373. * Overwrite the current bounding info
  27374. * @param boundingInfo defines the new bounding info
  27375. * @returns the current mesh
  27376. */
  27377. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27378. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27379. readonly useBones: boolean;
  27380. /** @hidden */
  27381. _preActivate(): void;
  27382. /** @hidden */
  27383. _preActivateForIntermediateRendering(renderId: number): void;
  27384. /** @hidden */
  27385. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27386. /** @hidden */
  27387. _postActivate(): void;
  27388. /** @hidden */
  27389. _freeze(): void;
  27390. /** @hidden */
  27391. _unFreeze(): void;
  27392. /**
  27393. * Gets the current world matrix
  27394. * @returns a Matrix
  27395. */
  27396. getWorldMatrix(): Matrix;
  27397. /** @hidden */
  27398. _getWorldMatrixDeterminant(): number;
  27399. /**
  27400. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27401. */
  27402. readonly isAnInstance: boolean;
  27403. /**
  27404. * Gets a boolean indicating if this mesh has instances
  27405. */
  27406. readonly hasInstances: boolean;
  27407. /**
  27408. * Perform relative position change from the point of view of behind the front of the mesh.
  27409. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27410. * Supports definition of mesh facing forward or backward
  27411. * @param amountRight defines the distance on the right axis
  27412. * @param amountUp defines the distance on the up axis
  27413. * @param amountForward defines the distance on the forward axis
  27414. * @returns the current mesh
  27415. */
  27416. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27417. /**
  27418. * Calculate relative position change from the point of view of behind the front of the mesh.
  27419. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27420. * Supports definition of mesh facing forward or backward
  27421. * @param amountRight defines the distance on the right axis
  27422. * @param amountUp defines the distance on the up axis
  27423. * @param amountForward defines the distance on the forward axis
  27424. * @returns the new displacement vector
  27425. */
  27426. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27427. /**
  27428. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27429. * Supports definition of mesh facing forward or backward
  27430. * @param flipBack defines the flip
  27431. * @param twirlClockwise defines the twirl
  27432. * @param tiltRight defines the tilt
  27433. * @returns the current mesh
  27434. */
  27435. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27436. /**
  27437. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27438. * Supports definition of mesh facing forward or backward.
  27439. * @param flipBack defines the flip
  27440. * @param twirlClockwise defines the twirl
  27441. * @param tiltRight defines the tilt
  27442. * @returns the new rotation vector
  27443. */
  27444. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27445. /**
  27446. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27447. * This means the mesh underlying bounding box and sphere are recomputed.
  27448. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27449. * @returns the current mesh
  27450. */
  27451. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27452. /** @hidden */
  27453. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27454. /** @hidden */
  27455. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27456. /** @hidden */
  27457. _updateBoundingInfo(): AbstractMesh;
  27458. /** @hidden */
  27459. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27460. /** @hidden */
  27461. protected _afterComputeWorldMatrix(): void;
  27462. /** @hidden */
  27463. readonly _effectiveMesh: AbstractMesh;
  27464. /**
  27465. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27466. * A mesh is in the frustum if its bounding box intersects the frustum
  27467. * @param frustumPlanes defines the frustum to test
  27468. * @returns true if the mesh is in the frustum planes
  27469. */
  27470. isInFrustum(frustumPlanes: Plane[]): boolean;
  27471. /**
  27472. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27473. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27474. * @param frustumPlanes defines the frustum to test
  27475. * @returns true if the mesh is completely in the frustum planes
  27476. */
  27477. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27478. /**
  27479. * True if the mesh intersects another mesh or a SolidParticle object
  27480. * @param mesh defines a target mesh or SolidParticle to test
  27481. * @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)
  27482. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27483. * @returns true if there is an intersection
  27484. */
  27485. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27486. /**
  27487. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27488. * @param point defines the point to test
  27489. * @returns true if there is an intersection
  27490. */
  27491. intersectsPoint(point: Vector3): boolean;
  27492. /**
  27493. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27494. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27495. */
  27496. checkCollisions: boolean;
  27497. /**
  27498. * Gets Collider object used to compute collisions (not physics)
  27499. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27500. */
  27501. readonly collider: Nullable<Collider>;
  27502. /**
  27503. * Move the mesh using collision engine
  27504. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27505. * @param displacement defines the requested displacement vector
  27506. * @returns the current mesh
  27507. */
  27508. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27509. private _onCollisionPositionChange;
  27510. /** @hidden */
  27511. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27512. /** @hidden */
  27513. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27514. /** @hidden */
  27515. _checkCollision(collider: Collider): AbstractMesh;
  27516. /** @hidden */
  27517. _generatePointsArray(): boolean;
  27518. /**
  27519. * Checks if the passed Ray intersects with the mesh
  27520. * @param ray defines the ray to use
  27521. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27522. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27523. * @returns the picking info
  27524. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27525. */
  27526. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27527. /**
  27528. * Clones the current mesh
  27529. * @param name defines the mesh name
  27530. * @param newParent defines the new mesh parent
  27531. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27532. * @returns the new mesh
  27533. */
  27534. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27535. /**
  27536. * Disposes all the submeshes of the current meshnp
  27537. * @returns the current mesh
  27538. */
  27539. releaseSubMeshes(): AbstractMesh;
  27540. /**
  27541. * Releases resources associated with this abstract mesh.
  27542. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27543. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27544. */
  27545. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27546. /**
  27547. * Adds the passed mesh as a child to the current mesh
  27548. * @param mesh defines the child mesh
  27549. * @returns the current mesh
  27550. */
  27551. addChild(mesh: AbstractMesh): AbstractMesh;
  27552. /**
  27553. * Removes the passed mesh from the current mesh children list
  27554. * @param mesh defines the child mesh
  27555. * @returns the current mesh
  27556. */
  27557. removeChild(mesh: AbstractMesh): AbstractMesh;
  27558. /** @hidden */
  27559. private _initFacetData;
  27560. /**
  27561. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27562. * This method can be called within the render loop.
  27563. * 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
  27564. * @returns the current mesh
  27565. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27566. */
  27567. updateFacetData(): AbstractMesh;
  27568. /**
  27569. * Returns the facetLocalNormals array.
  27570. * The normals are expressed in the mesh local spac
  27571. * @returns an array of Vector3
  27572. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27573. */
  27574. getFacetLocalNormals(): Vector3[];
  27575. /**
  27576. * Returns the facetLocalPositions array.
  27577. * The facet positions are expressed in the mesh local space
  27578. * @returns an array of Vector3
  27579. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27580. */
  27581. getFacetLocalPositions(): Vector3[];
  27582. /**
  27583. * Returns the facetLocalPartioning array
  27584. * @returns an array of array of numbers
  27585. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27586. */
  27587. getFacetLocalPartitioning(): number[][];
  27588. /**
  27589. * Returns the i-th facet position in the world system.
  27590. * This method allocates a new Vector3 per call
  27591. * @param i defines the facet index
  27592. * @returns a new Vector3
  27593. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27594. */
  27595. getFacetPosition(i: number): Vector3;
  27596. /**
  27597. * Sets the reference Vector3 with the i-th facet position in the world system
  27598. * @param i defines the facet index
  27599. * @param ref defines the target vector
  27600. * @returns the current mesh
  27601. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27602. */
  27603. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27604. /**
  27605. * Returns the i-th facet normal in the world system.
  27606. * This method allocates a new Vector3 per call
  27607. * @param i defines the facet index
  27608. * @returns a new Vector3
  27609. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27610. */
  27611. getFacetNormal(i: number): Vector3;
  27612. /**
  27613. * Sets the reference Vector3 with the i-th facet normal in the world system
  27614. * @param i defines the facet index
  27615. * @param ref defines the target vector
  27616. * @returns the current mesh
  27617. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27618. */
  27619. getFacetNormalToRef(i: number, ref: Vector3): this;
  27620. /**
  27621. * 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)
  27622. * @param x defines x coordinate
  27623. * @param y defines y coordinate
  27624. * @param z defines z coordinate
  27625. * @returns the array of facet indexes
  27626. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27627. */
  27628. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27629. /**
  27630. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27631. * @param projected sets as the (x,y,z) world projection on the facet
  27632. * @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
  27633. * @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
  27634. * @param x defines x coordinate
  27635. * @param y defines y coordinate
  27636. * @param z defines z coordinate
  27637. * @returns the face index if found (or null instead)
  27638. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27639. */
  27640. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27641. /**
  27642. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27643. * @param projected sets as the (x,y,z) local projection on the facet
  27644. * @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
  27645. * @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
  27646. * @param x defines x coordinate
  27647. * @param y defines y coordinate
  27648. * @param z defines z coordinate
  27649. * @returns the face index if found (or null instead)
  27650. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27651. */
  27652. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27653. /**
  27654. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27655. * @returns the parameters
  27656. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27657. */
  27658. getFacetDataParameters(): any;
  27659. /**
  27660. * Disables the feature FacetData and frees the related memory
  27661. * @returns the current mesh
  27662. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27663. */
  27664. disableFacetData(): AbstractMesh;
  27665. /**
  27666. * Updates the AbstractMesh indices array
  27667. * @param indices defines the data source
  27668. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27669. * @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)
  27670. * @returns the current mesh
  27671. */
  27672. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27673. /**
  27674. * Creates new normals data for the mesh
  27675. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27676. * @returns the current mesh
  27677. */
  27678. createNormals(updatable: boolean): AbstractMesh;
  27679. /**
  27680. * Align the mesh with a normal
  27681. * @param normal defines the normal to use
  27682. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27683. * @returns the current mesh
  27684. */
  27685. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27686. /** @hidden */
  27687. _checkOcclusionQuery(): boolean;
  27688. /**
  27689. * Disables the mesh edge rendering mode
  27690. * @returns the currentAbstractMesh
  27691. */
  27692. disableEdgesRendering(): AbstractMesh;
  27693. /**
  27694. * Enables the edge rendering mode on the mesh.
  27695. * This mode makes the mesh edges visible
  27696. * @param epsilon defines the maximal distance between two angles to detect a face
  27697. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27698. * @returns the currentAbstractMesh
  27699. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27700. */
  27701. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27702. }
  27703. }
  27704. declare module "babylonjs/Actions/actionEvent" {
  27705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27706. import { Nullable } from "babylonjs/types";
  27707. import { Sprite } from "babylonjs/Sprites/sprite";
  27708. import { Scene } from "babylonjs/scene";
  27709. import { Vector2 } from "babylonjs/Maths/math.vector";
  27710. /**
  27711. * Interface used to define ActionEvent
  27712. */
  27713. export interface IActionEvent {
  27714. /** The mesh or sprite that triggered the action */
  27715. source: any;
  27716. /** The X mouse cursor position at the time of the event */
  27717. pointerX: number;
  27718. /** The Y mouse cursor position at the time of the event */
  27719. pointerY: number;
  27720. /** The mesh that is currently pointed at (can be null) */
  27721. meshUnderPointer: Nullable<AbstractMesh>;
  27722. /** the original (browser) event that triggered the ActionEvent */
  27723. sourceEvent?: any;
  27724. /** additional data for the event */
  27725. additionalData?: any;
  27726. }
  27727. /**
  27728. * ActionEvent is the event being sent when an action is triggered.
  27729. */
  27730. export class ActionEvent implements IActionEvent {
  27731. /** The mesh or sprite that triggered the action */
  27732. source: any;
  27733. /** The X mouse cursor position at the time of the event */
  27734. pointerX: number;
  27735. /** The Y mouse cursor position at the time of the event */
  27736. pointerY: number;
  27737. /** The mesh that is currently pointed at (can be null) */
  27738. meshUnderPointer: Nullable<AbstractMesh>;
  27739. /** the original (browser) event that triggered the ActionEvent */
  27740. sourceEvent?: any;
  27741. /** additional data for the event */
  27742. additionalData?: any;
  27743. /**
  27744. * Creates a new ActionEvent
  27745. * @param source The mesh or sprite that triggered the action
  27746. * @param pointerX The X mouse cursor position at the time of the event
  27747. * @param pointerY The Y mouse cursor position at the time of the event
  27748. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27749. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27750. * @param additionalData additional data for the event
  27751. */
  27752. constructor(
  27753. /** The mesh or sprite that triggered the action */
  27754. source: any,
  27755. /** The X mouse cursor position at the time of the event */
  27756. pointerX: number,
  27757. /** The Y mouse cursor position at the time of the event */
  27758. pointerY: number,
  27759. /** The mesh that is currently pointed at (can be null) */
  27760. meshUnderPointer: Nullable<AbstractMesh>,
  27761. /** the original (browser) event that triggered the ActionEvent */
  27762. sourceEvent?: any,
  27763. /** additional data for the event */
  27764. additionalData?: any);
  27765. /**
  27766. * Helper function to auto-create an ActionEvent from a source mesh.
  27767. * @param source The source mesh that triggered the event
  27768. * @param evt The original (browser) event
  27769. * @param additionalData additional data for the event
  27770. * @returns the new ActionEvent
  27771. */
  27772. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27773. /**
  27774. * Helper function to auto-create an ActionEvent from a source sprite
  27775. * @param source The source sprite that triggered the event
  27776. * @param scene Scene associated with the sprite
  27777. * @param evt The original (browser) event
  27778. * @param additionalData additional data for the event
  27779. * @returns the new ActionEvent
  27780. */
  27781. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27782. /**
  27783. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27784. * @param scene the scene where the event occurred
  27785. * @param evt The original (browser) event
  27786. * @returns the new ActionEvent
  27787. */
  27788. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27789. /**
  27790. * Helper function to auto-create an ActionEvent from a primitive
  27791. * @param prim defines the target primitive
  27792. * @param pointerPos defines the pointer position
  27793. * @param evt The original (browser) event
  27794. * @param additionalData additional data for the event
  27795. * @returns the new ActionEvent
  27796. */
  27797. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27798. }
  27799. }
  27800. declare module "babylonjs/Actions/abstractActionManager" {
  27801. import { IDisposable } from "babylonjs/scene";
  27802. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27803. import { IAction } from "babylonjs/Actions/action";
  27804. import { Nullable } from "babylonjs/types";
  27805. /**
  27806. * Abstract class used to decouple action Manager from scene and meshes.
  27807. * Do not instantiate.
  27808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27809. */
  27810. export abstract class AbstractActionManager implements IDisposable {
  27811. /** Gets the list of active triggers */
  27812. static Triggers: {
  27813. [key: string]: number;
  27814. };
  27815. /** Gets the cursor to use when hovering items */
  27816. hoverCursor: string;
  27817. /** Gets the list of actions */
  27818. actions: IAction[];
  27819. /**
  27820. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27821. */
  27822. isRecursive: boolean;
  27823. /**
  27824. * Releases all associated resources
  27825. */
  27826. abstract dispose(): void;
  27827. /**
  27828. * Does this action manager has pointer triggers
  27829. */
  27830. abstract readonly hasPointerTriggers: boolean;
  27831. /**
  27832. * Does this action manager has pick triggers
  27833. */
  27834. abstract readonly hasPickTriggers: boolean;
  27835. /**
  27836. * Process a specific trigger
  27837. * @param trigger defines the trigger to process
  27838. * @param evt defines the event details to be processed
  27839. */
  27840. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27841. /**
  27842. * Does this action manager handles actions of any of the given triggers
  27843. * @param triggers defines the triggers to be tested
  27844. * @return a boolean indicating whether one (or more) of the triggers is handled
  27845. */
  27846. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27847. /**
  27848. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27849. * speed.
  27850. * @param triggerA defines the trigger to be tested
  27851. * @param triggerB defines the trigger to be tested
  27852. * @return a boolean indicating whether one (or more) of the triggers is handled
  27853. */
  27854. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27855. /**
  27856. * Does this action manager handles actions of a given trigger
  27857. * @param trigger defines the trigger to be tested
  27858. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27859. * @return whether the trigger is handled
  27860. */
  27861. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27862. /**
  27863. * Serialize this manager to a JSON object
  27864. * @param name defines the property name to store this manager
  27865. * @returns a JSON representation of this manager
  27866. */
  27867. abstract serialize(name: string): any;
  27868. /**
  27869. * Registers an action to this action manager
  27870. * @param action defines the action to be registered
  27871. * @return the action amended (prepared) after registration
  27872. */
  27873. abstract registerAction(action: IAction): Nullable<IAction>;
  27874. /**
  27875. * Unregisters an action to this action manager
  27876. * @param action defines the action to be unregistered
  27877. * @return a boolean indicating whether the action has been unregistered
  27878. */
  27879. abstract unregisterAction(action: IAction): Boolean;
  27880. /**
  27881. * Does exist one action manager with at least one trigger
  27882. **/
  27883. static readonly HasTriggers: boolean;
  27884. /**
  27885. * Does exist one action manager with at least one pick trigger
  27886. **/
  27887. static readonly HasPickTriggers: boolean;
  27888. /**
  27889. * Does exist one action manager that handles actions of a given trigger
  27890. * @param trigger defines the trigger to be tested
  27891. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27892. **/
  27893. static HasSpecificTrigger(trigger: number): boolean;
  27894. }
  27895. }
  27896. declare module "babylonjs/node" {
  27897. import { Scene } from "babylonjs/scene";
  27898. import { Nullable } from "babylonjs/types";
  27899. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27900. import { Engine } from "babylonjs/Engines/engine";
  27901. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27902. import { Observable } from "babylonjs/Misc/observable";
  27903. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27904. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27905. import { Animatable } from "babylonjs/Animations/animatable";
  27906. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27907. import { Animation } from "babylonjs/Animations/animation";
  27908. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27909. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27910. /**
  27911. * Defines how a node can be built from a string name.
  27912. */
  27913. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27914. /**
  27915. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27916. */
  27917. export class Node implements IBehaviorAware<Node> {
  27918. /** @hidden */
  27919. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27920. private static _NodeConstructors;
  27921. /**
  27922. * Add a new node constructor
  27923. * @param type defines the type name of the node to construct
  27924. * @param constructorFunc defines the constructor function
  27925. */
  27926. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27927. /**
  27928. * Returns a node constructor based on type name
  27929. * @param type defines the type name
  27930. * @param name defines the new node name
  27931. * @param scene defines the hosting scene
  27932. * @param options defines optional options to transmit to constructors
  27933. * @returns the new constructor or null
  27934. */
  27935. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27936. /**
  27937. * Gets or sets the name of the node
  27938. */
  27939. name: string;
  27940. /**
  27941. * Gets or sets the id of the node
  27942. */
  27943. id: string;
  27944. /**
  27945. * Gets or sets the unique id of the node
  27946. */
  27947. uniqueId: number;
  27948. /**
  27949. * Gets or sets a string used to store user defined state for the node
  27950. */
  27951. state: string;
  27952. /**
  27953. * Gets or sets an object used to store user defined information for the node
  27954. */
  27955. metadata: any;
  27956. /**
  27957. * For internal use only. Please do not use.
  27958. */
  27959. reservedDataStore: any;
  27960. /**
  27961. * List of inspectable custom properties (used by the Inspector)
  27962. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27963. */
  27964. inspectableCustomProperties: IInspectable[];
  27965. private _doNotSerialize;
  27966. /**
  27967. * Gets or sets a boolean used to define if the node must be serialized
  27968. */
  27969. doNotSerialize: boolean;
  27970. /** @hidden */
  27971. _isDisposed: boolean;
  27972. /**
  27973. * Gets a list of Animations associated with the node
  27974. */
  27975. animations: import("babylonjs/Animations/animation").Animation[];
  27976. protected _ranges: {
  27977. [name: string]: Nullable<AnimationRange>;
  27978. };
  27979. /**
  27980. * Callback raised when the node is ready to be used
  27981. */
  27982. onReady: Nullable<(node: Node) => void>;
  27983. private _isEnabled;
  27984. private _isParentEnabled;
  27985. private _isReady;
  27986. /** @hidden */
  27987. _currentRenderId: number;
  27988. private _parentUpdateId;
  27989. /** @hidden */
  27990. _childUpdateId: number;
  27991. /** @hidden */
  27992. _waitingParentId: Nullable<string>;
  27993. /** @hidden */
  27994. _scene: Scene;
  27995. /** @hidden */
  27996. _cache: any;
  27997. private _parentNode;
  27998. private _children;
  27999. /** @hidden */
  28000. _worldMatrix: Matrix;
  28001. /** @hidden */
  28002. _worldMatrixDeterminant: number;
  28003. /** @hidden */
  28004. _worldMatrixDeterminantIsDirty: boolean;
  28005. /** @hidden */
  28006. private _sceneRootNodesIndex;
  28007. /**
  28008. * Gets a boolean indicating if the node has been disposed
  28009. * @returns true if the node was disposed
  28010. */
  28011. isDisposed(): boolean;
  28012. /**
  28013. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28014. * @see https://doc.babylonjs.com/how_to/parenting
  28015. */
  28016. parent: Nullable<Node>;
  28017. /** @hidden */
  28018. _addToSceneRootNodes(): void;
  28019. /** @hidden */
  28020. _removeFromSceneRootNodes(): void;
  28021. private _animationPropertiesOverride;
  28022. /**
  28023. * Gets or sets the animation properties override
  28024. */
  28025. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  28026. /**
  28027. * Gets a string idenfifying the name of the class
  28028. * @returns "Node" string
  28029. */
  28030. getClassName(): string;
  28031. /** @hidden */
  28032. readonly _isNode: boolean;
  28033. /**
  28034. * An event triggered when the mesh is disposed
  28035. */
  28036. onDisposeObservable: Observable<Node>;
  28037. private _onDisposeObserver;
  28038. /**
  28039. * Sets a callback that will be raised when the node will be disposed
  28040. */
  28041. onDispose: () => void;
  28042. /**
  28043. * Creates a new Node
  28044. * @param name the name and id to be given to this node
  28045. * @param scene the scene this node will be added to
  28046. */
  28047. constructor(name: string, scene?: Nullable<Scene>);
  28048. /**
  28049. * Gets the scene of the node
  28050. * @returns a scene
  28051. */
  28052. getScene(): Scene;
  28053. /**
  28054. * Gets the engine of the node
  28055. * @returns a Engine
  28056. */
  28057. getEngine(): Engine;
  28058. private _behaviors;
  28059. /**
  28060. * Attach a behavior to the node
  28061. * @see http://doc.babylonjs.com/features/behaviour
  28062. * @param behavior defines the behavior to attach
  28063. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28064. * @returns the current Node
  28065. */
  28066. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28067. /**
  28068. * Remove an attached behavior
  28069. * @see http://doc.babylonjs.com/features/behaviour
  28070. * @param behavior defines the behavior to attach
  28071. * @returns the current Node
  28072. */
  28073. removeBehavior(behavior: Behavior<Node>): Node;
  28074. /**
  28075. * Gets the list of attached behaviors
  28076. * @see http://doc.babylonjs.com/features/behaviour
  28077. */
  28078. readonly behaviors: Behavior<Node>[];
  28079. /**
  28080. * Gets an attached behavior by name
  28081. * @param name defines the name of the behavior to look for
  28082. * @see http://doc.babylonjs.com/features/behaviour
  28083. * @returns null if behavior was not found else the requested behavior
  28084. */
  28085. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28086. /**
  28087. * Returns the latest update of the World matrix
  28088. * @returns a Matrix
  28089. */
  28090. getWorldMatrix(): Matrix;
  28091. /** @hidden */
  28092. _getWorldMatrixDeterminant(): number;
  28093. /**
  28094. * Returns directly the latest state of the mesh World matrix.
  28095. * A Matrix is returned.
  28096. */
  28097. readonly worldMatrixFromCache: Matrix;
  28098. /** @hidden */
  28099. _initCache(): void;
  28100. /** @hidden */
  28101. updateCache(force?: boolean): void;
  28102. /** @hidden */
  28103. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28104. /** @hidden */
  28105. _updateCache(ignoreParentClass?: boolean): void;
  28106. /** @hidden */
  28107. _isSynchronized(): boolean;
  28108. /** @hidden */
  28109. _markSyncedWithParent(): void;
  28110. /** @hidden */
  28111. isSynchronizedWithParent(): boolean;
  28112. /** @hidden */
  28113. isSynchronized(): boolean;
  28114. /**
  28115. * Is this node ready to be used/rendered
  28116. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28117. * @return true if the node is ready
  28118. */
  28119. isReady(completeCheck?: boolean): boolean;
  28120. /**
  28121. * Is this node enabled?
  28122. * 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
  28123. * @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
  28124. * @return whether this node (and its parent) is enabled
  28125. */
  28126. isEnabled(checkAncestors?: boolean): boolean;
  28127. /** @hidden */
  28128. protected _syncParentEnabledState(): void;
  28129. /**
  28130. * Set the enabled state of this node
  28131. * @param value defines the new enabled state
  28132. */
  28133. setEnabled(value: boolean): void;
  28134. /**
  28135. * Is this node a descendant of the given node?
  28136. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28137. * @param ancestor defines the parent node to inspect
  28138. * @returns a boolean indicating if this node is a descendant of the given node
  28139. */
  28140. isDescendantOf(ancestor: Node): boolean;
  28141. /** @hidden */
  28142. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28143. /**
  28144. * Will return all nodes that have this node as ascendant
  28145. * @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
  28146. * @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
  28147. * @return all children nodes of all types
  28148. */
  28149. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28150. /**
  28151. * Get all child-meshes of this node
  28152. * @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)
  28153. * @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
  28154. * @returns an array of AbstractMesh
  28155. */
  28156. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28157. /**
  28158. * Get all direct children of this node
  28159. * @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
  28160. * @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)
  28161. * @returns an array of Node
  28162. */
  28163. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28164. /** @hidden */
  28165. _setReady(state: boolean): void;
  28166. /**
  28167. * Get an animation by name
  28168. * @param name defines the name of the animation to look for
  28169. * @returns null if not found else the requested animation
  28170. */
  28171. getAnimationByName(name: string): Nullable<Animation>;
  28172. /**
  28173. * Creates an animation range for this node
  28174. * @param name defines the name of the range
  28175. * @param from defines the starting key
  28176. * @param to defines the end key
  28177. */
  28178. createAnimationRange(name: string, from: number, to: number): void;
  28179. /**
  28180. * Delete a specific animation range
  28181. * @param name defines the name of the range to delete
  28182. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28183. */
  28184. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28185. /**
  28186. * Get an animation range by name
  28187. * @param name defines the name of the animation range to look for
  28188. * @returns null if not found else the requested animation range
  28189. */
  28190. getAnimationRange(name: string): Nullable<AnimationRange>;
  28191. /**
  28192. * Gets the list of all animation ranges defined on this node
  28193. * @returns an array
  28194. */
  28195. getAnimationRanges(): Nullable<AnimationRange>[];
  28196. /**
  28197. * Will start the animation sequence
  28198. * @param name defines the range frames for animation sequence
  28199. * @param loop defines if the animation should loop (false by default)
  28200. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28201. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28202. * @returns the object created for this animation. If range does not exist, it will return null
  28203. */
  28204. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28205. /**
  28206. * Serialize animation ranges into a JSON compatible object
  28207. * @returns serialization object
  28208. */
  28209. serializeAnimationRanges(): any;
  28210. /**
  28211. * Computes the world matrix of the node
  28212. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28213. * @returns the world matrix
  28214. */
  28215. computeWorldMatrix(force?: boolean): Matrix;
  28216. /**
  28217. * Releases resources associated with this node.
  28218. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28219. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28220. */
  28221. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28222. /**
  28223. * Parse animation range data from a serialization object and store them into a given node
  28224. * @param node defines where to store the animation ranges
  28225. * @param parsedNode defines the serialization object to read data from
  28226. * @param scene defines the hosting scene
  28227. */
  28228. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28229. /**
  28230. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28231. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28232. * @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
  28233. * @returns the new bounding vectors
  28234. */
  28235. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28236. min: Vector3;
  28237. max: Vector3;
  28238. };
  28239. }
  28240. }
  28241. declare module "babylonjs/Animations/animation" {
  28242. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  28243. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  28244. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28245. import { Nullable } from "babylonjs/types";
  28246. import { Scene } from "babylonjs/scene";
  28247. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  28248. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28249. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  28250. import { Node } from "babylonjs/node";
  28251. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28252. import { Size } from "babylonjs/Maths/math.size";
  28253. import { Animatable } from "babylonjs/Animations/animatable";
  28254. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  28255. /**
  28256. * @hidden
  28257. */
  28258. export class _IAnimationState {
  28259. key: number;
  28260. repeatCount: number;
  28261. workValue?: any;
  28262. loopMode?: number;
  28263. offsetValue?: any;
  28264. highLimitValue?: any;
  28265. }
  28266. /**
  28267. * Class used to store any kind of animation
  28268. */
  28269. export class Animation {
  28270. /**Name of the animation */
  28271. name: string;
  28272. /**Property to animate */
  28273. targetProperty: string;
  28274. /**The frames per second of the animation */
  28275. framePerSecond: number;
  28276. /**The data type of the animation */
  28277. dataType: number;
  28278. /**The loop mode of the animation */
  28279. loopMode?: number | undefined;
  28280. /**Specifies if blending should be enabled */
  28281. enableBlending?: boolean | undefined;
  28282. /**
  28283. * Use matrix interpolation instead of using direct key value when animating matrices
  28284. */
  28285. static AllowMatricesInterpolation: boolean;
  28286. /**
  28287. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28288. */
  28289. static AllowMatrixDecomposeForInterpolation: boolean;
  28290. /**
  28291. * Stores the key frames of the animation
  28292. */
  28293. private _keys;
  28294. /**
  28295. * Stores the easing function of the animation
  28296. */
  28297. private _easingFunction;
  28298. /**
  28299. * @hidden Internal use only
  28300. */
  28301. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28302. /**
  28303. * The set of event that will be linked to this animation
  28304. */
  28305. private _events;
  28306. /**
  28307. * Stores an array of target property paths
  28308. */
  28309. targetPropertyPath: string[];
  28310. /**
  28311. * Stores the blending speed of the animation
  28312. */
  28313. blendingSpeed: number;
  28314. /**
  28315. * Stores the animation ranges for the animation
  28316. */
  28317. private _ranges;
  28318. /**
  28319. * @hidden Internal use
  28320. */
  28321. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28322. /**
  28323. * Sets up an animation
  28324. * @param property The property to animate
  28325. * @param animationType The animation type to apply
  28326. * @param framePerSecond The frames per second of the animation
  28327. * @param easingFunction The easing function used in the animation
  28328. * @returns The created animation
  28329. */
  28330. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28331. /**
  28332. * Create and start an animation on a node
  28333. * @param name defines the name of the global animation that will be run on all nodes
  28334. * @param node defines the root node where the animation will take place
  28335. * @param targetProperty defines property to animate
  28336. * @param framePerSecond defines the number of frame per second yo use
  28337. * @param totalFrame defines the number of frames in total
  28338. * @param from defines the initial value
  28339. * @param to defines the final value
  28340. * @param loopMode defines which loop mode you want to use (off by default)
  28341. * @param easingFunction defines the easing function to use (linear by default)
  28342. * @param onAnimationEnd defines the callback to call when animation end
  28343. * @returns the animatable created for this animation
  28344. */
  28345. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28346. /**
  28347. * Create and start an animation on a node and its descendants
  28348. * @param name defines the name of the global animation that will be run on all nodes
  28349. * @param node defines the root node where the animation will take place
  28350. * @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
  28351. * @param targetProperty defines property to animate
  28352. * @param framePerSecond defines the number of frame per second to use
  28353. * @param totalFrame defines the number of frames in total
  28354. * @param from defines the initial value
  28355. * @param to defines the final value
  28356. * @param loopMode defines which loop mode you want to use (off by default)
  28357. * @param easingFunction defines the easing function to use (linear by default)
  28358. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28359. * @returns the list of animatables created for all nodes
  28360. * @example https://www.babylonjs-playground.com/#MH0VLI
  28361. */
  28362. 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[]>;
  28363. /**
  28364. * Creates a new animation, merges it with the existing animations and starts it
  28365. * @param name Name of the animation
  28366. * @param node Node which contains the scene that begins the animations
  28367. * @param targetProperty Specifies which property to animate
  28368. * @param framePerSecond The frames per second of the animation
  28369. * @param totalFrame The total number of frames
  28370. * @param from The frame at the beginning of the animation
  28371. * @param to The frame at the end of the animation
  28372. * @param loopMode Specifies the loop mode of the animation
  28373. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28374. * @param onAnimationEnd Callback to run once the animation is complete
  28375. * @returns Nullable animation
  28376. */
  28377. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28378. /**
  28379. * Transition property of an host to the target Value
  28380. * @param property The property to transition
  28381. * @param targetValue The target Value of the property
  28382. * @param host The object where the property to animate belongs
  28383. * @param scene Scene used to run the animation
  28384. * @param frameRate Framerate (in frame/s) to use
  28385. * @param transition The transition type we want to use
  28386. * @param duration The duration of the animation, in milliseconds
  28387. * @param onAnimationEnd Callback trigger at the end of the animation
  28388. * @returns Nullable animation
  28389. */
  28390. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28391. /**
  28392. * Return the array of runtime animations currently using this animation
  28393. */
  28394. readonly runtimeAnimations: RuntimeAnimation[];
  28395. /**
  28396. * Specifies if any of the runtime animations are currently running
  28397. */
  28398. readonly hasRunningRuntimeAnimations: boolean;
  28399. /**
  28400. * Initializes the animation
  28401. * @param name Name of the animation
  28402. * @param targetProperty Property to animate
  28403. * @param framePerSecond The frames per second of the animation
  28404. * @param dataType The data type of the animation
  28405. * @param loopMode The loop mode of the animation
  28406. * @param enableBlending Specifies if blending should be enabled
  28407. */
  28408. constructor(
  28409. /**Name of the animation */
  28410. name: string,
  28411. /**Property to animate */
  28412. targetProperty: string,
  28413. /**The frames per second of the animation */
  28414. framePerSecond: number,
  28415. /**The data type of the animation */
  28416. dataType: number,
  28417. /**The loop mode of the animation */
  28418. loopMode?: number | undefined,
  28419. /**Specifies if blending should be enabled */
  28420. enableBlending?: boolean | undefined);
  28421. /**
  28422. * Converts the animation to a string
  28423. * @param fullDetails support for multiple levels of logging within scene loading
  28424. * @returns String form of the animation
  28425. */
  28426. toString(fullDetails?: boolean): string;
  28427. /**
  28428. * Add an event to this animation
  28429. * @param event Event to add
  28430. */
  28431. addEvent(event: AnimationEvent): void;
  28432. /**
  28433. * Remove all events found at the given frame
  28434. * @param frame The frame to remove events from
  28435. */
  28436. removeEvents(frame: number): void;
  28437. /**
  28438. * Retrieves all the events from the animation
  28439. * @returns Events from the animation
  28440. */
  28441. getEvents(): AnimationEvent[];
  28442. /**
  28443. * Creates an animation range
  28444. * @param name Name of the animation range
  28445. * @param from Starting frame of the animation range
  28446. * @param to Ending frame of the animation
  28447. */
  28448. createRange(name: string, from: number, to: number): void;
  28449. /**
  28450. * Deletes an animation range by name
  28451. * @param name Name of the animation range to delete
  28452. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28453. */
  28454. deleteRange(name: string, deleteFrames?: boolean): void;
  28455. /**
  28456. * Gets the animation range by name, or null if not defined
  28457. * @param name Name of the animation range
  28458. * @returns Nullable animation range
  28459. */
  28460. getRange(name: string): Nullable<AnimationRange>;
  28461. /**
  28462. * Gets the key frames from the animation
  28463. * @returns The key frames of the animation
  28464. */
  28465. getKeys(): Array<IAnimationKey>;
  28466. /**
  28467. * Gets the highest frame rate of the animation
  28468. * @returns Highest frame rate of the animation
  28469. */
  28470. getHighestFrame(): number;
  28471. /**
  28472. * Gets the easing function of the animation
  28473. * @returns Easing function of the animation
  28474. */
  28475. getEasingFunction(): IEasingFunction;
  28476. /**
  28477. * Sets the easing function of the animation
  28478. * @param easingFunction A custom mathematical formula for animation
  28479. */
  28480. setEasingFunction(easingFunction: EasingFunction): void;
  28481. /**
  28482. * Interpolates a scalar linearly
  28483. * @param startValue Start value of the animation curve
  28484. * @param endValue End value of the animation curve
  28485. * @param gradient Scalar amount to interpolate
  28486. * @returns Interpolated scalar value
  28487. */
  28488. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28489. /**
  28490. * Interpolates a scalar cubically
  28491. * @param startValue Start value of the animation curve
  28492. * @param outTangent End tangent of the animation
  28493. * @param endValue End value of the animation curve
  28494. * @param inTangent Start tangent of the animation curve
  28495. * @param gradient Scalar amount to interpolate
  28496. * @returns Interpolated scalar value
  28497. */
  28498. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28499. /**
  28500. * Interpolates a quaternion using a spherical linear interpolation
  28501. * @param startValue Start value of the animation curve
  28502. * @param endValue End value of the animation curve
  28503. * @param gradient Scalar amount to interpolate
  28504. * @returns Interpolated quaternion value
  28505. */
  28506. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28507. /**
  28508. * Interpolates a quaternion cubically
  28509. * @param startValue Start value of the animation curve
  28510. * @param outTangent End tangent of the animation curve
  28511. * @param endValue End value of the animation curve
  28512. * @param inTangent Start tangent of the animation curve
  28513. * @param gradient Scalar amount to interpolate
  28514. * @returns Interpolated quaternion value
  28515. */
  28516. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28517. /**
  28518. * Interpolates a Vector3 linearl
  28519. * @param startValue Start value of the animation curve
  28520. * @param endValue End value of the animation curve
  28521. * @param gradient Scalar amount to interpolate
  28522. * @returns Interpolated scalar value
  28523. */
  28524. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28525. /**
  28526. * Interpolates a Vector3 cubically
  28527. * @param startValue Start value of the animation curve
  28528. * @param outTangent End tangent of the animation
  28529. * @param endValue End value of the animation curve
  28530. * @param inTangent Start tangent of the animation curve
  28531. * @param gradient Scalar amount to interpolate
  28532. * @returns InterpolatedVector3 value
  28533. */
  28534. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28535. /**
  28536. * Interpolates a Vector2 linearly
  28537. * @param startValue Start value of the animation curve
  28538. * @param endValue End value of the animation curve
  28539. * @param gradient Scalar amount to interpolate
  28540. * @returns Interpolated Vector2 value
  28541. */
  28542. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28543. /**
  28544. * Interpolates a Vector2 cubically
  28545. * @param startValue Start value of the animation curve
  28546. * @param outTangent End tangent of the animation
  28547. * @param endValue End value of the animation curve
  28548. * @param inTangent Start tangent of the animation curve
  28549. * @param gradient Scalar amount to interpolate
  28550. * @returns Interpolated Vector2 value
  28551. */
  28552. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28553. /**
  28554. * Interpolates a size linearly
  28555. * @param startValue Start value of the animation curve
  28556. * @param endValue End value of the animation curve
  28557. * @param gradient Scalar amount to interpolate
  28558. * @returns Interpolated Size value
  28559. */
  28560. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28561. /**
  28562. * Interpolates a Color3 linearly
  28563. * @param startValue Start value of the animation curve
  28564. * @param endValue End value of the animation curve
  28565. * @param gradient Scalar amount to interpolate
  28566. * @returns Interpolated Color3 value
  28567. */
  28568. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28569. /**
  28570. * Interpolates a Color4 linearly
  28571. * @param startValue Start value of the animation curve
  28572. * @param endValue End value of the animation curve
  28573. * @param gradient Scalar amount to interpolate
  28574. * @returns Interpolated Color3 value
  28575. */
  28576. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28577. /**
  28578. * @hidden Internal use only
  28579. */
  28580. _getKeyValue(value: any): any;
  28581. /**
  28582. * @hidden Internal use only
  28583. */
  28584. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28585. /**
  28586. * Defines the function to use to interpolate matrices
  28587. * @param startValue defines the start matrix
  28588. * @param endValue defines the end matrix
  28589. * @param gradient defines the gradient between both matrices
  28590. * @param result defines an optional target matrix where to store the interpolation
  28591. * @returns the interpolated matrix
  28592. */
  28593. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28594. /**
  28595. * Makes a copy of the animation
  28596. * @returns Cloned animation
  28597. */
  28598. clone(): Animation;
  28599. /**
  28600. * Sets the key frames of the animation
  28601. * @param values The animation key frames to set
  28602. */
  28603. setKeys(values: Array<IAnimationKey>): void;
  28604. /**
  28605. * Serializes the animation to an object
  28606. * @returns Serialized object
  28607. */
  28608. serialize(): any;
  28609. /**
  28610. * Float animation type
  28611. */
  28612. static readonly ANIMATIONTYPE_FLOAT: number;
  28613. /**
  28614. * Vector3 animation type
  28615. */
  28616. static readonly ANIMATIONTYPE_VECTOR3: number;
  28617. /**
  28618. * Quaternion animation type
  28619. */
  28620. static readonly ANIMATIONTYPE_QUATERNION: number;
  28621. /**
  28622. * Matrix animation type
  28623. */
  28624. static readonly ANIMATIONTYPE_MATRIX: number;
  28625. /**
  28626. * Color3 animation type
  28627. */
  28628. static readonly ANIMATIONTYPE_COLOR3: number;
  28629. /**
  28630. * Color3 animation type
  28631. */
  28632. static readonly ANIMATIONTYPE_COLOR4: number;
  28633. /**
  28634. * Vector2 animation type
  28635. */
  28636. static readonly ANIMATIONTYPE_VECTOR2: number;
  28637. /**
  28638. * Size animation type
  28639. */
  28640. static readonly ANIMATIONTYPE_SIZE: number;
  28641. /**
  28642. * Relative Loop Mode
  28643. */
  28644. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28645. /**
  28646. * Cycle Loop Mode
  28647. */
  28648. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28649. /**
  28650. * Constant Loop Mode
  28651. */
  28652. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28653. /** @hidden */
  28654. static _UniversalLerp(left: any, right: any, amount: number): any;
  28655. /**
  28656. * Parses an animation object and creates an animation
  28657. * @param parsedAnimation Parsed animation object
  28658. * @returns Animation object
  28659. */
  28660. static Parse(parsedAnimation: any): Animation;
  28661. /**
  28662. * Appends the serialized animations from the source animations
  28663. * @param source Source containing the animations
  28664. * @param destination Target to store the animations
  28665. */
  28666. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28667. }
  28668. }
  28669. declare module "babylonjs/Animations/animatable.interface" {
  28670. import { Nullable } from "babylonjs/types";
  28671. import { Animation } from "babylonjs/Animations/animation";
  28672. /**
  28673. * Interface containing an array of animations
  28674. */
  28675. export interface IAnimatable {
  28676. /**
  28677. * Array of animations
  28678. */
  28679. animations: Nullable<Array<Animation>>;
  28680. }
  28681. }
  28682. declare module "babylonjs/Materials/fresnelParameters" {
  28683. import { Color3 } from "babylonjs/Maths/math.color";
  28684. /**
  28685. * This represents all the required information to add a fresnel effect on a material:
  28686. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28687. */
  28688. export class FresnelParameters {
  28689. private _isEnabled;
  28690. /**
  28691. * Define if the fresnel effect is enable or not.
  28692. */
  28693. isEnabled: boolean;
  28694. /**
  28695. * Define the color used on edges (grazing angle)
  28696. */
  28697. leftColor: Color3;
  28698. /**
  28699. * Define the color used on center
  28700. */
  28701. rightColor: Color3;
  28702. /**
  28703. * Define bias applied to computed fresnel term
  28704. */
  28705. bias: number;
  28706. /**
  28707. * Defined the power exponent applied to fresnel term
  28708. */
  28709. power: number;
  28710. /**
  28711. * Clones the current fresnel and its valuues
  28712. * @returns a clone fresnel configuration
  28713. */
  28714. clone(): FresnelParameters;
  28715. /**
  28716. * Serializes the current fresnel parameters to a JSON representation.
  28717. * @return the JSON serialization
  28718. */
  28719. serialize(): any;
  28720. /**
  28721. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28722. * @param parsedFresnelParameters Define the JSON representation
  28723. * @returns the parsed parameters
  28724. */
  28725. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28726. }
  28727. }
  28728. declare module "babylonjs/Misc/decorators" {
  28729. import { Nullable } from "babylonjs/types";
  28730. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28731. import { Scene } from "babylonjs/scene";
  28732. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28733. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28734. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28735. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28736. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28737. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28738. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28739. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28740. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28741. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28742. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28743. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28744. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28745. /**
  28746. * Decorator used to define property that can be serialized as reference to a camera
  28747. * @param sourceName defines the name of the property to decorate
  28748. */
  28749. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28750. /**
  28751. * Class used to help serialization objects
  28752. */
  28753. export class SerializationHelper {
  28754. /** @hidden */
  28755. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28756. /** @hidden */
  28757. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28758. /** @hidden */
  28759. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28760. /** @hidden */
  28761. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28762. /**
  28763. * Appends the serialized animations from the source animations
  28764. * @param source Source containing the animations
  28765. * @param destination Target to store the animations
  28766. */
  28767. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28768. /**
  28769. * Static function used to serialized a specific entity
  28770. * @param entity defines the entity to serialize
  28771. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28772. * @returns a JSON compatible object representing the serialization of the entity
  28773. */
  28774. static Serialize<T>(entity: T, serializationObject?: any): any;
  28775. /**
  28776. * Creates a new entity from a serialization data object
  28777. * @param creationFunction defines a function used to instanciated the new entity
  28778. * @param source defines the source serialization data
  28779. * @param scene defines the hosting scene
  28780. * @param rootUrl defines the root url for resources
  28781. * @returns a new entity
  28782. */
  28783. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28784. /**
  28785. * Clones an object
  28786. * @param creationFunction defines the function used to instanciate the new object
  28787. * @param source defines the source object
  28788. * @returns the cloned object
  28789. */
  28790. static Clone<T>(creationFunction: () => T, source: T): T;
  28791. /**
  28792. * Instanciates a new object based on a source one (some data will be shared between both object)
  28793. * @param creationFunction defines the function used to instanciate the new object
  28794. * @param source defines the source object
  28795. * @returns the new object
  28796. */
  28797. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28798. }
  28799. }
  28800. declare module "babylonjs/Misc/guid" {
  28801. /**
  28802. * Class used to manipulate GUIDs
  28803. */
  28804. export class GUID {
  28805. /**
  28806. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28807. * Be aware Math.random() could cause collisions, but:
  28808. * "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"
  28809. * @returns a pseudo random id
  28810. */
  28811. static RandomId(): string;
  28812. }
  28813. }
  28814. declare module "babylonjs/Materials/Textures/baseTexture" {
  28815. import { Observable } from "babylonjs/Misc/observable";
  28816. import { Nullable } from "babylonjs/types";
  28817. import { Scene } from "babylonjs/scene";
  28818. import { Matrix } from "babylonjs/Maths/math.vector";
  28819. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28820. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28821. import { ISize } from "babylonjs/Maths/math.size";
  28822. /**
  28823. * Base class of all the textures in babylon.
  28824. * It groups all the common properties the materials, post process, lights... might need
  28825. * in order to make a correct use of the texture.
  28826. */
  28827. export class BaseTexture implements IAnimatable {
  28828. /**
  28829. * Default anisotropic filtering level for the application.
  28830. * It is set to 4 as a good tradeoff between perf and quality.
  28831. */
  28832. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28833. /**
  28834. * Gets or sets the unique id of the texture
  28835. */
  28836. uniqueId: number;
  28837. /**
  28838. * Define the name of the texture.
  28839. */
  28840. name: string;
  28841. /**
  28842. * Gets or sets an object used to store user defined information.
  28843. */
  28844. metadata: any;
  28845. /**
  28846. * For internal use only. Please do not use.
  28847. */
  28848. reservedDataStore: any;
  28849. private _hasAlpha;
  28850. /**
  28851. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28852. */
  28853. hasAlpha: boolean;
  28854. /**
  28855. * Defines if the alpha value should be determined via the rgb values.
  28856. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28857. */
  28858. getAlphaFromRGB: boolean;
  28859. /**
  28860. * Intensity or strength of the texture.
  28861. * It is commonly used by materials to fine tune the intensity of the texture
  28862. */
  28863. level: number;
  28864. /**
  28865. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28866. * This is part of the texture as textures usually maps to one uv set.
  28867. */
  28868. coordinatesIndex: number;
  28869. private _coordinatesMode;
  28870. /**
  28871. * How a texture is mapped.
  28872. *
  28873. * | Value | Type | Description |
  28874. * | ----- | ----------------------------------- | ----------- |
  28875. * | 0 | EXPLICIT_MODE | |
  28876. * | 1 | SPHERICAL_MODE | |
  28877. * | 2 | PLANAR_MODE | |
  28878. * | 3 | CUBIC_MODE | |
  28879. * | 4 | PROJECTION_MODE | |
  28880. * | 5 | SKYBOX_MODE | |
  28881. * | 6 | INVCUBIC_MODE | |
  28882. * | 7 | EQUIRECTANGULAR_MODE | |
  28883. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28884. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28885. */
  28886. coordinatesMode: number;
  28887. /**
  28888. * | Value | Type | Description |
  28889. * | ----- | ------------------ | ----------- |
  28890. * | 0 | CLAMP_ADDRESSMODE | |
  28891. * | 1 | WRAP_ADDRESSMODE | |
  28892. * | 2 | MIRROR_ADDRESSMODE | |
  28893. */
  28894. wrapU: number;
  28895. /**
  28896. * | Value | Type | Description |
  28897. * | ----- | ------------------ | ----------- |
  28898. * | 0 | CLAMP_ADDRESSMODE | |
  28899. * | 1 | WRAP_ADDRESSMODE | |
  28900. * | 2 | MIRROR_ADDRESSMODE | |
  28901. */
  28902. wrapV: number;
  28903. /**
  28904. * | Value | Type | Description |
  28905. * | ----- | ------------------ | ----------- |
  28906. * | 0 | CLAMP_ADDRESSMODE | |
  28907. * | 1 | WRAP_ADDRESSMODE | |
  28908. * | 2 | MIRROR_ADDRESSMODE | |
  28909. */
  28910. wrapR: number;
  28911. /**
  28912. * With compliant hardware and browser (supporting anisotropic filtering)
  28913. * this defines the level of anisotropic filtering in the texture.
  28914. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28915. */
  28916. anisotropicFilteringLevel: number;
  28917. /**
  28918. * Define if the texture is a cube texture or if false a 2d texture.
  28919. */
  28920. isCube: boolean;
  28921. /**
  28922. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28923. */
  28924. is3D: boolean;
  28925. /**
  28926. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  28927. */
  28928. is2DArray: boolean;
  28929. /**
  28930. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28931. * HDR texture are usually stored in linear space.
  28932. * This only impacts the PBR and Background materials
  28933. */
  28934. gammaSpace: boolean;
  28935. /**
  28936. * Gets or sets whether or not the texture contains RGBD data.
  28937. */
  28938. isRGBD: boolean;
  28939. /**
  28940. * Is Z inverted in the texture (useful in a cube texture).
  28941. */
  28942. invertZ: boolean;
  28943. /**
  28944. * Are mip maps generated for this texture or not.
  28945. */
  28946. readonly noMipmap: boolean;
  28947. /**
  28948. * @hidden
  28949. */
  28950. lodLevelInAlpha: boolean;
  28951. /**
  28952. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28953. */
  28954. lodGenerationOffset: number;
  28955. /**
  28956. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28957. */
  28958. lodGenerationScale: number;
  28959. /**
  28960. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28961. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28962. * average roughness values.
  28963. */
  28964. linearSpecularLOD: boolean;
  28965. /**
  28966. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28967. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28968. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28969. */
  28970. irradianceTexture: Nullable<BaseTexture>;
  28971. /**
  28972. * Define if the texture is a render target.
  28973. */
  28974. isRenderTarget: boolean;
  28975. /**
  28976. * Define the unique id of the texture in the scene.
  28977. */
  28978. readonly uid: string;
  28979. /**
  28980. * Return a string representation of the texture.
  28981. * @returns the texture as a string
  28982. */
  28983. toString(): string;
  28984. /**
  28985. * Get the class name of the texture.
  28986. * @returns "BaseTexture"
  28987. */
  28988. getClassName(): string;
  28989. /**
  28990. * Define the list of animation attached to the texture.
  28991. */
  28992. animations: import("babylonjs/Animations/animation").Animation[];
  28993. /**
  28994. * An event triggered when the texture is disposed.
  28995. */
  28996. onDisposeObservable: Observable<BaseTexture>;
  28997. private _onDisposeObserver;
  28998. /**
  28999. * Callback triggered when the texture has been disposed.
  29000. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29001. */
  29002. onDispose: () => void;
  29003. /**
  29004. * Define the current state of the loading sequence when in delayed load mode.
  29005. */
  29006. delayLoadState: number;
  29007. private _scene;
  29008. /** @hidden */
  29009. _texture: Nullable<InternalTexture>;
  29010. private _uid;
  29011. /**
  29012. * Define if the texture is preventinga material to render or not.
  29013. * If not and the texture is not ready, the engine will use a default black texture instead.
  29014. */
  29015. readonly isBlocking: boolean;
  29016. /**
  29017. * Instantiates a new BaseTexture.
  29018. * Base class of all the textures in babylon.
  29019. * It groups all the common properties the materials, post process, lights... might need
  29020. * in order to make a correct use of the texture.
  29021. * @param scene Define the scene the texture blongs to
  29022. */
  29023. constructor(scene: Nullable<Scene>);
  29024. /**
  29025. * Get the scene the texture belongs to.
  29026. * @returns the scene or null if undefined
  29027. */
  29028. getScene(): Nullable<Scene>;
  29029. /**
  29030. * Get the texture transform matrix used to offset tile the texture for istance.
  29031. * @returns the transformation matrix
  29032. */
  29033. getTextureMatrix(): Matrix;
  29034. /**
  29035. * Get the texture reflection matrix used to rotate/transform the reflection.
  29036. * @returns the reflection matrix
  29037. */
  29038. getReflectionTextureMatrix(): Matrix;
  29039. /**
  29040. * Get the underlying lower level texture from Babylon.
  29041. * @returns the insternal texture
  29042. */
  29043. getInternalTexture(): Nullable<InternalTexture>;
  29044. /**
  29045. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29046. * @returns true if ready or not blocking
  29047. */
  29048. isReadyOrNotBlocking(): boolean;
  29049. /**
  29050. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29051. * @returns true if fully ready
  29052. */
  29053. isReady(): boolean;
  29054. private _cachedSize;
  29055. /**
  29056. * Get the size of the texture.
  29057. * @returns the texture size.
  29058. */
  29059. getSize(): ISize;
  29060. /**
  29061. * Get the base size of the texture.
  29062. * It can be different from the size if the texture has been resized for POT for instance
  29063. * @returns the base size
  29064. */
  29065. getBaseSize(): ISize;
  29066. /**
  29067. * Update the sampling mode of the texture.
  29068. * Default is Trilinear mode.
  29069. *
  29070. * | Value | Type | Description |
  29071. * | ----- | ------------------ | ----------- |
  29072. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29073. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29074. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29075. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29076. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29077. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29078. * | 7 | NEAREST_LINEAR | |
  29079. * | 8 | NEAREST_NEAREST | |
  29080. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29081. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29082. * | 11 | LINEAR_LINEAR | |
  29083. * | 12 | LINEAR_NEAREST | |
  29084. *
  29085. * > _mag_: magnification filter (close to the viewer)
  29086. * > _min_: minification filter (far from the viewer)
  29087. * > _mip_: filter used between mip map levels
  29088. *@param samplingMode Define the new sampling mode of the texture
  29089. */
  29090. updateSamplingMode(samplingMode: number): void;
  29091. /**
  29092. * Scales the texture if is `canRescale()`
  29093. * @param ratio the resize factor we want to use to rescale
  29094. */
  29095. scale(ratio: number): void;
  29096. /**
  29097. * Get if the texture can rescale.
  29098. */
  29099. readonly canRescale: boolean;
  29100. /** @hidden */
  29101. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29102. /** @hidden */
  29103. _rebuild(): void;
  29104. /**
  29105. * Triggers the load sequence in delayed load mode.
  29106. */
  29107. delayLoad(): void;
  29108. /**
  29109. * Clones the texture.
  29110. * @returns the cloned texture
  29111. */
  29112. clone(): Nullable<BaseTexture>;
  29113. /**
  29114. * Get the texture underlying type (INT, FLOAT...)
  29115. */
  29116. readonly textureType: number;
  29117. /**
  29118. * Get the texture underlying format (RGB, RGBA...)
  29119. */
  29120. readonly textureFormat: number;
  29121. /**
  29122. * Indicates that textures need to be re-calculated for all materials
  29123. */
  29124. protected _markAllSubMeshesAsTexturesDirty(): void;
  29125. /**
  29126. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29127. * This will returns an RGBA array buffer containing either in values (0-255) or
  29128. * float values (0-1) depending of the underlying buffer type.
  29129. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29130. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29131. * @param buffer defines a user defined buffer to fill with data (can be null)
  29132. * @returns The Array buffer containing the pixels data.
  29133. */
  29134. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29135. /**
  29136. * Release and destroy the underlying lower level texture aka internalTexture.
  29137. */
  29138. releaseInternalTexture(): void;
  29139. /** @hidden */
  29140. readonly _lodTextureHigh: Nullable<BaseTexture>;
  29141. /** @hidden */
  29142. readonly _lodTextureMid: Nullable<BaseTexture>;
  29143. /** @hidden */
  29144. readonly _lodTextureLow: Nullable<BaseTexture>;
  29145. /**
  29146. * Dispose the texture and release its associated resources.
  29147. */
  29148. dispose(): void;
  29149. /**
  29150. * Serialize the texture into a JSON representation that can be parsed later on.
  29151. * @returns the JSON representation of the texture
  29152. */
  29153. serialize(): any;
  29154. /**
  29155. * Helper function to be called back once a list of texture contains only ready textures.
  29156. * @param textures Define the list of textures to wait for
  29157. * @param callback Define the callback triggered once the entire list will be ready
  29158. */
  29159. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29160. }
  29161. }
  29162. declare module "babylonjs/Materials/effect" {
  29163. import { Observable } from "babylonjs/Misc/observable";
  29164. import { Nullable } from "babylonjs/types";
  29165. import { IDisposable } from "babylonjs/scene";
  29166. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29167. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29168. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29169. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29170. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29171. import { Engine } from "babylonjs/Engines/engine";
  29172. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29173. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29174. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29175. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29176. /**
  29177. * Options to be used when creating an effect.
  29178. */
  29179. export interface IEffectCreationOptions {
  29180. /**
  29181. * Atrributes that will be used in the shader.
  29182. */
  29183. attributes: string[];
  29184. /**
  29185. * Uniform varible names that will be set in the shader.
  29186. */
  29187. uniformsNames: string[];
  29188. /**
  29189. * Uniform buffer varible names that will be set in the shader.
  29190. */
  29191. uniformBuffersNames: string[];
  29192. /**
  29193. * Sampler texture variable names that will be set in the shader.
  29194. */
  29195. samplers: string[];
  29196. /**
  29197. * Define statements that will be set in the shader.
  29198. */
  29199. defines: any;
  29200. /**
  29201. * Possible fallbacks for this effect to improve performance when needed.
  29202. */
  29203. fallbacks: Nullable<IEffectFallbacks>;
  29204. /**
  29205. * Callback that will be called when the shader is compiled.
  29206. */
  29207. onCompiled: Nullable<(effect: Effect) => void>;
  29208. /**
  29209. * Callback that will be called if an error occurs during shader compilation.
  29210. */
  29211. onError: Nullable<(effect: Effect, errors: string) => void>;
  29212. /**
  29213. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29214. */
  29215. indexParameters?: any;
  29216. /**
  29217. * Max number of lights that can be used in the shader.
  29218. */
  29219. maxSimultaneousLights?: number;
  29220. /**
  29221. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29222. */
  29223. transformFeedbackVaryings?: Nullable<string[]>;
  29224. }
  29225. /**
  29226. * Effect containing vertex and fragment shader that can be executed on an object.
  29227. */
  29228. export class Effect implements IDisposable {
  29229. /**
  29230. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29231. */
  29232. static ShadersRepository: string;
  29233. /**
  29234. * Name of the effect.
  29235. */
  29236. name: any;
  29237. /**
  29238. * String container all the define statements that should be set on the shader.
  29239. */
  29240. defines: string;
  29241. /**
  29242. * Callback that will be called when the shader is compiled.
  29243. */
  29244. onCompiled: Nullable<(effect: Effect) => void>;
  29245. /**
  29246. * Callback that will be called if an error occurs during shader compilation.
  29247. */
  29248. onError: Nullable<(effect: Effect, errors: string) => void>;
  29249. /**
  29250. * Callback that will be called when effect is bound.
  29251. */
  29252. onBind: Nullable<(effect: Effect) => void>;
  29253. /**
  29254. * Unique ID of the effect.
  29255. */
  29256. uniqueId: number;
  29257. /**
  29258. * Observable that will be called when the shader is compiled.
  29259. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29260. */
  29261. onCompileObservable: Observable<Effect>;
  29262. /**
  29263. * Observable that will be called if an error occurs during shader compilation.
  29264. */
  29265. onErrorObservable: Observable<Effect>;
  29266. /** @hidden */
  29267. _onBindObservable: Nullable<Observable<Effect>>;
  29268. /**
  29269. * Observable that will be called when effect is bound.
  29270. */
  29271. readonly onBindObservable: Observable<Effect>;
  29272. /** @hidden */
  29273. _bonesComputationForcedToCPU: boolean;
  29274. private static _uniqueIdSeed;
  29275. private _engine;
  29276. private _uniformBuffersNames;
  29277. private _uniformsNames;
  29278. private _samplerList;
  29279. private _samplers;
  29280. private _isReady;
  29281. private _compilationError;
  29282. private _allFallbacksProcessed;
  29283. private _attributesNames;
  29284. private _attributes;
  29285. private _uniforms;
  29286. /**
  29287. * Key for the effect.
  29288. * @hidden
  29289. */
  29290. _key: string;
  29291. private _indexParameters;
  29292. private _fallbacks;
  29293. private _vertexSourceCode;
  29294. private _fragmentSourceCode;
  29295. private _vertexSourceCodeOverride;
  29296. private _fragmentSourceCodeOverride;
  29297. private _transformFeedbackVaryings;
  29298. /**
  29299. * Compiled shader to webGL program.
  29300. * @hidden
  29301. */
  29302. _pipelineContext: Nullable<IPipelineContext>;
  29303. private _valueCache;
  29304. private static _baseCache;
  29305. /**
  29306. * Instantiates an effect.
  29307. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29308. * @param baseName Name of the effect.
  29309. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29310. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29311. * @param samplers List of sampler variables that will be passed to the shader.
  29312. * @param engine Engine to be used to render the effect
  29313. * @param defines Define statements to be added to the shader.
  29314. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29315. * @param onCompiled Callback that will be called when the shader is compiled.
  29316. * @param onError Callback that will be called if an error occurs during shader compilation.
  29317. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29318. */
  29319. 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);
  29320. private _useFinalCode;
  29321. /**
  29322. * Unique key for this effect
  29323. */
  29324. readonly key: string;
  29325. /**
  29326. * If the effect has been compiled and prepared.
  29327. * @returns if the effect is compiled and prepared.
  29328. */
  29329. isReady(): boolean;
  29330. private _isReadyInternal;
  29331. /**
  29332. * The engine the effect was initialized with.
  29333. * @returns the engine.
  29334. */
  29335. getEngine(): Engine;
  29336. /**
  29337. * The pipeline context for this effect
  29338. * @returns the associated pipeline context
  29339. */
  29340. getPipelineContext(): Nullable<IPipelineContext>;
  29341. /**
  29342. * The set of names of attribute variables for the shader.
  29343. * @returns An array of attribute names.
  29344. */
  29345. getAttributesNames(): string[];
  29346. /**
  29347. * Returns the attribute at the given index.
  29348. * @param index The index of the attribute.
  29349. * @returns The location of the attribute.
  29350. */
  29351. getAttributeLocation(index: number): number;
  29352. /**
  29353. * Returns the attribute based on the name of the variable.
  29354. * @param name of the attribute to look up.
  29355. * @returns the attribute location.
  29356. */
  29357. getAttributeLocationByName(name: string): number;
  29358. /**
  29359. * The number of attributes.
  29360. * @returns the numnber of attributes.
  29361. */
  29362. getAttributesCount(): number;
  29363. /**
  29364. * Gets the index of a uniform variable.
  29365. * @param uniformName of the uniform to look up.
  29366. * @returns the index.
  29367. */
  29368. getUniformIndex(uniformName: string): number;
  29369. /**
  29370. * Returns the attribute based on the name of the variable.
  29371. * @param uniformName of the uniform to look up.
  29372. * @returns the location of the uniform.
  29373. */
  29374. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29375. /**
  29376. * Returns an array of sampler variable names
  29377. * @returns The array of sampler variable neames.
  29378. */
  29379. getSamplers(): string[];
  29380. /**
  29381. * The error from the last compilation.
  29382. * @returns the error string.
  29383. */
  29384. getCompilationError(): string;
  29385. /**
  29386. * Gets a boolean indicating that all fallbacks were used during compilation
  29387. * @returns true if all fallbacks were used
  29388. */
  29389. allFallbacksProcessed(): boolean;
  29390. /**
  29391. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29392. * @param func The callback to be used.
  29393. */
  29394. executeWhenCompiled(func: (effect: Effect) => void): void;
  29395. private _checkIsReady;
  29396. private _loadShader;
  29397. /**
  29398. * Recompiles the webGL program
  29399. * @param vertexSourceCode The source code for the vertex shader.
  29400. * @param fragmentSourceCode The source code for the fragment shader.
  29401. * @param onCompiled Callback called when completed.
  29402. * @param onError Callback called on error.
  29403. * @hidden
  29404. */
  29405. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29406. /**
  29407. * Prepares the effect
  29408. * @hidden
  29409. */
  29410. _prepareEffect(): void;
  29411. private _processCompilationErrors;
  29412. /**
  29413. * Checks if the effect is supported. (Must be called after compilation)
  29414. */
  29415. readonly isSupported: boolean;
  29416. /**
  29417. * Binds a texture to the engine to be used as output of the shader.
  29418. * @param channel Name of the output variable.
  29419. * @param texture Texture to bind.
  29420. * @hidden
  29421. */
  29422. _bindTexture(channel: string, texture: InternalTexture): void;
  29423. /**
  29424. * Sets a texture on the engine to be used in the shader.
  29425. * @param channel Name of the sampler variable.
  29426. * @param texture Texture to set.
  29427. */
  29428. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29429. /**
  29430. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29431. * @param channel Name of the sampler variable.
  29432. * @param texture Texture to set.
  29433. */
  29434. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29435. /**
  29436. * Sets an array of textures on the engine to be used in the shader.
  29437. * @param channel Name of the variable.
  29438. * @param textures Textures to set.
  29439. */
  29440. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29441. /**
  29442. * 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)
  29443. * @param channel Name of the sampler variable.
  29444. * @param postProcess Post process to get the input texture from.
  29445. */
  29446. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29447. /**
  29448. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29449. * 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)
  29450. * @param channel Name of the sampler variable.
  29451. * @param postProcess Post process to get the output texture from.
  29452. */
  29453. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29454. /** @hidden */
  29455. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29456. /** @hidden */
  29457. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29458. /** @hidden */
  29459. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29460. /** @hidden */
  29461. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29462. /**
  29463. * Binds a buffer to a uniform.
  29464. * @param buffer Buffer to bind.
  29465. * @param name Name of the uniform variable to bind to.
  29466. */
  29467. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29468. /**
  29469. * Binds block to a uniform.
  29470. * @param blockName Name of the block to bind.
  29471. * @param index Index to bind.
  29472. */
  29473. bindUniformBlock(blockName: string, index: number): void;
  29474. /**
  29475. * Sets an interger value on a uniform variable.
  29476. * @param uniformName Name of the variable.
  29477. * @param value Value to be set.
  29478. * @returns this effect.
  29479. */
  29480. setInt(uniformName: string, value: number): Effect;
  29481. /**
  29482. * Sets an int array on a uniform variable.
  29483. * @param uniformName Name of the variable.
  29484. * @param array array to be set.
  29485. * @returns this effect.
  29486. */
  29487. setIntArray(uniformName: string, array: Int32Array): Effect;
  29488. /**
  29489. * 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)
  29490. * @param uniformName Name of the variable.
  29491. * @param array array to be set.
  29492. * @returns this effect.
  29493. */
  29494. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29495. /**
  29496. * 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)
  29497. * @param uniformName Name of the variable.
  29498. * @param array array to be set.
  29499. * @returns this effect.
  29500. */
  29501. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29502. /**
  29503. * 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)
  29504. * @param uniformName Name of the variable.
  29505. * @param array array to be set.
  29506. * @returns this effect.
  29507. */
  29508. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29509. /**
  29510. * Sets an float array on a uniform variable.
  29511. * @param uniformName Name of the variable.
  29512. * @param array array to be set.
  29513. * @returns this effect.
  29514. */
  29515. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29516. /**
  29517. * 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)
  29518. * @param uniformName Name of the variable.
  29519. * @param array array to be set.
  29520. * @returns this effect.
  29521. */
  29522. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29523. /**
  29524. * 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)
  29525. * @param uniformName Name of the variable.
  29526. * @param array array to be set.
  29527. * @returns this effect.
  29528. */
  29529. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29530. /**
  29531. * 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)
  29532. * @param uniformName Name of the variable.
  29533. * @param array array to be set.
  29534. * @returns this effect.
  29535. */
  29536. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29537. /**
  29538. * Sets an array on a uniform variable.
  29539. * @param uniformName Name of the variable.
  29540. * @param array array to be set.
  29541. * @returns this effect.
  29542. */
  29543. setArray(uniformName: string, array: number[]): Effect;
  29544. /**
  29545. * 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)
  29546. * @param uniformName Name of the variable.
  29547. * @param array array to be set.
  29548. * @returns this effect.
  29549. */
  29550. setArray2(uniformName: string, array: number[]): Effect;
  29551. /**
  29552. * 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)
  29553. * @param uniformName Name of the variable.
  29554. * @param array array to be set.
  29555. * @returns this effect.
  29556. */
  29557. setArray3(uniformName: string, array: number[]): Effect;
  29558. /**
  29559. * 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)
  29560. * @param uniformName Name of the variable.
  29561. * @param array array to be set.
  29562. * @returns this effect.
  29563. */
  29564. setArray4(uniformName: string, array: number[]): Effect;
  29565. /**
  29566. * Sets matrices on a uniform variable.
  29567. * @param uniformName Name of the variable.
  29568. * @param matrices matrices to be set.
  29569. * @returns this effect.
  29570. */
  29571. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29572. /**
  29573. * Sets matrix on a uniform variable.
  29574. * @param uniformName Name of the variable.
  29575. * @param matrix matrix to be set.
  29576. * @returns this effect.
  29577. */
  29578. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29579. /**
  29580. * 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)
  29581. * @param uniformName Name of the variable.
  29582. * @param matrix matrix to be set.
  29583. * @returns this effect.
  29584. */
  29585. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29586. /**
  29587. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29588. * @param uniformName Name of the variable.
  29589. * @param matrix matrix to be set.
  29590. * @returns this effect.
  29591. */
  29592. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29593. /**
  29594. * Sets a float on a uniform variable.
  29595. * @param uniformName Name of the variable.
  29596. * @param value value to be set.
  29597. * @returns this effect.
  29598. */
  29599. setFloat(uniformName: string, value: number): Effect;
  29600. /**
  29601. * Sets a boolean on a uniform variable.
  29602. * @param uniformName Name of the variable.
  29603. * @param bool value to be set.
  29604. * @returns this effect.
  29605. */
  29606. setBool(uniformName: string, bool: boolean): Effect;
  29607. /**
  29608. * Sets a Vector2 on a uniform variable.
  29609. * @param uniformName Name of the variable.
  29610. * @param vector2 vector2 to be set.
  29611. * @returns this effect.
  29612. */
  29613. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29614. /**
  29615. * Sets a float2 on a uniform variable.
  29616. * @param uniformName Name of the variable.
  29617. * @param x First float in float2.
  29618. * @param y Second float in float2.
  29619. * @returns this effect.
  29620. */
  29621. setFloat2(uniformName: string, x: number, y: number): Effect;
  29622. /**
  29623. * Sets a Vector3 on a uniform variable.
  29624. * @param uniformName Name of the variable.
  29625. * @param vector3 Value to be set.
  29626. * @returns this effect.
  29627. */
  29628. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29629. /**
  29630. * Sets a float3 on a uniform variable.
  29631. * @param uniformName Name of the variable.
  29632. * @param x First float in float3.
  29633. * @param y Second float in float3.
  29634. * @param z Third float in float3.
  29635. * @returns this effect.
  29636. */
  29637. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29638. /**
  29639. * Sets a Vector4 on a uniform variable.
  29640. * @param uniformName Name of the variable.
  29641. * @param vector4 Value to be set.
  29642. * @returns this effect.
  29643. */
  29644. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29645. /**
  29646. * Sets a float4 on a uniform variable.
  29647. * @param uniformName Name of the variable.
  29648. * @param x First float in float4.
  29649. * @param y Second float in float4.
  29650. * @param z Third float in float4.
  29651. * @param w Fourth float in float4.
  29652. * @returns this effect.
  29653. */
  29654. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29655. /**
  29656. * Sets a Color3 on a uniform variable.
  29657. * @param uniformName Name of the variable.
  29658. * @param color3 Value to be set.
  29659. * @returns this effect.
  29660. */
  29661. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29662. /**
  29663. * Sets a Color4 on a uniform variable.
  29664. * @param uniformName Name of the variable.
  29665. * @param color3 Value to be set.
  29666. * @param alpha Alpha value to be set.
  29667. * @returns this effect.
  29668. */
  29669. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29670. /**
  29671. * Sets a Color4 on a uniform variable
  29672. * @param uniformName defines the name of the variable
  29673. * @param color4 defines the value to be set
  29674. * @returns this effect.
  29675. */
  29676. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29677. /** Release all associated resources */
  29678. dispose(): void;
  29679. /**
  29680. * This function will add a new shader to the shader store
  29681. * @param name the name of the shader
  29682. * @param pixelShader optional pixel shader content
  29683. * @param vertexShader optional vertex shader content
  29684. */
  29685. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29686. /**
  29687. * Store of each shader (The can be looked up using effect.key)
  29688. */
  29689. static ShadersStore: {
  29690. [key: string]: string;
  29691. };
  29692. /**
  29693. * Store of each included file for a shader (The can be looked up using effect.key)
  29694. */
  29695. static IncludesShadersStore: {
  29696. [key: string]: string;
  29697. };
  29698. /**
  29699. * Resets the cache of effects.
  29700. */
  29701. static ResetCache(): void;
  29702. }
  29703. }
  29704. declare module "babylonjs/Engines/engineCapabilities" {
  29705. /**
  29706. * Interface used to describe the capabilities of the engine relatively to the current browser
  29707. */
  29708. export interface EngineCapabilities {
  29709. /** Maximum textures units per fragment shader */
  29710. maxTexturesImageUnits: number;
  29711. /** Maximum texture units per vertex shader */
  29712. maxVertexTextureImageUnits: number;
  29713. /** Maximum textures units in the entire pipeline */
  29714. maxCombinedTexturesImageUnits: number;
  29715. /** Maximum texture size */
  29716. maxTextureSize: number;
  29717. /** Maximum cube texture size */
  29718. maxCubemapTextureSize: number;
  29719. /** Maximum render texture size */
  29720. maxRenderTextureSize: number;
  29721. /** Maximum number of vertex attributes */
  29722. maxVertexAttribs: number;
  29723. /** Maximum number of varyings */
  29724. maxVaryingVectors: number;
  29725. /** Maximum number of uniforms per vertex shader */
  29726. maxVertexUniformVectors: number;
  29727. /** Maximum number of uniforms per fragment shader */
  29728. maxFragmentUniformVectors: number;
  29729. /** Defines if standard derivates (dx/dy) are supported */
  29730. standardDerivatives: boolean;
  29731. /** Defines if s3tc texture compression is supported */
  29732. s3tc?: WEBGL_compressed_texture_s3tc;
  29733. /** Defines if pvrtc texture compression is supported */
  29734. pvrtc: any;
  29735. /** Defines if etc1 texture compression is supported */
  29736. etc1: any;
  29737. /** Defines if etc2 texture compression is supported */
  29738. etc2: any;
  29739. /** Defines if astc texture compression is supported */
  29740. astc: any;
  29741. /** Defines if float textures are supported */
  29742. textureFloat: boolean;
  29743. /** Defines if vertex array objects are supported */
  29744. vertexArrayObject: boolean;
  29745. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29746. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  29747. /** Gets the maximum level of anisotropy supported */
  29748. maxAnisotropy: number;
  29749. /** Defines if instancing is supported */
  29750. instancedArrays: boolean;
  29751. /** Defines if 32 bits indices are supported */
  29752. uintIndices: boolean;
  29753. /** Defines if high precision shaders are supported */
  29754. highPrecisionShaderSupported: boolean;
  29755. /** Defines if depth reading in the fragment shader is supported */
  29756. fragmentDepthSupported: boolean;
  29757. /** Defines if float texture linear filtering is supported*/
  29758. textureFloatLinearFiltering: boolean;
  29759. /** Defines if rendering to float textures is supported */
  29760. textureFloatRender: boolean;
  29761. /** Defines if half float textures are supported*/
  29762. textureHalfFloat: boolean;
  29763. /** Defines if half float texture linear filtering is supported*/
  29764. textureHalfFloatLinearFiltering: boolean;
  29765. /** Defines if rendering to half float textures is supported */
  29766. textureHalfFloatRender: boolean;
  29767. /** Defines if textureLOD shader command is supported */
  29768. textureLOD: boolean;
  29769. /** Defines if draw buffers extension is supported */
  29770. drawBuffersExtension: boolean;
  29771. /** Defines if depth textures are supported */
  29772. depthTextureExtension: boolean;
  29773. /** Defines if float color buffer are supported */
  29774. colorBufferFloat: boolean;
  29775. /** Gets disjoint timer query extension (null if not supported) */
  29776. timerQuery?: EXT_disjoint_timer_query;
  29777. /** Defines if timestamp can be used with timer query */
  29778. canUseTimestampForTimerQuery: boolean;
  29779. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29780. multiview?: any;
  29781. /** Function used to let the system compiles shaders in background */
  29782. parallelShaderCompile?: {
  29783. COMPLETION_STATUS_KHR: number;
  29784. };
  29785. /** Max number of texture samples for MSAA */
  29786. maxMSAASamples: number;
  29787. /** Defines if the blend min max extension is supported */
  29788. blendMinMax: boolean;
  29789. }
  29790. }
  29791. declare module "babylonjs/States/depthCullingState" {
  29792. import { Nullable } from "babylonjs/types";
  29793. /**
  29794. * @hidden
  29795. **/
  29796. export class DepthCullingState {
  29797. private _isDepthTestDirty;
  29798. private _isDepthMaskDirty;
  29799. private _isDepthFuncDirty;
  29800. private _isCullFaceDirty;
  29801. private _isCullDirty;
  29802. private _isZOffsetDirty;
  29803. private _isFrontFaceDirty;
  29804. private _depthTest;
  29805. private _depthMask;
  29806. private _depthFunc;
  29807. private _cull;
  29808. private _cullFace;
  29809. private _zOffset;
  29810. private _frontFace;
  29811. /**
  29812. * Initializes the state.
  29813. */
  29814. constructor();
  29815. readonly isDirty: boolean;
  29816. zOffset: number;
  29817. cullFace: Nullable<number>;
  29818. cull: Nullable<boolean>;
  29819. depthFunc: Nullable<number>;
  29820. depthMask: boolean;
  29821. depthTest: boolean;
  29822. frontFace: Nullable<number>;
  29823. reset(): void;
  29824. apply(gl: WebGLRenderingContext): void;
  29825. }
  29826. }
  29827. declare module "babylonjs/States/stencilState" {
  29828. /**
  29829. * @hidden
  29830. **/
  29831. export class StencilState {
  29832. /** 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 */
  29833. static readonly ALWAYS: number;
  29834. /** Passed to stencilOperation to specify that stencil value must be kept */
  29835. static readonly KEEP: number;
  29836. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29837. static readonly REPLACE: number;
  29838. private _isStencilTestDirty;
  29839. private _isStencilMaskDirty;
  29840. private _isStencilFuncDirty;
  29841. private _isStencilOpDirty;
  29842. private _stencilTest;
  29843. private _stencilMask;
  29844. private _stencilFunc;
  29845. private _stencilFuncRef;
  29846. private _stencilFuncMask;
  29847. private _stencilOpStencilFail;
  29848. private _stencilOpDepthFail;
  29849. private _stencilOpStencilDepthPass;
  29850. readonly isDirty: boolean;
  29851. stencilFunc: number;
  29852. stencilFuncRef: number;
  29853. stencilFuncMask: number;
  29854. stencilOpStencilFail: number;
  29855. stencilOpDepthFail: number;
  29856. stencilOpStencilDepthPass: number;
  29857. stencilMask: number;
  29858. stencilTest: boolean;
  29859. constructor();
  29860. reset(): void;
  29861. apply(gl: WebGLRenderingContext): void;
  29862. }
  29863. }
  29864. declare module "babylonjs/States/alphaCullingState" {
  29865. /**
  29866. * @hidden
  29867. **/
  29868. export class AlphaState {
  29869. private _isAlphaBlendDirty;
  29870. private _isBlendFunctionParametersDirty;
  29871. private _isBlendEquationParametersDirty;
  29872. private _isBlendConstantsDirty;
  29873. private _alphaBlend;
  29874. private _blendFunctionParameters;
  29875. private _blendEquationParameters;
  29876. private _blendConstants;
  29877. /**
  29878. * Initializes the state.
  29879. */
  29880. constructor();
  29881. readonly isDirty: boolean;
  29882. alphaBlend: boolean;
  29883. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29884. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29885. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29886. reset(): void;
  29887. apply(gl: WebGLRenderingContext): void;
  29888. }
  29889. }
  29890. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29891. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29892. /** @hidden */
  29893. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29894. attributeProcessor(attribute: string): string;
  29895. varyingProcessor(varying: string, isFragment: boolean): string;
  29896. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29897. }
  29898. }
  29899. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29900. /**
  29901. * Interface for attribute information associated with buffer instanciation
  29902. */
  29903. export interface InstancingAttributeInfo {
  29904. /**
  29905. * Index/offset of the attribute in the vertex shader
  29906. */
  29907. index: number;
  29908. /**
  29909. * size of the attribute, 1, 2, 3 or 4
  29910. */
  29911. attributeSize: number;
  29912. /**
  29913. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29914. * default is FLOAT
  29915. */
  29916. attributeType: number;
  29917. /**
  29918. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29919. */
  29920. normalized: boolean;
  29921. /**
  29922. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29923. */
  29924. offset: number;
  29925. /**
  29926. * Name of the GLSL attribute, for debugging purpose only
  29927. */
  29928. attributeName: string;
  29929. }
  29930. }
  29931. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29932. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29933. import { Nullable } from "babylonjs/types";
  29934. module "babylonjs/Engines/thinEngine" {
  29935. interface ThinEngine {
  29936. /**
  29937. * Update a video texture
  29938. * @param texture defines the texture to update
  29939. * @param video defines the video element to use
  29940. * @param invertY defines if data must be stored with Y axis inverted
  29941. */
  29942. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29943. }
  29944. }
  29945. }
  29946. declare module "babylonjs/Materials/Textures/videoTexture" {
  29947. import { Observable } from "babylonjs/Misc/observable";
  29948. import { Nullable } from "babylonjs/types";
  29949. import { Scene } from "babylonjs/scene";
  29950. import { Texture } from "babylonjs/Materials/Textures/texture";
  29951. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29952. /**
  29953. * Settings for finer control over video usage
  29954. */
  29955. export interface VideoTextureSettings {
  29956. /**
  29957. * Applies `autoplay` to video, if specified
  29958. */
  29959. autoPlay?: boolean;
  29960. /**
  29961. * Applies `loop` to video, if specified
  29962. */
  29963. loop?: boolean;
  29964. /**
  29965. * Automatically updates internal texture from video at every frame in the render loop
  29966. */
  29967. autoUpdateTexture: boolean;
  29968. /**
  29969. * Image src displayed during the video loading or until the user interacts with the video.
  29970. */
  29971. poster?: string;
  29972. }
  29973. /**
  29974. * If you want to display a video in your scene, this is the special texture for that.
  29975. * This special texture works similar to other textures, with the exception of a few parameters.
  29976. * @see https://doc.babylonjs.com/how_to/video_texture
  29977. */
  29978. export class VideoTexture extends Texture {
  29979. /**
  29980. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29981. */
  29982. readonly autoUpdateTexture: boolean;
  29983. /**
  29984. * The video instance used by the texture internally
  29985. */
  29986. readonly video: HTMLVideoElement;
  29987. private _onUserActionRequestedObservable;
  29988. /**
  29989. * Event triggerd when a dom action is required by the user to play the video.
  29990. * This happens due to recent changes in browser policies preventing video to auto start.
  29991. */
  29992. readonly onUserActionRequestedObservable: Observable<Texture>;
  29993. private _generateMipMaps;
  29994. private _engine;
  29995. private _stillImageCaptured;
  29996. private _displayingPosterTexture;
  29997. private _settings;
  29998. private _createInternalTextureOnEvent;
  29999. private _frameId;
  30000. /**
  30001. * Creates a video texture.
  30002. * If you want to display a video in your scene, this is the special texture for that.
  30003. * This special texture works similar to other textures, with the exception of a few parameters.
  30004. * @see https://doc.babylonjs.com/how_to/video_texture
  30005. * @param name optional name, will detect from video source, if not defined
  30006. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30007. * @param scene is obviously the current scene.
  30008. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30009. * @param invertY is false by default but can be used to invert video on Y axis
  30010. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30011. * @param settings allows finer control over video usage
  30012. */
  30013. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30014. private _getName;
  30015. private _getVideo;
  30016. private _createInternalTexture;
  30017. private reset;
  30018. /**
  30019. * @hidden Internal method to initiate `update`.
  30020. */
  30021. _rebuild(): void;
  30022. /**
  30023. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30024. */
  30025. update(): void;
  30026. /**
  30027. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30028. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30029. */
  30030. updateTexture(isVisible: boolean): void;
  30031. protected _updateInternalTexture: () => void;
  30032. /**
  30033. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30034. * @param url New url.
  30035. */
  30036. updateURL(url: string): void;
  30037. /**
  30038. * Dispose the texture and release its associated resources.
  30039. */
  30040. dispose(): void;
  30041. /**
  30042. * Creates a video texture straight from a stream.
  30043. * @param scene Define the scene the texture should be created in
  30044. * @param stream Define the stream the texture should be created from
  30045. * @returns The created video texture as a promise
  30046. */
  30047. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30048. /**
  30049. * Creates a video texture straight from your WebCam video feed.
  30050. * @param scene Define the scene the texture should be created in
  30051. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30052. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30053. * @returns The created video texture as a promise
  30054. */
  30055. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30056. minWidth: number;
  30057. maxWidth: number;
  30058. minHeight: number;
  30059. maxHeight: number;
  30060. deviceId: string;
  30061. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30062. /**
  30063. * Creates a video texture straight from your WebCam video feed.
  30064. * @param scene Define the scene the texture should be created in
  30065. * @param onReady Define a callback to triggered once the texture will be ready
  30066. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30067. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30068. */
  30069. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30070. minWidth: number;
  30071. maxWidth: number;
  30072. minHeight: number;
  30073. maxHeight: number;
  30074. deviceId: string;
  30075. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30076. }
  30077. }
  30078. declare module "babylonjs/Engines/thinEngine" {
  30079. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30080. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  30081. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30082. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30083. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  30084. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  30085. import { Observable } from "babylonjs/Misc/observable";
  30086. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  30087. import { StencilState } from "babylonjs/States/stencilState";
  30088. import { AlphaState } from "babylonjs/States/alphaCullingState";
  30089. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30090. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30091. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30092. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30093. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30094. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30095. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30096. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  30097. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30098. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30099. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30100. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  30101. /**
  30102. * Defines the interface used by objects working like Scene
  30103. * @hidden
  30104. */
  30105. interface ISceneLike {
  30106. _addPendingData(data: any): void;
  30107. _removePendingData(data: any): void;
  30108. offlineProvider: IOfflineProvider;
  30109. }
  30110. /** Interface defining initialization parameters for Engine class */
  30111. export interface EngineOptions extends WebGLContextAttributes {
  30112. /**
  30113. * Defines if the engine should no exceed a specified device ratio
  30114. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30115. */
  30116. limitDeviceRatio?: number;
  30117. /**
  30118. * Defines if webvr should be enabled automatically
  30119. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30120. */
  30121. autoEnableWebVR?: boolean;
  30122. /**
  30123. * Defines if webgl2 should be turned off even if supported
  30124. * @see http://doc.babylonjs.com/features/webgl2
  30125. */
  30126. disableWebGL2Support?: boolean;
  30127. /**
  30128. * Defines if webaudio should be initialized as well
  30129. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30130. */
  30131. audioEngine?: boolean;
  30132. /**
  30133. * Defines if animations should run using a deterministic lock step
  30134. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30135. */
  30136. deterministicLockstep?: boolean;
  30137. /** Defines the maximum steps to use with deterministic lock step mode */
  30138. lockstepMaxSteps?: number;
  30139. /**
  30140. * Defines that engine should ignore context lost events
  30141. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30142. */
  30143. doNotHandleContextLost?: boolean;
  30144. /**
  30145. * Defines that engine should ignore modifying touch action attribute and style
  30146. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30147. */
  30148. doNotHandleTouchAction?: boolean;
  30149. /**
  30150. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30151. */
  30152. useHighPrecisionFloats?: boolean;
  30153. }
  30154. /**
  30155. * The base engine class (root of all engines)
  30156. */
  30157. export class ThinEngine {
  30158. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30159. static ExceptionList: ({
  30160. key: string;
  30161. capture: string;
  30162. captureConstraint: number;
  30163. targets: string[];
  30164. } | {
  30165. key: string;
  30166. capture: null;
  30167. captureConstraint: null;
  30168. targets: string[];
  30169. })[];
  30170. /** @hidden */
  30171. static _TextureLoaders: IInternalTextureLoader[];
  30172. /**
  30173. * Returns the current npm package of the sdk
  30174. */
  30175. static readonly NpmPackage: string;
  30176. /**
  30177. * Returns the current version of the framework
  30178. */
  30179. static readonly Version: string;
  30180. /**
  30181. * Returns a string describing the current engine
  30182. */
  30183. readonly description: string;
  30184. /**
  30185. * Gets or sets the epsilon value used by collision engine
  30186. */
  30187. static CollisionsEpsilon: number;
  30188. /**
  30189. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30190. */
  30191. static ShadersRepository: string;
  30192. /** @hidden */
  30193. _shaderProcessor: IShaderProcessor;
  30194. /**
  30195. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30196. */
  30197. forcePOTTextures: boolean;
  30198. /**
  30199. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30200. */
  30201. isFullscreen: boolean;
  30202. /**
  30203. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30204. */
  30205. cullBackFaces: boolean;
  30206. /**
  30207. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30208. */
  30209. renderEvenInBackground: boolean;
  30210. /**
  30211. * Gets or sets a boolean indicating that cache can be kept between frames
  30212. */
  30213. preventCacheWipeBetweenFrames: boolean;
  30214. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30215. validateShaderPrograms: boolean;
  30216. /**
  30217. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30218. */
  30219. disableUniformBuffers: boolean;
  30220. /** @hidden */
  30221. _uniformBuffers: UniformBuffer[];
  30222. /**
  30223. * Gets a boolean indicating that the engine supports uniform buffers
  30224. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30225. */
  30226. readonly supportsUniformBuffers: boolean;
  30227. /** @hidden */
  30228. _gl: WebGLRenderingContext;
  30229. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30230. protected _windowIsBackground: boolean;
  30231. protected _webGLVersion: number;
  30232. protected _creationOptions: EngineOptions;
  30233. protected _highPrecisionShadersAllowed: boolean;
  30234. /** @hidden */
  30235. readonly _shouldUseHighPrecisionShader: boolean;
  30236. /**
  30237. * Gets a boolean indicating that only power of 2 textures are supported
  30238. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30239. */
  30240. readonly needPOTTextures: boolean;
  30241. /** @hidden */
  30242. _badOS: boolean;
  30243. /** @hidden */
  30244. _badDesktopOS: boolean;
  30245. private _hardwareScalingLevel;
  30246. /** @hidden */
  30247. _caps: EngineCapabilities;
  30248. private _isStencilEnable;
  30249. protected _colorWrite: boolean;
  30250. private _glVersion;
  30251. private _glRenderer;
  30252. private _glVendor;
  30253. /** @hidden */
  30254. _videoTextureSupported: boolean;
  30255. protected _renderingQueueLaunched: boolean;
  30256. protected _activeRenderLoops: (() => void)[];
  30257. /**
  30258. * Observable signaled when a context lost event is raised
  30259. */
  30260. onContextLostObservable: Observable<ThinEngine>;
  30261. /**
  30262. * Observable signaled when a context restored event is raised
  30263. */
  30264. onContextRestoredObservable: Observable<ThinEngine>;
  30265. private _onContextLost;
  30266. private _onContextRestored;
  30267. protected _contextWasLost: boolean;
  30268. /** @hidden */
  30269. _doNotHandleContextLost: boolean;
  30270. /**
  30271. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30272. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30273. */
  30274. doNotHandleContextLost: boolean;
  30275. /**
  30276. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30277. */
  30278. disableVertexArrayObjects: boolean;
  30279. /** @hidden */
  30280. protected _depthCullingState: DepthCullingState;
  30281. /** @hidden */
  30282. protected _stencilState: StencilState;
  30283. /** @hidden */
  30284. protected _alphaState: AlphaState;
  30285. /** @hidden */
  30286. _internalTexturesCache: InternalTexture[];
  30287. /** @hidden */
  30288. protected _activeChannel: number;
  30289. private _currentTextureChannel;
  30290. /** @hidden */
  30291. protected _boundTexturesCache: {
  30292. [key: string]: Nullable<InternalTexture>;
  30293. };
  30294. /** @hidden */
  30295. protected _currentEffect: Nullable<Effect>;
  30296. /** @hidden */
  30297. protected _currentProgram: Nullable<WebGLProgram>;
  30298. private _compiledEffects;
  30299. private _vertexAttribArraysEnabled;
  30300. /** @hidden */
  30301. protected _cachedViewport: Nullable<IViewportLike>;
  30302. private _cachedVertexArrayObject;
  30303. /** @hidden */
  30304. protected _cachedVertexBuffers: any;
  30305. /** @hidden */
  30306. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30307. /** @hidden */
  30308. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30309. /** @hidden */
  30310. _currentRenderTarget: Nullable<InternalTexture>;
  30311. private _uintIndicesCurrentlySet;
  30312. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30313. /** @hidden */
  30314. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30315. private _currentBufferPointers;
  30316. private _currentInstanceLocations;
  30317. private _currentInstanceBuffers;
  30318. private _textureUnits;
  30319. /** @hidden */
  30320. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30321. /** @hidden */
  30322. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30323. /** @hidden */
  30324. _boundRenderFunction: any;
  30325. private _vaoRecordInProgress;
  30326. private _mustWipeVertexAttributes;
  30327. private _emptyTexture;
  30328. private _emptyCubeTexture;
  30329. private _emptyTexture3D;
  30330. private _emptyTexture2DArray;
  30331. /** @hidden */
  30332. _frameHandler: number;
  30333. private _nextFreeTextureSlots;
  30334. private _maxSimultaneousTextures;
  30335. private _activeRequests;
  30336. protected _texturesSupported: string[];
  30337. /** @hidden */
  30338. _textureFormatInUse: Nullable<string>;
  30339. protected readonly _supportsHardwareTextureRescaling: boolean;
  30340. /**
  30341. * Gets the list of texture formats supported
  30342. */
  30343. readonly texturesSupported: Array<string>;
  30344. /**
  30345. * Gets the list of texture formats in use
  30346. */
  30347. readonly textureFormatInUse: Nullable<string>;
  30348. /**
  30349. * Gets the current viewport
  30350. */
  30351. readonly currentViewport: Nullable<IViewportLike>;
  30352. /**
  30353. * Gets the default empty texture
  30354. */
  30355. readonly emptyTexture: InternalTexture;
  30356. /**
  30357. * Gets the default empty 3D texture
  30358. */
  30359. readonly emptyTexture3D: InternalTexture;
  30360. /**
  30361. * Gets the default empty 2D array texture
  30362. */
  30363. readonly emptyTexture2DArray: InternalTexture;
  30364. /**
  30365. * Gets the default empty cube texture
  30366. */
  30367. readonly emptyCubeTexture: InternalTexture;
  30368. /**
  30369. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30370. */
  30371. readonly premultipliedAlpha: boolean;
  30372. /**
  30373. * Observable event triggered before each texture is initialized
  30374. */
  30375. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30376. /**
  30377. * Creates a new engine
  30378. * @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
  30379. * @param antialias defines enable antialiasing (default: false)
  30380. * @param options defines further options to be sent to the getContext() function
  30381. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30382. */
  30383. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30384. private _rebuildInternalTextures;
  30385. private _rebuildEffects;
  30386. /**
  30387. * Gets a boolean indicating if all created effects are ready
  30388. * @returns true if all effects are ready
  30389. */
  30390. areAllEffectsReady(): boolean;
  30391. protected _rebuildBuffers(): void;
  30392. private _initGLContext;
  30393. /**
  30394. * Gets version of the current webGL context
  30395. */
  30396. readonly webGLVersion: number;
  30397. /**
  30398. * Gets a string idenfifying the name of the class
  30399. * @returns "Engine" string
  30400. */
  30401. getClassName(): string;
  30402. /**
  30403. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30404. */
  30405. readonly isStencilEnable: boolean;
  30406. /** @hidden */
  30407. _prepareWorkingCanvas(): void;
  30408. /**
  30409. * Reset the texture cache to empty state
  30410. */
  30411. resetTextureCache(): void;
  30412. /**
  30413. * Gets an object containing information about the current webGL context
  30414. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30415. */
  30416. getGlInfo(): {
  30417. vendor: string;
  30418. renderer: string;
  30419. version: string;
  30420. };
  30421. /**
  30422. * Defines the hardware scaling level.
  30423. * By default the hardware scaling level is computed from the window device ratio.
  30424. * 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.
  30425. * @param level defines the level to use
  30426. */
  30427. setHardwareScalingLevel(level: number): void;
  30428. /**
  30429. * Gets the current hardware scaling level.
  30430. * By default the hardware scaling level is computed from the window device ratio.
  30431. * 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.
  30432. * @returns a number indicating the current hardware scaling level
  30433. */
  30434. getHardwareScalingLevel(): number;
  30435. /**
  30436. * Gets the list of loaded textures
  30437. * @returns an array containing all loaded textures
  30438. */
  30439. getLoadedTexturesCache(): InternalTexture[];
  30440. /**
  30441. * Gets the object containing all engine capabilities
  30442. * @returns the EngineCapabilities object
  30443. */
  30444. getCaps(): EngineCapabilities;
  30445. /**
  30446. * stop executing a render loop function and remove it from the execution array
  30447. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30448. */
  30449. stopRenderLoop(renderFunction?: () => void): void;
  30450. /** @hidden */
  30451. _renderLoop(): void;
  30452. /**
  30453. * Gets the HTML canvas attached with the current webGL context
  30454. * @returns a HTML canvas
  30455. */
  30456. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30457. /**
  30458. * Gets host window
  30459. * @returns the host window object
  30460. */
  30461. getHostWindow(): Nullable<Window>;
  30462. /**
  30463. * Gets the current render width
  30464. * @param useScreen defines if screen size must be used (or the current render target if any)
  30465. * @returns a number defining the current render width
  30466. */
  30467. getRenderWidth(useScreen?: boolean): number;
  30468. /**
  30469. * Gets the current render height
  30470. * @param useScreen defines if screen size must be used (or the current render target if any)
  30471. * @returns a number defining the current render height
  30472. */
  30473. getRenderHeight(useScreen?: boolean): number;
  30474. /**
  30475. * Can be used to override the current requestAnimationFrame requester.
  30476. * @hidden
  30477. */
  30478. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30479. /**
  30480. * Register and execute a render loop. The engine can have more than one render function
  30481. * @param renderFunction defines the function to continuously execute
  30482. */
  30483. runRenderLoop(renderFunction: () => void): void;
  30484. /**
  30485. * Clear the current render buffer or the current render target (if any is set up)
  30486. * @param color defines the color to use
  30487. * @param backBuffer defines if the back buffer must be cleared
  30488. * @param depth defines if the depth buffer must be cleared
  30489. * @param stencil defines if the stencil buffer must be cleared
  30490. */
  30491. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30492. private _viewportCached;
  30493. /** @hidden */
  30494. _viewport(x: number, y: number, width: number, height: number): void;
  30495. /**
  30496. * Set the WebGL's viewport
  30497. * @param viewport defines the viewport element to be used
  30498. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30499. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30500. */
  30501. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30502. /**
  30503. * Begin a new frame
  30504. */
  30505. beginFrame(): void;
  30506. /**
  30507. * Enf the current frame
  30508. */
  30509. endFrame(): void;
  30510. /**
  30511. * Resize the view according to the canvas' size
  30512. */
  30513. resize(): void;
  30514. /**
  30515. * Force a specific size of the canvas
  30516. * @param width defines the new canvas' width
  30517. * @param height defines the new canvas' height
  30518. */
  30519. setSize(width: number, height: number): void;
  30520. /**
  30521. * Binds the frame buffer to the specified texture.
  30522. * @param texture The texture to render to or null for the default canvas
  30523. * @param faceIndex The face of the texture to render to in case of cube texture
  30524. * @param requiredWidth The width of the target to render to
  30525. * @param requiredHeight The height of the target to render to
  30526. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30527. * @param depthStencilTexture The depth stencil texture to use to render
  30528. * @param lodLevel defines le lod level to bind to the frame buffer
  30529. */
  30530. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30531. /** @hidden */
  30532. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30533. /**
  30534. * Unbind the current render target texture from the webGL context
  30535. * @param texture defines the render target texture to unbind
  30536. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30537. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30538. */
  30539. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30540. /**
  30541. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30542. */
  30543. flushFramebuffer(): void;
  30544. /**
  30545. * Unbind the current render target and bind the default framebuffer
  30546. */
  30547. restoreDefaultFramebuffer(): void;
  30548. /** @hidden */
  30549. protected _resetVertexBufferBinding(): void;
  30550. /**
  30551. * Creates a vertex buffer
  30552. * @param data the data for the vertex buffer
  30553. * @returns the new WebGL static buffer
  30554. */
  30555. createVertexBuffer(data: DataArray): DataBuffer;
  30556. private _createVertexBuffer;
  30557. /**
  30558. * Creates a dynamic vertex buffer
  30559. * @param data the data for the dynamic vertex buffer
  30560. * @returns the new WebGL dynamic buffer
  30561. */
  30562. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30563. protected _resetIndexBufferBinding(): void;
  30564. /**
  30565. * Creates a new index buffer
  30566. * @param indices defines the content of the index buffer
  30567. * @param updatable defines if the index buffer must be updatable
  30568. * @returns a new webGL buffer
  30569. */
  30570. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30571. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30572. /**
  30573. * Bind a webGL buffer to the webGL context
  30574. * @param buffer defines the buffer to bind
  30575. */
  30576. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30577. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30578. private bindBuffer;
  30579. /**
  30580. * update the bound buffer with the given data
  30581. * @param data defines the data to update
  30582. */
  30583. updateArrayBuffer(data: Float32Array): void;
  30584. private _vertexAttribPointer;
  30585. private _bindIndexBufferWithCache;
  30586. private _bindVertexBuffersAttributes;
  30587. /**
  30588. * Records a vertex array object
  30589. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30590. * @param vertexBuffers defines the list of vertex buffers to store
  30591. * @param indexBuffer defines the index buffer to store
  30592. * @param effect defines the effect to store
  30593. * @returns the new vertex array object
  30594. */
  30595. recordVertexArrayObject(vertexBuffers: {
  30596. [key: string]: VertexBuffer;
  30597. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30598. /**
  30599. * Bind a specific vertex array object
  30600. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30601. * @param vertexArrayObject defines the vertex array object to bind
  30602. * @param indexBuffer defines the index buffer to bind
  30603. */
  30604. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30605. /**
  30606. * Bind webGl buffers directly to the webGL context
  30607. * @param vertexBuffer defines the vertex buffer to bind
  30608. * @param indexBuffer defines the index buffer to bind
  30609. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30610. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30611. * @param effect defines the effect associated with the vertex buffer
  30612. */
  30613. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30614. private _unbindVertexArrayObject;
  30615. /**
  30616. * Bind a list of vertex buffers to the webGL context
  30617. * @param vertexBuffers defines the list of vertex buffers to bind
  30618. * @param indexBuffer defines the index buffer to bind
  30619. * @param effect defines the effect associated with the vertex buffers
  30620. */
  30621. bindBuffers(vertexBuffers: {
  30622. [key: string]: Nullable<VertexBuffer>;
  30623. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30624. /**
  30625. * Unbind all instance attributes
  30626. */
  30627. unbindInstanceAttributes(): void;
  30628. /**
  30629. * Release and free the memory of a vertex array object
  30630. * @param vao defines the vertex array object to delete
  30631. */
  30632. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30633. /** @hidden */
  30634. _releaseBuffer(buffer: DataBuffer): boolean;
  30635. protected _deleteBuffer(buffer: DataBuffer): void;
  30636. /**
  30637. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30638. * @param instancesBuffer defines the webGL buffer to update and bind
  30639. * @param data defines the data to store in the buffer
  30640. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30641. */
  30642. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30643. /**
  30644. * Apply all cached states (depth, culling, stencil and alpha)
  30645. */
  30646. applyStates(): void;
  30647. /**
  30648. * Send a draw order
  30649. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30650. * @param indexStart defines the starting index
  30651. * @param indexCount defines the number of index to draw
  30652. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30653. */
  30654. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30655. /**
  30656. * Draw a list of points
  30657. * @param verticesStart defines the index of first vertex to draw
  30658. * @param verticesCount defines the count of vertices to draw
  30659. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30660. */
  30661. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30662. /**
  30663. * Draw a list of unindexed primitives
  30664. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30665. * @param verticesStart defines the index of first vertex to draw
  30666. * @param verticesCount defines the count of vertices to draw
  30667. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30668. */
  30669. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30670. /**
  30671. * Draw a list of indexed primitives
  30672. * @param fillMode defines the primitive to use
  30673. * @param indexStart defines the starting index
  30674. * @param indexCount defines the number of index to draw
  30675. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30676. */
  30677. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30678. /**
  30679. * Draw a list of unindexed primitives
  30680. * @param fillMode defines the primitive to use
  30681. * @param verticesStart defines the index of first vertex to draw
  30682. * @param verticesCount defines the count of vertices to draw
  30683. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30684. */
  30685. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30686. private _drawMode;
  30687. /** @hidden */
  30688. protected _reportDrawCall(): void;
  30689. /** @hidden */
  30690. _releaseEffect(effect: Effect): void;
  30691. /** @hidden */
  30692. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30693. /**
  30694. * Create a new effect (used to store vertex/fragment shaders)
  30695. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30696. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30697. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30698. * @param samplers defines an array of string used to represent textures
  30699. * @param defines defines the string containing the defines to use to compile the shaders
  30700. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30701. * @param onCompiled defines a function to call when the effect creation is successful
  30702. * @param onError defines a function to call when the effect creation has failed
  30703. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30704. * @returns the new Effect
  30705. */
  30706. 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;
  30707. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30708. private _compileShader;
  30709. private _compileRawShader;
  30710. /**
  30711. * Directly creates a webGL program
  30712. * @param pipelineContext defines the pipeline context to attach to
  30713. * @param vertexCode defines the vertex shader code to use
  30714. * @param fragmentCode defines the fragment shader code to use
  30715. * @param context defines the webGL context to use (if not set, the current one will be used)
  30716. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30717. * @returns the new webGL program
  30718. */
  30719. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30720. /**
  30721. * Creates a webGL program
  30722. * @param pipelineContext defines the pipeline context to attach to
  30723. * @param vertexCode defines the vertex shader code to use
  30724. * @param fragmentCode defines the fragment shader code to use
  30725. * @param defines defines the string containing the defines to use to compile the shaders
  30726. * @param context defines the webGL context to use (if not set, the current one will be used)
  30727. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30728. * @returns the new webGL program
  30729. */
  30730. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30731. /**
  30732. * Creates a new pipeline context
  30733. * @returns the new pipeline
  30734. */
  30735. createPipelineContext(): IPipelineContext;
  30736. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30737. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30738. /** @hidden */
  30739. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30740. /** @hidden */
  30741. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30742. /** @hidden */
  30743. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30744. /**
  30745. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30746. * @param pipelineContext defines the pipeline context to use
  30747. * @param uniformsNames defines the list of uniform names
  30748. * @returns an array of webGL uniform locations
  30749. */
  30750. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30751. /**
  30752. * Gets the lsit of active attributes for a given webGL program
  30753. * @param pipelineContext defines the pipeline context to use
  30754. * @param attributesNames defines the list of attribute names to get
  30755. * @returns an array of indices indicating the offset of each attribute
  30756. */
  30757. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30758. /**
  30759. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30760. * @param effect defines the effect to activate
  30761. */
  30762. enableEffect(effect: Nullable<Effect>): void;
  30763. /**
  30764. * Set the value of an uniform to a number (int)
  30765. * @param uniform defines the webGL uniform location where to store the value
  30766. * @param value defines the int number to store
  30767. */
  30768. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30769. /**
  30770. * Set the value of an uniform to an array of int32
  30771. * @param uniform defines the webGL uniform location where to store the value
  30772. * @param array defines the array of int32 to store
  30773. */
  30774. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30775. /**
  30776. * Set the value of an uniform to an array of int32 (stored as vec2)
  30777. * @param uniform defines the webGL uniform location where to store the value
  30778. * @param array defines the array of int32 to store
  30779. */
  30780. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30781. /**
  30782. * Set the value of an uniform to an array of int32 (stored as vec3)
  30783. * @param uniform defines the webGL uniform location where to store the value
  30784. * @param array defines the array of int32 to store
  30785. */
  30786. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30787. /**
  30788. * Set the value of an uniform to an array of int32 (stored as vec4)
  30789. * @param uniform defines the webGL uniform location where to store the value
  30790. * @param array defines the array of int32 to store
  30791. */
  30792. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30793. /**
  30794. * Set the value of an uniform to an array of number
  30795. * @param uniform defines the webGL uniform location where to store the value
  30796. * @param array defines the array of number to store
  30797. */
  30798. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30799. /**
  30800. * Set the value of an uniform to an array of number (stored as vec2)
  30801. * @param uniform defines the webGL uniform location where to store the value
  30802. * @param array defines the array of number to store
  30803. */
  30804. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30805. /**
  30806. * Set the value of an uniform to an array of number (stored as vec3)
  30807. * @param uniform defines the webGL uniform location where to store the value
  30808. * @param array defines the array of number to store
  30809. */
  30810. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30811. /**
  30812. * Set the value of an uniform to an array of number (stored as vec4)
  30813. * @param uniform defines the webGL uniform location where to store the value
  30814. * @param array defines the array of number to store
  30815. */
  30816. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30817. /**
  30818. * Set the value of an uniform to an array of float32 (stored as matrices)
  30819. * @param uniform defines the webGL uniform location where to store the value
  30820. * @param matrices defines the array of float32 to store
  30821. */
  30822. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30823. /**
  30824. * Set the value of an uniform to a matrix (3x3)
  30825. * @param uniform defines the webGL uniform location where to store the value
  30826. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30827. */
  30828. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30829. /**
  30830. * Set the value of an uniform to a matrix (2x2)
  30831. * @param uniform defines the webGL uniform location where to store the value
  30832. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30833. */
  30834. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30835. /**
  30836. * Set the value of an uniform to a number (float)
  30837. * @param uniform defines the webGL uniform location where to store the value
  30838. * @param value defines the float number to store
  30839. */
  30840. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30841. /**
  30842. * Set the value of an uniform to a vec2
  30843. * @param uniform defines the webGL uniform location where to store the value
  30844. * @param x defines the 1st component of the value
  30845. * @param y defines the 2nd component of the value
  30846. */
  30847. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30848. /**
  30849. * Set the value of an uniform to a vec3
  30850. * @param uniform defines the webGL uniform location where to store the value
  30851. * @param x defines the 1st component of the value
  30852. * @param y defines the 2nd component of the value
  30853. * @param z defines the 3rd component of the value
  30854. */
  30855. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30856. /**
  30857. * Set the value of an uniform to a vec4
  30858. * @param uniform defines the webGL uniform location where to store the value
  30859. * @param x defines the 1st component of the value
  30860. * @param y defines the 2nd component of the value
  30861. * @param z defines the 3rd component of the value
  30862. * @param w defines the 4th component of the value
  30863. */
  30864. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30865. /**
  30866. * Gets the depth culling state manager
  30867. */
  30868. readonly depthCullingState: DepthCullingState;
  30869. /**
  30870. * Gets the alpha state manager
  30871. */
  30872. readonly alphaState: AlphaState;
  30873. /**
  30874. * Gets the stencil state manager
  30875. */
  30876. readonly stencilState: StencilState;
  30877. /**
  30878. * Clears the list of texture accessible through engine.
  30879. * This can help preventing texture load conflict due to name collision.
  30880. */
  30881. clearInternalTexturesCache(): void;
  30882. /**
  30883. * Force the entire cache to be cleared
  30884. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30885. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30886. */
  30887. wipeCaches(bruteForce?: boolean): void;
  30888. /** @hidden */
  30889. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30890. min: number;
  30891. mag: number;
  30892. };
  30893. /** @hidden */
  30894. _createTexture(): WebGLTexture;
  30895. /**
  30896. * Usually called from Texture.ts.
  30897. * Passed information to create a WebGLTexture
  30898. * @param urlArg defines a value which contains one of the following:
  30899. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30900. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30901. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30902. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30903. * @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)
  30904. * @param scene needed for loading to the correct scene
  30905. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30906. * @param onLoad optional callback to be called upon successful completion
  30907. * @param onError optional callback to be called upon failure
  30908. * @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
  30909. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30910. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30911. * @param forcedExtension defines the extension to use to pick the right loader
  30912. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30913. * @param mimeType defines an optional mime type
  30914. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30915. */
  30916. 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;
  30917. /**
  30918. * @hidden
  30919. */
  30920. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30921. /**
  30922. * Creates a raw texture
  30923. * @param data defines the data to store in the texture
  30924. * @param width defines the width of the texture
  30925. * @param height defines the height of the texture
  30926. * @param format defines the format of the data
  30927. * @param generateMipMaps defines if the engine should generate the mip levels
  30928. * @param invertY defines if data must be stored with Y axis inverted
  30929. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30930. * @param compression defines the compression used (null by default)
  30931. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30932. * @returns the raw texture inside an InternalTexture
  30933. */
  30934. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30935. /**
  30936. * Creates a new raw cube texture
  30937. * @param data defines the array of data to use to create each face
  30938. * @param size defines the size of the textures
  30939. * @param format defines the format of the data
  30940. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30941. * @param generateMipMaps defines if the engine should generate the mip levels
  30942. * @param invertY defines if data must be stored with Y axis inverted
  30943. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30944. * @param compression defines the compression used (null by default)
  30945. * @returns the cube texture as an InternalTexture
  30946. */
  30947. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30948. /**
  30949. * Creates a new raw 3D texture
  30950. * @param data defines the data used to create the texture
  30951. * @param width defines the width of the texture
  30952. * @param height defines the height of the texture
  30953. * @param depth defines the depth of the texture
  30954. * @param format defines the format of the texture
  30955. * @param generateMipMaps defines if the engine must generate mip levels
  30956. * @param invertY defines if data must be stored with Y axis inverted
  30957. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30958. * @param compression defines the compressed used (can be null)
  30959. * @param textureType defines the compressed used (can be null)
  30960. * @returns a new raw 3D texture (stored in an InternalTexture)
  30961. */
  30962. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30963. /**
  30964. * Creates a new raw 2D array texture
  30965. * @param data defines the data used to create the texture
  30966. * @param width defines the width of the texture
  30967. * @param height defines the height of the texture
  30968. * @param depth defines the number of layers of the texture
  30969. * @param format defines the format of the texture
  30970. * @param generateMipMaps defines if the engine must generate mip levels
  30971. * @param invertY defines if data must be stored with Y axis inverted
  30972. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30973. * @param compression defines the compressed used (can be null)
  30974. * @param textureType defines the compressed used (can be null)
  30975. * @returns a new raw 2D array texture (stored in an InternalTexture)
  30976. */
  30977. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30978. private _unpackFlipYCached;
  30979. /**
  30980. * In case you are sharing the context with other applications, it might
  30981. * be interested to not cache the unpack flip y state to ensure a consistent
  30982. * value would be set.
  30983. */
  30984. enableUnpackFlipYCached: boolean;
  30985. /** @hidden */
  30986. _unpackFlipY(value: boolean): void;
  30987. /** @hidden */
  30988. _getUnpackAlignement(): number;
  30989. /**
  30990. * Update the sampling mode of a given texture
  30991. * @param samplingMode defines the required sampling mode
  30992. * @param texture defines the texture to update
  30993. */
  30994. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30995. /** @hidden */
  30996. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30997. width: number;
  30998. height: number;
  30999. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31000. /** @hidden */
  31001. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31002. /** @hidden */
  31003. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31004. /** @hidden */
  31005. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31006. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31007. private _prepareWebGLTexture;
  31008. /** @hidden */
  31009. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31010. /** @hidden */
  31011. _releaseFramebufferObjects(texture: InternalTexture): void;
  31012. /** @hidden */
  31013. _releaseTexture(texture: InternalTexture): void;
  31014. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31015. protected _setProgram(program: WebGLProgram): void;
  31016. protected _boundUniforms: {
  31017. [key: number]: WebGLUniformLocation;
  31018. };
  31019. /**
  31020. * Binds an effect to the webGL context
  31021. * @param effect defines the effect to bind
  31022. */
  31023. bindSamplers(effect: Effect): void;
  31024. private _activateCurrentTexture;
  31025. /** @hidden */
  31026. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31027. /** @hidden */
  31028. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31029. /**
  31030. * Unbind all textures from the webGL context
  31031. */
  31032. unbindAllTextures(): void;
  31033. /**
  31034. * Sets a texture to the according uniform.
  31035. * @param channel The texture channel
  31036. * @param uniform The uniform to set
  31037. * @param texture The texture to apply
  31038. */
  31039. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31040. private _bindSamplerUniformToChannel;
  31041. private _getTextureWrapMode;
  31042. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31043. /**
  31044. * Sets an array of texture to the webGL context
  31045. * @param channel defines the channel where the texture array must be set
  31046. * @param uniform defines the associated uniform location
  31047. * @param textures defines the array of textures to bind
  31048. */
  31049. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31050. /** @hidden */
  31051. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31052. private _setTextureParameterFloat;
  31053. private _setTextureParameterInteger;
  31054. /**
  31055. * Unbind all vertex attributes from the webGL context
  31056. */
  31057. unbindAllAttributes(): void;
  31058. /**
  31059. * 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
  31060. */
  31061. releaseEffects(): void;
  31062. /**
  31063. * Dispose and release all associated resources
  31064. */
  31065. dispose(): void;
  31066. /**
  31067. * Attach a new callback raised when context lost event is fired
  31068. * @param callback defines the callback to call
  31069. */
  31070. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31071. /**
  31072. * Attach a new callback raised when context restored event is fired
  31073. * @param callback defines the callback to call
  31074. */
  31075. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31076. /**
  31077. * Get the current error code of the webGL context
  31078. * @returns the error code
  31079. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31080. */
  31081. getError(): number;
  31082. private _canRenderToFloatFramebuffer;
  31083. private _canRenderToHalfFloatFramebuffer;
  31084. private _canRenderToFramebuffer;
  31085. /** @hidden */
  31086. _getWebGLTextureType(type: number): number;
  31087. /** @hidden */
  31088. _getInternalFormat(format: number): number;
  31089. /** @hidden */
  31090. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31091. /** @hidden */
  31092. _getRGBAMultiSampleBufferFormat(type: number): number;
  31093. /** @hidden */
  31094. _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;
  31095. /**
  31096. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31097. * @returns true if the engine can be created
  31098. * @ignorenaming
  31099. */
  31100. static isSupported(): boolean;
  31101. /**
  31102. * Find the next highest power of two.
  31103. * @param x Number to start search from.
  31104. * @return Next highest power of two.
  31105. */
  31106. static CeilingPOT(x: number): number;
  31107. /**
  31108. * Find the next lowest power of two.
  31109. * @param x Number to start search from.
  31110. * @return Next lowest power of two.
  31111. */
  31112. static FloorPOT(x: number): number;
  31113. /**
  31114. * Find the nearest power of two.
  31115. * @param x Number to start search from.
  31116. * @return Next nearest power of two.
  31117. */
  31118. static NearestPOT(x: number): number;
  31119. /**
  31120. * Get the closest exponent of two
  31121. * @param value defines the value to approximate
  31122. * @param max defines the maximum value to return
  31123. * @param mode defines how to define the closest value
  31124. * @returns closest exponent of two of the given value
  31125. */
  31126. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31127. /**
  31128. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31129. * @param func - the function to be called
  31130. * @param requester - the object that will request the next frame. Falls back to window.
  31131. * @returns frame number
  31132. */
  31133. static QueueNewFrame(func: () => void, requester?: any): number;
  31134. }
  31135. }
  31136. declare module "babylonjs/Maths/sphericalPolynomial" {
  31137. import { Vector3 } from "babylonjs/Maths/math.vector";
  31138. import { Color3 } from "babylonjs/Maths/math.color";
  31139. /**
  31140. * Class representing spherical harmonics coefficients to the 3rd degree
  31141. */
  31142. export class SphericalHarmonics {
  31143. /**
  31144. * Defines whether or not the harmonics have been prescaled for rendering.
  31145. */
  31146. preScaled: boolean;
  31147. /**
  31148. * The l0,0 coefficients of the spherical harmonics
  31149. */
  31150. l00: Vector3;
  31151. /**
  31152. * The l1,-1 coefficients of the spherical harmonics
  31153. */
  31154. l1_1: Vector3;
  31155. /**
  31156. * The l1,0 coefficients of the spherical harmonics
  31157. */
  31158. l10: Vector3;
  31159. /**
  31160. * The l1,1 coefficients of the spherical harmonics
  31161. */
  31162. l11: Vector3;
  31163. /**
  31164. * The l2,-2 coefficients of the spherical harmonics
  31165. */
  31166. l2_2: Vector3;
  31167. /**
  31168. * The l2,-1 coefficients of the spherical harmonics
  31169. */
  31170. l2_1: Vector3;
  31171. /**
  31172. * The l2,0 coefficients of the spherical harmonics
  31173. */
  31174. l20: Vector3;
  31175. /**
  31176. * The l2,1 coefficients of the spherical harmonics
  31177. */
  31178. l21: Vector3;
  31179. /**
  31180. * The l2,2 coefficients of the spherical harmonics
  31181. */
  31182. l22: Vector3;
  31183. /**
  31184. * Adds a light to the spherical harmonics
  31185. * @param direction the direction of the light
  31186. * @param color the color of the light
  31187. * @param deltaSolidAngle the delta solid angle of the light
  31188. */
  31189. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31190. /**
  31191. * Scales the spherical harmonics by the given amount
  31192. * @param scale the amount to scale
  31193. */
  31194. scaleInPlace(scale: number): void;
  31195. /**
  31196. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31197. *
  31198. * ```
  31199. * E_lm = A_l * L_lm
  31200. * ```
  31201. *
  31202. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31203. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31204. * the scaling factors are given in equation 9.
  31205. */
  31206. convertIncidentRadianceToIrradiance(): void;
  31207. /**
  31208. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31209. *
  31210. * ```
  31211. * L = (1/pi) * E * rho
  31212. * ```
  31213. *
  31214. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31215. */
  31216. convertIrradianceToLambertianRadiance(): void;
  31217. /**
  31218. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31219. * required operations at run time.
  31220. *
  31221. * This is simply done by scaling back the SH with Ylm constants parameter.
  31222. * The trigonometric part being applied by the shader at run time.
  31223. */
  31224. preScaleForRendering(): void;
  31225. /**
  31226. * Constructs a spherical harmonics from an array.
  31227. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31228. * @returns the spherical harmonics
  31229. */
  31230. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31231. /**
  31232. * Gets the spherical harmonics from polynomial
  31233. * @param polynomial the spherical polynomial
  31234. * @returns the spherical harmonics
  31235. */
  31236. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31237. }
  31238. /**
  31239. * Class representing spherical polynomial coefficients to the 3rd degree
  31240. */
  31241. export class SphericalPolynomial {
  31242. private _harmonics;
  31243. /**
  31244. * The spherical harmonics used to create the polynomials.
  31245. */
  31246. readonly preScaledHarmonics: SphericalHarmonics;
  31247. /**
  31248. * The x coefficients of the spherical polynomial
  31249. */
  31250. x: Vector3;
  31251. /**
  31252. * The y coefficients of the spherical polynomial
  31253. */
  31254. y: Vector3;
  31255. /**
  31256. * The z coefficients of the spherical polynomial
  31257. */
  31258. z: Vector3;
  31259. /**
  31260. * The xx coefficients of the spherical polynomial
  31261. */
  31262. xx: Vector3;
  31263. /**
  31264. * The yy coefficients of the spherical polynomial
  31265. */
  31266. yy: Vector3;
  31267. /**
  31268. * The zz coefficients of the spherical polynomial
  31269. */
  31270. zz: Vector3;
  31271. /**
  31272. * The xy coefficients of the spherical polynomial
  31273. */
  31274. xy: Vector3;
  31275. /**
  31276. * The yz coefficients of the spherical polynomial
  31277. */
  31278. yz: Vector3;
  31279. /**
  31280. * The zx coefficients of the spherical polynomial
  31281. */
  31282. zx: Vector3;
  31283. /**
  31284. * Adds an ambient color to the spherical polynomial
  31285. * @param color the color to add
  31286. */
  31287. addAmbient(color: Color3): void;
  31288. /**
  31289. * Scales the spherical polynomial by the given amount
  31290. * @param scale the amount to scale
  31291. */
  31292. scaleInPlace(scale: number): void;
  31293. /**
  31294. * Gets the spherical polynomial from harmonics
  31295. * @param harmonics the spherical harmonics
  31296. * @returns the spherical polynomial
  31297. */
  31298. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31299. /**
  31300. * Constructs a spherical polynomial from an array.
  31301. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31302. * @returns the spherical polynomial
  31303. */
  31304. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31305. }
  31306. }
  31307. declare module "babylonjs/Materials/Textures/internalTexture" {
  31308. import { Observable } from "babylonjs/Misc/observable";
  31309. import { Nullable, int } from "babylonjs/types";
  31310. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31311. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31312. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31313. /**
  31314. * Defines the source of the internal texture
  31315. */
  31316. export enum InternalTextureSource {
  31317. /**
  31318. * The source of the texture data is unknown
  31319. */
  31320. Unknown = 0,
  31321. /**
  31322. * Texture data comes from an URL
  31323. */
  31324. Url = 1,
  31325. /**
  31326. * Texture data is only used for temporary storage
  31327. */
  31328. Temp = 2,
  31329. /**
  31330. * Texture data comes from raw data (ArrayBuffer)
  31331. */
  31332. Raw = 3,
  31333. /**
  31334. * Texture content is dynamic (video or dynamic texture)
  31335. */
  31336. Dynamic = 4,
  31337. /**
  31338. * Texture content is generated by rendering to it
  31339. */
  31340. RenderTarget = 5,
  31341. /**
  31342. * Texture content is part of a multi render target process
  31343. */
  31344. MultiRenderTarget = 6,
  31345. /**
  31346. * Texture data comes from a cube data file
  31347. */
  31348. Cube = 7,
  31349. /**
  31350. * Texture data comes from a raw cube data
  31351. */
  31352. CubeRaw = 8,
  31353. /**
  31354. * Texture data come from a prefiltered cube data file
  31355. */
  31356. CubePrefiltered = 9,
  31357. /**
  31358. * Texture content is raw 3D data
  31359. */
  31360. Raw3D = 10,
  31361. /**
  31362. * Texture content is raw 2D array data
  31363. */
  31364. Raw2DArray = 11,
  31365. /**
  31366. * Texture content is a depth texture
  31367. */
  31368. Depth = 12,
  31369. /**
  31370. * Texture data comes from a raw cube data encoded with RGBD
  31371. */
  31372. CubeRawRGBD = 13
  31373. }
  31374. /**
  31375. * Class used to store data associated with WebGL texture data for the engine
  31376. * This class should not be used directly
  31377. */
  31378. export class InternalTexture {
  31379. /** @hidden */
  31380. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31381. /**
  31382. * Defines if the texture is ready
  31383. */
  31384. isReady: boolean;
  31385. /**
  31386. * Defines if the texture is a cube texture
  31387. */
  31388. isCube: boolean;
  31389. /**
  31390. * Defines if the texture contains 3D data
  31391. */
  31392. is3D: boolean;
  31393. /**
  31394. * Defines if the texture contains 2D array data
  31395. */
  31396. is2DArray: boolean;
  31397. /**
  31398. * Defines if the texture contains multiview data
  31399. */
  31400. isMultiview: boolean;
  31401. /**
  31402. * Gets the URL used to load this texture
  31403. */
  31404. url: string;
  31405. /**
  31406. * Gets the sampling mode of the texture
  31407. */
  31408. samplingMode: number;
  31409. /**
  31410. * Gets a boolean indicating if the texture needs mipmaps generation
  31411. */
  31412. generateMipMaps: boolean;
  31413. /**
  31414. * Gets the number of samples used by the texture (WebGL2+ only)
  31415. */
  31416. samples: number;
  31417. /**
  31418. * Gets the type of the texture (int, float...)
  31419. */
  31420. type: number;
  31421. /**
  31422. * Gets the format of the texture (RGB, RGBA...)
  31423. */
  31424. format: number;
  31425. /**
  31426. * Observable called when the texture is loaded
  31427. */
  31428. onLoadedObservable: Observable<InternalTexture>;
  31429. /**
  31430. * Gets the width of the texture
  31431. */
  31432. width: number;
  31433. /**
  31434. * Gets the height of the texture
  31435. */
  31436. height: number;
  31437. /**
  31438. * Gets the depth of the texture
  31439. */
  31440. depth: number;
  31441. /**
  31442. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31443. */
  31444. baseWidth: number;
  31445. /**
  31446. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31447. */
  31448. baseHeight: number;
  31449. /**
  31450. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31451. */
  31452. baseDepth: number;
  31453. /**
  31454. * Gets a boolean indicating if the texture is inverted on Y axis
  31455. */
  31456. invertY: boolean;
  31457. /** @hidden */
  31458. _invertVScale: boolean;
  31459. /** @hidden */
  31460. _associatedChannel: number;
  31461. /** @hidden */
  31462. _source: InternalTextureSource;
  31463. /** @hidden */
  31464. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31465. /** @hidden */
  31466. _bufferView: Nullable<ArrayBufferView>;
  31467. /** @hidden */
  31468. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31469. /** @hidden */
  31470. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31471. /** @hidden */
  31472. _size: number;
  31473. /** @hidden */
  31474. _extension: string;
  31475. /** @hidden */
  31476. _files: Nullable<string[]>;
  31477. /** @hidden */
  31478. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31479. /** @hidden */
  31480. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31481. /** @hidden */
  31482. _framebuffer: Nullable<WebGLFramebuffer>;
  31483. /** @hidden */
  31484. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31485. /** @hidden */
  31486. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31487. /** @hidden */
  31488. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31489. /** @hidden */
  31490. _attachments: Nullable<number[]>;
  31491. /** @hidden */
  31492. _cachedCoordinatesMode: Nullable<number>;
  31493. /** @hidden */
  31494. _cachedWrapU: Nullable<number>;
  31495. /** @hidden */
  31496. _cachedWrapV: Nullable<number>;
  31497. /** @hidden */
  31498. _cachedWrapR: Nullable<number>;
  31499. /** @hidden */
  31500. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31501. /** @hidden */
  31502. _isDisabled: boolean;
  31503. /** @hidden */
  31504. _compression: Nullable<string>;
  31505. /** @hidden */
  31506. _generateStencilBuffer: boolean;
  31507. /** @hidden */
  31508. _generateDepthBuffer: boolean;
  31509. /** @hidden */
  31510. _comparisonFunction: number;
  31511. /** @hidden */
  31512. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31513. /** @hidden */
  31514. _lodGenerationScale: number;
  31515. /** @hidden */
  31516. _lodGenerationOffset: number;
  31517. /** @hidden */
  31518. _colorTextureArray: Nullable<WebGLTexture>;
  31519. /** @hidden */
  31520. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31521. /** @hidden */
  31522. _lodTextureHigh: Nullable<BaseTexture>;
  31523. /** @hidden */
  31524. _lodTextureMid: Nullable<BaseTexture>;
  31525. /** @hidden */
  31526. _lodTextureLow: Nullable<BaseTexture>;
  31527. /** @hidden */
  31528. _isRGBD: boolean;
  31529. /** @hidden */
  31530. _linearSpecularLOD: boolean;
  31531. /** @hidden */
  31532. _irradianceTexture: Nullable<BaseTexture>;
  31533. /** @hidden */
  31534. _webGLTexture: Nullable<WebGLTexture>;
  31535. /** @hidden */
  31536. _references: number;
  31537. private _engine;
  31538. /**
  31539. * Gets the Engine the texture belongs to.
  31540. * @returns The babylon engine
  31541. */
  31542. getEngine(): ThinEngine;
  31543. /**
  31544. * Gets the data source type of the texture
  31545. */
  31546. readonly source: InternalTextureSource;
  31547. /**
  31548. * Creates a new InternalTexture
  31549. * @param engine defines the engine to use
  31550. * @param source defines the type of data that will be used
  31551. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31552. */
  31553. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31554. /**
  31555. * Increments the number of references (ie. the number of Texture that point to it)
  31556. */
  31557. incrementReferences(): void;
  31558. /**
  31559. * Change the size of the texture (not the size of the content)
  31560. * @param width defines the new width
  31561. * @param height defines the new height
  31562. * @param depth defines the new depth (1 by default)
  31563. */
  31564. updateSize(width: int, height: int, depth?: int): void;
  31565. /** @hidden */
  31566. _rebuild(): void;
  31567. /** @hidden */
  31568. _swapAndDie(target: InternalTexture): void;
  31569. /**
  31570. * Dispose the current allocated resources
  31571. */
  31572. dispose(): void;
  31573. }
  31574. }
  31575. declare module "babylonjs/Audio/analyser" {
  31576. import { Scene } from "babylonjs/scene";
  31577. /**
  31578. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31579. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31580. */
  31581. export class Analyser {
  31582. /**
  31583. * Gets or sets the smoothing
  31584. * @ignorenaming
  31585. */
  31586. SMOOTHING: number;
  31587. /**
  31588. * Gets or sets the FFT table size
  31589. * @ignorenaming
  31590. */
  31591. FFT_SIZE: number;
  31592. /**
  31593. * Gets or sets the bar graph amplitude
  31594. * @ignorenaming
  31595. */
  31596. BARGRAPHAMPLITUDE: number;
  31597. /**
  31598. * Gets or sets the position of the debug canvas
  31599. * @ignorenaming
  31600. */
  31601. DEBUGCANVASPOS: {
  31602. x: number;
  31603. y: number;
  31604. };
  31605. /**
  31606. * Gets or sets the debug canvas size
  31607. * @ignorenaming
  31608. */
  31609. DEBUGCANVASSIZE: {
  31610. width: number;
  31611. height: number;
  31612. };
  31613. private _byteFreqs;
  31614. private _byteTime;
  31615. private _floatFreqs;
  31616. private _webAudioAnalyser;
  31617. private _debugCanvas;
  31618. private _debugCanvasContext;
  31619. private _scene;
  31620. private _registerFunc;
  31621. private _audioEngine;
  31622. /**
  31623. * Creates a new analyser
  31624. * @param scene defines hosting scene
  31625. */
  31626. constructor(scene: Scene);
  31627. /**
  31628. * Get the number of data values you will have to play with for the visualization
  31629. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31630. * @returns a number
  31631. */
  31632. getFrequencyBinCount(): number;
  31633. /**
  31634. * Gets the current frequency data as a byte array
  31635. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31636. * @returns a Uint8Array
  31637. */
  31638. getByteFrequencyData(): Uint8Array;
  31639. /**
  31640. * Gets the current waveform as a byte array
  31641. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31642. * @returns a Uint8Array
  31643. */
  31644. getByteTimeDomainData(): Uint8Array;
  31645. /**
  31646. * Gets the current frequency data as a float array
  31647. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31648. * @returns a Float32Array
  31649. */
  31650. getFloatFrequencyData(): Float32Array;
  31651. /**
  31652. * Renders the debug canvas
  31653. */
  31654. drawDebugCanvas(): void;
  31655. /**
  31656. * Stops rendering the debug canvas and removes it
  31657. */
  31658. stopDebugCanvas(): void;
  31659. /**
  31660. * Connects two audio nodes
  31661. * @param inputAudioNode defines first node to connect
  31662. * @param outputAudioNode defines second node to connect
  31663. */
  31664. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31665. /**
  31666. * Releases all associated resources
  31667. */
  31668. dispose(): void;
  31669. }
  31670. }
  31671. declare module "babylonjs/Audio/audioEngine" {
  31672. import { IDisposable } from "babylonjs/scene";
  31673. import { Analyser } from "babylonjs/Audio/analyser";
  31674. import { Nullable } from "babylonjs/types";
  31675. import { Observable } from "babylonjs/Misc/observable";
  31676. /**
  31677. * This represents an audio engine and it is responsible
  31678. * to play, synchronize and analyse sounds throughout the application.
  31679. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31680. */
  31681. export interface IAudioEngine extends IDisposable {
  31682. /**
  31683. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31684. */
  31685. readonly canUseWebAudio: boolean;
  31686. /**
  31687. * Gets the current AudioContext if available.
  31688. */
  31689. readonly audioContext: Nullable<AudioContext>;
  31690. /**
  31691. * The master gain node defines the global audio volume of your audio engine.
  31692. */
  31693. readonly masterGain: GainNode;
  31694. /**
  31695. * Gets whether or not mp3 are supported by your browser.
  31696. */
  31697. readonly isMP3supported: boolean;
  31698. /**
  31699. * Gets whether or not ogg are supported by your browser.
  31700. */
  31701. readonly isOGGsupported: boolean;
  31702. /**
  31703. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31704. * @ignoreNaming
  31705. */
  31706. WarnedWebAudioUnsupported: boolean;
  31707. /**
  31708. * Defines if the audio engine relies on a custom unlocked button.
  31709. * In this case, the embedded button will not be displayed.
  31710. */
  31711. useCustomUnlockedButton: boolean;
  31712. /**
  31713. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31714. */
  31715. readonly unlocked: boolean;
  31716. /**
  31717. * Event raised when audio has been unlocked on the browser.
  31718. */
  31719. onAudioUnlockedObservable: Observable<AudioEngine>;
  31720. /**
  31721. * Event raised when audio has been locked on the browser.
  31722. */
  31723. onAudioLockedObservable: Observable<AudioEngine>;
  31724. /**
  31725. * Flags the audio engine in Locked state.
  31726. * This happens due to new browser policies preventing audio to autoplay.
  31727. */
  31728. lock(): void;
  31729. /**
  31730. * Unlocks the audio engine once a user action has been done on the dom.
  31731. * This is helpful to resume play once browser policies have been satisfied.
  31732. */
  31733. unlock(): void;
  31734. }
  31735. /**
  31736. * This represents the default audio engine used in babylon.
  31737. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31738. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31739. */
  31740. export class AudioEngine implements IAudioEngine {
  31741. private _audioContext;
  31742. private _audioContextInitialized;
  31743. private _muteButton;
  31744. private _hostElement;
  31745. /**
  31746. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31747. */
  31748. canUseWebAudio: boolean;
  31749. /**
  31750. * The master gain node defines the global audio volume of your audio engine.
  31751. */
  31752. masterGain: GainNode;
  31753. /**
  31754. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31755. * @ignoreNaming
  31756. */
  31757. WarnedWebAudioUnsupported: boolean;
  31758. /**
  31759. * Gets whether or not mp3 are supported by your browser.
  31760. */
  31761. isMP3supported: boolean;
  31762. /**
  31763. * Gets whether or not ogg are supported by your browser.
  31764. */
  31765. isOGGsupported: boolean;
  31766. /**
  31767. * Gets whether audio has been unlocked on the device.
  31768. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31769. * a user interaction has happened.
  31770. */
  31771. unlocked: boolean;
  31772. /**
  31773. * Defines if the audio engine relies on a custom unlocked button.
  31774. * In this case, the embedded button will not be displayed.
  31775. */
  31776. useCustomUnlockedButton: boolean;
  31777. /**
  31778. * Event raised when audio has been unlocked on the browser.
  31779. */
  31780. onAudioUnlockedObservable: Observable<AudioEngine>;
  31781. /**
  31782. * Event raised when audio has been locked on the browser.
  31783. */
  31784. onAudioLockedObservable: Observable<AudioEngine>;
  31785. /**
  31786. * Gets the current AudioContext if available.
  31787. */
  31788. readonly audioContext: Nullable<AudioContext>;
  31789. private _connectedAnalyser;
  31790. /**
  31791. * Instantiates a new audio engine.
  31792. *
  31793. * There should be only one per page as some browsers restrict the number
  31794. * of audio contexts you can create.
  31795. * @param hostElement defines the host element where to display the mute icon if necessary
  31796. */
  31797. constructor(hostElement?: Nullable<HTMLElement>);
  31798. /**
  31799. * Flags the audio engine in Locked state.
  31800. * This happens due to new browser policies preventing audio to autoplay.
  31801. */
  31802. lock(): void;
  31803. /**
  31804. * Unlocks the audio engine once a user action has been done on the dom.
  31805. * This is helpful to resume play once browser policies have been satisfied.
  31806. */
  31807. unlock(): void;
  31808. private _resumeAudioContext;
  31809. private _initializeAudioContext;
  31810. private _tryToRun;
  31811. private _triggerRunningState;
  31812. private _triggerSuspendedState;
  31813. private _displayMuteButton;
  31814. private _moveButtonToTopLeft;
  31815. private _onResize;
  31816. private _hideMuteButton;
  31817. /**
  31818. * Destroy and release the resources associated with the audio ccontext.
  31819. */
  31820. dispose(): void;
  31821. /**
  31822. * Gets the global volume sets on the master gain.
  31823. * @returns the global volume if set or -1 otherwise
  31824. */
  31825. getGlobalVolume(): number;
  31826. /**
  31827. * Sets the global volume of your experience (sets on the master gain).
  31828. * @param newVolume Defines the new global volume of the application
  31829. */
  31830. setGlobalVolume(newVolume: number): void;
  31831. /**
  31832. * Connect the audio engine to an audio analyser allowing some amazing
  31833. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31834. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31835. * @param analyser The analyser to connect to the engine
  31836. */
  31837. connectToAnalyser(analyser: Analyser): void;
  31838. }
  31839. }
  31840. declare module "babylonjs/Loading/loadingScreen" {
  31841. /**
  31842. * Interface used to present a loading screen while loading a scene
  31843. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31844. */
  31845. export interface ILoadingScreen {
  31846. /**
  31847. * Function called to display the loading screen
  31848. */
  31849. displayLoadingUI: () => void;
  31850. /**
  31851. * Function called to hide the loading screen
  31852. */
  31853. hideLoadingUI: () => void;
  31854. /**
  31855. * Gets or sets the color to use for the background
  31856. */
  31857. loadingUIBackgroundColor: string;
  31858. /**
  31859. * Gets or sets the text to display while loading
  31860. */
  31861. loadingUIText: string;
  31862. }
  31863. /**
  31864. * Class used for the default loading screen
  31865. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31866. */
  31867. export class DefaultLoadingScreen implements ILoadingScreen {
  31868. private _renderingCanvas;
  31869. private _loadingText;
  31870. private _loadingDivBackgroundColor;
  31871. private _loadingDiv;
  31872. private _loadingTextDiv;
  31873. /** Gets or sets the logo url to use for the default loading screen */
  31874. static DefaultLogoUrl: string;
  31875. /** Gets or sets the spinner url to use for the default loading screen */
  31876. static DefaultSpinnerUrl: string;
  31877. /**
  31878. * Creates a new default loading screen
  31879. * @param _renderingCanvas defines the canvas used to render the scene
  31880. * @param _loadingText defines the default text to display
  31881. * @param _loadingDivBackgroundColor defines the default background color
  31882. */
  31883. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31884. /**
  31885. * Function called to display the loading screen
  31886. */
  31887. displayLoadingUI(): void;
  31888. /**
  31889. * Function called to hide the loading screen
  31890. */
  31891. hideLoadingUI(): void;
  31892. /**
  31893. * Gets or sets the text to display while loading
  31894. */
  31895. loadingUIText: string;
  31896. /**
  31897. * Gets or sets the color to use for the background
  31898. */
  31899. loadingUIBackgroundColor: string;
  31900. private _resizeLoadingUI;
  31901. }
  31902. }
  31903. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31904. /**
  31905. * Interface for any object that can request an animation frame
  31906. */
  31907. export interface ICustomAnimationFrameRequester {
  31908. /**
  31909. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31910. */
  31911. renderFunction?: Function;
  31912. /**
  31913. * Called to request the next frame to render to
  31914. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31915. */
  31916. requestAnimationFrame: Function;
  31917. /**
  31918. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31919. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31920. */
  31921. requestID?: number;
  31922. }
  31923. }
  31924. declare module "babylonjs/Misc/performanceMonitor" {
  31925. /**
  31926. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31927. */
  31928. export class PerformanceMonitor {
  31929. private _enabled;
  31930. private _rollingFrameTime;
  31931. private _lastFrameTimeMs;
  31932. /**
  31933. * constructor
  31934. * @param frameSampleSize The number of samples required to saturate the sliding window
  31935. */
  31936. constructor(frameSampleSize?: number);
  31937. /**
  31938. * Samples current frame
  31939. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31940. */
  31941. sampleFrame(timeMs?: number): void;
  31942. /**
  31943. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31944. */
  31945. readonly averageFrameTime: number;
  31946. /**
  31947. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31948. */
  31949. readonly averageFrameTimeVariance: number;
  31950. /**
  31951. * Returns the frame time of the most recent frame
  31952. */
  31953. readonly instantaneousFrameTime: number;
  31954. /**
  31955. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31956. */
  31957. readonly averageFPS: number;
  31958. /**
  31959. * Returns the average framerate in frames per second using the most recent frame time
  31960. */
  31961. readonly instantaneousFPS: number;
  31962. /**
  31963. * Returns true if enough samples have been taken to completely fill the sliding window
  31964. */
  31965. readonly isSaturated: boolean;
  31966. /**
  31967. * Enables contributions to the sliding window sample set
  31968. */
  31969. enable(): void;
  31970. /**
  31971. * Disables contributions to the sliding window sample set
  31972. * Samples will not be interpolated over the disabled period
  31973. */
  31974. disable(): void;
  31975. /**
  31976. * Returns true if sampling is enabled
  31977. */
  31978. readonly isEnabled: boolean;
  31979. /**
  31980. * Resets performance monitor
  31981. */
  31982. reset(): void;
  31983. }
  31984. /**
  31985. * RollingAverage
  31986. *
  31987. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31988. */
  31989. export class RollingAverage {
  31990. /**
  31991. * Current average
  31992. */
  31993. average: number;
  31994. /**
  31995. * Current variance
  31996. */
  31997. variance: number;
  31998. protected _samples: Array<number>;
  31999. protected _sampleCount: number;
  32000. protected _pos: number;
  32001. protected _m2: number;
  32002. /**
  32003. * constructor
  32004. * @param length The number of samples required to saturate the sliding window
  32005. */
  32006. constructor(length: number);
  32007. /**
  32008. * Adds a sample to the sample set
  32009. * @param v The sample value
  32010. */
  32011. add(v: number): void;
  32012. /**
  32013. * Returns previously added values or null if outside of history or outside the sliding window domain
  32014. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32015. * @return Value previously recorded with add() or null if outside of range
  32016. */
  32017. history(i: number): number;
  32018. /**
  32019. * Returns true if enough samples have been taken to completely fill the sliding window
  32020. * @return true if sample-set saturated
  32021. */
  32022. isSaturated(): boolean;
  32023. /**
  32024. * Resets the rolling average (equivalent to 0 samples taken so far)
  32025. */
  32026. reset(): void;
  32027. /**
  32028. * Wraps a value around the sample range boundaries
  32029. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32030. * @return Wrapped position in sample range
  32031. */
  32032. protected _wrapPosition(i: number): number;
  32033. }
  32034. }
  32035. declare module "babylonjs/Misc/perfCounter" {
  32036. /**
  32037. * This class is used to track a performance counter which is number based.
  32038. * The user has access to many properties which give statistics of different nature.
  32039. *
  32040. * The implementer can track two kinds of Performance Counter: time and count.
  32041. * 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.
  32042. * 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.
  32043. */
  32044. export class PerfCounter {
  32045. /**
  32046. * Gets or sets a global boolean to turn on and off all the counters
  32047. */
  32048. static Enabled: boolean;
  32049. /**
  32050. * Returns the smallest value ever
  32051. */
  32052. readonly min: number;
  32053. /**
  32054. * Returns the biggest value ever
  32055. */
  32056. readonly max: number;
  32057. /**
  32058. * Returns the average value since the performance counter is running
  32059. */
  32060. readonly average: number;
  32061. /**
  32062. * Returns the average value of the last second the counter was monitored
  32063. */
  32064. readonly lastSecAverage: number;
  32065. /**
  32066. * Returns the current value
  32067. */
  32068. readonly current: number;
  32069. /**
  32070. * Gets the accumulated total
  32071. */
  32072. readonly total: number;
  32073. /**
  32074. * Gets the total value count
  32075. */
  32076. readonly count: number;
  32077. /**
  32078. * Creates a new counter
  32079. */
  32080. constructor();
  32081. /**
  32082. * Call this method to start monitoring a new frame.
  32083. * 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.
  32084. */
  32085. fetchNewFrame(): void;
  32086. /**
  32087. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32088. * @param newCount the count value to add to the monitored count
  32089. * @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.
  32090. */
  32091. addCount(newCount: number, fetchResult: boolean): void;
  32092. /**
  32093. * Start monitoring this performance counter
  32094. */
  32095. beginMonitoring(): void;
  32096. /**
  32097. * Compute the time lapsed since the previous beginMonitoring() call.
  32098. * @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
  32099. */
  32100. endMonitoring(newFrame?: boolean): void;
  32101. private _fetchResult;
  32102. private _startMonitoringTime;
  32103. private _min;
  32104. private _max;
  32105. private _average;
  32106. private _current;
  32107. private _totalValueCount;
  32108. private _totalAccumulated;
  32109. private _lastSecAverage;
  32110. private _lastSecAccumulated;
  32111. private _lastSecTime;
  32112. private _lastSecValueCount;
  32113. }
  32114. }
  32115. declare module "babylonjs/Engines/engine" {
  32116. import { Observable } from "babylonjs/Misc/observable";
  32117. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  32118. import { Scene } from "babylonjs/scene";
  32119. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32120. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  32121. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32122. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  32123. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32124. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32125. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  32126. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  32127. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32128. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32129. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  32130. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32131. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  32132. import { Material } from "babylonjs/Materials/material";
  32133. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32134. /**
  32135. * Defines the interface used by display changed events
  32136. */
  32137. export interface IDisplayChangedEventArgs {
  32138. /** Gets the vrDisplay object (if any) */
  32139. vrDisplay: Nullable<any>;
  32140. /** Gets a boolean indicating if webVR is supported */
  32141. vrSupported: boolean;
  32142. }
  32143. /**
  32144. * Defines the interface used by objects containing a viewport (like a camera)
  32145. */
  32146. interface IViewportOwnerLike {
  32147. /**
  32148. * Gets or sets the viewport
  32149. */
  32150. viewport: IViewportLike;
  32151. }
  32152. /**
  32153. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32154. */
  32155. export class Engine extends ThinEngine {
  32156. /** Defines that alpha blending is disabled */
  32157. static readonly ALPHA_DISABLE: number;
  32158. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32159. static readonly ALPHA_ADD: number;
  32160. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32161. static readonly ALPHA_COMBINE: number;
  32162. /** Defines that alpha blending to DEST - SRC * DEST */
  32163. static readonly ALPHA_SUBTRACT: number;
  32164. /** Defines that alpha blending to SRC * DEST */
  32165. static readonly ALPHA_MULTIPLY: number;
  32166. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32167. static readonly ALPHA_MAXIMIZED: number;
  32168. /** Defines that alpha blending to SRC + DEST */
  32169. static readonly ALPHA_ONEONE: number;
  32170. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32171. static readonly ALPHA_PREMULTIPLIED: number;
  32172. /**
  32173. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32174. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32175. */
  32176. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32177. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32178. static readonly ALPHA_INTERPOLATE: number;
  32179. /**
  32180. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32181. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32182. */
  32183. static readonly ALPHA_SCREENMODE: number;
  32184. /** Defines that the ressource is not delayed*/
  32185. static readonly DELAYLOADSTATE_NONE: number;
  32186. /** Defines that the ressource was successfully delay loaded */
  32187. static readonly DELAYLOADSTATE_LOADED: number;
  32188. /** Defines that the ressource is currently delay loading */
  32189. static readonly DELAYLOADSTATE_LOADING: number;
  32190. /** Defines that the ressource is delayed and has not started loading */
  32191. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32192. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32193. static readonly NEVER: number;
  32194. /** 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 */
  32195. static readonly ALWAYS: number;
  32196. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32197. static readonly LESS: number;
  32198. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32199. static readonly EQUAL: number;
  32200. /** 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 */
  32201. static readonly LEQUAL: number;
  32202. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32203. static readonly GREATER: number;
  32204. /** 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 */
  32205. static readonly GEQUAL: number;
  32206. /** 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 */
  32207. static readonly NOTEQUAL: number;
  32208. /** Passed to stencilOperation to specify that stencil value must be kept */
  32209. static readonly KEEP: number;
  32210. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32211. static readonly REPLACE: number;
  32212. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32213. static readonly INCR: number;
  32214. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32215. static readonly DECR: number;
  32216. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32217. static readonly INVERT: number;
  32218. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32219. static readonly INCR_WRAP: number;
  32220. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32221. static readonly DECR_WRAP: number;
  32222. /** Texture is not repeating outside of 0..1 UVs */
  32223. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32224. /** Texture is repeating outside of 0..1 UVs */
  32225. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32226. /** Texture is repeating and mirrored */
  32227. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32228. /** ALPHA */
  32229. static readonly TEXTUREFORMAT_ALPHA: number;
  32230. /** LUMINANCE */
  32231. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32232. /** LUMINANCE_ALPHA */
  32233. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32234. /** RGB */
  32235. static readonly TEXTUREFORMAT_RGB: number;
  32236. /** RGBA */
  32237. static readonly TEXTUREFORMAT_RGBA: number;
  32238. /** RED */
  32239. static readonly TEXTUREFORMAT_RED: number;
  32240. /** RED (2nd reference) */
  32241. static readonly TEXTUREFORMAT_R: number;
  32242. /** RG */
  32243. static readonly TEXTUREFORMAT_RG: number;
  32244. /** RED_INTEGER */
  32245. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32246. /** RED_INTEGER (2nd reference) */
  32247. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32248. /** RG_INTEGER */
  32249. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32250. /** RGB_INTEGER */
  32251. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32252. /** RGBA_INTEGER */
  32253. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32254. /** UNSIGNED_BYTE */
  32255. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32256. /** UNSIGNED_BYTE (2nd reference) */
  32257. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32258. /** FLOAT */
  32259. static readonly TEXTURETYPE_FLOAT: number;
  32260. /** HALF_FLOAT */
  32261. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32262. /** BYTE */
  32263. static readonly TEXTURETYPE_BYTE: number;
  32264. /** SHORT */
  32265. static readonly TEXTURETYPE_SHORT: number;
  32266. /** UNSIGNED_SHORT */
  32267. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32268. /** INT */
  32269. static readonly TEXTURETYPE_INT: number;
  32270. /** UNSIGNED_INT */
  32271. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32272. /** UNSIGNED_SHORT_4_4_4_4 */
  32273. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32274. /** UNSIGNED_SHORT_5_5_5_1 */
  32275. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32276. /** UNSIGNED_SHORT_5_6_5 */
  32277. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32278. /** UNSIGNED_INT_2_10_10_10_REV */
  32279. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32280. /** UNSIGNED_INT_24_8 */
  32281. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32282. /** UNSIGNED_INT_10F_11F_11F_REV */
  32283. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32284. /** UNSIGNED_INT_5_9_9_9_REV */
  32285. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32286. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32287. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32288. /** nearest is mag = nearest and min = nearest and mip = linear */
  32289. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32290. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32291. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32292. /** Trilinear is mag = linear and min = linear and mip = linear */
  32293. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32294. /** nearest is mag = nearest and min = nearest and mip = linear */
  32295. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32296. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32297. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32298. /** Trilinear is mag = linear and min = linear and mip = linear */
  32299. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32300. /** mag = nearest and min = nearest and mip = nearest */
  32301. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32302. /** mag = nearest and min = linear and mip = nearest */
  32303. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32304. /** mag = nearest and min = linear and mip = linear */
  32305. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32306. /** mag = nearest and min = linear and mip = none */
  32307. static readonly TEXTURE_NEAREST_LINEAR: number;
  32308. /** mag = nearest and min = nearest and mip = none */
  32309. static readonly TEXTURE_NEAREST_NEAREST: number;
  32310. /** mag = linear and min = nearest and mip = nearest */
  32311. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32312. /** mag = linear and min = nearest and mip = linear */
  32313. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32314. /** mag = linear and min = linear and mip = none */
  32315. static readonly TEXTURE_LINEAR_LINEAR: number;
  32316. /** mag = linear and min = nearest and mip = none */
  32317. static readonly TEXTURE_LINEAR_NEAREST: number;
  32318. /** Explicit coordinates mode */
  32319. static readonly TEXTURE_EXPLICIT_MODE: number;
  32320. /** Spherical coordinates mode */
  32321. static readonly TEXTURE_SPHERICAL_MODE: number;
  32322. /** Planar coordinates mode */
  32323. static readonly TEXTURE_PLANAR_MODE: number;
  32324. /** Cubic coordinates mode */
  32325. static readonly TEXTURE_CUBIC_MODE: number;
  32326. /** Projection coordinates mode */
  32327. static readonly TEXTURE_PROJECTION_MODE: number;
  32328. /** Skybox coordinates mode */
  32329. static readonly TEXTURE_SKYBOX_MODE: number;
  32330. /** Inverse Cubic coordinates mode */
  32331. static readonly TEXTURE_INVCUBIC_MODE: number;
  32332. /** Equirectangular coordinates mode */
  32333. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32334. /** Equirectangular Fixed coordinates mode */
  32335. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32336. /** Equirectangular Fixed Mirrored coordinates mode */
  32337. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32338. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32339. static readonly SCALEMODE_FLOOR: number;
  32340. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32341. static readonly SCALEMODE_NEAREST: number;
  32342. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32343. static readonly SCALEMODE_CEILING: number;
  32344. /**
  32345. * Returns the current npm package of the sdk
  32346. */
  32347. static readonly NpmPackage: string;
  32348. /**
  32349. * Returns the current version of the framework
  32350. */
  32351. static readonly Version: string;
  32352. /** Gets the list of created engines */
  32353. static readonly Instances: Engine[];
  32354. /**
  32355. * Gets the latest created engine
  32356. */
  32357. static readonly LastCreatedEngine: Nullable<Engine>;
  32358. /**
  32359. * Gets the latest created scene
  32360. */
  32361. static readonly LastCreatedScene: Nullable<Scene>;
  32362. /**
  32363. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32364. * @param flag defines which part of the materials must be marked as dirty
  32365. * @param predicate defines a predicate used to filter which materials should be affected
  32366. */
  32367. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32368. /**
  32369. * Method called to create the default loading screen.
  32370. * This can be overriden in your own app.
  32371. * @param canvas The rendering canvas element
  32372. * @returns The loading screen
  32373. */
  32374. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32375. /**
  32376. * Method called to create the default rescale post process on each engine.
  32377. */
  32378. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32379. /**
  32380. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32381. **/
  32382. enableOfflineSupport: boolean;
  32383. /**
  32384. * 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)
  32385. **/
  32386. disableManifestCheck: boolean;
  32387. /**
  32388. * Gets the list of created scenes
  32389. */
  32390. scenes: Scene[];
  32391. /**
  32392. * Event raised when a new scene is created
  32393. */
  32394. onNewSceneAddedObservable: Observable<Scene>;
  32395. /**
  32396. * Gets the list of created postprocesses
  32397. */
  32398. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32399. /**
  32400. * Gets a boolean indicating if the pointer is currently locked
  32401. */
  32402. isPointerLock: boolean;
  32403. /**
  32404. * Observable event triggered each time the rendering canvas is resized
  32405. */
  32406. onResizeObservable: Observable<Engine>;
  32407. /**
  32408. * Observable event triggered each time the canvas loses focus
  32409. */
  32410. onCanvasBlurObservable: Observable<Engine>;
  32411. /**
  32412. * Observable event triggered each time the canvas gains focus
  32413. */
  32414. onCanvasFocusObservable: Observable<Engine>;
  32415. /**
  32416. * Observable event triggered each time the canvas receives pointerout event
  32417. */
  32418. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32419. /**
  32420. * Observable raised when the engine begins a new frame
  32421. */
  32422. onBeginFrameObservable: Observable<Engine>;
  32423. /**
  32424. * If set, will be used to request the next animation frame for the render loop
  32425. */
  32426. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32427. /**
  32428. * Observable raised when the engine ends the current frame
  32429. */
  32430. onEndFrameObservable: Observable<Engine>;
  32431. /**
  32432. * Observable raised when the engine is about to compile a shader
  32433. */
  32434. onBeforeShaderCompilationObservable: Observable<Engine>;
  32435. /**
  32436. * Observable raised when the engine has jsut compiled a shader
  32437. */
  32438. onAfterShaderCompilationObservable: Observable<Engine>;
  32439. /**
  32440. * Gets the audio engine
  32441. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32442. * @ignorenaming
  32443. */
  32444. static audioEngine: IAudioEngine;
  32445. /**
  32446. * Default AudioEngine factory responsible of creating the Audio Engine.
  32447. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32448. */
  32449. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32450. /**
  32451. * Default offline support factory responsible of creating a tool used to store data locally.
  32452. * By default, this will create a Database object if the workload has been embedded.
  32453. */
  32454. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32455. private _loadingScreen;
  32456. private _pointerLockRequested;
  32457. private _dummyFramebuffer;
  32458. private _rescalePostProcess;
  32459. /** @hidden */
  32460. protected _alphaMode: number;
  32461. /** @hidden */
  32462. protected _alphaEquation: number;
  32463. private _deterministicLockstep;
  32464. private _lockstepMaxSteps;
  32465. protected readonly _supportsHardwareTextureRescaling: boolean;
  32466. private _fps;
  32467. private _deltaTime;
  32468. /** @hidden */
  32469. _drawCalls: PerfCounter;
  32470. /**
  32471. * Turn this value on if you want to pause FPS computation when in background
  32472. */
  32473. disablePerformanceMonitorInBackground: boolean;
  32474. private _performanceMonitor;
  32475. /**
  32476. * Gets the performance monitor attached to this engine
  32477. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32478. */
  32479. readonly performanceMonitor: PerformanceMonitor;
  32480. private _onFocus;
  32481. private _onBlur;
  32482. private _onCanvasPointerOut;
  32483. private _onCanvasBlur;
  32484. private _onCanvasFocus;
  32485. private _onFullscreenChange;
  32486. private _onPointerLockChange;
  32487. /**
  32488. * Gets the HTML element used to attach event listeners
  32489. * @returns a HTML element
  32490. */
  32491. getInputElement(): Nullable<HTMLElement>;
  32492. /**
  32493. * Creates a new engine
  32494. * @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
  32495. * @param antialias defines enable antialiasing (default: false)
  32496. * @param options defines further options to be sent to the getContext() function
  32497. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32498. */
  32499. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32500. /**
  32501. * Gets current aspect ratio
  32502. * @param viewportOwner defines the camera to use to get the aspect ratio
  32503. * @param useScreen defines if screen size must be used (or the current render target if any)
  32504. * @returns a number defining the aspect ratio
  32505. */
  32506. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32507. /**
  32508. * Gets current screen aspect ratio
  32509. * @returns a number defining the aspect ratio
  32510. */
  32511. getScreenAspectRatio(): number;
  32512. /**
  32513. * Gets host document
  32514. * @returns the host document object
  32515. */
  32516. getHostDocument(): Document;
  32517. /**
  32518. * Gets the client rect of the HTML canvas attached with the current webGL context
  32519. * @returns a client rectanglee
  32520. */
  32521. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32522. /**
  32523. * Gets the client rect of the HTML element used for events
  32524. * @returns a client rectanglee
  32525. */
  32526. getInputElementClientRect(): Nullable<ClientRect>;
  32527. /**
  32528. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32529. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32530. * @returns true if engine is in deterministic lock step mode
  32531. */
  32532. isDeterministicLockStep(): boolean;
  32533. /**
  32534. * Gets the max steps when engine is running in deterministic lock step
  32535. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32536. * @returns the max steps
  32537. */
  32538. getLockstepMaxSteps(): number;
  32539. /**
  32540. * Force the mipmap generation for the given render target texture
  32541. * @param texture defines the render target texture to use
  32542. */
  32543. generateMipMapsForCubemap(texture: InternalTexture): void;
  32544. /** States */
  32545. /**
  32546. * Set various states to the webGL context
  32547. * @param culling defines backface culling state
  32548. * @param zOffset defines the value to apply to zOffset (0 by default)
  32549. * @param force defines if states must be applied even if cache is up to date
  32550. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32551. */
  32552. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32553. /**
  32554. * Set the z offset to apply to current rendering
  32555. * @param value defines the offset to apply
  32556. */
  32557. setZOffset(value: number): void;
  32558. /**
  32559. * Gets the current value of the zOffset
  32560. * @returns the current zOffset state
  32561. */
  32562. getZOffset(): number;
  32563. /**
  32564. * Enable or disable depth buffering
  32565. * @param enable defines the state to set
  32566. */
  32567. setDepthBuffer(enable: boolean): void;
  32568. /**
  32569. * Gets a boolean indicating if depth writing is enabled
  32570. * @returns the current depth writing state
  32571. */
  32572. getDepthWrite(): boolean;
  32573. /**
  32574. * Enable or disable depth writing
  32575. * @param enable defines the state to set
  32576. */
  32577. setDepthWrite(enable: boolean): void;
  32578. /**
  32579. * Enable or disable color writing
  32580. * @param enable defines the state to set
  32581. */
  32582. setColorWrite(enable: boolean): void;
  32583. /**
  32584. * Gets a boolean indicating if color writing is enabled
  32585. * @returns the current color writing state
  32586. */
  32587. getColorWrite(): boolean;
  32588. /**
  32589. * Sets alpha constants used by some alpha blending modes
  32590. * @param r defines the red component
  32591. * @param g defines the green component
  32592. * @param b defines the blue component
  32593. * @param a defines the alpha component
  32594. */
  32595. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32596. /**
  32597. * Sets the current alpha mode
  32598. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32599. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32600. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32601. */
  32602. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32603. /**
  32604. * Gets the current alpha mode
  32605. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32606. * @returns the current alpha mode
  32607. */
  32608. getAlphaMode(): number;
  32609. /**
  32610. * Sets the current alpha equation
  32611. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32612. */
  32613. setAlphaEquation(equation: number): void;
  32614. /**
  32615. * Gets the current alpha equation.
  32616. * @returns the current alpha equation
  32617. */
  32618. getAlphaEquation(): number;
  32619. /**
  32620. * Gets a boolean indicating if stencil buffer is enabled
  32621. * @returns the current stencil buffer state
  32622. */
  32623. getStencilBuffer(): boolean;
  32624. /**
  32625. * Enable or disable the stencil buffer
  32626. * @param enable defines if the stencil buffer must be enabled or disabled
  32627. */
  32628. setStencilBuffer(enable: boolean): void;
  32629. /**
  32630. * Gets the current stencil mask
  32631. * @returns a number defining the new stencil mask to use
  32632. */
  32633. getStencilMask(): number;
  32634. /**
  32635. * Sets the current stencil mask
  32636. * @param mask defines the new stencil mask to use
  32637. */
  32638. setStencilMask(mask: number): void;
  32639. /**
  32640. * Gets the current stencil function
  32641. * @returns a number defining the stencil function to use
  32642. */
  32643. getStencilFunction(): number;
  32644. /**
  32645. * Gets the current stencil reference value
  32646. * @returns a number defining the stencil reference value to use
  32647. */
  32648. getStencilFunctionReference(): number;
  32649. /**
  32650. * Gets the current stencil mask
  32651. * @returns a number defining the stencil mask to use
  32652. */
  32653. getStencilFunctionMask(): number;
  32654. /**
  32655. * Sets the current stencil function
  32656. * @param stencilFunc defines the new stencil function to use
  32657. */
  32658. setStencilFunction(stencilFunc: number): void;
  32659. /**
  32660. * Sets the current stencil reference
  32661. * @param reference defines the new stencil reference to use
  32662. */
  32663. setStencilFunctionReference(reference: number): void;
  32664. /**
  32665. * Sets the current stencil mask
  32666. * @param mask defines the new stencil mask to use
  32667. */
  32668. setStencilFunctionMask(mask: number): void;
  32669. /**
  32670. * Gets the current stencil operation when stencil fails
  32671. * @returns a number defining stencil operation to use when stencil fails
  32672. */
  32673. getStencilOperationFail(): number;
  32674. /**
  32675. * Gets the current stencil operation when depth fails
  32676. * @returns a number defining stencil operation to use when depth fails
  32677. */
  32678. getStencilOperationDepthFail(): number;
  32679. /**
  32680. * Gets the current stencil operation when stencil passes
  32681. * @returns a number defining stencil operation to use when stencil passes
  32682. */
  32683. getStencilOperationPass(): number;
  32684. /**
  32685. * Sets the stencil operation to use when stencil fails
  32686. * @param operation defines the stencil operation to use when stencil fails
  32687. */
  32688. setStencilOperationFail(operation: number): void;
  32689. /**
  32690. * Sets the stencil operation to use when depth fails
  32691. * @param operation defines the stencil operation to use when depth fails
  32692. */
  32693. setStencilOperationDepthFail(operation: number): void;
  32694. /**
  32695. * Sets the stencil operation to use when stencil passes
  32696. * @param operation defines the stencil operation to use when stencil passes
  32697. */
  32698. setStencilOperationPass(operation: number): void;
  32699. /**
  32700. * Sets a boolean indicating if the dithering state is enabled or disabled
  32701. * @param value defines the dithering state
  32702. */
  32703. setDitheringState(value: boolean): void;
  32704. /**
  32705. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32706. * @param value defines the rasterizer state
  32707. */
  32708. setRasterizerState(value: boolean): void;
  32709. /**
  32710. * Gets the current depth function
  32711. * @returns a number defining the depth function
  32712. */
  32713. getDepthFunction(): Nullable<number>;
  32714. /**
  32715. * Sets the current depth function
  32716. * @param depthFunc defines the function to use
  32717. */
  32718. setDepthFunction(depthFunc: number): void;
  32719. /**
  32720. * Sets the current depth function to GREATER
  32721. */
  32722. setDepthFunctionToGreater(): void;
  32723. /**
  32724. * Sets the current depth function to GEQUAL
  32725. */
  32726. setDepthFunctionToGreaterOrEqual(): void;
  32727. /**
  32728. * Sets the current depth function to LESS
  32729. */
  32730. setDepthFunctionToLess(): void;
  32731. /**
  32732. * Sets the current depth function to LEQUAL
  32733. */
  32734. setDepthFunctionToLessOrEqual(): void;
  32735. private _cachedStencilBuffer;
  32736. private _cachedStencilFunction;
  32737. private _cachedStencilMask;
  32738. private _cachedStencilOperationPass;
  32739. private _cachedStencilOperationFail;
  32740. private _cachedStencilOperationDepthFail;
  32741. private _cachedStencilReference;
  32742. /**
  32743. * Caches the the state of the stencil buffer
  32744. */
  32745. cacheStencilState(): void;
  32746. /**
  32747. * Restores the state of the stencil buffer
  32748. */
  32749. restoreStencilState(): void;
  32750. /**
  32751. * Directly set the WebGL Viewport
  32752. * @param x defines the x coordinate of the viewport (in screen space)
  32753. * @param y defines the y coordinate of the viewport (in screen space)
  32754. * @param width defines the width of the viewport (in screen space)
  32755. * @param height defines the height of the viewport (in screen space)
  32756. * @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
  32757. */
  32758. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32759. /**
  32760. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32761. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32762. * @param y defines the y-coordinate of the corner of the clear rectangle
  32763. * @param width defines the width of the clear rectangle
  32764. * @param height defines the height of the clear rectangle
  32765. * @param clearColor defines the clear color
  32766. */
  32767. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32768. /**
  32769. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32770. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32771. * @param y defines the y-coordinate of the corner of the clear rectangle
  32772. * @param width defines the width of the clear rectangle
  32773. * @param height defines the height of the clear rectangle
  32774. */
  32775. enableScissor(x: number, y: number, width: number, height: number): void;
  32776. /**
  32777. * Disable previously set scissor test rectangle
  32778. */
  32779. disableScissor(): void;
  32780. protected _reportDrawCall(): void;
  32781. /**
  32782. * Initializes a webVR display and starts listening to display change events
  32783. * The onVRDisplayChangedObservable will be notified upon these changes
  32784. * @returns The onVRDisplayChangedObservable
  32785. */
  32786. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32787. /** @hidden */
  32788. _prepareVRComponent(): void;
  32789. /** @hidden */
  32790. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32791. /** @hidden */
  32792. _submitVRFrame(): void;
  32793. /**
  32794. * Call this function to leave webVR mode
  32795. * Will do nothing if webVR is not supported or if there is no webVR device
  32796. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32797. */
  32798. disableVR(): void;
  32799. /**
  32800. * Gets a boolean indicating that the system is in VR mode and is presenting
  32801. * @returns true if VR mode is engaged
  32802. */
  32803. isVRPresenting(): boolean;
  32804. /** @hidden */
  32805. _requestVRFrame(): void;
  32806. /** @hidden */
  32807. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32808. /**
  32809. * Gets the source code of the vertex shader associated with a specific webGL program
  32810. * @param program defines the program to use
  32811. * @returns a string containing the source code of the vertex shader associated with the program
  32812. */
  32813. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32814. /**
  32815. * Gets the source code of the fragment shader associated with a specific webGL program
  32816. * @param program defines the program to use
  32817. * @returns a string containing the source code of the fragment shader associated with the program
  32818. */
  32819. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32820. /**
  32821. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32822. * @param x defines the x coordinate of the rectangle where pixels must be read
  32823. * @param y defines the y coordinate of the rectangle where pixels must be read
  32824. * @param width defines the width of the rectangle where pixels must be read
  32825. * @param height defines the height of the rectangle where pixels must be read
  32826. * @returns a Uint8Array containing RGBA colors
  32827. */
  32828. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32829. /**
  32830. * Sets a depth stencil texture from a render target to the according uniform.
  32831. * @param channel The texture channel
  32832. * @param uniform The uniform to set
  32833. * @param texture The render target texture containing the depth stencil texture to apply
  32834. */
  32835. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32836. /**
  32837. * Sets a texture to the webGL context from a postprocess
  32838. * @param channel defines the channel to use
  32839. * @param postProcess defines the source postprocess
  32840. */
  32841. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32842. /**
  32843. * Binds the output of the passed in post process to the texture channel specified
  32844. * @param channel The channel the texture should be bound to
  32845. * @param postProcess The post process which's output should be bound
  32846. */
  32847. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32848. /** @hidden */
  32849. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32850. protected _rebuildBuffers(): void;
  32851. /** @hidden */
  32852. _renderFrame(): void;
  32853. _renderLoop(): void;
  32854. /** @hidden */
  32855. _renderViews(): boolean;
  32856. /**
  32857. * Toggle full screen mode
  32858. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32859. */
  32860. switchFullscreen(requestPointerLock: boolean): void;
  32861. /**
  32862. * Enters full screen mode
  32863. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32864. */
  32865. enterFullscreen(requestPointerLock: boolean): void;
  32866. /**
  32867. * Exits full screen mode
  32868. */
  32869. exitFullscreen(): void;
  32870. /**
  32871. * Enters Pointerlock mode
  32872. */
  32873. enterPointerlock(): void;
  32874. /**
  32875. * Exits Pointerlock mode
  32876. */
  32877. exitPointerlock(): void;
  32878. /**
  32879. * Begin a new frame
  32880. */
  32881. beginFrame(): void;
  32882. /**
  32883. * Enf the current frame
  32884. */
  32885. endFrame(): void;
  32886. resize(): void;
  32887. /**
  32888. * Set the compressed texture format to use, based on the formats you have, and the formats
  32889. * supported by the hardware / browser.
  32890. *
  32891. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32892. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32893. * to API arguments needed to compressed textures. This puts the burden on the container
  32894. * generator to house the arcane code for determining these for current & future formats.
  32895. *
  32896. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32897. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32898. *
  32899. * Note: The result of this call is not taken into account when a texture is base64.
  32900. *
  32901. * @param formatsAvailable defines the list of those format families you have created
  32902. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32903. *
  32904. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32905. * @returns The extension selected.
  32906. */
  32907. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32908. /**
  32909. * Force a specific size of the canvas
  32910. * @param width defines the new canvas' width
  32911. * @param height defines the new canvas' height
  32912. */
  32913. setSize(width: number, height: number): void;
  32914. /**
  32915. * Updates a dynamic vertex buffer.
  32916. * @param vertexBuffer the vertex buffer to update
  32917. * @param data the data used to update the vertex buffer
  32918. * @param byteOffset the byte offset of the data
  32919. * @param byteLength the byte length of the data
  32920. */
  32921. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  32922. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32923. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32924. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32925. _releaseTexture(texture: InternalTexture): void;
  32926. /**
  32927. * @hidden
  32928. * Rescales a texture
  32929. * @param source input texutre
  32930. * @param destination destination texture
  32931. * @param scene scene to use to render the resize
  32932. * @param internalFormat format to use when resizing
  32933. * @param onComplete callback to be called when resize has completed
  32934. */
  32935. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32936. /**
  32937. * Gets the current framerate
  32938. * @returns a number representing the framerate
  32939. */
  32940. getFps(): number;
  32941. /**
  32942. * Gets the time spent between current and previous frame
  32943. * @returns a number representing the delta time in ms
  32944. */
  32945. getDeltaTime(): number;
  32946. private _measureFps;
  32947. /** @hidden */
  32948. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  32949. /**
  32950. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32951. * @param renderTarget The render target to set the frame buffer for
  32952. */
  32953. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32954. /**
  32955. * Update a dynamic index buffer
  32956. * @param indexBuffer defines the target index buffer
  32957. * @param indices defines the data to update
  32958. * @param offset defines the offset in the target index buffer where update should start
  32959. */
  32960. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32961. /**
  32962. * Updates the sample count of a render target texture
  32963. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32964. * @param texture defines the texture to update
  32965. * @param samples defines the sample count to set
  32966. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32967. */
  32968. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32969. /**
  32970. * Updates a depth texture Comparison Mode and Function.
  32971. * If the comparison Function is equal to 0, the mode will be set to none.
  32972. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32973. * @param texture The texture to set the comparison function for
  32974. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32975. */
  32976. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32977. /**
  32978. * Creates a webGL buffer to use with instanciation
  32979. * @param capacity defines the size of the buffer
  32980. * @returns the webGL buffer
  32981. */
  32982. createInstancesBuffer(capacity: number): DataBuffer;
  32983. /**
  32984. * Delete a webGL buffer used with instanciation
  32985. * @param buffer defines the webGL buffer to delete
  32986. */
  32987. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  32988. /** @hidden */
  32989. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32990. dispose(): void;
  32991. private _disableTouchAction;
  32992. /**
  32993. * Display the loading screen
  32994. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32995. */
  32996. displayLoadingUI(): void;
  32997. /**
  32998. * Hide the loading screen
  32999. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33000. */
  33001. hideLoadingUI(): void;
  33002. /**
  33003. * Gets the current loading screen object
  33004. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33005. */
  33006. /**
  33007. * Sets the current loading screen object
  33008. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33009. */
  33010. loadingScreen: ILoadingScreen;
  33011. /**
  33012. * Sets the current loading screen text
  33013. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33014. */
  33015. loadingUIText: string;
  33016. /**
  33017. * Sets the current loading screen background color
  33018. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33019. */
  33020. loadingUIBackgroundColor: string;
  33021. /** Pointerlock and fullscreen */
  33022. /**
  33023. * Ask the browser to promote the current element to pointerlock mode
  33024. * @param element defines the DOM element to promote
  33025. */
  33026. static _RequestPointerlock(element: HTMLElement): void;
  33027. /**
  33028. * Asks the browser to exit pointerlock mode
  33029. */
  33030. static _ExitPointerlock(): void;
  33031. /**
  33032. * Ask the browser to promote the current element to fullscreen rendering mode
  33033. * @param element defines the DOM element to promote
  33034. */
  33035. static _RequestFullscreen(element: HTMLElement): void;
  33036. /**
  33037. * Asks the browser to exit fullscreen mode
  33038. */
  33039. static _ExitFullscreen(): void;
  33040. }
  33041. }
  33042. declare module "babylonjs/Engines/engineStore" {
  33043. import { Nullable } from "babylonjs/types";
  33044. import { Engine } from "babylonjs/Engines/engine";
  33045. import { Scene } from "babylonjs/scene";
  33046. /**
  33047. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33048. * during the life time of the application.
  33049. */
  33050. export class EngineStore {
  33051. /** Gets the list of created engines */
  33052. static Instances: import("babylonjs/Engines/engine").Engine[];
  33053. /** @hidden */
  33054. static _LastCreatedScene: Nullable<Scene>;
  33055. /**
  33056. * Gets the latest created engine
  33057. */
  33058. static readonly LastCreatedEngine: Nullable<Engine>;
  33059. /**
  33060. * Gets the latest created scene
  33061. */
  33062. static readonly LastCreatedScene: Nullable<Scene>;
  33063. /**
  33064. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33065. * @ignorenaming
  33066. */
  33067. static UseFallbackTexture: boolean;
  33068. /**
  33069. * Texture content used if a texture cannot loaded
  33070. * @ignorenaming
  33071. */
  33072. static FallbackTexture: string;
  33073. }
  33074. }
  33075. declare module "babylonjs/Misc/promise" {
  33076. /**
  33077. * Helper class that provides a small promise polyfill
  33078. */
  33079. export class PromisePolyfill {
  33080. /**
  33081. * Static function used to check if the polyfill is required
  33082. * If this is the case then the function will inject the polyfill to window.Promise
  33083. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33084. */
  33085. static Apply(force?: boolean): void;
  33086. }
  33087. }
  33088. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  33089. /**
  33090. * Interface for screenshot methods with describe argument called `size` as object with options
  33091. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33092. */
  33093. export interface IScreenshotSize {
  33094. /**
  33095. * number in pixels for canvas height
  33096. */
  33097. height?: number;
  33098. /**
  33099. * multiplier allowing render at a higher or lower resolution
  33100. * If value is defined then height and width will be ignored and taken from camera
  33101. */
  33102. precision?: number;
  33103. /**
  33104. * number in pixels for canvas width
  33105. */
  33106. width?: number;
  33107. }
  33108. }
  33109. declare module "babylonjs/Misc/tools" {
  33110. import { Nullable, float } from "babylonjs/types";
  33111. import { DomManagement } from "babylonjs/Misc/domManagement";
  33112. import { WebRequest } from "babylonjs/Misc/webRequest";
  33113. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33114. import { ReadFileError } from "babylonjs/Misc/fileTools";
  33115. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33116. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  33117. import { Camera } from "babylonjs/Cameras/camera";
  33118. import { Engine } from "babylonjs/Engines/engine";
  33119. interface IColor4Like {
  33120. r: float;
  33121. g: float;
  33122. b: float;
  33123. a: float;
  33124. }
  33125. /**
  33126. * Class containing a set of static utilities functions
  33127. */
  33128. export class Tools {
  33129. /**
  33130. * Gets or sets the base URL to use to load assets
  33131. */
  33132. static BaseUrl: string;
  33133. /**
  33134. * Enable/Disable Custom HTTP Request Headers globally.
  33135. * default = false
  33136. * @see CustomRequestHeaders
  33137. */
  33138. static UseCustomRequestHeaders: boolean;
  33139. /**
  33140. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33141. * i.e. when loading files, where the server/service expects an Authorization header
  33142. */
  33143. static CustomRequestHeaders: {
  33144. [key: string]: string;
  33145. };
  33146. /**
  33147. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33148. */
  33149. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  33150. /**
  33151. * Default behaviour for cors in the application.
  33152. * It can be a string if the expected behavior is identical in the entire app.
  33153. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33154. */
  33155. static CorsBehavior: string | ((url: string | string[]) => string);
  33156. /**
  33157. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33158. * @ignorenaming
  33159. */
  33160. static UseFallbackTexture: boolean;
  33161. /**
  33162. * Use this object to register external classes like custom textures or material
  33163. * to allow the laoders to instantiate them
  33164. */
  33165. static RegisteredExternalClasses: {
  33166. [key: string]: Object;
  33167. };
  33168. /**
  33169. * Texture content used if a texture cannot loaded
  33170. * @ignorenaming
  33171. */
  33172. static fallbackTexture: string;
  33173. /**
  33174. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33175. * @param u defines the coordinate on X axis
  33176. * @param v defines the coordinate on Y axis
  33177. * @param width defines the width of the source data
  33178. * @param height defines the height of the source data
  33179. * @param pixels defines the source byte array
  33180. * @param color defines the output color
  33181. */
  33182. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33183. /**
  33184. * Interpolates between a and b via alpha
  33185. * @param a The lower value (returned when alpha = 0)
  33186. * @param b The upper value (returned when alpha = 1)
  33187. * @param alpha The interpolation-factor
  33188. * @return The mixed value
  33189. */
  33190. static Mix(a: number, b: number, alpha: number): number;
  33191. /**
  33192. * Tries to instantiate a new object from a given class name
  33193. * @param className defines the class name to instantiate
  33194. * @returns the new object or null if the system was not able to do the instantiation
  33195. */
  33196. static Instantiate(className: string): any;
  33197. /**
  33198. * Provides a slice function that will work even on IE
  33199. * @param data defines the array to slice
  33200. * @param start defines the start of the data (optional)
  33201. * @param end defines the end of the data (optional)
  33202. * @returns the new sliced array
  33203. */
  33204. static Slice<T>(data: T, start?: number, end?: number): T;
  33205. /**
  33206. * Polyfill for setImmediate
  33207. * @param action defines the action to execute after the current execution block
  33208. */
  33209. static SetImmediate(action: () => void): void;
  33210. /**
  33211. * Function indicating if a number is an exponent of 2
  33212. * @param value defines the value to test
  33213. * @returns true if the value is an exponent of 2
  33214. */
  33215. static IsExponentOfTwo(value: number): boolean;
  33216. private static _tmpFloatArray;
  33217. /**
  33218. * Returns the nearest 32-bit single precision float representation of a Number
  33219. * @param value A Number. If the parameter is of a different type, it will get converted
  33220. * to a number or to NaN if it cannot be converted
  33221. * @returns number
  33222. */
  33223. static FloatRound(value: number): number;
  33224. /**
  33225. * Extracts the filename from a path
  33226. * @param path defines the path to use
  33227. * @returns the filename
  33228. */
  33229. static GetFilename(path: string): string;
  33230. /**
  33231. * Extracts the "folder" part of a path (everything before the filename).
  33232. * @param uri The URI to extract the info from
  33233. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33234. * @returns The "folder" part of the path
  33235. */
  33236. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33237. /**
  33238. * Extracts text content from a DOM element hierarchy
  33239. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33240. */
  33241. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33242. /**
  33243. * Convert an angle in radians to degrees
  33244. * @param angle defines the angle to convert
  33245. * @returns the angle in degrees
  33246. */
  33247. static ToDegrees(angle: number): number;
  33248. /**
  33249. * Convert an angle in degrees to radians
  33250. * @param angle defines the angle to convert
  33251. * @returns the angle in radians
  33252. */
  33253. static ToRadians(angle: number): number;
  33254. /**
  33255. * Returns an array if obj is not an array
  33256. * @param obj defines the object to evaluate as an array
  33257. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33258. * @returns either obj directly if obj is an array or a new array containing obj
  33259. */
  33260. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33261. /**
  33262. * Gets the pointer prefix to use
  33263. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33264. */
  33265. static GetPointerPrefix(): string;
  33266. /**
  33267. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33268. * @param url define the url we are trying
  33269. * @param element define the dom element where to configure the cors policy
  33270. */
  33271. static SetCorsBehavior(url: string | string[], element: {
  33272. crossOrigin: string | null;
  33273. }): void;
  33274. /**
  33275. * Removes unwanted characters from an url
  33276. * @param url defines the url to clean
  33277. * @returns the cleaned url
  33278. */
  33279. static CleanUrl(url: string): string;
  33280. /**
  33281. * Gets or sets a function used to pre-process url before using them to load assets
  33282. */
  33283. static PreprocessUrl: (url: string) => string;
  33284. /**
  33285. * Loads an image as an HTMLImageElement.
  33286. * @param input url string, ArrayBuffer, or Blob to load
  33287. * @param onLoad callback called when the image successfully loads
  33288. * @param onError callback called when the image fails to load
  33289. * @param offlineProvider offline provider for caching
  33290. * @param mimeType optional mime type
  33291. * @returns the HTMLImageElement of the loaded image
  33292. */
  33293. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33294. /**
  33295. * Loads a file from a url
  33296. * @param url url string, ArrayBuffer, or Blob to load
  33297. * @param onSuccess callback called when the file successfully loads
  33298. * @param onProgress callback called while file is loading (if the server supports this mode)
  33299. * @param offlineProvider defines the offline provider for caching
  33300. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33301. * @param onError callback called when the file fails to load
  33302. * @returns a file request object
  33303. */
  33304. 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;
  33305. /**
  33306. * Loads a file from a url
  33307. * @param url the file url to load
  33308. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33309. */
  33310. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33311. /**
  33312. * Load a script (identified by an url). When the url returns, the
  33313. * content of this file is added into a new script element, attached to the DOM (body element)
  33314. * @param scriptUrl defines the url of the script to laod
  33315. * @param onSuccess defines the callback called when the script is loaded
  33316. * @param onError defines the callback to call if an error occurs
  33317. * @param scriptId defines the id of the script element
  33318. */
  33319. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33320. /**
  33321. * Load an asynchronous script (identified by an url). When the url returns, the
  33322. * content of this file is added into a new script element, attached to the DOM (body element)
  33323. * @param scriptUrl defines the url of the script to laod
  33324. * @param scriptId defines the id of the script element
  33325. * @returns a promise request object
  33326. */
  33327. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33328. /**
  33329. * Loads a file from a blob
  33330. * @param fileToLoad defines the blob to use
  33331. * @param callback defines the callback to call when data is loaded
  33332. * @param progressCallback defines the callback to call during loading process
  33333. * @returns a file request object
  33334. */
  33335. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33336. /**
  33337. * Reads a file from a File object
  33338. * @param file defines the file to load
  33339. * @param onSuccess defines the callback to call when data is loaded
  33340. * @param onProgress defines the callback to call during loading process
  33341. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33342. * @param onError defines the callback to call when an error occurs
  33343. * @returns a file request object
  33344. */
  33345. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33346. /**
  33347. * Creates a data url from a given string content
  33348. * @param content defines the content to convert
  33349. * @returns the new data url link
  33350. */
  33351. static FileAsURL(content: string): string;
  33352. /**
  33353. * Format the given number to a specific decimal format
  33354. * @param value defines the number to format
  33355. * @param decimals defines the number of decimals to use
  33356. * @returns the formatted string
  33357. */
  33358. static Format(value: number, decimals?: number): string;
  33359. /**
  33360. * Tries to copy an object by duplicating every property
  33361. * @param source defines the source object
  33362. * @param destination defines the target object
  33363. * @param doNotCopyList defines a list of properties to avoid
  33364. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33365. */
  33366. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33367. /**
  33368. * Gets a boolean indicating if the given object has no own property
  33369. * @param obj defines the object to test
  33370. * @returns true if object has no own property
  33371. */
  33372. static IsEmpty(obj: any): boolean;
  33373. /**
  33374. * Function used to register events at window level
  33375. * @param windowElement defines the Window object to use
  33376. * @param events defines the events to register
  33377. */
  33378. static RegisterTopRootEvents(windowElement: Window, events: {
  33379. name: string;
  33380. handler: Nullable<(e: FocusEvent) => any>;
  33381. }[]): void;
  33382. /**
  33383. * Function used to unregister events from window level
  33384. * @param windowElement defines the Window object to use
  33385. * @param events defines the events to unregister
  33386. */
  33387. static UnregisterTopRootEvents(windowElement: Window, events: {
  33388. name: string;
  33389. handler: Nullable<(e: FocusEvent) => any>;
  33390. }[]): void;
  33391. /**
  33392. * @ignore
  33393. */
  33394. static _ScreenshotCanvas: HTMLCanvasElement;
  33395. /**
  33396. * Dumps the current bound framebuffer
  33397. * @param width defines the rendering width
  33398. * @param height defines the rendering height
  33399. * @param engine defines the hosting engine
  33400. * @param successCallback defines the callback triggered once the data are available
  33401. * @param mimeType defines the mime type of the result
  33402. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33403. */
  33404. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33405. /**
  33406. * Converts the canvas data to blob.
  33407. * This acts as a polyfill for browsers not supporting the to blob function.
  33408. * @param canvas Defines the canvas to extract the data from
  33409. * @param successCallback Defines the callback triggered once the data are available
  33410. * @param mimeType Defines the mime type of the result
  33411. */
  33412. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33413. /**
  33414. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33415. * @param successCallback defines the callback triggered once the data are available
  33416. * @param mimeType defines the mime type of the result
  33417. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33418. */
  33419. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33420. /**
  33421. * Downloads a blob in the browser
  33422. * @param blob defines the blob to download
  33423. * @param fileName defines the name of the downloaded file
  33424. */
  33425. static Download(blob: Blob, fileName: string): void;
  33426. /**
  33427. * Captures a screenshot of the current rendering
  33428. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33429. * @param engine defines the rendering engine
  33430. * @param camera defines the source camera
  33431. * @param size This parameter can be set to a single number or to an object with the
  33432. * following (optional) properties: precision, width, height. If a single number is passed,
  33433. * it will be used for both width and height. If an object is passed, the screenshot size
  33434. * will be derived from the parameters. The precision property is a multiplier allowing
  33435. * rendering at a higher or lower resolution
  33436. * @param successCallback defines the callback receives a single parameter which contains the
  33437. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33438. * src parameter of an <img> to display it
  33439. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33440. * Check your browser for supported MIME types
  33441. */
  33442. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33443. /**
  33444. * Captures a screenshot of the current rendering
  33445. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33446. * @param engine defines the rendering engine
  33447. * @param camera defines the source camera
  33448. * @param size This parameter can be set to a single number or to an object with the
  33449. * following (optional) properties: precision, width, height. If a single number is passed,
  33450. * it will be used for both width and height. If an object is passed, the screenshot size
  33451. * will be derived from the parameters. The precision property is a multiplier allowing
  33452. * rendering at a higher or lower resolution
  33453. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33454. * Check your browser for supported MIME types
  33455. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33456. * to the src parameter of an <img> to display it
  33457. */
  33458. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33459. /**
  33460. * Generates an image screenshot from the specified camera.
  33461. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33462. * @param engine The engine to use for rendering
  33463. * @param camera The camera to use for rendering
  33464. * @param size This parameter can be set to a single number or to an object with the
  33465. * following (optional) properties: precision, width, height. If a single number is passed,
  33466. * it will be used for both width and height. If an object is passed, the screenshot size
  33467. * will be derived from the parameters. The precision property is a multiplier allowing
  33468. * rendering at a higher or lower resolution
  33469. * @param successCallback The callback receives a single parameter which contains the
  33470. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33471. * src parameter of an <img> to display it
  33472. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33473. * Check your browser for supported MIME types
  33474. * @param samples Texture samples (default: 1)
  33475. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33476. * @param fileName A name for for the downloaded file.
  33477. */
  33478. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33479. /**
  33480. * Generates an image screenshot from the specified camera.
  33481. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33482. * @param engine The engine to use for rendering
  33483. * @param camera The camera to use for rendering
  33484. * @param size This parameter can be set to a single number or to an object with the
  33485. * following (optional) properties: precision, width, height. If a single number is passed,
  33486. * it will be used for both width and height. If an object is passed, the screenshot size
  33487. * will be derived from the parameters. The precision property is a multiplier allowing
  33488. * rendering at a higher or lower resolution
  33489. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33490. * Check your browser for supported MIME types
  33491. * @param samples Texture samples (default: 1)
  33492. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33493. * @param fileName A name for for the downloaded file.
  33494. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33495. * to the src parameter of an <img> to display it
  33496. */
  33497. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33498. /**
  33499. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33500. * Be aware Math.random() could cause collisions, but:
  33501. * "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"
  33502. * @returns a pseudo random id
  33503. */
  33504. static RandomId(): string;
  33505. /**
  33506. * Test if the given uri is a base64 string
  33507. * @param uri The uri to test
  33508. * @return True if the uri is a base64 string or false otherwise
  33509. */
  33510. static IsBase64(uri: string): boolean;
  33511. /**
  33512. * Decode the given base64 uri.
  33513. * @param uri The uri to decode
  33514. * @return The decoded base64 data.
  33515. */
  33516. static DecodeBase64(uri: string): ArrayBuffer;
  33517. /**
  33518. * Gets the absolute url.
  33519. * @param url the input url
  33520. * @return the absolute url
  33521. */
  33522. static GetAbsoluteUrl(url: string): string;
  33523. /**
  33524. * No log
  33525. */
  33526. static readonly NoneLogLevel: number;
  33527. /**
  33528. * Only message logs
  33529. */
  33530. static readonly MessageLogLevel: number;
  33531. /**
  33532. * Only warning logs
  33533. */
  33534. static readonly WarningLogLevel: number;
  33535. /**
  33536. * Only error logs
  33537. */
  33538. static readonly ErrorLogLevel: number;
  33539. /**
  33540. * All logs
  33541. */
  33542. static readonly AllLogLevel: number;
  33543. /**
  33544. * Gets a value indicating the number of loading errors
  33545. * @ignorenaming
  33546. */
  33547. static readonly errorsCount: number;
  33548. /**
  33549. * Callback called when a new log is added
  33550. */
  33551. static OnNewCacheEntry: (entry: string) => void;
  33552. /**
  33553. * Log a message to the console
  33554. * @param message defines the message to log
  33555. */
  33556. static Log(message: string): void;
  33557. /**
  33558. * Write a warning message to the console
  33559. * @param message defines the message to log
  33560. */
  33561. static Warn(message: string): void;
  33562. /**
  33563. * Write an error message to the console
  33564. * @param message defines the message to log
  33565. */
  33566. static Error(message: string): void;
  33567. /**
  33568. * Gets current log cache (list of logs)
  33569. */
  33570. static readonly LogCache: string;
  33571. /**
  33572. * Clears the log cache
  33573. */
  33574. static ClearLogCache(): void;
  33575. /**
  33576. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33577. */
  33578. static LogLevels: number;
  33579. /**
  33580. * Checks if the window object exists
  33581. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33582. */
  33583. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33584. /**
  33585. * No performance log
  33586. */
  33587. static readonly PerformanceNoneLogLevel: number;
  33588. /**
  33589. * Use user marks to log performance
  33590. */
  33591. static readonly PerformanceUserMarkLogLevel: number;
  33592. /**
  33593. * Log performance to the console
  33594. */
  33595. static readonly PerformanceConsoleLogLevel: number;
  33596. private static _performance;
  33597. /**
  33598. * Sets the current performance log level
  33599. */
  33600. static PerformanceLogLevel: number;
  33601. private static _StartPerformanceCounterDisabled;
  33602. private static _EndPerformanceCounterDisabled;
  33603. private static _StartUserMark;
  33604. private static _EndUserMark;
  33605. private static _StartPerformanceConsole;
  33606. private static _EndPerformanceConsole;
  33607. /**
  33608. * Starts a performance counter
  33609. */
  33610. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33611. /**
  33612. * Ends a specific performance coutner
  33613. */
  33614. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33615. /**
  33616. * Gets either window.performance.now() if supported or Date.now() else
  33617. */
  33618. static readonly Now: number;
  33619. /**
  33620. * This method will return the name of the class used to create the instance of the given object.
  33621. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33622. * @param object the object to get the class name from
  33623. * @param isType defines if the object is actually a type
  33624. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33625. */
  33626. static GetClassName(object: any, isType?: boolean): string;
  33627. /**
  33628. * Gets the first element of an array satisfying a given predicate
  33629. * @param array defines the array to browse
  33630. * @param predicate defines the predicate to use
  33631. * @returns null if not found or the element
  33632. */
  33633. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33634. /**
  33635. * This method will return the name of the full name of the class, including its owning module (if any).
  33636. * 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).
  33637. * @param object the object to get the class name from
  33638. * @param isType defines if the object is actually a type
  33639. * @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.
  33640. * @ignorenaming
  33641. */
  33642. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33643. /**
  33644. * Returns a promise that resolves after the given amount of time.
  33645. * @param delay Number of milliseconds to delay
  33646. * @returns Promise that resolves after the given amount of time
  33647. */
  33648. static DelayAsync(delay: number): Promise<void>;
  33649. }
  33650. /**
  33651. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33652. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33653. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33654. * @param name The name of the class, case should be preserved
  33655. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33656. */
  33657. export function className(name: string, module?: string): (target: Object) => void;
  33658. /**
  33659. * An implementation of a loop for asynchronous functions.
  33660. */
  33661. export class AsyncLoop {
  33662. /**
  33663. * Defines the number of iterations for the loop
  33664. */
  33665. iterations: number;
  33666. /**
  33667. * Defines the current index of the loop.
  33668. */
  33669. index: number;
  33670. private _done;
  33671. private _fn;
  33672. private _successCallback;
  33673. /**
  33674. * Constructor.
  33675. * @param iterations the number of iterations.
  33676. * @param func the function to run each iteration
  33677. * @param successCallback the callback that will be called upon succesful execution
  33678. * @param offset starting offset.
  33679. */
  33680. constructor(
  33681. /**
  33682. * Defines the number of iterations for the loop
  33683. */
  33684. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33685. /**
  33686. * Execute the next iteration. Must be called after the last iteration was finished.
  33687. */
  33688. executeNext(): void;
  33689. /**
  33690. * Break the loop and run the success callback.
  33691. */
  33692. breakLoop(): void;
  33693. /**
  33694. * Create and run an async loop.
  33695. * @param iterations the number of iterations.
  33696. * @param fn the function to run each iteration
  33697. * @param successCallback the callback that will be called upon succesful execution
  33698. * @param offset starting offset.
  33699. * @returns the created async loop object
  33700. */
  33701. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33702. /**
  33703. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33704. * @param iterations total number of iterations
  33705. * @param syncedIterations number of synchronous iterations in each async iteration.
  33706. * @param fn the function to call each iteration.
  33707. * @param callback a success call back that will be called when iterating stops.
  33708. * @param breakFunction a break condition (optional)
  33709. * @param timeout timeout settings for the setTimeout function. default - 0.
  33710. * @returns the created async loop object
  33711. */
  33712. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33713. }
  33714. }
  33715. declare module "babylonjs/Misc/stringDictionary" {
  33716. import { Nullable } from "babylonjs/types";
  33717. /**
  33718. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33719. * The underlying implementation relies on an associative array to ensure the best performances.
  33720. * The value can be anything including 'null' but except 'undefined'
  33721. */
  33722. export class StringDictionary<T> {
  33723. /**
  33724. * This will clear this dictionary and copy the content from the 'source' one.
  33725. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33726. * @param source the dictionary to take the content from and copy to this dictionary
  33727. */
  33728. copyFrom(source: StringDictionary<T>): void;
  33729. /**
  33730. * Get a value based from its key
  33731. * @param key the given key to get the matching value from
  33732. * @return the value if found, otherwise undefined is returned
  33733. */
  33734. get(key: string): T | undefined;
  33735. /**
  33736. * Get a value from its key or add it if it doesn't exist.
  33737. * This method will ensure you that a given key/data will be present in the dictionary.
  33738. * @param key the given key to get the matching value from
  33739. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33740. * The factory will only be invoked if there's no data for the given key.
  33741. * @return the value corresponding to the key.
  33742. */
  33743. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33744. /**
  33745. * Get a value from its key if present in the dictionary otherwise add it
  33746. * @param key the key to get the value from
  33747. * @param val if there's no such key/value pair in the dictionary add it with this value
  33748. * @return the value corresponding to the key
  33749. */
  33750. getOrAdd(key: string, val: T): T;
  33751. /**
  33752. * Check if there's a given key in the dictionary
  33753. * @param key the key to check for
  33754. * @return true if the key is present, false otherwise
  33755. */
  33756. contains(key: string): boolean;
  33757. /**
  33758. * Add a new key and its corresponding value
  33759. * @param key the key to add
  33760. * @param value the value corresponding to the key
  33761. * @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
  33762. */
  33763. add(key: string, value: T): boolean;
  33764. /**
  33765. * Update a specific value associated to a key
  33766. * @param key defines the key to use
  33767. * @param value defines the value to store
  33768. * @returns true if the value was updated (or false if the key was not found)
  33769. */
  33770. set(key: string, value: T): boolean;
  33771. /**
  33772. * Get the element of the given key and remove it from the dictionary
  33773. * @param key defines the key to search
  33774. * @returns the value associated with the key or null if not found
  33775. */
  33776. getAndRemove(key: string): Nullable<T>;
  33777. /**
  33778. * Remove a key/value from the dictionary.
  33779. * @param key the key to remove
  33780. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33781. */
  33782. remove(key: string): boolean;
  33783. /**
  33784. * Clear the whole content of the dictionary
  33785. */
  33786. clear(): void;
  33787. /**
  33788. * Gets the current count
  33789. */
  33790. readonly count: number;
  33791. /**
  33792. * Execute a callback on each key/val of the dictionary.
  33793. * Note that you can remove any element in this dictionary in the callback implementation
  33794. * @param callback the callback to execute on a given key/value pair
  33795. */
  33796. forEach(callback: (key: string, val: T) => void): void;
  33797. /**
  33798. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33799. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33800. * Note that you can remove any element in this dictionary in the callback implementation
  33801. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33802. * @returns the first item
  33803. */
  33804. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33805. private _count;
  33806. private _data;
  33807. }
  33808. }
  33809. declare module "babylonjs/Collisions/collisionCoordinator" {
  33810. import { Nullable } from "babylonjs/types";
  33811. import { Scene } from "babylonjs/scene";
  33812. import { Vector3 } from "babylonjs/Maths/math.vector";
  33813. import { Collider } from "babylonjs/Collisions/collider";
  33814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33815. /** @hidden */
  33816. export interface ICollisionCoordinator {
  33817. createCollider(): Collider;
  33818. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33819. init(scene: Scene): void;
  33820. }
  33821. /** @hidden */
  33822. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33823. private _scene;
  33824. private _scaledPosition;
  33825. private _scaledVelocity;
  33826. private _finalPosition;
  33827. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33828. createCollider(): Collider;
  33829. init(scene: Scene): void;
  33830. private _collideWithWorld;
  33831. }
  33832. }
  33833. declare module "babylonjs/Inputs/scene.inputManager" {
  33834. import { Nullable } from "babylonjs/types";
  33835. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33836. import { Vector2 } from "babylonjs/Maths/math.vector";
  33837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33838. import { Scene } from "babylonjs/scene";
  33839. /**
  33840. * Class used to manage all inputs for the scene.
  33841. */
  33842. export class InputManager {
  33843. /** The distance in pixel that you have to move to prevent some events */
  33844. static DragMovementThreshold: number;
  33845. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33846. static LongPressDelay: number;
  33847. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33848. static DoubleClickDelay: number;
  33849. /** If you need to check double click without raising a single click at first click, enable this flag */
  33850. static ExclusiveDoubleClickMode: boolean;
  33851. private _wheelEventName;
  33852. private _onPointerMove;
  33853. private _onPointerDown;
  33854. private _onPointerUp;
  33855. private _initClickEvent;
  33856. private _initActionManager;
  33857. private _delayedSimpleClick;
  33858. private _delayedSimpleClickTimeout;
  33859. private _previousDelayedSimpleClickTimeout;
  33860. private _meshPickProceed;
  33861. private _previousButtonPressed;
  33862. private _currentPickResult;
  33863. private _previousPickResult;
  33864. private _totalPointersPressed;
  33865. private _doubleClickOccured;
  33866. private _pointerOverMesh;
  33867. private _pickedDownMesh;
  33868. private _pickedUpMesh;
  33869. private _pointerX;
  33870. private _pointerY;
  33871. private _unTranslatedPointerX;
  33872. private _unTranslatedPointerY;
  33873. private _startingPointerPosition;
  33874. private _previousStartingPointerPosition;
  33875. private _startingPointerTime;
  33876. private _previousStartingPointerTime;
  33877. private _pointerCaptures;
  33878. private _onKeyDown;
  33879. private _onKeyUp;
  33880. private _onCanvasFocusObserver;
  33881. private _onCanvasBlurObserver;
  33882. private _scene;
  33883. /**
  33884. * Creates a new InputManager
  33885. * @param scene defines the hosting scene
  33886. */
  33887. constructor(scene: Scene);
  33888. /**
  33889. * Gets the mesh that is currently under the pointer
  33890. */
  33891. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33892. /**
  33893. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33894. */
  33895. readonly unTranslatedPointer: Vector2;
  33896. /**
  33897. * Gets or sets the current on-screen X position of the pointer
  33898. */
  33899. pointerX: number;
  33900. /**
  33901. * Gets or sets the current on-screen Y position of the pointer
  33902. */
  33903. pointerY: number;
  33904. private _updatePointerPosition;
  33905. private _processPointerMove;
  33906. private _setRayOnPointerInfo;
  33907. private _checkPrePointerObservable;
  33908. /**
  33909. * Use this method to simulate a pointer move on a mesh
  33910. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33911. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33912. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33913. */
  33914. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33915. /**
  33916. * Use this method to simulate a pointer down on a mesh
  33917. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33918. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33919. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33920. */
  33921. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33922. private _processPointerDown;
  33923. /** @hidden */
  33924. _isPointerSwiping(): boolean;
  33925. /**
  33926. * Use this method to simulate a pointer up on a mesh
  33927. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33928. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33929. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33930. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33931. */
  33932. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33933. private _processPointerUp;
  33934. /**
  33935. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33936. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33937. * @returns true if the pointer was captured
  33938. */
  33939. isPointerCaptured(pointerId?: number): boolean;
  33940. /**
  33941. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33942. * @param attachUp defines if you want to attach events to pointerup
  33943. * @param attachDown defines if you want to attach events to pointerdown
  33944. * @param attachMove defines if you want to attach events to pointermove
  33945. */
  33946. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33947. /**
  33948. * Detaches all event handlers
  33949. */
  33950. detachControl(): void;
  33951. /**
  33952. * Force the value of meshUnderPointer
  33953. * @param mesh defines the mesh to use
  33954. */
  33955. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33956. /**
  33957. * Gets the mesh under the pointer
  33958. * @returns a Mesh or null if no mesh is under the pointer
  33959. */
  33960. getPointerOverMesh(): Nullable<AbstractMesh>;
  33961. }
  33962. }
  33963. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33964. /**
  33965. * Helper class used to generate session unique ID
  33966. */
  33967. export class UniqueIdGenerator {
  33968. private static _UniqueIdCounter;
  33969. /**
  33970. * Gets an unique (relatively to the current scene) Id
  33971. */
  33972. static readonly UniqueId: number;
  33973. }
  33974. }
  33975. declare module "babylonjs/Animations/animationGroup" {
  33976. import { Animatable } from "babylonjs/Animations/animatable";
  33977. import { Animation } from "babylonjs/Animations/animation";
  33978. import { Scene, IDisposable } from "babylonjs/scene";
  33979. import { Observable } from "babylonjs/Misc/observable";
  33980. import { Nullable } from "babylonjs/types";
  33981. import "babylonjs/Animations/animatable";
  33982. /**
  33983. * This class defines the direct association between an animation and a target
  33984. */
  33985. export class TargetedAnimation {
  33986. /**
  33987. * Animation to perform
  33988. */
  33989. animation: Animation;
  33990. /**
  33991. * Target to animate
  33992. */
  33993. target: any;
  33994. /**
  33995. * Serialize the object
  33996. * @returns the JSON object representing the current entity
  33997. */
  33998. serialize(): any;
  33999. }
  34000. /**
  34001. * Use this class to create coordinated animations on multiple targets
  34002. */
  34003. export class AnimationGroup implements IDisposable {
  34004. /** The name of the animation group */
  34005. name: string;
  34006. private _scene;
  34007. private _targetedAnimations;
  34008. private _animatables;
  34009. private _from;
  34010. private _to;
  34011. private _isStarted;
  34012. private _isPaused;
  34013. private _speedRatio;
  34014. private _loopAnimation;
  34015. /**
  34016. * Gets or sets the unique id of the node
  34017. */
  34018. uniqueId: number;
  34019. /**
  34020. * This observable will notify when one animation have ended
  34021. */
  34022. onAnimationEndObservable: Observable<TargetedAnimation>;
  34023. /**
  34024. * Observer raised when one animation loops
  34025. */
  34026. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34027. /**
  34028. * Observer raised when all animations have looped
  34029. */
  34030. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34031. /**
  34032. * This observable will notify when all animations have ended.
  34033. */
  34034. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34035. /**
  34036. * This observable will notify when all animations have paused.
  34037. */
  34038. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34039. /**
  34040. * This observable will notify when all animations are playing.
  34041. */
  34042. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34043. /**
  34044. * Gets the first frame
  34045. */
  34046. readonly from: number;
  34047. /**
  34048. * Gets the last frame
  34049. */
  34050. readonly to: number;
  34051. /**
  34052. * Define if the animations are started
  34053. */
  34054. readonly isStarted: boolean;
  34055. /**
  34056. * Gets a value indicating that the current group is playing
  34057. */
  34058. readonly isPlaying: boolean;
  34059. /**
  34060. * Gets or sets the speed ratio to use for all animations
  34061. */
  34062. /**
  34063. * Gets or sets the speed ratio to use for all animations
  34064. */
  34065. speedRatio: number;
  34066. /**
  34067. * Gets or sets if all animations should loop or not
  34068. */
  34069. loopAnimation: boolean;
  34070. /**
  34071. * Gets the targeted animations for this animation group
  34072. */
  34073. readonly targetedAnimations: Array<TargetedAnimation>;
  34074. /**
  34075. * returning the list of animatables controlled by this animation group.
  34076. */
  34077. readonly animatables: Array<Animatable>;
  34078. /**
  34079. * Instantiates a new Animation Group.
  34080. * This helps managing several animations at once.
  34081. * @see http://doc.babylonjs.com/how_to/group
  34082. * @param name Defines the name of the group
  34083. * @param scene Defines the scene the group belongs to
  34084. */
  34085. constructor(
  34086. /** The name of the animation group */
  34087. name: string, scene?: Nullable<Scene>);
  34088. /**
  34089. * Add an animation (with its target) in the group
  34090. * @param animation defines the animation we want to add
  34091. * @param target defines the target of the animation
  34092. * @returns the TargetedAnimation object
  34093. */
  34094. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34095. /**
  34096. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34097. * It can add constant keys at begin or end
  34098. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34099. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34100. * @returns the animation group
  34101. */
  34102. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34103. private _animationLoopCount;
  34104. private _animationLoopFlags;
  34105. private _processLoop;
  34106. /**
  34107. * Start all animations on given targets
  34108. * @param loop defines if animations must loop
  34109. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34110. * @param from defines the from key (optional)
  34111. * @param to defines the to key (optional)
  34112. * @returns the current animation group
  34113. */
  34114. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34115. /**
  34116. * Pause all animations
  34117. * @returns the animation group
  34118. */
  34119. pause(): AnimationGroup;
  34120. /**
  34121. * Play all animations to initial state
  34122. * This function will start() the animations if they were not started or will restart() them if they were paused
  34123. * @param loop defines if animations must loop
  34124. * @returns the animation group
  34125. */
  34126. play(loop?: boolean): AnimationGroup;
  34127. /**
  34128. * Reset all animations to initial state
  34129. * @returns the animation group
  34130. */
  34131. reset(): AnimationGroup;
  34132. /**
  34133. * Restart animations from key 0
  34134. * @returns the animation group
  34135. */
  34136. restart(): AnimationGroup;
  34137. /**
  34138. * Stop all animations
  34139. * @returns the animation group
  34140. */
  34141. stop(): AnimationGroup;
  34142. /**
  34143. * Set animation weight for all animatables
  34144. * @param weight defines the weight to use
  34145. * @return the animationGroup
  34146. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34147. */
  34148. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34149. /**
  34150. * Synchronize and normalize all animatables with a source animatable
  34151. * @param root defines the root animatable to synchronize with
  34152. * @return the animationGroup
  34153. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34154. */
  34155. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34156. /**
  34157. * Goes to a specific frame in this animation group
  34158. * @param frame the frame number to go to
  34159. * @return the animationGroup
  34160. */
  34161. goToFrame(frame: number): AnimationGroup;
  34162. /**
  34163. * Dispose all associated resources
  34164. */
  34165. dispose(): void;
  34166. private _checkAnimationGroupEnded;
  34167. /**
  34168. * Clone the current animation group and returns a copy
  34169. * @param newName defines the name of the new group
  34170. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34171. * @returns the new aniamtion group
  34172. */
  34173. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34174. /**
  34175. * Serializes the animationGroup to an object
  34176. * @returns Serialized object
  34177. */
  34178. serialize(): any;
  34179. /**
  34180. * Returns a new AnimationGroup object parsed from the source provided.
  34181. * @param parsedAnimationGroup defines the source
  34182. * @param scene defines the scene that will receive the animationGroup
  34183. * @returns a new AnimationGroup
  34184. */
  34185. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34186. /**
  34187. * Returns the string "AnimationGroup"
  34188. * @returns "AnimationGroup"
  34189. */
  34190. getClassName(): string;
  34191. /**
  34192. * Creates a detailled string about the object
  34193. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34194. * @returns a string representing the object
  34195. */
  34196. toString(fullDetails?: boolean): string;
  34197. }
  34198. }
  34199. declare module "babylonjs/scene" {
  34200. import { Nullable } from "babylonjs/types";
  34201. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34202. import { Observable } from "babylonjs/Misc/observable";
  34203. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  34204. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  34205. import { Geometry } from "babylonjs/Meshes/geometry";
  34206. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34207. import { SubMesh } from "babylonjs/Meshes/subMesh";
  34208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34209. import { Mesh } from "babylonjs/Meshes/mesh";
  34210. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34211. import { Bone } from "babylonjs/Bones/bone";
  34212. import { Skeleton } from "babylonjs/Bones/skeleton";
  34213. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34214. import { Camera } from "babylonjs/Cameras/camera";
  34215. import { AbstractScene } from "babylonjs/abstractScene";
  34216. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34217. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34218. import { Material } from "babylonjs/Materials/material";
  34219. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34220. import { Effect } from "babylonjs/Materials/effect";
  34221. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  34222. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34223. import { Light } from "babylonjs/Lights/light";
  34224. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  34225. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  34226. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  34227. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  34228. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34229. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  34230. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34231. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  34232. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  34233. import { Engine } from "babylonjs/Engines/engine";
  34234. import { Node } from "babylonjs/node";
  34235. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  34236. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34237. import { WebRequest } from "babylonjs/Misc/webRequest";
  34238. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  34239. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34240. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34241. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34242. import { Plane } from "babylonjs/Maths/math.plane";
  34243. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  34244. import { Ray } from "babylonjs/Culling/ray";
  34245. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  34246. import { Animation } from "babylonjs/Animations/animation";
  34247. import { Animatable } from "babylonjs/Animations/animatable";
  34248. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34249. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34250. import { Collider } from "babylonjs/Collisions/collider";
  34251. /**
  34252. * Define an interface for all classes that will hold resources
  34253. */
  34254. export interface IDisposable {
  34255. /**
  34256. * Releases all held resources
  34257. */
  34258. dispose(): void;
  34259. }
  34260. /** Interface defining initialization parameters for Scene class */
  34261. export interface SceneOptions {
  34262. /**
  34263. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34264. * It will improve performance when the number of geometries becomes important.
  34265. */
  34266. useGeometryUniqueIdsMap?: boolean;
  34267. /**
  34268. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34269. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34270. */
  34271. useMaterialMeshMap?: boolean;
  34272. /**
  34273. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34274. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34275. */
  34276. useClonedMeshhMap?: boolean;
  34277. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34278. virtual?: boolean;
  34279. }
  34280. /**
  34281. * Represents a scene to be rendered by the engine.
  34282. * @see http://doc.babylonjs.com/features/scene
  34283. */
  34284. export class Scene extends AbstractScene implements IAnimatable {
  34285. /** The fog is deactivated */
  34286. static readonly FOGMODE_NONE: number;
  34287. /** The fog density is following an exponential function */
  34288. static readonly FOGMODE_EXP: number;
  34289. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34290. static readonly FOGMODE_EXP2: number;
  34291. /** The fog density is following a linear function. */
  34292. static readonly FOGMODE_LINEAR: number;
  34293. /**
  34294. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34295. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34296. */
  34297. static MinDeltaTime: number;
  34298. /**
  34299. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34300. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34301. */
  34302. static MaxDeltaTime: number;
  34303. /**
  34304. * Factory used to create the default material.
  34305. * @param name The name of the material to create
  34306. * @param scene The scene to create the material for
  34307. * @returns The default material
  34308. */
  34309. static DefaultMaterialFactory(scene: Scene): Material;
  34310. /**
  34311. * Factory used to create the a collision coordinator.
  34312. * @returns The collision coordinator
  34313. */
  34314. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34315. /** @hidden */
  34316. _inputManager: InputManager;
  34317. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34318. cameraToUseForPointers: Nullable<Camera>;
  34319. /** @hidden */
  34320. readonly _isScene: boolean;
  34321. /**
  34322. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34323. */
  34324. autoClear: boolean;
  34325. /**
  34326. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34327. */
  34328. autoClearDepthAndStencil: boolean;
  34329. /**
  34330. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34331. */
  34332. clearColor: Color4;
  34333. /**
  34334. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34335. */
  34336. ambientColor: Color3;
  34337. /**
  34338. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34339. * It should only be one of the following (if not the default embedded one):
  34340. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34341. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34342. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34343. * The material properties need to be setup according to the type of texture in use.
  34344. */
  34345. environmentBRDFTexture: BaseTexture;
  34346. /** @hidden */
  34347. protected _environmentTexture: Nullable<BaseTexture>;
  34348. /**
  34349. * Texture used in all pbr material as the reflection texture.
  34350. * As in the majority of the scene they are the same (exception for multi room and so on),
  34351. * this is easier to reference from here than from all the materials.
  34352. */
  34353. /**
  34354. * Texture used in all pbr material as the reflection texture.
  34355. * As in the majority of the scene they are the same (exception for multi room and so on),
  34356. * this is easier to set here than in all the materials.
  34357. */
  34358. environmentTexture: Nullable<BaseTexture>;
  34359. /** @hidden */
  34360. protected _environmentIntensity: number;
  34361. /**
  34362. * Intensity of the environment in all pbr material.
  34363. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34364. * As in the majority of the scene they are the same (exception for multi room and so on),
  34365. * this is easier to reference from here than from all the materials.
  34366. */
  34367. /**
  34368. * Intensity of the environment in all pbr material.
  34369. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34370. * As in the majority of the scene they are the same (exception for multi room and so on),
  34371. * this is easier to set here than in all the materials.
  34372. */
  34373. environmentIntensity: number;
  34374. /** @hidden */
  34375. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34376. /**
  34377. * Default image processing configuration used either in the rendering
  34378. * Forward main pass or through the imageProcessingPostProcess if present.
  34379. * As in the majority of the scene they are the same (exception for multi camera),
  34380. * this is easier to reference from here than from all the materials and post process.
  34381. *
  34382. * No setter as we it is a shared configuration, you can set the values instead.
  34383. */
  34384. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34385. private _forceWireframe;
  34386. /**
  34387. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34388. */
  34389. forceWireframe: boolean;
  34390. private _forcePointsCloud;
  34391. /**
  34392. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34393. */
  34394. forcePointsCloud: boolean;
  34395. /**
  34396. * Gets or sets the active clipplane 1
  34397. */
  34398. clipPlane: Nullable<Plane>;
  34399. /**
  34400. * Gets or sets the active clipplane 2
  34401. */
  34402. clipPlane2: Nullable<Plane>;
  34403. /**
  34404. * Gets or sets the active clipplane 3
  34405. */
  34406. clipPlane3: Nullable<Plane>;
  34407. /**
  34408. * Gets or sets the active clipplane 4
  34409. */
  34410. clipPlane4: Nullable<Plane>;
  34411. /**
  34412. * Gets or sets a boolean indicating if animations are enabled
  34413. */
  34414. animationsEnabled: boolean;
  34415. private _animationPropertiesOverride;
  34416. /**
  34417. * Gets or sets the animation properties override
  34418. */
  34419. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34420. /**
  34421. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34422. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34423. */
  34424. useConstantAnimationDeltaTime: boolean;
  34425. /**
  34426. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34427. * Please note that it requires to run a ray cast through the scene on every frame
  34428. */
  34429. constantlyUpdateMeshUnderPointer: boolean;
  34430. /**
  34431. * Defines the HTML cursor to use when hovering over interactive elements
  34432. */
  34433. hoverCursor: string;
  34434. /**
  34435. * Defines the HTML default cursor to use (empty by default)
  34436. */
  34437. defaultCursor: string;
  34438. /**
  34439. * Defines wether cursors are handled by the scene.
  34440. */
  34441. doNotHandleCursors: boolean;
  34442. /**
  34443. * This is used to call preventDefault() on pointer down
  34444. * in order to block unwanted artifacts like system double clicks
  34445. */
  34446. preventDefaultOnPointerDown: boolean;
  34447. /**
  34448. * This is used to call preventDefault() on pointer up
  34449. * in order to block unwanted artifacts like system double clicks
  34450. */
  34451. preventDefaultOnPointerUp: boolean;
  34452. /**
  34453. * Gets or sets user defined metadata
  34454. */
  34455. metadata: any;
  34456. /**
  34457. * For internal use only. Please do not use.
  34458. */
  34459. reservedDataStore: any;
  34460. /**
  34461. * Gets the name of the plugin used to load this scene (null by default)
  34462. */
  34463. loadingPluginName: string;
  34464. /**
  34465. * Use this array to add regular expressions used to disable offline support for specific urls
  34466. */
  34467. disableOfflineSupportExceptionRules: RegExp[];
  34468. /**
  34469. * An event triggered when the scene is disposed.
  34470. */
  34471. onDisposeObservable: Observable<Scene>;
  34472. private _onDisposeObserver;
  34473. /** Sets a function to be executed when this scene is disposed. */
  34474. onDispose: () => void;
  34475. /**
  34476. * An event triggered before rendering the scene (right after animations and physics)
  34477. */
  34478. onBeforeRenderObservable: Observable<Scene>;
  34479. private _onBeforeRenderObserver;
  34480. /** Sets a function to be executed before rendering this scene */
  34481. beforeRender: Nullable<() => void>;
  34482. /**
  34483. * An event triggered after rendering the scene
  34484. */
  34485. onAfterRenderObservable: Observable<Scene>;
  34486. /**
  34487. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34488. */
  34489. onAfterRenderCameraObservable: Observable<Camera>;
  34490. private _onAfterRenderObserver;
  34491. /** Sets a function to be executed after rendering this scene */
  34492. afterRender: Nullable<() => void>;
  34493. /**
  34494. * An event triggered before animating the scene
  34495. */
  34496. onBeforeAnimationsObservable: Observable<Scene>;
  34497. /**
  34498. * An event triggered after animations processing
  34499. */
  34500. onAfterAnimationsObservable: Observable<Scene>;
  34501. /**
  34502. * An event triggered before draw calls are ready to be sent
  34503. */
  34504. onBeforeDrawPhaseObservable: Observable<Scene>;
  34505. /**
  34506. * An event triggered after draw calls have been sent
  34507. */
  34508. onAfterDrawPhaseObservable: Observable<Scene>;
  34509. /**
  34510. * An event triggered when the scene is ready
  34511. */
  34512. onReadyObservable: Observable<Scene>;
  34513. /**
  34514. * An event triggered before rendering a camera
  34515. */
  34516. onBeforeCameraRenderObservable: Observable<Camera>;
  34517. private _onBeforeCameraRenderObserver;
  34518. /** Sets a function to be executed before rendering a camera*/
  34519. beforeCameraRender: () => void;
  34520. /**
  34521. * An event triggered after rendering a camera
  34522. */
  34523. onAfterCameraRenderObservable: Observable<Camera>;
  34524. private _onAfterCameraRenderObserver;
  34525. /** Sets a function to be executed after rendering a camera*/
  34526. afterCameraRender: () => void;
  34527. /**
  34528. * An event triggered when active meshes evaluation is about to start
  34529. */
  34530. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34531. /**
  34532. * An event triggered when active meshes evaluation is done
  34533. */
  34534. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34535. /**
  34536. * An event triggered when particles rendering is about to start
  34537. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34538. */
  34539. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34540. /**
  34541. * An event triggered when particles rendering is done
  34542. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34543. */
  34544. onAfterParticlesRenderingObservable: Observable<Scene>;
  34545. /**
  34546. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34547. */
  34548. onDataLoadedObservable: Observable<Scene>;
  34549. /**
  34550. * An event triggered when a camera is created
  34551. */
  34552. onNewCameraAddedObservable: Observable<Camera>;
  34553. /**
  34554. * An event triggered when a camera is removed
  34555. */
  34556. onCameraRemovedObservable: Observable<Camera>;
  34557. /**
  34558. * An event triggered when a light is created
  34559. */
  34560. onNewLightAddedObservable: Observable<Light>;
  34561. /**
  34562. * An event triggered when a light is removed
  34563. */
  34564. onLightRemovedObservable: Observable<Light>;
  34565. /**
  34566. * An event triggered when a geometry is created
  34567. */
  34568. onNewGeometryAddedObservable: Observable<Geometry>;
  34569. /**
  34570. * An event triggered when a geometry is removed
  34571. */
  34572. onGeometryRemovedObservable: Observable<Geometry>;
  34573. /**
  34574. * An event triggered when a transform node is created
  34575. */
  34576. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34577. /**
  34578. * An event triggered when a transform node is removed
  34579. */
  34580. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34581. /**
  34582. * An event triggered when a mesh is created
  34583. */
  34584. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34585. /**
  34586. * An event triggered when a mesh is removed
  34587. */
  34588. onMeshRemovedObservable: Observable<AbstractMesh>;
  34589. /**
  34590. * An event triggered when a skeleton is created
  34591. */
  34592. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34593. /**
  34594. * An event triggered when a skeleton is removed
  34595. */
  34596. onSkeletonRemovedObservable: Observable<Skeleton>;
  34597. /**
  34598. * An event triggered when a material is created
  34599. */
  34600. onNewMaterialAddedObservable: Observable<Material>;
  34601. /**
  34602. * An event triggered when a material is removed
  34603. */
  34604. onMaterialRemovedObservable: Observable<Material>;
  34605. /**
  34606. * An event triggered when a texture is created
  34607. */
  34608. onNewTextureAddedObservable: Observable<BaseTexture>;
  34609. /**
  34610. * An event triggered when a texture is removed
  34611. */
  34612. onTextureRemovedObservable: Observable<BaseTexture>;
  34613. /**
  34614. * An event triggered when render targets are about to be rendered
  34615. * Can happen multiple times per frame.
  34616. */
  34617. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34618. /**
  34619. * An event triggered when render targets were rendered.
  34620. * Can happen multiple times per frame.
  34621. */
  34622. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34623. /**
  34624. * An event triggered before calculating deterministic simulation step
  34625. */
  34626. onBeforeStepObservable: Observable<Scene>;
  34627. /**
  34628. * An event triggered after calculating deterministic simulation step
  34629. */
  34630. onAfterStepObservable: Observable<Scene>;
  34631. /**
  34632. * An event triggered when the activeCamera property is updated
  34633. */
  34634. onActiveCameraChanged: Observable<Scene>;
  34635. /**
  34636. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34637. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34638. * 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)
  34639. */
  34640. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34641. /**
  34642. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34643. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34644. * 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)
  34645. */
  34646. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34647. /**
  34648. * This Observable will when a mesh has been imported into the scene.
  34649. */
  34650. onMeshImportedObservable: Observable<AbstractMesh>;
  34651. /**
  34652. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34653. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34654. */
  34655. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34656. /** @hidden */
  34657. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34658. /**
  34659. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34660. */
  34661. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34662. /**
  34663. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34664. */
  34665. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34666. /**
  34667. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34668. */
  34669. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34670. /** Callback called when a pointer move is detected */
  34671. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34672. /** Callback called when a pointer down is detected */
  34673. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34674. /** Callback called when a pointer up is detected */
  34675. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34676. /** Callback called when a pointer pick is detected */
  34677. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34678. /**
  34679. * 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).
  34680. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34681. */
  34682. onPrePointerObservable: Observable<PointerInfoPre>;
  34683. /**
  34684. * Observable event triggered each time an input event is received from the rendering canvas
  34685. */
  34686. onPointerObservable: Observable<PointerInfo>;
  34687. /**
  34688. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34689. */
  34690. readonly unTranslatedPointer: Vector2;
  34691. /**
  34692. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34693. */
  34694. static DragMovementThreshold: number;
  34695. /**
  34696. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34697. */
  34698. static LongPressDelay: number;
  34699. /**
  34700. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34701. */
  34702. static DoubleClickDelay: number;
  34703. /** If you need to check double click without raising a single click at first click, enable this flag */
  34704. static ExclusiveDoubleClickMode: boolean;
  34705. /** @hidden */
  34706. _mirroredCameraPosition: Nullable<Vector3>;
  34707. /**
  34708. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34709. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34710. */
  34711. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34712. /**
  34713. * Observable event triggered each time an keyboard event is received from the hosting window
  34714. */
  34715. onKeyboardObservable: Observable<KeyboardInfo>;
  34716. private _useRightHandedSystem;
  34717. /**
  34718. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34719. */
  34720. useRightHandedSystem: boolean;
  34721. private _timeAccumulator;
  34722. private _currentStepId;
  34723. private _currentInternalStep;
  34724. /**
  34725. * Sets the step Id used by deterministic lock step
  34726. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34727. * @param newStepId defines the step Id
  34728. */
  34729. setStepId(newStepId: number): void;
  34730. /**
  34731. * Gets the step Id used by deterministic lock step
  34732. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34733. * @returns the step Id
  34734. */
  34735. getStepId(): number;
  34736. /**
  34737. * Gets the internal step used by deterministic lock step
  34738. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34739. * @returns the internal step
  34740. */
  34741. getInternalStep(): number;
  34742. private _fogEnabled;
  34743. /**
  34744. * Gets or sets a boolean indicating if fog is enabled on this scene
  34745. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34746. * (Default is true)
  34747. */
  34748. fogEnabled: boolean;
  34749. private _fogMode;
  34750. /**
  34751. * Gets or sets the fog mode to use
  34752. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34753. * | mode | value |
  34754. * | --- | --- |
  34755. * | FOGMODE_NONE | 0 |
  34756. * | FOGMODE_EXP | 1 |
  34757. * | FOGMODE_EXP2 | 2 |
  34758. * | FOGMODE_LINEAR | 3 |
  34759. */
  34760. fogMode: number;
  34761. /**
  34762. * Gets or sets the fog color to use
  34763. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34764. * (Default is Color3(0.2, 0.2, 0.3))
  34765. */
  34766. fogColor: Color3;
  34767. /**
  34768. * Gets or sets the fog density to use
  34769. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34770. * (Default is 0.1)
  34771. */
  34772. fogDensity: number;
  34773. /**
  34774. * Gets or sets the fog start distance to use
  34775. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34776. * (Default is 0)
  34777. */
  34778. fogStart: number;
  34779. /**
  34780. * Gets or sets the fog end distance to use
  34781. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34782. * (Default is 1000)
  34783. */
  34784. fogEnd: number;
  34785. private _shadowsEnabled;
  34786. /**
  34787. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34788. */
  34789. shadowsEnabled: boolean;
  34790. private _lightsEnabled;
  34791. /**
  34792. * Gets or sets a boolean indicating if lights are enabled on this scene
  34793. */
  34794. lightsEnabled: boolean;
  34795. /** All of the active cameras added to this scene. */
  34796. activeCameras: Camera[];
  34797. /** @hidden */
  34798. _activeCamera: Nullable<Camera>;
  34799. /** Gets or sets the current active camera */
  34800. activeCamera: Nullable<Camera>;
  34801. private _defaultMaterial;
  34802. /** The default material used on meshes when no material is affected */
  34803. /** The default material used on meshes when no material is affected */
  34804. defaultMaterial: Material;
  34805. private _texturesEnabled;
  34806. /**
  34807. * Gets or sets a boolean indicating if textures are enabled on this scene
  34808. */
  34809. texturesEnabled: boolean;
  34810. /**
  34811. * Gets or sets a boolean indicating if particles are enabled on this scene
  34812. */
  34813. particlesEnabled: boolean;
  34814. /**
  34815. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34816. */
  34817. spritesEnabled: boolean;
  34818. private _skeletonsEnabled;
  34819. /**
  34820. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34821. */
  34822. skeletonsEnabled: boolean;
  34823. /**
  34824. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34825. */
  34826. lensFlaresEnabled: boolean;
  34827. /**
  34828. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34829. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34830. */
  34831. collisionsEnabled: boolean;
  34832. private _collisionCoordinator;
  34833. /** @hidden */
  34834. readonly collisionCoordinator: ICollisionCoordinator;
  34835. /**
  34836. * Defines the gravity applied to this scene (used only for collisions)
  34837. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34838. */
  34839. gravity: Vector3;
  34840. /**
  34841. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34842. */
  34843. postProcessesEnabled: boolean;
  34844. /**
  34845. * The list of postprocesses added to the scene
  34846. */
  34847. postProcesses: PostProcess[];
  34848. /**
  34849. * Gets the current postprocess manager
  34850. */
  34851. postProcessManager: PostProcessManager;
  34852. /**
  34853. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34854. */
  34855. renderTargetsEnabled: boolean;
  34856. /**
  34857. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34858. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34859. */
  34860. dumpNextRenderTargets: boolean;
  34861. /**
  34862. * The list of user defined render targets added to the scene
  34863. */
  34864. customRenderTargets: RenderTargetTexture[];
  34865. /**
  34866. * Defines if texture loading must be delayed
  34867. * If true, textures will only be loaded when they need to be rendered
  34868. */
  34869. useDelayedTextureLoading: boolean;
  34870. /**
  34871. * Gets the list of meshes imported to the scene through SceneLoader
  34872. */
  34873. importedMeshesFiles: String[];
  34874. /**
  34875. * Gets or sets a boolean indicating if probes are enabled on this scene
  34876. */
  34877. probesEnabled: boolean;
  34878. /**
  34879. * Gets or sets the current offline provider to use to store scene data
  34880. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34881. */
  34882. offlineProvider: IOfflineProvider;
  34883. /**
  34884. * Gets or sets the action manager associated with the scene
  34885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34886. */
  34887. actionManager: AbstractActionManager;
  34888. private _meshesForIntersections;
  34889. /**
  34890. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34891. */
  34892. proceduralTexturesEnabled: boolean;
  34893. private _engine;
  34894. private _totalVertices;
  34895. /** @hidden */
  34896. _activeIndices: PerfCounter;
  34897. /** @hidden */
  34898. _activeParticles: PerfCounter;
  34899. /** @hidden */
  34900. _activeBones: PerfCounter;
  34901. private _animationRatio;
  34902. /** @hidden */
  34903. _animationTimeLast: number;
  34904. /** @hidden */
  34905. _animationTime: number;
  34906. /**
  34907. * Gets or sets a general scale for animation speed
  34908. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34909. */
  34910. animationTimeScale: number;
  34911. /** @hidden */
  34912. _cachedMaterial: Nullable<Material>;
  34913. /** @hidden */
  34914. _cachedEffect: Nullable<Effect>;
  34915. /** @hidden */
  34916. _cachedVisibility: Nullable<number>;
  34917. private _renderId;
  34918. private _frameId;
  34919. private _executeWhenReadyTimeoutId;
  34920. private _intermediateRendering;
  34921. private _viewUpdateFlag;
  34922. private _projectionUpdateFlag;
  34923. /** @hidden */
  34924. _toBeDisposed: Nullable<IDisposable>[];
  34925. private _activeRequests;
  34926. /** @hidden */
  34927. _pendingData: any[];
  34928. private _isDisposed;
  34929. /**
  34930. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34931. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34932. */
  34933. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34934. private _activeMeshes;
  34935. private _processedMaterials;
  34936. private _renderTargets;
  34937. /** @hidden */
  34938. _activeParticleSystems: SmartArray<IParticleSystem>;
  34939. private _activeSkeletons;
  34940. private _softwareSkinnedMeshes;
  34941. private _renderingManager;
  34942. /** @hidden */
  34943. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34944. private _transformMatrix;
  34945. private _sceneUbo;
  34946. /** @hidden */
  34947. _viewMatrix: Matrix;
  34948. private _projectionMatrix;
  34949. /** @hidden */
  34950. _forcedViewPosition: Nullable<Vector3>;
  34951. /** @hidden */
  34952. _frustumPlanes: Plane[];
  34953. /**
  34954. * Gets the list of frustum planes (built from the active camera)
  34955. */
  34956. readonly frustumPlanes: Plane[];
  34957. /**
  34958. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34959. * This is useful if there are more lights that the maximum simulteanous authorized
  34960. */
  34961. requireLightSorting: boolean;
  34962. /** @hidden */
  34963. readonly useMaterialMeshMap: boolean;
  34964. /** @hidden */
  34965. readonly useClonedMeshhMap: boolean;
  34966. private _externalData;
  34967. private _uid;
  34968. /**
  34969. * @hidden
  34970. * Backing store of defined scene components.
  34971. */
  34972. _components: ISceneComponent[];
  34973. /**
  34974. * @hidden
  34975. * Backing store of defined scene components.
  34976. */
  34977. _serializableComponents: ISceneSerializableComponent[];
  34978. /**
  34979. * List of components to register on the next registration step.
  34980. */
  34981. private _transientComponents;
  34982. /**
  34983. * Registers the transient components if needed.
  34984. */
  34985. private _registerTransientComponents;
  34986. /**
  34987. * @hidden
  34988. * Add a component to the scene.
  34989. * Note that the ccomponent could be registered on th next frame if this is called after
  34990. * the register component stage.
  34991. * @param component Defines the component to add to the scene
  34992. */
  34993. _addComponent(component: ISceneComponent): void;
  34994. /**
  34995. * @hidden
  34996. * Gets a component from the scene.
  34997. * @param name defines the name of the component to retrieve
  34998. * @returns the component or null if not present
  34999. */
  35000. _getComponent(name: string): Nullable<ISceneComponent>;
  35001. /**
  35002. * @hidden
  35003. * Defines the actions happening before camera updates.
  35004. */
  35005. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35006. /**
  35007. * @hidden
  35008. * Defines the actions happening before clear the canvas.
  35009. */
  35010. _beforeClearStage: Stage<SimpleStageAction>;
  35011. /**
  35012. * @hidden
  35013. * Defines the actions when collecting render targets for the frame.
  35014. */
  35015. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35016. /**
  35017. * @hidden
  35018. * Defines the actions happening for one camera in the frame.
  35019. */
  35020. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35021. /**
  35022. * @hidden
  35023. * Defines the actions happening during the per mesh ready checks.
  35024. */
  35025. _isReadyForMeshStage: Stage<MeshStageAction>;
  35026. /**
  35027. * @hidden
  35028. * Defines the actions happening before evaluate active mesh checks.
  35029. */
  35030. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35031. /**
  35032. * @hidden
  35033. * Defines the actions happening during the evaluate sub mesh checks.
  35034. */
  35035. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35036. /**
  35037. * @hidden
  35038. * Defines the actions happening during the active mesh stage.
  35039. */
  35040. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35041. /**
  35042. * @hidden
  35043. * Defines the actions happening during the per camera render target step.
  35044. */
  35045. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35046. /**
  35047. * @hidden
  35048. * Defines the actions happening just before the active camera is drawing.
  35049. */
  35050. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35051. /**
  35052. * @hidden
  35053. * Defines the actions happening just before a render target is drawing.
  35054. */
  35055. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35056. /**
  35057. * @hidden
  35058. * Defines the actions happening just before a rendering group is drawing.
  35059. */
  35060. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35061. /**
  35062. * @hidden
  35063. * Defines the actions happening just before a mesh is drawing.
  35064. */
  35065. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35066. /**
  35067. * @hidden
  35068. * Defines the actions happening just after a mesh has been drawn.
  35069. */
  35070. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35071. /**
  35072. * @hidden
  35073. * Defines the actions happening just after a rendering group has been drawn.
  35074. */
  35075. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35076. /**
  35077. * @hidden
  35078. * Defines the actions happening just after the active camera has been drawn.
  35079. */
  35080. _afterCameraDrawStage: Stage<CameraStageAction>;
  35081. /**
  35082. * @hidden
  35083. * Defines the actions happening just after a render target has been drawn.
  35084. */
  35085. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35086. /**
  35087. * @hidden
  35088. * Defines the actions happening just after rendering all cameras and computing intersections.
  35089. */
  35090. _afterRenderStage: Stage<SimpleStageAction>;
  35091. /**
  35092. * @hidden
  35093. * Defines the actions happening when a pointer move event happens.
  35094. */
  35095. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35096. /**
  35097. * @hidden
  35098. * Defines the actions happening when a pointer down event happens.
  35099. */
  35100. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35101. /**
  35102. * @hidden
  35103. * Defines the actions happening when a pointer up event happens.
  35104. */
  35105. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35106. /**
  35107. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35108. */
  35109. private geometriesByUniqueId;
  35110. /**
  35111. * Creates a new Scene
  35112. * @param engine defines the engine to use to render this scene
  35113. * @param options defines the scene options
  35114. */
  35115. constructor(engine: Engine, options?: SceneOptions);
  35116. /**
  35117. * Gets a string idenfifying the name of the class
  35118. * @returns "Scene" string
  35119. */
  35120. getClassName(): string;
  35121. private _defaultMeshCandidates;
  35122. /**
  35123. * @hidden
  35124. */
  35125. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35126. private _defaultSubMeshCandidates;
  35127. /**
  35128. * @hidden
  35129. */
  35130. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35131. /**
  35132. * Sets the default candidate providers for the scene.
  35133. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35134. * and getCollidingSubMeshCandidates to their default function
  35135. */
  35136. setDefaultCandidateProviders(): void;
  35137. /**
  35138. * Gets the mesh that is currently under the pointer
  35139. */
  35140. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35141. /**
  35142. * Gets or sets the current on-screen X position of the pointer
  35143. */
  35144. pointerX: number;
  35145. /**
  35146. * Gets or sets the current on-screen Y position of the pointer
  35147. */
  35148. pointerY: number;
  35149. /**
  35150. * Gets the cached material (ie. the latest rendered one)
  35151. * @returns the cached material
  35152. */
  35153. getCachedMaterial(): Nullable<Material>;
  35154. /**
  35155. * Gets the cached effect (ie. the latest rendered one)
  35156. * @returns the cached effect
  35157. */
  35158. getCachedEffect(): Nullable<Effect>;
  35159. /**
  35160. * Gets the cached visibility state (ie. the latest rendered one)
  35161. * @returns the cached visibility state
  35162. */
  35163. getCachedVisibility(): Nullable<number>;
  35164. /**
  35165. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35166. * @param material defines the current material
  35167. * @param effect defines the current effect
  35168. * @param visibility defines the current visibility state
  35169. * @returns true if one parameter is not cached
  35170. */
  35171. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35172. /**
  35173. * Gets the engine associated with the scene
  35174. * @returns an Engine
  35175. */
  35176. getEngine(): Engine;
  35177. /**
  35178. * Gets the total number of vertices rendered per frame
  35179. * @returns the total number of vertices rendered per frame
  35180. */
  35181. getTotalVertices(): number;
  35182. /**
  35183. * Gets the performance counter for total vertices
  35184. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35185. */
  35186. readonly totalVerticesPerfCounter: PerfCounter;
  35187. /**
  35188. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35189. * @returns the total number of active indices rendered per frame
  35190. */
  35191. getActiveIndices(): number;
  35192. /**
  35193. * Gets the performance counter for active indices
  35194. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35195. */
  35196. readonly totalActiveIndicesPerfCounter: PerfCounter;
  35197. /**
  35198. * Gets the total number of active particles rendered per frame
  35199. * @returns the total number of active particles rendered per frame
  35200. */
  35201. getActiveParticles(): number;
  35202. /**
  35203. * Gets the performance counter for active particles
  35204. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35205. */
  35206. readonly activeParticlesPerfCounter: PerfCounter;
  35207. /**
  35208. * Gets the total number of active bones rendered per frame
  35209. * @returns the total number of active bones rendered per frame
  35210. */
  35211. getActiveBones(): number;
  35212. /**
  35213. * Gets the performance counter for active bones
  35214. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35215. */
  35216. readonly activeBonesPerfCounter: PerfCounter;
  35217. /**
  35218. * Gets the array of active meshes
  35219. * @returns an array of AbstractMesh
  35220. */
  35221. getActiveMeshes(): SmartArray<AbstractMesh>;
  35222. /**
  35223. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35224. * @returns a number
  35225. */
  35226. getAnimationRatio(): number;
  35227. /**
  35228. * Gets an unique Id for the current render phase
  35229. * @returns a number
  35230. */
  35231. getRenderId(): number;
  35232. /**
  35233. * Gets an unique Id for the current frame
  35234. * @returns a number
  35235. */
  35236. getFrameId(): number;
  35237. /** Call this function if you want to manually increment the render Id*/
  35238. incrementRenderId(): void;
  35239. private _createUbo;
  35240. /**
  35241. * Use this method to simulate a pointer move on a mesh
  35242. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35243. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35244. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35245. * @returns the current scene
  35246. */
  35247. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35248. /**
  35249. * Use this method to simulate a pointer down on a mesh
  35250. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35251. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35252. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35253. * @returns the current scene
  35254. */
  35255. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35256. /**
  35257. * Use this method to simulate a pointer up on a mesh
  35258. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35259. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35260. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35261. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35262. * @returns the current scene
  35263. */
  35264. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35265. /**
  35266. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35267. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35268. * @returns true if the pointer was captured
  35269. */
  35270. isPointerCaptured(pointerId?: number): boolean;
  35271. /**
  35272. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35273. * @param attachUp defines if you want to attach events to pointerup
  35274. * @param attachDown defines if you want to attach events to pointerdown
  35275. * @param attachMove defines if you want to attach events to pointermove
  35276. */
  35277. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35278. /** Detaches all event handlers*/
  35279. detachControl(): void;
  35280. /**
  35281. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35282. * Delay loaded resources are not taking in account
  35283. * @return true if all required resources are ready
  35284. */
  35285. isReady(): boolean;
  35286. /** Resets all cached information relative to material (including effect and visibility) */
  35287. resetCachedMaterial(): void;
  35288. /**
  35289. * Registers a function to be called before every frame render
  35290. * @param func defines the function to register
  35291. */
  35292. registerBeforeRender(func: () => void): void;
  35293. /**
  35294. * Unregisters a function called before every frame render
  35295. * @param func defines the function to unregister
  35296. */
  35297. unregisterBeforeRender(func: () => void): void;
  35298. /**
  35299. * Registers a function to be called after every frame render
  35300. * @param func defines the function to register
  35301. */
  35302. registerAfterRender(func: () => void): void;
  35303. /**
  35304. * Unregisters a function called after every frame render
  35305. * @param func defines the function to unregister
  35306. */
  35307. unregisterAfterRender(func: () => void): void;
  35308. private _executeOnceBeforeRender;
  35309. /**
  35310. * The provided function will run before render once and will be disposed afterwards.
  35311. * A timeout delay can be provided so that the function will be executed in N ms.
  35312. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35313. * @param func The function to be executed.
  35314. * @param timeout optional delay in ms
  35315. */
  35316. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35317. /** @hidden */
  35318. _addPendingData(data: any): void;
  35319. /** @hidden */
  35320. _removePendingData(data: any): void;
  35321. /**
  35322. * Returns the number of items waiting to be loaded
  35323. * @returns the number of items waiting to be loaded
  35324. */
  35325. getWaitingItemsCount(): number;
  35326. /**
  35327. * Returns a boolean indicating if the scene is still loading data
  35328. */
  35329. readonly isLoading: boolean;
  35330. /**
  35331. * Registers a function to be executed when the scene is ready
  35332. * @param {Function} func - the function to be executed
  35333. */
  35334. executeWhenReady(func: () => void): void;
  35335. /**
  35336. * Returns a promise that resolves when the scene is ready
  35337. * @returns A promise that resolves when the scene is ready
  35338. */
  35339. whenReadyAsync(): Promise<void>;
  35340. /** @hidden */
  35341. _checkIsReady(): void;
  35342. /**
  35343. * Gets all animatable attached to the scene
  35344. */
  35345. readonly animatables: Animatable[];
  35346. /**
  35347. * Resets the last animation time frame.
  35348. * Useful to override when animations start running when loading a scene for the first time.
  35349. */
  35350. resetLastAnimationTimeFrame(): void;
  35351. /**
  35352. * Gets the current view matrix
  35353. * @returns a Matrix
  35354. */
  35355. getViewMatrix(): Matrix;
  35356. /**
  35357. * Gets the current projection matrix
  35358. * @returns a Matrix
  35359. */
  35360. getProjectionMatrix(): Matrix;
  35361. /**
  35362. * Gets the current transform matrix
  35363. * @returns a Matrix made of View * Projection
  35364. */
  35365. getTransformMatrix(): Matrix;
  35366. /**
  35367. * Sets the current transform matrix
  35368. * @param viewL defines the View matrix to use
  35369. * @param projectionL defines the Projection matrix to use
  35370. * @param viewR defines the right View matrix to use (if provided)
  35371. * @param projectionR defines the right Projection matrix to use (if provided)
  35372. */
  35373. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35374. /**
  35375. * Gets the uniform buffer used to store scene data
  35376. * @returns a UniformBuffer
  35377. */
  35378. getSceneUniformBuffer(): UniformBuffer;
  35379. /**
  35380. * Gets an unique (relatively to the current scene) Id
  35381. * @returns an unique number for the scene
  35382. */
  35383. getUniqueId(): number;
  35384. /**
  35385. * Add a mesh to the list of scene's meshes
  35386. * @param newMesh defines the mesh to add
  35387. * @param recursive if all child meshes should also be added to the scene
  35388. */
  35389. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35390. /**
  35391. * Remove a mesh for the list of scene's meshes
  35392. * @param toRemove defines the mesh to remove
  35393. * @param recursive if all child meshes should also be removed from the scene
  35394. * @returns the index where the mesh was in the mesh list
  35395. */
  35396. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35397. /**
  35398. * Add a transform node to the list of scene's transform nodes
  35399. * @param newTransformNode defines the transform node to add
  35400. */
  35401. addTransformNode(newTransformNode: TransformNode): void;
  35402. /**
  35403. * Remove a transform node for the list of scene's transform nodes
  35404. * @param toRemove defines the transform node to remove
  35405. * @returns the index where the transform node was in the transform node list
  35406. */
  35407. removeTransformNode(toRemove: TransformNode): number;
  35408. /**
  35409. * Remove a skeleton for the list of scene's skeletons
  35410. * @param toRemove defines the skeleton to remove
  35411. * @returns the index where the skeleton was in the skeleton list
  35412. */
  35413. removeSkeleton(toRemove: Skeleton): number;
  35414. /**
  35415. * Remove a morph target for the list of scene's morph targets
  35416. * @param toRemove defines the morph target to remove
  35417. * @returns the index where the morph target was in the morph target list
  35418. */
  35419. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35420. /**
  35421. * Remove a light for the list of scene's lights
  35422. * @param toRemove defines the light to remove
  35423. * @returns the index where the light was in the light list
  35424. */
  35425. removeLight(toRemove: Light): number;
  35426. /**
  35427. * Remove a camera for the list of scene's cameras
  35428. * @param toRemove defines the camera to remove
  35429. * @returns the index where the camera was in the camera list
  35430. */
  35431. removeCamera(toRemove: Camera): number;
  35432. /**
  35433. * Remove a particle system for the list of scene's particle systems
  35434. * @param toRemove defines the particle system to remove
  35435. * @returns the index where the particle system was in the particle system list
  35436. */
  35437. removeParticleSystem(toRemove: IParticleSystem): number;
  35438. /**
  35439. * Remove a animation for the list of scene's animations
  35440. * @param toRemove defines the animation to remove
  35441. * @returns the index where the animation was in the animation list
  35442. */
  35443. removeAnimation(toRemove: Animation): number;
  35444. /**
  35445. * Will stop the animation of the given target
  35446. * @param target - the target
  35447. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35448. * @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)
  35449. */
  35450. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35451. /**
  35452. * Removes the given animation group from this scene.
  35453. * @param toRemove The animation group to remove
  35454. * @returns The index of the removed animation group
  35455. */
  35456. removeAnimationGroup(toRemove: AnimationGroup): number;
  35457. /**
  35458. * Removes the given multi-material from this scene.
  35459. * @param toRemove The multi-material to remove
  35460. * @returns The index of the removed multi-material
  35461. */
  35462. removeMultiMaterial(toRemove: MultiMaterial): number;
  35463. /**
  35464. * Removes the given material from this scene.
  35465. * @param toRemove The material to remove
  35466. * @returns The index of the removed material
  35467. */
  35468. removeMaterial(toRemove: Material): number;
  35469. /**
  35470. * Removes the given action manager from this scene.
  35471. * @param toRemove The action manager to remove
  35472. * @returns The index of the removed action manager
  35473. */
  35474. removeActionManager(toRemove: AbstractActionManager): number;
  35475. /**
  35476. * Removes the given texture from this scene.
  35477. * @param toRemove The texture to remove
  35478. * @returns The index of the removed texture
  35479. */
  35480. removeTexture(toRemove: BaseTexture): number;
  35481. /**
  35482. * Adds the given light to this scene
  35483. * @param newLight The light to add
  35484. */
  35485. addLight(newLight: Light): void;
  35486. /**
  35487. * Sorts the list list based on light priorities
  35488. */
  35489. sortLightsByPriority(): void;
  35490. /**
  35491. * Adds the given camera to this scene
  35492. * @param newCamera The camera to add
  35493. */
  35494. addCamera(newCamera: Camera): void;
  35495. /**
  35496. * Adds the given skeleton to this scene
  35497. * @param newSkeleton The skeleton to add
  35498. */
  35499. addSkeleton(newSkeleton: Skeleton): void;
  35500. /**
  35501. * Adds the given particle system to this scene
  35502. * @param newParticleSystem The particle system to add
  35503. */
  35504. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35505. /**
  35506. * Adds the given animation to this scene
  35507. * @param newAnimation The animation to add
  35508. */
  35509. addAnimation(newAnimation: Animation): void;
  35510. /**
  35511. * Adds the given animation group to this scene.
  35512. * @param newAnimationGroup The animation group to add
  35513. */
  35514. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35515. /**
  35516. * Adds the given multi-material to this scene
  35517. * @param newMultiMaterial The multi-material to add
  35518. */
  35519. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35520. /**
  35521. * Adds the given material to this scene
  35522. * @param newMaterial The material to add
  35523. */
  35524. addMaterial(newMaterial: Material): void;
  35525. /**
  35526. * Adds the given morph target to this scene
  35527. * @param newMorphTargetManager The morph target to add
  35528. */
  35529. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35530. /**
  35531. * Adds the given geometry to this scene
  35532. * @param newGeometry The geometry to add
  35533. */
  35534. addGeometry(newGeometry: Geometry): void;
  35535. /**
  35536. * Adds the given action manager to this scene
  35537. * @param newActionManager The action manager to add
  35538. */
  35539. addActionManager(newActionManager: AbstractActionManager): void;
  35540. /**
  35541. * Adds the given texture to this scene.
  35542. * @param newTexture The texture to add
  35543. */
  35544. addTexture(newTexture: BaseTexture): void;
  35545. /**
  35546. * Switch active camera
  35547. * @param newCamera defines the new active camera
  35548. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35549. */
  35550. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35551. /**
  35552. * sets the active camera of the scene using its ID
  35553. * @param id defines the camera's ID
  35554. * @return the new active camera or null if none found.
  35555. */
  35556. setActiveCameraByID(id: string): Nullable<Camera>;
  35557. /**
  35558. * sets the active camera of the scene using its name
  35559. * @param name defines the camera's name
  35560. * @returns the new active camera or null if none found.
  35561. */
  35562. setActiveCameraByName(name: string): Nullable<Camera>;
  35563. /**
  35564. * get an animation group using its name
  35565. * @param name defines the material's name
  35566. * @return the animation group or null if none found.
  35567. */
  35568. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35569. /**
  35570. * Get a material using its unique id
  35571. * @param uniqueId defines the material's unique id
  35572. * @return the material or null if none found.
  35573. */
  35574. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35575. /**
  35576. * get a material using its id
  35577. * @param id defines the material's ID
  35578. * @return the material or null if none found.
  35579. */
  35580. getMaterialByID(id: string): Nullable<Material>;
  35581. /**
  35582. * Gets a the last added material using a given id
  35583. * @param id defines the material's ID
  35584. * @return the last material with the given id or null if none found.
  35585. */
  35586. getLastMaterialByID(id: string): Nullable<Material>;
  35587. /**
  35588. * Gets a material using its name
  35589. * @param name defines the material's name
  35590. * @return the material or null if none found.
  35591. */
  35592. getMaterialByName(name: string): Nullable<Material>;
  35593. /**
  35594. * Get a texture using its unique id
  35595. * @param uniqueId defines the texture's unique id
  35596. * @return the texture or null if none found.
  35597. */
  35598. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35599. /**
  35600. * Gets a camera using its id
  35601. * @param id defines the id to look for
  35602. * @returns the camera or null if not found
  35603. */
  35604. getCameraByID(id: string): Nullable<Camera>;
  35605. /**
  35606. * Gets a camera using its unique id
  35607. * @param uniqueId defines the unique id to look for
  35608. * @returns the camera or null if not found
  35609. */
  35610. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35611. /**
  35612. * Gets a camera using its name
  35613. * @param name defines the camera's name
  35614. * @return the camera or null if none found.
  35615. */
  35616. getCameraByName(name: string): Nullable<Camera>;
  35617. /**
  35618. * Gets a bone using its id
  35619. * @param id defines the bone's id
  35620. * @return the bone or null if not found
  35621. */
  35622. getBoneByID(id: string): Nullable<Bone>;
  35623. /**
  35624. * Gets a bone using its id
  35625. * @param name defines the bone's name
  35626. * @return the bone or null if not found
  35627. */
  35628. getBoneByName(name: string): Nullable<Bone>;
  35629. /**
  35630. * Gets a light node using its name
  35631. * @param name defines the the light's name
  35632. * @return the light or null if none found.
  35633. */
  35634. getLightByName(name: string): Nullable<Light>;
  35635. /**
  35636. * Gets a light node using its id
  35637. * @param id defines the light's id
  35638. * @return the light or null if none found.
  35639. */
  35640. getLightByID(id: string): Nullable<Light>;
  35641. /**
  35642. * Gets a light node using its scene-generated unique ID
  35643. * @param uniqueId defines the light's unique id
  35644. * @return the light or null if none found.
  35645. */
  35646. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35647. /**
  35648. * Gets a particle system by id
  35649. * @param id defines the particle system id
  35650. * @return the corresponding system or null if none found
  35651. */
  35652. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35653. /**
  35654. * Gets a geometry using its ID
  35655. * @param id defines the geometry's id
  35656. * @return the geometry or null if none found.
  35657. */
  35658. getGeometryByID(id: string): Nullable<Geometry>;
  35659. private _getGeometryByUniqueID;
  35660. /**
  35661. * Add a new geometry to this scene
  35662. * @param geometry defines the geometry to be added to the scene.
  35663. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35664. * @return a boolean defining if the geometry was added or not
  35665. */
  35666. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35667. /**
  35668. * Removes an existing geometry
  35669. * @param geometry defines the geometry to be removed from the scene
  35670. * @return a boolean defining if the geometry was removed or not
  35671. */
  35672. removeGeometry(geometry: Geometry): boolean;
  35673. /**
  35674. * Gets the list of geometries attached to the scene
  35675. * @returns an array of Geometry
  35676. */
  35677. getGeometries(): Geometry[];
  35678. /**
  35679. * Gets the first added mesh found of a given ID
  35680. * @param id defines the id to search for
  35681. * @return the mesh found or null if not found at all
  35682. */
  35683. getMeshByID(id: string): Nullable<AbstractMesh>;
  35684. /**
  35685. * Gets a list of meshes using their id
  35686. * @param id defines the id to search for
  35687. * @returns a list of meshes
  35688. */
  35689. getMeshesByID(id: string): Array<AbstractMesh>;
  35690. /**
  35691. * Gets the first added transform node found of a given ID
  35692. * @param id defines the id to search for
  35693. * @return the found transform node or null if not found at all.
  35694. */
  35695. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35696. /**
  35697. * Gets a transform node with its auto-generated unique id
  35698. * @param uniqueId efines the unique id to search for
  35699. * @return the found transform node or null if not found at all.
  35700. */
  35701. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35702. /**
  35703. * Gets a list of transform nodes using their id
  35704. * @param id defines the id to search for
  35705. * @returns a list of transform nodes
  35706. */
  35707. getTransformNodesByID(id: string): Array<TransformNode>;
  35708. /**
  35709. * Gets a mesh with its auto-generated unique id
  35710. * @param uniqueId defines the unique id to search for
  35711. * @return the found mesh or null if not found at all.
  35712. */
  35713. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35714. /**
  35715. * Gets a the last added mesh using a given id
  35716. * @param id defines the id to search for
  35717. * @return the found mesh or null if not found at all.
  35718. */
  35719. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35720. /**
  35721. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35722. * @param id defines the id to search for
  35723. * @return the found node or null if not found at all
  35724. */
  35725. getLastEntryByID(id: string): Nullable<Node>;
  35726. /**
  35727. * Gets a node (Mesh, Camera, Light) using a given id
  35728. * @param id defines the id to search for
  35729. * @return the found node or null if not found at all
  35730. */
  35731. getNodeByID(id: string): Nullable<Node>;
  35732. /**
  35733. * Gets a node (Mesh, Camera, Light) using a given name
  35734. * @param name defines the name to search for
  35735. * @return the found node or null if not found at all.
  35736. */
  35737. getNodeByName(name: string): Nullable<Node>;
  35738. /**
  35739. * Gets a mesh using a given name
  35740. * @param name defines the name to search for
  35741. * @return the found mesh or null if not found at all.
  35742. */
  35743. getMeshByName(name: string): Nullable<AbstractMesh>;
  35744. /**
  35745. * Gets a transform node using a given name
  35746. * @param name defines the name to search for
  35747. * @return the found transform node or null if not found at all.
  35748. */
  35749. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35750. /**
  35751. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35752. * @param id defines the id to search for
  35753. * @return the found skeleton or null if not found at all.
  35754. */
  35755. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35756. /**
  35757. * Gets a skeleton using a given auto generated unique id
  35758. * @param uniqueId defines the unique id to search for
  35759. * @return the found skeleton or null if not found at all.
  35760. */
  35761. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35762. /**
  35763. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35764. * @param id defines the id to search for
  35765. * @return the found skeleton or null if not found at all.
  35766. */
  35767. getSkeletonById(id: string): Nullable<Skeleton>;
  35768. /**
  35769. * Gets a skeleton using a given name
  35770. * @param name defines the name to search for
  35771. * @return the found skeleton or null if not found at all.
  35772. */
  35773. getSkeletonByName(name: string): Nullable<Skeleton>;
  35774. /**
  35775. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35776. * @param id defines the id to search for
  35777. * @return the found morph target manager or null if not found at all.
  35778. */
  35779. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35780. /**
  35781. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35782. * @param id defines the id to search for
  35783. * @return the found morph target or null if not found at all.
  35784. */
  35785. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35786. /**
  35787. * Gets a boolean indicating if the given mesh is active
  35788. * @param mesh defines the mesh to look for
  35789. * @returns true if the mesh is in the active list
  35790. */
  35791. isActiveMesh(mesh: AbstractMesh): boolean;
  35792. /**
  35793. * Return a unique id as a string which can serve as an identifier for the scene
  35794. */
  35795. readonly uid: string;
  35796. /**
  35797. * Add an externaly attached data from its key.
  35798. * This method call will fail and return false, if such key already exists.
  35799. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35800. * @param key the unique key that identifies the data
  35801. * @param data the data object to associate to the key for this Engine instance
  35802. * @return true if no such key were already present and the data was added successfully, false otherwise
  35803. */
  35804. addExternalData<T>(key: string, data: T): boolean;
  35805. /**
  35806. * Get an externaly attached data from its key
  35807. * @param key the unique key that identifies the data
  35808. * @return the associated data, if present (can be null), or undefined if not present
  35809. */
  35810. getExternalData<T>(key: string): Nullable<T>;
  35811. /**
  35812. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35813. * @param key the unique key that identifies the data
  35814. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35815. * @return the associated data, can be null if the factory returned null.
  35816. */
  35817. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35818. /**
  35819. * Remove an externaly attached data from the Engine instance
  35820. * @param key the unique key that identifies the data
  35821. * @return true if the data was successfully removed, false if it doesn't exist
  35822. */
  35823. removeExternalData(key: string): boolean;
  35824. private _evaluateSubMesh;
  35825. /**
  35826. * Clear the processed materials smart array preventing retention point in material dispose.
  35827. */
  35828. freeProcessedMaterials(): void;
  35829. private _preventFreeActiveMeshesAndRenderingGroups;
  35830. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35831. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35832. * when disposing several meshes in a row or a hierarchy of meshes.
  35833. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35834. */
  35835. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35836. /**
  35837. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35838. */
  35839. freeActiveMeshes(): void;
  35840. /**
  35841. * Clear the info related to rendering groups preventing retention points during dispose.
  35842. */
  35843. freeRenderingGroups(): void;
  35844. /** @hidden */
  35845. _isInIntermediateRendering(): boolean;
  35846. /**
  35847. * Lambda returning the list of potentially active meshes.
  35848. */
  35849. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35850. /**
  35851. * Lambda returning the list of potentially active sub meshes.
  35852. */
  35853. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35854. /**
  35855. * Lambda returning the list of potentially intersecting sub meshes.
  35856. */
  35857. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35858. /**
  35859. * Lambda returning the list of potentially colliding sub meshes.
  35860. */
  35861. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35862. private _activeMeshesFrozen;
  35863. private _skipEvaluateActiveMeshesCompletely;
  35864. /**
  35865. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35866. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  35867. * @returns the current scene
  35868. */
  35869. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  35870. /**
  35871. * Use this function to restart evaluating active meshes on every frame
  35872. * @returns the current scene
  35873. */
  35874. unfreezeActiveMeshes(): Scene;
  35875. private _evaluateActiveMeshes;
  35876. private _activeMesh;
  35877. /**
  35878. * Update the transform matrix to update from the current active camera
  35879. * @param force defines a boolean used to force the update even if cache is up to date
  35880. */
  35881. updateTransformMatrix(force?: boolean): void;
  35882. private _bindFrameBuffer;
  35883. /** @hidden */
  35884. _allowPostProcessClearColor: boolean;
  35885. /** @hidden */
  35886. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35887. private _processSubCameras;
  35888. private _checkIntersections;
  35889. /** @hidden */
  35890. _advancePhysicsEngineStep(step: number): void;
  35891. /**
  35892. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35893. */
  35894. getDeterministicFrameTime: () => number;
  35895. /** @hidden */
  35896. _animate(): void;
  35897. /** Execute all animations (for a frame) */
  35898. animate(): void;
  35899. /**
  35900. * Render the scene
  35901. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35902. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35903. */
  35904. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35905. /**
  35906. * Freeze all materials
  35907. * A frozen material will not be updatable but should be faster to render
  35908. */
  35909. freezeMaterials(): void;
  35910. /**
  35911. * Unfreeze all materials
  35912. * A frozen material will not be updatable but should be faster to render
  35913. */
  35914. unfreezeMaterials(): void;
  35915. /**
  35916. * Releases all held ressources
  35917. */
  35918. dispose(): void;
  35919. /**
  35920. * Gets if the scene is already disposed
  35921. */
  35922. readonly isDisposed: boolean;
  35923. /**
  35924. * Call this function to reduce memory footprint of the scene.
  35925. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35926. */
  35927. clearCachedVertexData(): void;
  35928. /**
  35929. * This function will remove the local cached buffer data from texture.
  35930. * It will save memory but will prevent the texture from being rebuilt
  35931. */
  35932. cleanCachedTextureBuffer(): void;
  35933. /**
  35934. * Get the world extend vectors with an optional filter
  35935. *
  35936. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35937. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35938. */
  35939. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35940. min: Vector3;
  35941. max: Vector3;
  35942. };
  35943. /**
  35944. * Creates a ray that can be used to pick in the scene
  35945. * @param x defines the x coordinate of the origin (on-screen)
  35946. * @param y defines the y coordinate of the origin (on-screen)
  35947. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35948. * @param camera defines the camera to use for the picking
  35949. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35950. * @returns a Ray
  35951. */
  35952. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35953. /**
  35954. * Creates a ray that can be used to pick in the scene
  35955. * @param x defines the x coordinate of the origin (on-screen)
  35956. * @param y defines the y coordinate of the origin (on-screen)
  35957. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35958. * @param result defines the ray where to store the picking ray
  35959. * @param camera defines the camera to use for the picking
  35960. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35961. * @returns the current scene
  35962. */
  35963. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35964. /**
  35965. * Creates a ray that can be used to pick in the scene
  35966. * @param x defines the x coordinate of the origin (on-screen)
  35967. * @param y defines the y coordinate of the origin (on-screen)
  35968. * @param camera defines the camera to use for the picking
  35969. * @returns a Ray
  35970. */
  35971. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35972. /**
  35973. * Creates a ray that can be used to pick in the scene
  35974. * @param x defines the x coordinate of the origin (on-screen)
  35975. * @param y defines the y coordinate of the origin (on-screen)
  35976. * @param result defines the ray where to store the picking ray
  35977. * @param camera defines the camera to use for the picking
  35978. * @returns the current scene
  35979. */
  35980. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35981. /** Launch a ray to try to pick a mesh in the scene
  35982. * @param x position on screen
  35983. * @param y position on screen
  35984. * @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
  35985. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35986. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35987. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35988. * @returns a PickingInfo
  35989. */
  35990. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35991. /** Use the given ray to pick a mesh in the scene
  35992. * @param ray The ray to use to pick meshes
  35993. * @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
  35994. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35995. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35996. * @returns a PickingInfo
  35997. */
  35998. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35999. /**
  36000. * Launch a ray to try to pick a mesh in the scene
  36001. * @param x X position on screen
  36002. * @param y Y position on screen
  36003. * @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
  36004. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36005. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36006. * @returns an array of PickingInfo
  36007. */
  36008. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36009. /**
  36010. * Launch a ray to try to pick a mesh in the scene
  36011. * @param ray Ray to use
  36012. * @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
  36013. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36014. * @returns an array of PickingInfo
  36015. */
  36016. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36017. /**
  36018. * Force the value of meshUnderPointer
  36019. * @param mesh defines the mesh to use
  36020. */
  36021. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36022. /**
  36023. * Gets the mesh under the pointer
  36024. * @returns a Mesh or null if no mesh is under the pointer
  36025. */
  36026. getPointerOverMesh(): Nullable<AbstractMesh>;
  36027. /** @hidden */
  36028. _rebuildGeometries(): void;
  36029. /** @hidden */
  36030. _rebuildTextures(): void;
  36031. private _getByTags;
  36032. /**
  36033. * Get a list of meshes by tags
  36034. * @param tagsQuery defines the tags query to use
  36035. * @param forEach defines a predicate used to filter results
  36036. * @returns an array of Mesh
  36037. */
  36038. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36039. /**
  36040. * Get a list of cameras by tags
  36041. * @param tagsQuery defines the tags query to use
  36042. * @param forEach defines a predicate used to filter results
  36043. * @returns an array of Camera
  36044. */
  36045. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36046. /**
  36047. * Get a list of lights by tags
  36048. * @param tagsQuery defines the tags query to use
  36049. * @param forEach defines a predicate used to filter results
  36050. * @returns an array of Light
  36051. */
  36052. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36053. /**
  36054. * Get a list of materials by tags
  36055. * @param tagsQuery defines the tags query to use
  36056. * @param forEach defines a predicate used to filter results
  36057. * @returns an array of Material
  36058. */
  36059. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36060. /**
  36061. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36062. * This allowed control for front to back rendering or reversly depending of the special needs.
  36063. *
  36064. * @param renderingGroupId The rendering group id corresponding to its index
  36065. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36066. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36067. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36068. */
  36069. 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;
  36070. /**
  36071. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36072. *
  36073. * @param renderingGroupId The rendering group id corresponding to its index
  36074. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36075. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36076. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36077. */
  36078. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36079. /**
  36080. * Gets the current auto clear configuration for one rendering group of the rendering
  36081. * manager.
  36082. * @param index the rendering group index to get the information for
  36083. * @returns The auto clear setup for the requested rendering group
  36084. */
  36085. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36086. private _blockMaterialDirtyMechanism;
  36087. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36088. blockMaterialDirtyMechanism: boolean;
  36089. /**
  36090. * Will flag all materials as dirty to trigger new shader compilation
  36091. * @param flag defines the flag used to specify which material part must be marked as dirty
  36092. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36093. */
  36094. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36095. /** @hidden */
  36096. _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;
  36097. /** @hidden */
  36098. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36099. /** @hidden */
  36100. _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;
  36101. /** @hidden */
  36102. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36103. /** @hidden */
  36104. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36105. /** @hidden */
  36106. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36107. }
  36108. }
  36109. declare module "babylonjs/assetContainer" {
  36110. import { AbstractScene } from "babylonjs/abstractScene";
  36111. import { Scene } from "babylonjs/scene";
  36112. import { Mesh } from "babylonjs/Meshes/mesh";
  36113. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36114. import { Skeleton } from "babylonjs/Bones/skeleton";
  36115. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36116. /**
  36117. * Set of assets to keep when moving a scene into an asset container.
  36118. */
  36119. export class KeepAssets extends AbstractScene {
  36120. }
  36121. /**
  36122. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36123. */
  36124. export class InstantiatedEntries {
  36125. /**
  36126. * List of new root nodes (eg. nodes with no parent)
  36127. */
  36128. rootNodes: TransformNode[];
  36129. /**
  36130. * List of new skeletons
  36131. */
  36132. skeletons: Skeleton[];
  36133. /**
  36134. * List of new animation groups
  36135. */
  36136. animationGroups: AnimationGroup[];
  36137. }
  36138. /**
  36139. * Container with a set of assets that can be added or removed from a scene.
  36140. */
  36141. export class AssetContainer extends AbstractScene {
  36142. /**
  36143. * The scene the AssetContainer belongs to.
  36144. */
  36145. scene: Scene;
  36146. /**
  36147. * Instantiates an AssetContainer.
  36148. * @param scene The scene the AssetContainer belongs to.
  36149. */
  36150. constructor(scene: Scene);
  36151. /**
  36152. * Instantiate or clone all meshes and add the new ones to the scene.
  36153. * Skeletons and animation groups will all be cloned
  36154. * @param nameFunction defines an optional function used to get new names for clones
  36155. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36156. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36157. */
  36158. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36159. /**
  36160. * Adds all the assets from the container to the scene.
  36161. */
  36162. addAllToScene(): void;
  36163. /**
  36164. * Removes all the assets in the container from the scene
  36165. */
  36166. removeAllFromScene(): void;
  36167. /**
  36168. * Disposes all the assets in the container
  36169. */
  36170. dispose(): void;
  36171. private _moveAssets;
  36172. /**
  36173. * Removes all the assets contained in the scene and adds them to the container.
  36174. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36175. */
  36176. moveAllFromScene(keepAssets?: KeepAssets): void;
  36177. /**
  36178. * 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.
  36179. * @returns the root mesh
  36180. */
  36181. createRootMesh(): Mesh;
  36182. }
  36183. }
  36184. declare module "babylonjs/abstractScene" {
  36185. import { Scene } from "babylonjs/scene";
  36186. import { Nullable } from "babylonjs/types";
  36187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36188. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36189. import { Geometry } from "babylonjs/Meshes/geometry";
  36190. import { Skeleton } from "babylonjs/Bones/skeleton";
  36191. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36192. import { AssetContainer } from "babylonjs/assetContainer";
  36193. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36194. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36195. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36196. import { Material } from "babylonjs/Materials/material";
  36197. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36198. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36199. import { Camera } from "babylonjs/Cameras/camera";
  36200. import { Light } from "babylonjs/Lights/light";
  36201. import { Node } from "babylonjs/node";
  36202. import { Animation } from "babylonjs/Animations/animation";
  36203. /**
  36204. * Defines how the parser contract is defined.
  36205. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36206. */
  36207. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36208. /**
  36209. * Defines how the individual parser contract is defined.
  36210. * These parser can parse an individual asset
  36211. */
  36212. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36213. /**
  36214. * Base class of the scene acting as a container for the different elements composing a scene.
  36215. * This class is dynamically extended by the different components of the scene increasing
  36216. * flexibility and reducing coupling
  36217. */
  36218. export abstract class AbstractScene {
  36219. /**
  36220. * Stores the list of available parsers in the application.
  36221. */
  36222. private static _BabylonFileParsers;
  36223. /**
  36224. * Stores the list of available individual parsers in the application.
  36225. */
  36226. private static _IndividualBabylonFileParsers;
  36227. /**
  36228. * Adds a parser in the list of available ones
  36229. * @param name Defines the name of the parser
  36230. * @param parser Defines the parser to add
  36231. */
  36232. static AddParser(name: string, parser: BabylonFileParser): void;
  36233. /**
  36234. * Gets a general parser from the list of avaialble ones
  36235. * @param name Defines the name of the parser
  36236. * @returns the requested parser or null
  36237. */
  36238. static GetParser(name: string): Nullable<BabylonFileParser>;
  36239. /**
  36240. * Adds n individual parser in the list of available ones
  36241. * @param name Defines the name of the parser
  36242. * @param parser Defines the parser to add
  36243. */
  36244. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36245. /**
  36246. * Gets an individual parser from the list of avaialble ones
  36247. * @param name Defines the name of the parser
  36248. * @returns the requested parser or null
  36249. */
  36250. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36251. /**
  36252. * Parser json data and populate both a scene and its associated container object
  36253. * @param jsonData Defines the data to parse
  36254. * @param scene Defines the scene to parse the data for
  36255. * @param container Defines the container attached to the parsing sequence
  36256. * @param rootUrl Defines the root url of the data
  36257. */
  36258. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36259. /**
  36260. * Gets the list of root nodes (ie. nodes with no parent)
  36261. */
  36262. rootNodes: Node[];
  36263. /** All of the cameras added to this scene
  36264. * @see http://doc.babylonjs.com/babylon101/cameras
  36265. */
  36266. cameras: Camera[];
  36267. /**
  36268. * All of the lights added to this scene
  36269. * @see http://doc.babylonjs.com/babylon101/lights
  36270. */
  36271. lights: Light[];
  36272. /**
  36273. * All of the (abstract) meshes added to this scene
  36274. */
  36275. meshes: AbstractMesh[];
  36276. /**
  36277. * The list of skeletons added to the scene
  36278. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36279. */
  36280. skeletons: Skeleton[];
  36281. /**
  36282. * All of the particle systems added to this scene
  36283. * @see http://doc.babylonjs.com/babylon101/particles
  36284. */
  36285. particleSystems: IParticleSystem[];
  36286. /**
  36287. * Gets a list of Animations associated with the scene
  36288. */
  36289. animations: Animation[];
  36290. /**
  36291. * All of the animation groups added to this scene
  36292. * @see http://doc.babylonjs.com/how_to/group
  36293. */
  36294. animationGroups: AnimationGroup[];
  36295. /**
  36296. * All of the multi-materials added to this scene
  36297. * @see http://doc.babylonjs.com/how_to/multi_materials
  36298. */
  36299. multiMaterials: MultiMaterial[];
  36300. /**
  36301. * All of the materials added to this scene
  36302. * In the context of a Scene, it is not supposed to be modified manually.
  36303. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36304. * Note also that the order of the Material within the array is not significant and might change.
  36305. * @see http://doc.babylonjs.com/babylon101/materials
  36306. */
  36307. materials: Material[];
  36308. /**
  36309. * The list of morph target managers added to the scene
  36310. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36311. */
  36312. morphTargetManagers: MorphTargetManager[];
  36313. /**
  36314. * The list of geometries used in the scene.
  36315. */
  36316. geometries: Geometry[];
  36317. /**
  36318. * All of the tranform nodes added to this scene
  36319. * In the context of a Scene, it is not supposed to be modified manually.
  36320. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36321. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36322. * @see http://doc.babylonjs.com/how_to/transformnode
  36323. */
  36324. transformNodes: TransformNode[];
  36325. /**
  36326. * ActionManagers available on the scene.
  36327. */
  36328. actionManagers: AbstractActionManager[];
  36329. /**
  36330. * Textures to keep.
  36331. */
  36332. textures: BaseTexture[];
  36333. /**
  36334. * Environment texture for the scene
  36335. */
  36336. environmentTexture: Nullable<BaseTexture>;
  36337. }
  36338. }
  36339. declare module "babylonjs/Audio/sound" {
  36340. import { Observable } from "babylonjs/Misc/observable";
  36341. import { Vector3 } from "babylonjs/Maths/math.vector";
  36342. import { Nullable } from "babylonjs/types";
  36343. import { Scene } from "babylonjs/scene";
  36344. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36345. /**
  36346. * Interface used to define options for Sound class
  36347. */
  36348. export interface ISoundOptions {
  36349. /**
  36350. * Does the sound autoplay once loaded.
  36351. */
  36352. autoplay?: boolean;
  36353. /**
  36354. * Does the sound loop after it finishes playing once.
  36355. */
  36356. loop?: boolean;
  36357. /**
  36358. * Sound's volume
  36359. */
  36360. volume?: number;
  36361. /**
  36362. * Is it a spatial sound?
  36363. */
  36364. spatialSound?: boolean;
  36365. /**
  36366. * Maximum distance to hear that sound
  36367. */
  36368. maxDistance?: number;
  36369. /**
  36370. * Uses user defined attenuation function
  36371. */
  36372. useCustomAttenuation?: boolean;
  36373. /**
  36374. * Define the roll off factor of spatial sounds.
  36375. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36376. */
  36377. rolloffFactor?: number;
  36378. /**
  36379. * Define the reference distance the sound should be heard perfectly.
  36380. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36381. */
  36382. refDistance?: number;
  36383. /**
  36384. * Define the distance attenuation model the sound will follow.
  36385. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36386. */
  36387. distanceModel?: string;
  36388. /**
  36389. * Defines the playback speed (1 by default)
  36390. */
  36391. playbackRate?: number;
  36392. /**
  36393. * Defines if the sound is from a streaming source
  36394. */
  36395. streaming?: boolean;
  36396. /**
  36397. * Defines an optional length (in seconds) inside the sound file
  36398. */
  36399. length?: number;
  36400. /**
  36401. * Defines an optional offset (in seconds) inside the sound file
  36402. */
  36403. offset?: number;
  36404. /**
  36405. * If true, URLs will not be required to state the audio file codec to use.
  36406. */
  36407. skipCodecCheck?: boolean;
  36408. }
  36409. /**
  36410. * Defines a sound that can be played in the application.
  36411. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36412. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36413. */
  36414. export class Sound {
  36415. /**
  36416. * The name of the sound in the scene.
  36417. */
  36418. name: string;
  36419. /**
  36420. * Does the sound autoplay once loaded.
  36421. */
  36422. autoplay: boolean;
  36423. /**
  36424. * Does the sound loop after it finishes playing once.
  36425. */
  36426. loop: boolean;
  36427. /**
  36428. * Does the sound use a custom attenuation curve to simulate the falloff
  36429. * happening when the source gets further away from the camera.
  36430. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36431. */
  36432. useCustomAttenuation: boolean;
  36433. /**
  36434. * The sound track id this sound belongs to.
  36435. */
  36436. soundTrackId: number;
  36437. /**
  36438. * Is this sound currently played.
  36439. */
  36440. isPlaying: boolean;
  36441. /**
  36442. * Is this sound currently paused.
  36443. */
  36444. isPaused: boolean;
  36445. /**
  36446. * Does this sound enables spatial sound.
  36447. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36448. */
  36449. spatialSound: boolean;
  36450. /**
  36451. * Define the reference distance the sound should be heard perfectly.
  36452. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36453. */
  36454. refDistance: number;
  36455. /**
  36456. * Define the roll off factor of spatial sounds.
  36457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36458. */
  36459. rolloffFactor: number;
  36460. /**
  36461. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36463. */
  36464. maxDistance: number;
  36465. /**
  36466. * Define the distance attenuation model the sound will follow.
  36467. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36468. */
  36469. distanceModel: string;
  36470. /**
  36471. * @hidden
  36472. * Back Compat
  36473. **/
  36474. onended: () => any;
  36475. /**
  36476. * Observable event when the current playing sound finishes.
  36477. */
  36478. onEndedObservable: Observable<Sound>;
  36479. private _panningModel;
  36480. private _playbackRate;
  36481. private _streaming;
  36482. private _startTime;
  36483. private _startOffset;
  36484. private _position;
  36485. /** @hidden */
  36486. _positionInEmitterSpace: boolean;
  36487. private _localDirection;
  36488. private _volume;
  36489. private _isReadyToPlay;
  36490. private _isDirectional;
  36491. private _readyToPlayCallback;
  36492. private _audioBuffer;
  36493. private _soundSource;
  36494. private _streamingSource;
  36495. private _soundPanner;
  36496. private _soundGain;
  36497. private _inputAudioNode;
  36498. private _outputAudioNode;
  36499. private _coneInnerAngle;
  36500. private _coneOuterAngle;
  36501. private _coneOuterGain;
  36502. private _scene;
  36503. private _connectedTransformNode;
  36504. private _customAttenuationFunction;
  36505. private _registerFunc;
  36506. private _isOutputConnected;
  36507. private _htmlAudioElement;
  36508. private _urlType;
  36509. private _length?;
  36510. private _offset?;
  36511. /** @hidden */
  36512. static _SceneComponentInitialization: (scene: Scene) => void;
  36513. /**
  36514. * Create a sound and attach it to a scene
  36515. * @param name Name of your sound
  36516. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36517. * @param scene defines the scene the sound belongs to
  36518. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36519. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36520. */
  36521. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36522. /**
  36523. * Release the sound and its associated resources
  36524. */
  36525. dispose(): void;
  36526. /**
  36527. * Gets if the sounds is ready to be played or not.
  36528. * @returns true if ready, otherwise false
  36529. */
  36530. isReady(): boolean;
  36531. private _soundLoaded;
  36532. /**
  36533. * Sets the data of the sound from an audiobuffer
  36534. * @param audioBuffer The audioBuffer containing the data
  36535. */
  36536. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36537. /**
  36538. * Updates the current sounds options such as maxdistance, loop...
  36539. * @param options A JSON object containing values named as the object properties
  36540. */
  36541. updateOptions(options: ISoundOptions): void;
  36542. private _createSpatialParameters;
  36543. private _updateSpatialParameters;
  36544. /**
  36545. * Switch the panning model to HRTF:
  36546. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36547. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36548. */
  36549. switchPanningModelToHRTF(): void;
  36550. /**
  36551. * Switch the panning model to Equal Power:
  36552. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36554. */
  36555. switchPanningModelToEqualPower(): void;
  36556. private _switchPanningModel;
  36557. /**
  36558. * Connect this sound to a sound track audio node like gain...
  36559. * @param soundTrackAudioNode the sound track audio node to connect to
  36560. */
  36561. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36562. /**
  36563. * Transform this sound into a directional source
  36564. * @param coneInnerAngle Size of the inner cone in degree
  36565. * @param coneOuterAngle Size of the outer cone in degree
  36566. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36567. */
  36568. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36569. /**
  36570. * Gets or sets the inner angle for the directional cone.
  36571. */
  36572. /**
  36573. * Gets or sets the inner angle for the directional cone.
  36574. */
  36575. directionalConeInnerAngle: number;
  36576. /**
  36577. * Gets or sets the outer angle for the directional cone.
  36578. */
  36579. /**
  36580. * Gets or sets the outer angle for the directional cone.
  36581. */
  36582. directionalConeOuterAngle: number;
  36583. /**
  36584. * Sets the position of the emitter if spatial sound is enabled
  36585. * @param newPosition Defines the new posisiton
  36586. */
  36587. setPosition(newPosition: Vector3): void;
  36588. /**
  36589. * Sets the local direction of the emitter if spatial sound is enabled
  36590. * @param newLocalDirection Defines the new local direction
  36591. */
  36592. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36593. private _updateDirection;
  36594. /** @hidden */
  36595. updateDistanceFromListener(): void;
  36596. /**
  36597. * Sets a new custom attenuation function for the sound.
  36598. * @param callback Defines the function used for the attenuation
  36599. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36600. */
  36601. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36602. /**
  36603. * Play the sound
  36604. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36605. * @param offset (optional) Start the sound at a specific time in seconds
  36606. * @param length (optional) Sound duration (in seconds)
  36607. */
  36608. play(time?: number, offset?: number, length?: number): void;
  36609. private _onended;
  36610. /**
  36611. * Stop the sound
  36612. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36613. */
  36614. stop(time?: number): void;
  36615. /**
  36616. * Put the sound in pause
  36617. */
  36618. pause(): void;
  36619. /**
  36620. * Sets a dedicated volume for this sounds
  36621. * @param newVolume Define the new volume of the sound
  36622. * @param time Define time for gradual change to new volume
  36623. */
  36624. setVolume(newVolume: number, time?: number): void;
  36625. /**
  36626. * Set the sound play back rate
  36627. * @param newPlaybackRate Define the playback rate the sound should be played at
  36628. */
  36629. setPlaybackRate(newPlaybackRate: number): void;
  36630. /**
  36631. * Gets the volume of the sound.
  36632. * @returns the volume of the sound
  36633. */
  36634. getVolume(): number;
  36635. /**
  36636. * Attach the sound to a dedicated mesh
  36637. * @param transformNode The transform node to connect the sound with
  36638. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36639. */
  36640. attachToMesh(transformNode: TransformNode): void;
  36641. /**
  36642. * Detach the sound from the previously attached mesh
  36643. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36644. */
  36645. detachFromMesh(): void;
  36646. private _onRegisterAfterWorldMatrixUpdate;
  36647. /**
  36648. * Clone the current sound in the scene.
  36649. * @returns the new sound clone
  36650. */
  36651. clone(): Nullable<Sound>;
  36652. /**
  36653. * Gets the current underlying audio buffer containing the data
  36654. * @returns the audio buffer
  36655. */
  36656. getAudioBuffer(): Nullable<AudioBuffer>;
  36657. /**
  36658. * Serializes the Sound in a JSON representation
  36659. * @returns the JSON representation of the sound
  36660. */
  36661. serialize(): any;
  36662. /**
  36663. * Parse a JSON representation of a sound to innstantiate in a given scene
  36664. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36665. * @param scene Define the scene the new parsed sound should be created in
  36666. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36667. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36668. * @returns the newly parsed sound
  36669. */
  36670. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36671. }
  36672. }
  36673. declare module "babylonjs/Actions/directAudioActions" {
  36674. import { Action } from "babylonjs/Actions/action";
  36675. import { Condition } from "babylonjs/Actions/condition";
  36676. import { Sound } from "babylonjs/Audio/sound";
  36677. /**
  36678. * This defines an action helpful to play a defined sound on a triggered action.
  36679. */
  36680. export class PlaySoundAction extends Action {
  36681. private _sound;
  36682. /**
  36683. * Instantiate the action
  36684. * @param triggerOptions defines the trigger options
  36685. * @param sound defines the sound to play
  36686. * @param condition defines the trigger related conditions
  36687. */
  36688. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36689. /** @hidden */
  36690. _prepare(): void;
  36691. /**
  36692. * Execute the action and play the sound.
  36693. */
  36694. execute(): void;
  36695. /**
  36696. * Serializes the actions and its related information.
  36697. * @param parent defines the object to serialize in
  36698. * @returns the serialized object
  36699. */
  36700. serialize(parent: any): any;
  36701. }
  36702. /**
  36703. * This defines an action helpful to stop a defined sound on a triggered action.
  36704. */
  36705. export class StopSoundAction extends Action {
  36706. private _sound;
  36707. /**
  36708. * Instantiate the action
  36709. * @param triggerOptions defines the trigger options
  36710. * @param sound defines the sound to stop
  36711. * @param condition defines the trigger related conditions
  36712. */
  36713. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36714. /** @hidden */
  36715. _prepare(): void;
  36716. /**
  36717. * Execute the action and stop the sound.
  36718. */
  36719. execute(): void;
  36720. /**
  36721. * Serializes the actions and its related information.
  36722. * @param parent defines the object to serialize in
  36723. * @returns the serialized object
  36724. */
  36725. serialize(parent: any): any;
  36726. }
  36727. }
  36728. declare module "babylonjs/Actions/interpolateValueAction" {
  36729. import { Action } from "babylonjs/Actions/action";
  36730. import { Condition } from "babylonjs/Actions/condition";
  36731. import { Observable } from "babylonjs/Misc/observable";
  36732. /**
  36733. * This defines an action responsible to change the value of a property
  36734. * by interpolating between its current value and the newly set one once triggered.
  36735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36736. */
  36737. export class InterpolateValueAction extends Action {
  36738. /**
  36739. * Defines the path of the property where the value should be interpolated
  36740. */
  36741. propertyPath: string;
  36742. /**
  36743. * Defines the target value at the end of the interpolation.
  36744. */
  36745. value: any;
  36746. /**
  36747. * Defines the time it will take for the property to interpolate to the value.
  36748. */
  36749. duration: number;
  36750. /**
  36751. * Defines if the other scene animations should be stopped when the action has been triggered
  36752. */
  36753. stopOtherAnimations?: boolean;
  36754. /**
  36755. * Defines a callback raised once the interpolation animation has been done.
  36756. */
  36757. onInterpolationDone?: () => void;
  36758. /**
  36759. * Observable triggered once the interpolation animation has been done.
  36760. */
  36761. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36762. private _target;
  36763. private _effectiveTarget;
  36764. private _property;
  36765. /**
  36766. * Instantiate the action
  36767. * @param triggerOptions defines the trigger options
  36768. * @param target defines the object containing the value to interpolate
  36769. * @param propertyPath defines the path to the property in the target object
  36770. * @param value defines the target value at the end of the interpolation
  36771. * @param duration deines the time it will take for the property to interpolate to the value.
  36772. * @param condition defines the trigger related conditions
  36773. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36774. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36775. */
  36776. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36777. /** @hidden */
  36778. _prepare(): void;
  36779. /**
  36780. * Execute the action starts the value interpolation.
  36781. */
  36782. execute(): void;
  36783. /**
  36784. * Serializes the actions and its related information.
  36785. * @param parent defines the object to serialize in
  36786. * @returns the serialized object
  36787. */
  36788. serialize(parent: any): any;
  36789. }
  36790. }
  36791. declare module "babylonjs/Actions/index" {
  36792. export * from "babylonjs/Actions/abstractActionManager";
  36793. export * from "babylonjs/Actions/action";
  36794. export * from "babylonjs/Actions/actionEvent";
  36795. export * from "babylonjs/Actions/actionManager";
  36796. export * from "babylonjs/Actions/condition";
  36797. export * from "babylonjs/Actions/directActions";
  36798. export * from "babylonjs/Actions/directAudioActions";
  36799. export * from "babylonjs/Actions/interpolateValueAction";
  36800. }
  36801. declare module "babylonjs/Animations/index" {
  36802. export * from "babylonjs/Animations/animatable";
  36803. export * from "babylonjs/Animations/animation";
  36804. export * from "babylonjs/Animations/animationGroup";
  36805. export * from "babylonjs/Animations/animationPropertiesOverride";
  36806. export * from "babylonjs/Animations/easing";
  36807. export * from "babylonjs/Animations/runtimeAnimation";
  36808. export * from "babylonjs/Animations/animationEvent";
  36809. export * from "babylonjs/Animations/animationGroup";
  36810. export * from "babylonjs/Animations/animationKey";
  36811. export * from "babylonjs/Animations/animationRange";
  36812. export * from "babylonjs/Animations/animatable.interface";
  36813. }
  36814. declare module "babylonjs/Audio/soundTrack" {
  36815. import { Sound } from "babylonjs/Audio/sound";
  36816. import { Analyser } from "babylonjs/Audio/analyser";
  36817. import { Scene } from "babylonjs/scene";
  36818. /**
  36819. * Options allowed during the creation of a sound track.
  36820. */
  36821. export interface ISoundTrackOptions {
  36822. /**
  36823. * The volume the sound track should take during creation
  36824. */
  36825. volume?: number;
  36826. /**
  36827. * Define if the sound track is the main sound track of the scene
  36828. */
  36829. mainTrack?: boolean;
  36830. }
  36831. /**
  36832. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36833. * It will be also used in a future release to apply effects on a specific track.
  36834. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36835. */
  36836. export class SoundTrack {
  36837. /**
  36838. * The unique identifier of the sound track in the scene.
  36839. */
  36840. id: number;
  36841. /**
  36842. * The list of sounds included in the sound track.
  36843. */
  36844. soundCollection: Array<Sound>;
  36845. private _outputAudioNode;
  36846. private _scene;
  36847. private _connectedAnalyser;
  36848. private _options;
  36849. private _isInitialized;
  36850. /**
  36851. * Creates a new sound track.
  36852. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36853. * @param scene Define the scene the sound track belongs to
  36854. * @param options
  36855. */
  36856. constructor(scene: Scene, options?: ISoundTrackOptions);
  36857. private _initializeSoundTrackAudioGraph;
  36858. /**
  36859. * Release the sound track and its associated resources
  36860. */
  36861. dispose(): void;
  36862. /**
  36863. * Adds a sound to this sound track
  36864. * @param sound define the cound to add
  36865. * @ignoreNaming
  36866. */
  36867. AddSound(sound: Sound): void;
  36868. /**
  36869. * Removes a sound to this sound track
  36870. * @param sound define the cound to remove
  36871. * @ignoreNaming
  36872. */
  36873. RemoveSound(sound: Sound): void;
  36874. /**
  36875. * Set a global volume for the full sound track.
  36876. * @param newVolume Define the new volume of the sound track
  36877. */
  36878. setVolume(newVolume: number): void;
  36879. /**
  36880. * Switch the panning model to HRTF:
  36881. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36882. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36883. */
  36884. switchPanningModelToHRTF(): void;
  36885. /**
  36886. * Switch the panning model to Equal Power:
  36887. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36889. */
  36890. switchPanningModelToEqualPower(): void;
  36891. /**
  36892. * Connect the sound track to an audio analyser allowing some amazing
  36893. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36894. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36895. * @param analyser The analyser to connect to the engine
  36896. */
  36897. connectToAnalyser(analyser: Analyser): void;
  36898. }
  36899. }
  36900. declare module "babylonjs/Audio/audioSceneComponent" {
  36901. import { Sound } from "babylonjs/Audio/sound";
  36902. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36903. import { Nullable } from "babylonjs/types";
  36904. import { Vector3 } from "babylonjs/Maths/math.vector";
  36905. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36906. import { Scene } from "babylonjs/scene";
  36907. import { AbstractScene } from "babylonjs/abstractScene";
  36908. import "babylonjs/Audio/audioEngine";
  36909. module "babylonjs/abstractScene" {
  36910. interface AbstractScene {
  36911. /**
  36912. * The list of sounds used in the scene.
  36913. */
  36914. sounds: Nullable<Array<Sound>>;
  36915. }
  36916. }
  36917. module "babylonjs/scene" {
  36918. interface Scene {
  36919. /**
  36920. * @hidden
  36921. * Backing field
  36922. */
  36923. _mainSoundTrack: SoundTrack;
  36924. /**
  36925. * The main sound track played by the scene.
  36926. * It cotains your primary collection of sounds.
  36927. */
  36928. mainSoundTrack: SoundTrack;
  36929. /**
  36930. * The list of sound tracks added to the scene
  36931. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36932. */
  36933. soundTracks: Nullable<Array<SoundTrack>>;
  36934. /**
  36935. * Gets a sound using a given name
  36936. * @param name defines the name to search for
  36937. * @return the found sound or null if not found at all.
  36938. */
  36939. getSoundByName(name: string): Nullable<Sound>;
  36940. /**
  36941. * Gets or sets if audio support is enabled
  36942. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36943. */
  36944. audioEnabled: boolean;
  36945. /**
  36946. * Gets or sets if audio will be output to headphones
  36947. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36948. */
  36949. headphone: boolean;
  36950. /**
  36951. * Gets or sets custom audio listener position provider
  36952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36953. */
  36954. audioListenerPositionProvider: Nullable<() => Vector3>;
  36955. /**
  36956. * Gets or sets a refresh rate when using 3D audio positioning
  36957. */
  36958. audioPositioningRefreshRate: number;
  36959. }
  36960. }
  36961. /**
  36962. * Defines the sound scene component responsible to manage any sounds
  36963. * in a given scene.
  36964. */
  36965. export class AudioSceneComponent implements ISceneSerializableComponent {
  36966. /**
  36967. * The component name helpfull to identify the component in the list of scene components.
  36968. */
  36969. readonly name: string;
  36970. /**
  36971. * The scene the component belongs to.
  36972. */
  36973. scene: Scene;
  36974. private _audioEnabled;
  36975. /**
  36976. * Gets whether audio is enabled or not.
  36977. * Please use related enable/disable method to switch state.
  36978. */
  36979. readonly audioEnabled: boolean;
  36980. private _headphone;
  36981. /**
  36982. * Gets whether audio is outputing to headphone or not.
  36983. * Please use the according Switch methods to change output.
  36984. */
  36985. readonly headphone: boolean;
  36986. /**
  36987. * Gets or sets a refresh rate when using 3D audio positioning
  36988. */
  36989. audioPositioningRefreshRate: number;
  36990. private _audioListenerPositionProvider;
  36991. /**
  36992. * Gets the current audio listener position provider
  36993. */
  36994. /**
  36995. * Sets a custom listener position for all sounds in the scene
  36996. * By default, this is the position of the first active camera
  36997. */
  36998. audioListenerPositionProvider: Nullable<() => Vector3>;
  36999. /**
  37000. * Creates a new instance of the component for the given scene
  37001. * @param scene Defines the scene to register the component in
  37002. */
  37003. constructor(scene: Scene);
  37004. /**
  37005. * Registers the component in a given scene
  37006. */
  37007. register(): void;
  37008. /**
  37009. * Rebuilds the elements related to this component in case of
  37010. * context lost for instance.
  37011. */
  37012. rebuild(): void;
  37013. /**
  37014. * Serializes the component data to the specified json object
  37015. * @param serializationObject The object to serialize to
  37016. */
  37017. serialize(serializationObject: any): void;
  37018. /**
  37019. * Adds all the elements from the container to the scene
  37020. * @param container the container holding the elements
  37021. */
  37022. addFromContainer(container: AbstractScene): void;
  37023. /**
  37024. * Removes all the elements in the container from the scene
  37025. * @param container contains the elements to remove
  37026. * @param dispose if the removed element should be disposed (default: false)
  37027. */
  37028. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37029. /**
  37030. * Disposes the component and the associated ressources.
  37031. */
  37032. dispose(): void;
  37033. /**
  37034. * Disables audio in the associated scene.
  37035. */
  37036. disableAudio(): void;
  37037. /**
  37038. * Enables audio in the associated scene.
  37039. */
  37040. enableAudio(): void;
  37041. /**
  37042. * Switch audio to headphone output.
  37043. */
  37044. switchAudioModeForHeadphones(): void;
  37045. /**
  37046. * Switch audio to normal speakers.
  37047. */
  37048. switchAudioModeForNormalSpeakers(): void;
  37049. private _cachedCameraDirection;
  37050. private _cachedCameraPosition;
  37051. private _lastCheck;
  37052. private _afterRender;
  37053. }
  37054. }
  37055. declare module "babylonjs/Audio/weightedsound" {
  37056. import { Sound } from "babylonjs/Audio/sound";
  37057. /**
  37058. * Wraps one or more Sound objects and selects one with random weight for playback.
  37059. */
  37060. export class WeightedSound {
  37061. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37062. loop: boolean;
  37063. private _coneInnerAngle;
  37064. private _coneOuterAngle;
  37065. private _volume;
  37066. /** A Sound is currently playing. */
  37067. isPlaying: boolean;
  37068. /** A Sound is currently paused. */
  37069. isPaused: boolean;
  37070. private _sounds;
  37071. private _weights;
  37072. private _currentIndex?;
  37073. /**
  37074. * Creates a new WeightedSound from the list of sounds given.
  37075. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37076. * @param sounds Array of Sounds that will be selected from.
  37077. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37078. */
  37079. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37080. /**
  37081. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37082. */
  37083. /**
  37084. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37085. */
  37086. directionalConeInnerAngle: number;
  37087. /**
  37088. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37089. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37090. */
  37091. /**
  37092. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37093. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37094. */
  37095. directionalConeOuterAngle: number;
  37096. /**
  37097. * Playback volume.
  37098. */
  37099. /**
  37100. * Playback volume.
  37101. */
  37102. volume: number;
  37103. private _onended;
  37104. /**
  37105. * Suspend playback
  37106. */
  37107. pause(): void;
  37108. /**
  37109. * Stop playback
  37110. */
  37111. stop(): void;
  37112. /**
  37113. * Start playback.
  37114. * @param startOffset Position the clip head at a specific time in seconds.
  37115. */
  37116. play(startOffset?: number): void;
  37117. }
  37118. }
  37119. declare module "babylonjs/Audio/index" {
  37120. export * from "babylonjs/Audio/analyser";
  37121. export * from "babylonjs/Audio/audioEngine";
  37122. export * from "babylonjs/Audio/audioSceneComponent";
  37123. export * from "babylonjs/Audio/sound";
  37124. export * from "babylonjs/Audio/soundTrack";
  37125. export * from "babylonjs/Audio/weightedsound";
  37126. }
  37127. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  37128. import { Behavior } from "babylonjs/Behaviors/behavior";
  37129. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37130. import { BackEase } from "babylonjs/Animations/easing";
  37131. /**
  37132. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37133. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37134. */
  37135. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37136. /**
  37137. * Gets the name of the behavior.
  37138. */
  37139. readonly name: string;
  37140. /**
  37141. * The easing function used by animations
  37142. */
  37143. static EasingFunction: BackEase;
  37144. /**
  37145. * The easing mode used by animations
  37146. */
  37147. static EasingMode: number;
  37148. /**
  37149. * The duration of the animation, in milliseconds
  37150. */
  37151. transitionDuration: number;
  37152. /**
  37153. * Length of the distance animated by the transition when lower radius is reached
  37154. */
  37155. lowerRadiusTransitionRange: number;
  37156. /**
  37157. * Length of the distance animated by the transition when upper radius is reached
  37158. */
  37159. upperRadiusTransitionRange: number;
  37160. private _autoTransitionRange;
  37161. /**
  37162. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37163. */
  37164. /**
  37165. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37166. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37167. */
  37168. autoTransitionRange: boolean;
  37169. private _attachedCamera;
  37170. private _onAfterCheckInputsObserver;
  37171. private _onMeshTargetChangedObserver;
  37172. /**
  37173. * Initializes the behavior.
  37174. */
  37175. init(): void;
  37176. /**
  37177. * Attaches the behavior to its arc rotate camera.
  37178. * @param camera Defines the camera to attach the behavior to
  37179. */
  37180. attach(camera: ArcRotateCamera): void;
  37181. /**
  37182. * Detaches the behavior from its current arc rotate camera.
  37183. */
  37184. detach(): void;
  37185. private _radiusIsAnimating;
  37186. private _radiusBounceTransition;
  37187. private _animatables;
  37188. private _cachedWheelPrecision;
  37189. /**
  37190. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37191. * @param radiusLimit The limit to check against.
  37192. * @return Bool to indicate if at limit.
  37193. */
  37194. private _isRadiusAtLimit;
  37195. /**
  37196. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37197. * @param radiusDelta The delta by which to animate to. Can be negative.
  37198. */
  37199. private _applyBoundRadiusAnimation;
  37200. /**
  37201. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37202. */
  37203. protected _clearAnimationLocks(): void;
  37204. /**
  37205. * Stops and removes all animations that have been applied to the camera
  37206. */
  37207. stopAllAnimations(): void;
  37208. }
  37209. }
  37210. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  37211. import { Behavior } from "babylonjs/Behaviors/behavior";
  37212. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37213. import { ExponentialEase } from "babylonjs/Animations/easing";
  37214. import { Nullable } from "babylonjs/types";
  37215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37216. import { Vector3 } from "babylonjs/Maths/math.vector";
  37217. /**
  37218. * 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.
  37219. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37220. */
  37221. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37222. /**
  37223. * Gets the name of the behavior.
  37224. */
  37225. readonly name: string;
  37226. private _mode;
  37227. private _radiusScale;
  37228. private _positionScale;
  37229. private _defaultElevation;
  37230. private _elevationReturnTime;
  37231. private _elevationReturnWaitTime;
  37232. private _zoomStopsAnimation;
  37233. private _framingTime;
  37234. /**
  37235. * The easing function used by animations
  37236. */
  37237. static EasingFunction: ExponentialEase;
  37238. /**
  37239. * The easing mode used by animations
  37240. */
  37241. static EasingMode: number;
  37242. /**
  37243. * Sets the current mode used by the behavior
  37244. */
  37245. /**
  37246. * Gets current mode used by the behavior.
  37247. */
  37248. mode: number;
  37249. /**
  37250. * Sets the scale applied to the radius (1 by default)
  37251. */
  37252. /**
  37253. * Gets the scale applied to the radius
  37254. */
  37255. radiusScale: number;
  37256. /**
  37257. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37258. */
  37259. /**
  37260. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37261. */
  37262. positionScale: number;
  37263. /**
  37264. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37265. * behaviour is triggered, in radians.
  37266. */
  37267. /**
  37268. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37269. * behaviour is triggered, in radians.
  37270. */
  37271. defaultElevation: number;
  37272. /**
  37273. * Sets the time (in milliseconds) taken to return to the default beta position.
  37274. * Negative value indicates camera should not return to default.
  37275. */
  37276. /**
  37277. * Gets the time (in milliseconds) taken to return to the default beta position.
  37278. * Negative value indicates camera should not return to default.
  37279. */
  37280. elevationReturnTime: number;
  37281. /**
  37282. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37283. */
  37284. /**
  37285. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37286. */
  37287. elevationReturnWaitTime: number;
  37288. /**
  37289. * Sets the flag that indicates if user zooming should stop animation.
  37290. */
  37291. /**
  37292. * Gets the flag that indicates if user zooming should stop animation.
  37293. */
  37294. zoomStopsAnimation: boolean;
  37295. /**
  37296. * Sets the transition time when framing the mesh, in milliseconds
  37297. */
  37298. /**
  37299. * Gets the transition time when framing the mesh, in milliseconds
  37300. */
  37301. framingTime: number;
  37302. /**
  37303. * Define if the behavior should automatically change the configured
  37304. * camera limits and sensibilities.
  37305. */
  37306. autoCorrectCameraLimitsAndSensibility: boolean;
  37307. private _onPrePointerObservableObserver;
  37308. private _onAfterCheckInputsObserver;
  37309. private _onMeshTargetChangedObserver;
  37310. private _attachedCamera;
  37311. private _isPointerDown;
  37312. private _lastInteractionTime;
  37313. /**
  37314. * Initializes the behavior.
  37315. */
  37316. init(): void;
  37317. /**
  37318. * Attaches the behavior to its arc rotate camera.
  37319. * @param camera Defines the camera to attach the behavior to
  37320. */
  37321. attach(camera: ArcRotateCamera): void;
  37322. /**
  37323. * Detaches the behavior from its current arc rotate camera.
  37324. */
  37325. detach(): void;
  37326. private _animatables;
  37327. private _betaIsAnimating;
  37328. private _betaTransition;
  37329. private _radiusTransition;
  37330. private _vectorTransition;
  37331. /**
  37332. * Targets the given mesh and updates zoom level accordingly.
  37333. * @param mesh The mesh to target.
  37334. * @param radius Optional. If a cached radius position already exists, overrides default.
  37335. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37336. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37337. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37338. */
  37339. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37340. /**
  37341. * Targets the given mesh with its children and updates zoom level accordingly.
  37342. * @param mesh The mesh to target.
  37343. * @param radius Optional. If a cached radius position already exists, overrides default.
  37344. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37345. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37346. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37347. */
  37348. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37349. /**
  37350. * Targets the given meshes with their children and updates zoom level accordingly.
  37351. * @param meshes The mesh to target.
  37352. * @param radius Optional. If a cached radius position already exists, overrides default.
  37353. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37354. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37355. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37356. */
  37357. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37358. /**
  37359. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37360. * @param minimumWorld Determines the smaller position of the bounding box extend
  37361. * @param maximumWorld Determines the bigger position of the bounding box extend
  37362. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37363. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37364. */
  37365. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37366. /**
  37367. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37368. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37369. * frustum width.
  37370. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37371. * to fully enclose the mesh in the viewing frustum.
  37372. */
  37373. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37374. /**
  37375. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37376. * is automatically returned to its default position (expected to be above ground plane).
  37377. */
  37378. private _maintainCameraAboveGround;
  37379. /**
  37380. * Returns the frustum slope based on the canvas ratio and camera FOV
  37381. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37382. */
  37383. private _getFrustumSlope;
  37384. /**
  37385. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37386. */
  37387. private _clearAnimationLocks;
  37388. /**
  37389. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37390. */
  37391. private _applyUserInteraction;
  37392. /**
  37393. * Stops and removes all animations that have been applied to the camera
  37394. */
  37395. stopAllAnimations(): void;
  37396. /**
  37397. * Gets a value indicating if the user is moving the camera
  37398. */
  37399. readonly isUserIsMoving: boolean;
  37400. /**
  37401. * The camera can move all the way towards the mesh.
  37402. */
  37403. static IgnoreBoundsSizeMode: number;
  37404. /**
  37405. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37406. */
  37407. static FitFrustumSidesMode: number;
  37408. }
  37409. }
  37410. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37411. import { Nullable } from "babylonjs/types";
  37412. import { Camera } from "babylonjs/Cameras/camera";
  37413. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37414. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37415. /**
  37416. * Base class for Camera Pointer Inputs.
  37417. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37418. * for example usage.
  37419. */
  37420. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37421. /**
  37422. * Defines the camera the input is attached to.
  37423. */
  37424. abstract camera: Camera;
  37425. /**
  37426. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37427. */
  37428. protected _altKey: boolean;
  37429. protected _ctrlKey: boolean;
  37430. protected _metaKey: boolean;
  37431. protected _shiftKey: boolean;
  37432. /**
  37433. * Which mouse buttons were pressed at time of last mouse event.
  37434. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37435. */
  37436. protected _buttonsPressed: number;
  37437. /**
  37438. * Defines the buttons associated with the input to handle camera move.
  37439. */
  37440. buttons: number[];
  37441. /**
  37442. * Attach the input controls to a specific dom element to get the input from.
  37443. * @param element Defines the element the controls should be listened from
  37444. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37445. */
  37446. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37447. /**
  37448. * Detach the current controls from the specified dom element.
  37449. * @param element Defines the element to stop listening the inputs from
  37450. */
  37451. detachControl(element: Nullable<HTMLElement>): void;
  37452. /**
  37453. * Gets the class name of the current input.
  37454. * @returns the class name
  37455. */
  37456. getClassName(): string;
  37457. /**
  37458. * Get the friendly name associated with the input class.
  37459. * @returns the input friendly name
  37460. */
  37461. getSimpleName(): string;
  37462. /**
  37463. * Called on pointer POINTERDOUBLETAP event.
  37464. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37465. */
  37466. protected onDoubleTap(type: string): void;
  37467. /**
  37468. * Called on pointer POINTERMOVE event if only a single touch is active.
  37469. * Override this method to provide functionality.
  37470. */
  37471. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37472. /**
  37473. * Called on pointer POINTERMOVE event if multiple touches are active.
  37474. * Override this method to provide functionality.
  37475. */
  37476. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37477. /**
  37478. * Called on JS contextmenu event.
  37479. * Override this method to provide functionality.
  37480. */
  37481. protected onContextMenu(evt: PointerEvent): void;
  37482. /**
  37483. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37484. * press.
  37485. * Override this method to provide functionality.
  37486. */
  37487. protected onButtonDown(evt: PointerEvent): void;
  37488. /**
  37489. * Called each time a new POINTERUP event occurs. Ie, for each button
  37490. * release.
  37491. * Override this method to provide functionality.
  37492. */
  37493. protected onButtonUp(evt: PointerEvent): void;
  37494. /**
  37495. * Called when window becomes inactive.
  37496. * Override this method to provide functionality.
  37497. */
  37498. protected onLostFocus(): void;
  37499. private _pointerInput;
  37500. private _observer;
  37501. private _onLostFocus;
  37502. private pointA;
  37503. private pointB;
  37504. }
  37505. }
  37506. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37507. import { Nullable } from "babylonjs/types";
  37508. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37509. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37510. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37511. /**
  37512. * Manage the pointers inputs to control an arc rotate camera.
  37513. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37514. */
  37515. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37516. /**
  37517. * Defines the camera the input is attached to.
  37518. */
  37519. camera: ArcRotateCamera;
  37520. /**
  37521. * Gets the class name of the current input.
  37522. * @returns the class name
  37523. */
  37524. getClassName(): string;
  37525. /**
  37526. * Defines the buttons associated with the input to handle camera move.
  37527. */
  37528. buttons: number[];
  37529. /**
  37530. * Defines the pointer angular sensibility along the X axis or how fast is
  37531. * the camera rotating.
  37532. */
  37533. angularSensibilityX: number;
  37534. /**
  37535. * Defines the pointer angular sensibility along the Y axis or how fast is
  37536. * the camera rotating.
  37537. */
  37538. angularSensibilityY: number;
  37539. /**
  37540. * Defines the pointer pinch precision or how fast is the camera zooming.
  37541. */
  37542. pinchPrecision: number;
  37543. /**
  37544. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37545. * from 0.
  37546. * It defines the percentage of current camera.radius to use as delta when
  37547. * pinch zoom is used.
  37548. */
  37549. pinchDeltaPercentage: number;
  37550. /**
  37551. * Defines the pointer panning sensibility or how fast is the camera moving.
  37552. */
  37553. panningSensibility: number;
  37554. /**
  37555. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37556. */
  37557. multiTouchPanning: boolean;
  37558. /**
  37559. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37560. * zoom (pinch) through multitouch.
  37561. */
  37562. multiTouchPanAndZoom: boolean;
  37563. /**
  37564. * Revers pinch action direction.
  37565. */
  37566. pinchInwards: boolean;
  37567. private _isPanClick;
  37568. private _twoFingerActivityCount;
  37569. private _isPinching;
  37570. /**
  37571. * Called on pointer POINTERMOVE event if only a single touch is active.
  37572. */
  37573. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37574. /**
  37575. * Called on pointer POINTERDOUBLETAP event.
  37576. */
  37577. protected onDoubleTap(type: string): void;
  37578. /**
  37579. * Called on pointer POINTERMOVE event if multiple touches are active.
  37580. */
  37581. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37582. /**
  37583. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37584. * press.
  37585. */
  37586. protected onButtonDown(evt: PointerEvent): void;
  37587. /**
  37588. * Called each time a new POINTERUP event occurs. Ie, for each button
  37589. * release.
  37590. */
  37591. protected onButtonUp(evt: PointerEvent): void;
  37592. /**
  37593. * Called when window becomes inactive.
  37594. */
  37595. protected onLostFocus(): void;
  37596. }
  37597. }
  37598. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37599. import { Nullable } from "babylonjs/types";
  37600. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37601. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37602. /**
  37603. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37604. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37605. */
  37606. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37607. /**
  37608. * Defines the camera the input is attached to.
  37609. */
  37610. camera: ArcRotateCamera;
  37611. /**
  37612. * Defines the list of key codes associated with the up action (increase alpha)
  37613. */
  37614. keysUp: number[];
  37615. /**
  37616. * Defines the list of key codes associated with the down action (decrease alpha)
  37617. */
  37618. keysDown: number[];
  37619. /**
  37620. * Defines the list of key codes associated with the left action (increase beta)
  37621. */
  37622. keysLeft: number[];
  37623. /**
  37624. * Defines the list of key codes associated with the right action (decrease beta)
  37625. */
  37626. keysRight: number[];
  37627. /**
  37628. * Defines the list of key codes associated with the reset action.
  37629. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37630. */
  37631. keysReset: number[];
  37632. /**
  37633. * Defines the panning sensibility of the inputs.
  37634. * (How fast is the camera paning)
  37635. */
  37636. panningSensibility: number;
  37637. /**
  37638. * Defines the zooming sensibility of the inputs.
  37639. * (How fast is the camera zooming)
  37640. */
  37641. zoomingSensibility: number;
  37642. /**
  37643. * Defines wether maintaining the alt key down switch the movement mode from
  37644. * orientation to zoom.
  37645. */
  37646. useAltToZoom: boolean;
  37647. /**
  37648. * Rotation speed of the camera
  37649. */
  37650. angularSpeed: number;
  37651. private _keys;
  37652. private _ctrlPressed;
  37653. private _altPressed;
  37654. private _onCanvasBlurObserver;
  37655. private _onKeyboardObserver;
  37656. private _engine;
  37657. private _scene;
  37658. /**
  37659. * Attach the input controls to a specific dom element to get the input from.
  37660. * @param element Defines the element the controls should be listened from
  37661. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37662. */
  37663. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37664. /**
  37665. * Detach the current controls from the specified dom element.
  37666. * @param element Defines the element to stop listening the inputs from
  37667. */
  37668. detachControl(element: Nullable<HTMLElement>): void;
  37669. /**
  37670. * Update the current camera state depending on the inputs that have been used this frame.
  37671. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37672. */
  37673. checkInputs(): void;
  37674. /**
  37675. * Gets the class name of the current intput.
  37676. * @returns the class name
  37677. */
  37678. getClassName(): string;
  37679. /**
  37680. * Get the friendly name associated with the input class.
  37681. * @returns the input friendly name
  37682. */
  37683. getSimpleName(): string;
  37684. }
  37685. }
  37686. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37687. import { Nullable } from "babylonjs/types";
  37688. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37689. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37690. /**
  37691. * Manage the mouse wheel inputs to control an arc rotate camera.
  37692. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37693. */
  37694. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37695. /**
  37696. * Defines the camera the input is attached to.
  37697. */
  37698. camera: ArcRotateCamera;
  37699. /**
  37700. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37701. */
  37702. wheelPrecision: number;
  37703. /**
  37704. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37705. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37706. */
  37707. wheelDeltaPercentage: number;
  37708. private _wheel;
  37709. private _observer;
  37710. private computeDeltaFromMouseWheelLegacyEvent;
  37711. /**
  37712. * Attach the input controls to a specific dom element to get the input from.
  37713. * @param element Defines the element the controls should be listened from
  37714. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37715. */
  37716. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37717. /**
  37718. * Detach the current controls from the specified dom element.
  37719. * @param element Defines the element to stop listening the inputs from
  37720. */
  37721. detachControl(element: Nullable<HTMLElement>): void;
  37722. /**
  37723. * Gets the class name of the current intput.
  37724. * @returns the class name
  37725. */
  37726. getClassName(): string;
  37727. /**
  37728. * Get the friendly name associated with the input class.
  37729. * @returns the input friendly name
  37730. */
  37731. getSimpleName(): string;
  37732. }
  37733. }
  37734. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37735. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37736. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37737. /**
  37738. * Default Inputs manager for the ArcRotateCamera.
  37739. * It groups all the default supported inputs for ease of use.
  37740. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37741. */
  37742. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37743. /**
  37744. * Instantiates a new ArcRotateCameraInputsManager.
  37745. * @param camera Defines the camera the inputs belong to
  37746. */
  37747. constructor(camera: ArcRotateCamera);
  37748. /**
  37749. * Add mouse wheel input support to the input manager.
  37750. * @returns the current input manager
  37751. */
  37752. addMouseWheel(): ArcRotateCameraInputsManager;
  37753. /**
  37754. * Add pointers input support to the input manager.
  37755. * @returns the current input manager
  37756. */
  37757. addPointers(): ArcRotateCameraInputsManager;
  37758. /**
  37759. * Add keyboard input support to the input manager.
  37760. * @returns the current input manager
  37761. */
  37762. addKeyboard(): ArcRotateCameraInputsManager;
  37763. }
  37764. }
  37765. declare module "babylonjs/Cameras/arcRotateCamera" {
  37766. import { Observable } from "babylonjs/Misc/observable";
  37767. import { Nullable } from "babylonjs/types";
  37768. import { Scene } from "babylonjs/scene";
  37769. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37771. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37772. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37773. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37774. import { Camera } from "babylonjs/Cameras/camera";
  37775. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37776. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37777. import { Collider } from "babylonjs/Collisions/collider";
  37778. /**
  37779. * This represents an orbital type of camera.
  37780. *
  37781. * 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.
  37782. * 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.
  37783. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37784. */
  37785. export class ArcRotateCamera extends TargetCamera {
  37786. /**
  37787. * Defines the rotation angle of the camera along the longitudinal axis.
  37788. */
  37789. alpha: number;
  37790. /**
  37791. * Defines the rotation angle of the camera along the latitudinal axis.
  37792. */
  37793. beta: number;
  37794. /**
  37795. * Defines the radius of the camera from it s target point.
  37796. */
  37797. radius: number;
  37798. protected _target: Vector3;
  37799. protected _targetHost: Nullable<AbstractMesh>;
  37800. /**
  37801. * Defines the target point of the camera.
  37802. * The camera looks towards it form the radius distance.
  37803. */
  37804. target: Vector3;
  37805. /**
  37806. * Define the current local position of the camera in the scene
  37807. */
  37808. position: Vector3;
  37809. protected _upVector: Vector3;
  37810. protected _upToYMatrix: Matrix;
  37811. protected _YToUpMatrix: Matrix;
  37812. /**
  37813. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37814. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37815. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37816. */
  37817. upVector: Vector3;
  37818. /**
  37819. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37820. */
  37821. setMatUp(): void;
  37822. /**
  37823. * Current inertia value on the longitudinal axis.
  37824. * The bigger this number the longer it will take for the camera to stop.
  37825. */
  37826. inertialAlphaOffset: number;
  37827. /**
  37828. * Current inertia value on the latitudinal axis.
  37829. * The bigger this number the longer it will take for the camera to stop.
  37830. */
  37831. inertialBetaOffset: number;
  37832. /**
  37833. * Current inertia value on the radius axis.
  37834. * The bigger this number the longer it will take for the camera to stop.
  37835. */
  37836. inertialRadiusOffset: number;
  37837. /**
  37838. * Minimum allowed angle on the longitudinal axis.
  37839. * This can help limiting how the Camera is able to move in the scene.
  37840. */
  37841. lowerAlphaLimit: Nullable<number>;
  37842. /**
  37843. * Maximum allowed angle on the longitudinal axis.
  37844. * This can help limiting how the Camera is able to move in the scene.
  37845. */
  37846. upperAlphaLimit: Nullable<number>;
  37847. /**
  37848. * Minimum allowed angle on the latitudinal axis.
  37849. * This can help limiting how the Camera is able to move in the scene.
  37850. */
  37851. lowerBetaLimit: number;
  37852. /**
  37853. * Maximum allowed angle on the latitudinal axis.
  37854. * This can help limiting how the Camera is able to move in the scene.
  37855. */
  37856. upperBetaLimit: number;
  37857. /**
  37858. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37859. * This can help limiting how the Camera is able to move in the scene.
  37860. */
  37861. lowerRadiusLimit: Nullable<number>;
  37862. /**
  37863. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37864. * This can help limiting how the Camera is able to move in the scene.
  37865. */
  37866. upperRadiusLimit: Nullable<number>;
  37867. /**
  37868. * Defines the current inertia value used during panning of the camera along the X axis.
  37869. */
  37870. inertialPanningX: number;
  37871. /**
  37872. * Defines the current inertia value used during panning of the camera along the Y axis.
  37873. */
  37874. inertialPanningY: number;
  37875. /**
  37876. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37877. * Basically if your fingers moves away from more than this distance you will be considered
  37878. * in pinch mode.
  37879. */
  37880. pinchToPanMaxDistance: number;
  37881. /**
  37882. * Defines the maximum distance the camera can pan.
  37883. * This could help keeping the cammera always in your scene.
  37884. */
  37885. panningDistanceLimit: Nullable<number>;
  37886. /**
  37887. * Defines the target of the camera before paning.
  37888. */
  37889. panningOriginTarget: Vector3;
  37890. /**
  37891. * Defines the value of the inertia used during panning.
  37892. * 0 would mean stop inertia and one would mean no decelleration at all.
  37893. */
  37894. panningInertia: number;
  37895. /**
  37896. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37897. */
  37898. angularSensibilityX: number;
  37899. /**
  37900. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37901. */
  37902. angularSensibilityY: number;
  37903. /**
  37904. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37905. */
  37906. pinchPrecision: number;
  37907. /**
  37908. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37909. * It will be used instead of pinchDeltaPrecision if different from 0.
  37910. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37911. */
  37912. pinchDeltaPercentage: number;
  37913. /**
  37914. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37915. */
  37916. panningSensibility: number;
  37917. /**
  37918. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37919. */
  37920. keysUp: number[];
  37921. /**
  37922. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37923. */
  37924. keysDown: number[];
  37925. /**
  37926. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37927. */
  37928. keysLeft: number[];
  37929. /**
  37930. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37931. */
  37932. keysRight: number[];
  37933. /**
  37934. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37935. */
  37936. wheelPrecision: number;
  37937. /**
  37938. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37939. * It will be used instead of pinchDeltaPrecision if different from 0.
  37940. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37941. */
  37942. wheelDeltaPercentage: number;
  37943. /**
  37944. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37945. */
  37946. zoomOnFactor: number;
  37947. /**
  37948. * Defines a screen offset for the camera position.
  37949. */
  37950. targetScreenOffset: Vector2;
  37951. /**
  37952. * Allows the camera to be completely reversed.
  37953. * If false the camera can not arrive upside down.
  37954. */
  37955. allowUpsideDown: boolean;
  37956. /**
  37957. * Define if double tap/click is used to restore the previously saved state of the camera.
  37958. */
  37959. useInputToRestoreState: boolean;
  37960. /** @hidden */
  37961. _viewMatrix: Matrix;
  37962. /** @hidden */
  37963. _useCtrlForPanning: boolean;
  37964. /** @hidden */
  37965. _panningMouseButton: number;
  37966. /**
  37967. * Defines the input associated to the camera.
  37968. */
  37969. inputs: ArcRotateCameraInputsManager;
  37970. /** @hidden */
  37971. _reset: () => void;
  37972. /**
  37973. * Defines the allowed panning axis.
  37974. */
  37975. panningAxis: Vector3;
  37976. protected _localDirection: Vector3;
  37977. protected _transformedDirection: Vector3;
  37978. private _bouncingBehavior;
  37979. /**
  37980. * Gets the bouncing behavior of the camera if it has been enabled.
  37981. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37982. */
  37983. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37984. /**
  37985. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37986. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37987. */
  37988. useBouncingBehavior: boolean;
  37989. private _framingBehavior;
  37990. /**
  37991. * Gets the framing behavior of the camera if it has been enabled.
  37992. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37993. */
  37994. readonly framingBehavior: Nullable<FramingBehavior>;
  37995. /**
  37996. * Defines if the framing behavior of the camera is enabled on the camera.
  37997. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37998. */
  37999. useFramingBehavior: boolean;
  38000. private _autoRotationBehavior;
  38001. /**
  38002. * Gets the auto rotation behavior of the camera if it has been enabled.
  38003. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38004. */
  38005. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  38006. /**
  38007. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38008. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38009. */
  38010. useAutoRotationBehavior: boolean;
  38011. /**
  38012. * Observable triggered when the mesh target has been changed on the camera.
  38013. */
  38014. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38015. /**
  38016. * Event raised when the camera is colliding with a mesh.
  38017. */
  38018. onCollide: (collidedMesh: AbstractMesh) => void;
  38019. /**
  38020. * Defines whether the camera should check collision with the objects oh the scene.
  38021. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38022. */
  38023. checkCollisions: boolean;
  38024. /**
  38025. * Defines the collision radius of the camera.
  38026. * This simulates a sphere around the camera.
  38027. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38028. */
  38029. collisionRadius: Vector3;
  38030. protected _collider: Collider;
  38031. protected _previousPosition: Vector3;
  38032. protected _collisionVelocity: Vector3;
  38033. protected _newPosition: Vector3;
  38034. protected _previousAlpha: number;
  38035. protected _previousBeta: number;
  38036. protected _previousRadius: number;
  38037. protected _collisionTriggered: boolean;
  38038. protected _targetBoundingCenter: Nullable<Vector3>;
  38039. private _computationVector;
  38040. /**
  38041. * Instantiates a new ArcRotateCamera in a given scene
  38042. * @param name Defines the name of the camera
  38043. * @param alpha Defines the camera rotation along the logitudinal axis
  38044. * @param beta Defines the camera rotation along the latitudinal axis
  38045. * @param radius Defines the camera distance from its target
  38046. * @param target Defines the camera target
  38047. * @param scene Defines the scene the camera belongs to
  38048. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38049. */
  38050. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38051. /** @hidden */
  38052. _initCache(): void;
  38053. /** @hidden */
  38054. _updateCache(ignoreParentClass?: boolean): void;
  38055. protected _getTargetPosition(): Vector3;
  38056. private _storedAlpha;
  38057. private _storedBeta;
  38058. private _storedRadius;
  38059. private _storedTarget;
  38060. private _storedTargetScreenOffset;
  38061. /**
  38062. * Stores the current state of the camera (alpha, beta, radius and target)
  38063. * @returns the camera itself
  38064. */
  38065. storeState(): Camera;
  38066. /**
  38067. * @hidden
  38068. * Restored camera state. You must call storeState() first
  38069. */
  38070. _restoreStateValues(): boolean;
  38071. /** @hidden */
  38072. _isSynchronizedViewMatrix(): boolean;
  38073. /**
  38074. * Attached controls to the current camera.
  38075. * @param element Defines the element the controls should be listened from
  38076. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38077. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38078. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38079. */
  38080. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38081. /**
  38082. * Detach the current controls from the camera.
  38083. * The camera will stop reacting to inputs.
  38084. * @param element Defines the element to stop listening the inputs from
  38085. */
  38086. detachControl(element: HTMLElement): void;
  38087. /** @hidden */
  38088. _checkInputs(): void;
  38089. protected _checkLimits(): void;
  38090. /**
  38091. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38092. */
  38093. rebuildAnglesAndRadius(): void;
  38094. /**
  38095. * Use a position to define the current camera related information like alpha, beta and radius
  38096. * @param position Defines the position to set the camera at
  38097. */
  38098. setPosition(position: Vector3): void;
  38099. /**
  38100. * Defines the target the camera should look at.
  38101. * This will automatically adapt alpha beta and radius to fit within the new target.
  38102. * @param target Defines the new target as a Vector or a mesh
  38103. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38104. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38105. */
  38106. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38107. /** @hidden */
  38108. _getViewMatrix(): Matrix;
  38109. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38110. /**
  38111. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38112. * @param meshes Defines the mesh to zoom on
  38113. * @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)
  38114. */
  38115. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38116. /**
  38117. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38118. * The target will be changed but the radius
  38119. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38120. * @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)
  38121. */
  38122. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38123. min: Vector3;
  38124. max: Vector3;
  38125. distance: number;
  38126. }, doNotUpdateMaxZ?: boolean): void;
  38127. /**
  38128. * @override
  38129. * Override Camera.createRigCamera
  38130. */
  38131. createRigCamera(name: string, cameraIndex: number): Camera;
  38132. /**
  38133. * @hidden
  38134. * @override
  38135. * Override Camera._updateRigCameras
  38136. */
  38137. _updateRigCameras(): void;
  38138. /**
  38139. * Destroy the camera and release the current resources hold by it.
  38140. */
  38141. dispose(): void;
  38142. /**
  38143. * Gets the current object class name.
  38144. * @return the class name
  38145. */
  38146. getClassName(): string;
  38147. }
  38148. }
  38149. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  38150. import { Behavior } from "babylonjs/Behaviors/behavior";
  38151. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38152. /**
  38153. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38154. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38155. */
  38156. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38157. /**
  38158. * Gets the name of the behavior.
  38159. */
  38160. readonly name: string;
  38161. private _zoomStopsAnimation;
  38162. private _idleRotationSpeed;
  38163. private _idleRotationWaitTime;
  38164. private _idleRotationSpinupTime;
  38165. /**
  38166. * Sets the flag that indicates if user zooming should stop animation.
  38167. */
  38168. /**
  38169. * Gets the flag that indicates if user zooming should stop animation.
  38170. */
  38171. zoomStopsAnimation: boolean;
  38172. /**
  38173. * Sets the default speed at which the camera rotates around the model.
  38174. */
  38175. /**
  38176. * Gets the default speed at which the camera rotates around the model.
  38177. */
  38178. idleRotationSpeed: number;
  38179. /**
  38180. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38181. */
  38182. /**
  38183. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38184. */
  38185. idleRotationWaitTime: number;
  38186. /**
  38187. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38188. */
  38189. /**
  38190. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38191. */
  38192. idleRotationSpinupTime: number;
  38193. /**
  38194. * Gets a value indicating if the camera is currently rotating because of this behavior
  38195. */
  38196. readonly rotationInProgress: boolean;
  38197. private _onPrePointerObservableObserver;
  38198. private _onAfterCheckInputsObserver;
  38199. private _attachedCamera;
  38200. private _isPointerDown;
  38201. private _lastFrameTime;
  38202. private _lastInteractionTime;
  38203. private _cameraRotationSpeed;
  38204. /**
  38205. * Initializes the behavior.
  38206. */
  38207. init(): void;
  38208. /**
  38209. * Attaches the behavior to its arc rotate camera.
  38210. * @param camera Defines the camera to attach the behavior to
  38211. */
  38212. attach(camera: ArcRotateCamera): void;
  38213. /**
  38214. * Detaches the behavior from its current arc rotate camera.
  38215. */
  38216. detach(): void;
  38217. /**
  38218. * Returns true if user is scrolling.
  38219. * @return true if user is scrolling.
  38220. */
  38221. private _userIsZooming;
  38222. private _lastFrameRadius;
  38223. private _shouldAnimationStopForInteraction;
  38224. /**
  38225. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38226. */
  38227. private _applyUserInteraction;
  38228. private _userIsMoving;
  38229. }
  38230. }
  38231. declare module "babylonjs/Behaviors/Cameras/index" {
  38232. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  38233. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  38234. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  38235. }
  38236. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  38237. import { Mesh } from "babylonjs/Meshes/mesh";
  38238. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38239. import { Behavior } from "babylonjs/Behaviors/behavior";
  38240. /**
  38241. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38242. */
  38243. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38244. private ui;
  38245. /**
  38246. * The name of the behavior
  38247. */
  38248. name: string;
  38249. /**
  38250. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38251. */
  38252. distanceAwayFromFace: number;
  38253. /**
  38254. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38255. */
  38256. distanceAwayFromBottomOfFace: number;
  38257. private _faceVectors;
  38258. private _target;
  38259. private _scene;
  38260. private _onRenderObserver;
  38261. private _tmpMatrix;
  38262. private _tmpVector;
  38263. /**
  38264. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38265. * @param ui The transform node that should be attched to the mesh
  38266. */
  38267. constructor(ui: TransformNode);
  38268. /**
  38269. * Initializes the behavior
  38270. */
  38271. init(): void;
  38272. private _closestFace;
  38273. private _zeroVector;
  38274. private _lookAtTmpMatrix;
  38275. private _lookAtToRef;
  38276. /**
  38277. * Attaches the AttachToBoxBehavior to the passed in mesh
  38278. * @param target The mesh that the specified node will be attached to
  38279. */
  38280. attach(target: Mesh): void;
  38281. /**
  38282. * Detaches the behavior from the mesh
  38283. */
  38284. detach(): void;
  38285. }
  38286. }
  38287. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  38288. import { Behavior } from "babylonjs/Behaviors/behavior";
  38289. import { Mesh } from "babylonjs/Meshes/mesh";
  38290. /**
  38291. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38292. */
  38293. export class FadeInOutBehavior implements Behavior<Mesh> {
  38294. /**
  38295. * Time in milliseconds to delay before fading in (Default: 0)
  38296. */
  38297. delay: number;
  38298. /**
  38299. * Time in milliseconds for the mesh to fade in (Default: 300)
  38300. */
  38301. fadeInTime: number;
  38302. private _millisecondsPerFrame;
  38303. private _hovered;
  38304. private _hoverValue;
  38305. private _ownerNode;
  38306. /**
  38307. * Instatiates the FadeInOutBehavior
  38308. */
  38309. constructor();
  38310. /**
  38311. * The name of the behavior
  38312. */
  38313. readonly name: string;
  38314. /**
  38315. * Initializes the behavior
  38316. */
  38317. init(): void;
  38318. /**
  38319. * Attaches the fade behavior on the passed in mesh
  38320. * @param ownerNode The mesh that will be faded in/out once attached
  38321. */
  38322. attach(ownerNode: Mesh): void;
  38323. /**
  38324. * Detaches the behavior from the mesh
  38325. */
  38326. detach(): void;
  38327. /**
  38328. * Triggers the mesh to begin fading in or out
  38329. * @param value if the object should fade in or out (true to fade in)
  38330. */
  38331. fadeIn(value: boolean): void;
  38332. private _update;
  38333. private _setAllVisibility;
  38334. }
  38335. }
  38336. declare module "babylonjs/Misc/pivotTools" {
  38337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38338. /**
  38339. * Class containing a set of static utilities functions for managing Pivots
  38340. * @hidden
  38341. */
  38342. export class PivotTools {
  38343. private static _PivotCached;
  38344. private static _OldPivotPoint;
  38345. private static _PivotTranslation;
  38346. private static _PivotTmpVector;
  38347. /** @hidden */
  38348. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38349. /** @hidden */
  38350. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38351. }
  38352. }
  38353. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38354. import { Scene } from "babylonjs/scene";
  38355. import { Vector4 } from "babylonjs/Maths/math.vector";
  38356. import { Mesh } from "babylonjs/Meshes/mesh";
  38357. import { Nullable } from "babylonjs/types";
  38358. import { Plane } from "babylonjs/Maths/math.plane";
  38359. /**
  38360. * Class containing static functions to help procedurally build meshes
  38361. */
  38362. export class PlaneBuilder {
  38363. /**
  38364. * Creates a plane mesh
  38365. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38366. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38367. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38368. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38369. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38371. * @param name defines the name of the mesh
  38372. * @param options defines the options used to create the mesh
  38373. * @param scene defines the hosting scene
  38374. * @returns the plane mesh
  38375. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38376. */
  38377. static CreatePlane(name: string, options: {
  38378. size?: number;
  38379. width?: number;
  38380. height?: number;
  38381. sideOrientation?: number;
  38382. frontUVs?: Vector4;
  38383. backUVs?: Vector4;
  38384. updatable?: boolean;
  38385. sourcePlane?: Plane;
  38386. }, scene?: Nullable<Scene>): Mesh;
  38387. }
  38388. }
  38389. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38390. import { Behavior } from "babylonjs/Behaviors/behavior";
  38391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38392. import { Observable } from "babylonjs/Misc/observable";
  38393. import { Vector3 } from "babylonjs/Maths/math.vector";
  38394. import { Ray } from "babylonjs/Culling/ray";
  38395. import "babylonjs/Meshes/Builders/planeBuilder";
  38396. /**
  38397. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38398. */
  38399. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38400. private static _AnyMouseID;
  38401. /**
  38402. * Abstract mesh the behavior is set on
  38403. */
  38404. attachedNode: AbstractMesh;
  38405. private _dragPlane;
  38406. private _scene;
  38407. private _pointerObserver;
  38408. private _beforeRenderObserver;
  38409. private static _planeScene;
  38410. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38411. /**
  38412. * 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)
  38413. */
  38414. maxDragAngle: number;
  38415. /**
  38416. * @hidden
  38417. */
  38418. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38419. /**
  38420. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38421. */
  38422. currentDraggingPointerID: number;
  38423. /**
  38424. * The last position where the pointer hit the drag plane in world space
  38425. */
  38426. lastDragPosition: Vector3;
  38427. /**
  38428. * If the behavior is currently in a dragging state
  38429. */
  38430. dragging: boolean;
  38431. /**
  38432. * 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)
  38433. */
  38434. dragDeltaRatio: number;
  38435. /**
  38436. * If the drag plane orientation should be updated during the dragging (Default: true)
  38437. */
  38438. updateDragPlane: boolean;
  38439. private _debugMode;
  38440. private _moving;
  38441. /**
  38442. * Fires each time the attached mesh is dragged with the pointer
  38443. * * delta between last drag position and current drag position in world space
  38444. * * dragDistance along the drag axis
  38445. * * dragPlaneNormal normal of the current drag plane used during the drag
  38446. * * dragPlanePoint in world space where the drag intersects the drag plane
  38447. */
  38448. onDragObservable: Observable<{
  38449. delta: Vector3;
  38450. dragPlanePoint: Vector3;
  38451. dragPlaneNormal: Vector3;
  38452. dragDistance: number;
  38453. pointerId: number;
  38454. }>;
  38455. /**
  38456. * Fires each time a drag begins (eg. mouse down on mesh)
  38457. */
  38458. onDragStartObservable: Observable<{
  38459. dragPlanePoint: Vector3;
  38460. pointerId: number;
  38461. }>;
  38462. /**
  38463. * Fires each time a drag ends (eg. mouse release after drag)
  38464. */
  38465. onDragEndObservable: Observable<{
  38466. dragPlanePoint: Vector3;
  38467. pointerId: number;
  38468. }>;
  38469. /**
  38470. * If the attached mesh should be moved when dragged
  38471. */
  38472. moveAttached: boolean;
  38473. /**
  38474. * If the drag behavior will react to drag events (Default: true)
  38475. */
  38476. enabled: boolean;
  38477. /**
  38478. * If pointer events should start and release the drag (Default: true)
  38479. */
  38480. startAndReleaseDragOnPointerEvents: boolean;
  38481. /**
  38482. * If camera controls should be detached during the drag
  38483. */
  38484. detachCameraControls: boolean;
  38485. /**
  38486. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38487. */
  38488. useObjectOrienationForDragging: boolean;
  38489. private _options;
  38490. /**
  38491. * Creates a pointer drag behavior that can be attached to a mesh
  38492. * @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)
  38493. */
  38494. constructor(options?: {
  38495. dragAxis?: Vector3;
  38496. dragPlaneNormal?: Vector3;
  38497. });
  38498. /**
  38499. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38500. */
  38501. validateDrag: (targetPosition: Vector3) => boolean;
  38502. /**
  38503. * The name of the behavior
  38504. */
  38505. readonly name: string;
  38506. /**
  38507. * Initializes the behavior
  38508. */
  38509. init(): void;
  38510. private _tmpVector;
  38511. private _alternatePickedPoint;
  38512. private _worldDragAxis;
  38513. private _targetPosition;
  38514. private _attachedElement;
  38515. /**
  38516. * Attaches the drag behavior the passed in mesh
  38517. * @param ownerNode The mesh that will be dragged around once attached
  38518. * @param predicate Predicate to use for pick filtering
  38519. */
  38520. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38521. /**
  38522. * Force relase the drag action by code.
  38523. */
  38524. releaseDrag(): void;
  38525. private _startDragRay;
  38526. private _lastPointerRay;
  38527. /**
  38528. * Simulates the start of a pointer drag event on the behavior
  38529. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38530. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38531. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38532. */
  38533. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38534. private _startDrag;
  38535. private _dragDelta;
  38536. private _moveDrag;
  38537. private _pickWithRayOnDragPlane;
  38538. private _pointA;
  38539. private _pointB;
  38540. private _pointC;
  38541. private _lineA;
  38542. private _lineB;
  38543. private _localAxis;
  38544. private _lookAt;
  38545. private _updateDragPlanePosition;
  38546. /**
  38547. * Detaches the behavior from the mesh
  38548. */
  38549. detach(): void;
  38550. }
  38551. }
  38552. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38553. import { Mesh } from "babylonjs/Meshes/mesh";
  38554. import { Behavior } from "babylonjs/Behaviors/behavior";
  38555. /**
  38556. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38557. */
  38558. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38559. private _dragBehaviorA;
  38560. private _dragBehaviorB;
  38561. private _startDistance;
  38562. private _initialScale;
  38563. private _targetScale;
  38564. private _ownerNode;
  38565. private _sceneRenderObserver;
  38566. /**
  38567. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38568. */
  38569. constructor();
  38570. /**
  38571. * The name of the behavior
  38572. */
  38573. readonly name: string;
  38574. /**
  38575. * Initializes the behavior
  38576. */
  38577. init(): void;
  38578. private _getCurrentDistance;
  38579. /**
  38580. * Attaches the scale behavior the passed in mesh
  38581. * @param ownerNode The mesh that will be scaled around once attached
  38582. */
  38583. attach(ownerNode: Mesh): void;
  38584. /**
  38585. * Detaches the behavior from the mesh
  38586. */
  38587. detach(): void;
  38588. }
  38589. }
  38590. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38591. import { Behavior } from "babylonjs/Behaviors/behavior";
  38592. import { Mesh } from "babylonjs/Meshes/mesh";
  38593. import { Observable } from "babylonjs/Misc/observable";
  38594. /**
  38595. * 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
  38596. */
  38597. export class SixDofDragBehavior implements Behavior<Mesh> {
  38598. private static _virtualScene;
  38599. private _ownerNode;
  38600. private _sceneRenderObserver;
  38601. private _scene;
  38602. private _targetPosition;
  38603. private _virtualOriginMesh;
  38604. private _virtualDragMesh;
  38605. private _pointerObserver;
  38606. private _moving;
  38607. private _startingOrientation;
  38608. /**
  38609. * 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)
  38610. */
  38611. private zDragFactor;
  38612. /**
  38613. * If the object should rotate to face the drag origin
  38614. */
  38615. rotateDraggedObject: boolean;
  38616. /**
  38617. * If the behavior is currently in a dragging state
  38618. */
  38619. dragging: boolean;
  38620. /**
  38621. * 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)
  38622. */
  38623. dragDeltaRatio: number;
  38624. /**
  38625. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38626. */
  38627. currentDraggingPointerID: number;
  38628. /**
  38629. * If camera controls should be detached during the drag
  38630. */
  38631. detachCameraControls: boolean;
  38632. /**
  38633. * Fires each time a drag starts
  38634. */
  38635. onDragStartObservable: Observable<{}>;
  38636. /**
  38637. * Fires each time a drag ends (eg. mouse release after drag)
  38638. */
  38639. onDragEndObservable: Observable<{}>;
  38640. /**
  38641. * 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
  38642. */
  38643. constructor();
  38644. /**
  38645. * The name of the behavior
  38646. */
  38647. readonly name: string;
  38648. /**
  38649. * Initializes the behavior
  38650. */
  38651. init(): void;
  38652. /**
  38653. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38654. */
  38655. private readonly _pointerCamera;
  38656. /**
  38657. * Attaches the scale behavior the passed in mesh
  38658. * @param ownerNode The mesh that will be scaled around once attached
  38659. */
  38660. attach(ownerNode: Mesh): void;
  38661. /**
  38662. * Detaches the behavior from the mesh
  38663. */
  38664. detach(): void;
  38665. }
  38666. }
  38667. declare module "babylonjs/Behaviors/Meshes/index" {
  38668. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38669. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38670. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38671. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38672. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38673. }
  38674. declare module "babylonjs/Behaviors/index" {
  38675. export * from "babylonjs/Behaviors/behavior";
  38676. export * from "babylonjs/Behaviors/Cameras/index";
  38677. export * from "babylonjs/Behaviors/Meshes/index";
  38678. }
  38679. declare module "babylonjs/Bones/boneIKController" {
  38680. import { Bone } from "babylonjs/Bones/bone";
  38681. import { Vector3 } from "babylonjs/Maths/math.vector";
  38682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38683. import { Nullable } from "babylonjs/types";
  38684. /**
  38685. * Class used to apply inverse kinematics to bones
  38686. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38687. */
  38688. export class BoneIKController {
  38689. private static _tmpVecs;
  38690. private static _tmpQuat;
  38691. private static _tmpMats;
  38692. /**
  38693. * Gets or sets the target mesh
  38694. */
  38695. targetMesh: AbstractMesh;
  38696. /** Gets or sets the mesh used as pole */
  38697. poleTargetMesh: AbstractMesh;
  38698. /**
  38699. * Gets or sets the bone used as pole
  38700. */
  38701. poleTargetBone: Nullable<Bone>;
  38702. /**
  38703. * Gets or sets the target position
  38704. */
  38705. targetPosition: Vector3;
  38706. /**
  38707. * Gets or sets the pole target position
  38708. */
  38709. poleTargetPosition: Vector3;
  38710. /**
  38711. * Gets or sets the pole target local offset
  38712. */
  38713. poleTargetLocalOffset: Vector3;
  38714. /**
  38715. * Gets or sets the pole angle
  38716. */
  38717. poleAngle: number;
  38718. /**
  38719. * Gets or sets the mesh associated with the controller
  38720. */
  38721. mesh: AbstractMesh;
  38722. /**
  38723. * 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)
  38724. */
  38725. slerpAmount: number;
  38726. private _bone1Quat;
  38727. private _bone1Mat;
  38728. private _bone2Ang;
  38729. private _bone1;
  38730. private _bone2;
  38731. private _bone1Length;
  38732. private _bone2Length;
  38733. private _maxAngle;
  38734. private _maxReach;
  38735. private _rightHandedSystem;
  38736. private _bendAxis;
  38737. private _slerping;
  38738. private _adjustRoll;
  38739. /**
  38740. * Gets or sets maximum allowed angle
  38741. */
  38742. maxAngle: number;
  38743. /**
  38744. * Creates a new BoneIKController
  38745. * @param mesh defines the mesh to control
  38746. * @param bone defines the bone to control
  38747. * @param options defines options to set up the controller
  38748. */
  38749. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38750. targetMesh?: AbstractMesh;
  38751. poleTargetMesh?: AbstractMesh;
  38752. poleTargetBone?: Bone;
  38753. poleTargetLocalOffset?: Vector3;
  38754. poleAngle?: number;
  38755. bendAxis?: Vector3;
  38756. maxAngle?: number;
  38757. slerpAmount?: number;
  38758. });
  38759. private _setMaxAngle;
  38760. /**
  38761. * Force the controller to update the bones
  38762. */
  38763. update(): void;
  38764. }
  38765. }
  38766. declare module "babylonjs/Bones/boneLookController" {
  38767. import { Vector3 } from "babylonjs/Maths/math.vector";
  38768. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38769. import { Bone } from "babylonjs/Bones/bone";
  38770. import { Space } from "babylonjs/Maths/math.axis";
  38771. /**
  38772. * Class used to make a bone look toward a point in space
  38773. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38774. */
  38775. export class BoneLookController {
  38776. private static _tmpVecs;
  38777. private static _tmpQuat;
  38778. private static _tmpMats;
  38779. /**
  38780. * The target Vector3 that the bone will look at
  38781. */
  38782. target: Vector3;
  38783. /**
  38784. * The mesh that the bone is attached to
  38785. */
  38786. mesh: AbstractMesh;
  38787. /**
  38788. * The bone that will be looking to the target
  38789. */
  38790. bone: Bone;
  38791. /**
  38792. * The up axis of the coordinate system that is used when the bone is rotated
  38793. */
  38794. upAxis: Vector3;
  38795. /**
  38796. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38797. */
  38798. upAxisSpace: Space;
  38799. /**
  38800. * Used to make an adjustment to the yaw of the bone
  38801. */
  38802. adjustYaw: number;
  38803. /**
  38804. * Used to make an adjustment to the pitch of the bone
  38805. */
  38806. adjustPitch: number;
  38807. /**
  38808. * Used to make an adjustment to the roll of the bone
  38809. */
  38810. adjustRoll: number;
  38811. /**
  38812. * 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)
  38813. */
  38814. slerpAmount: number;
  38815. private _minYaw;
  38816. private _maxYaw;
  38817. private _minPitch;
  38818. private _maxPitch;
  38819. private _minYawSin;
  38820. private _minYawCos;
  38821. private _maxYawSin;
  38822. private _maxYawCos;
  38823. private _midYawConstraint;
  38824. private _minPitchTan;
  38825. private _maxPitchTan;
  38826. private _boneQuat;
  38827. private _slerping;
  38828. private _transformYawPitch;
  38829. private _transformYawPitchInv;
  38830. private _firstFrameSkipped;
  38831. private _yawRange;
  38832. private _fowardAxis;
  38833. /**
  38834. * Gets or sets the minimum yaw angle that the bone can look to
  38835. */
  38836. minYaw: number;
  38837. /**
  38838. * Gets or sets the maximum yaw angle that the bone can look to
  38839. */
  38840. maxYaw: number;
  38841. /**
  38842. * Gets or sets the minimum pitch angle that the bone can look to
  38843. */
  38844. minPitch: number;
  38845. /**
  38846. * Gets or sets the maximum pitch angle that the bone can look to
  38847. */
  38848. maxPitch: number;
  38849. /**
  38850. * Create a BoneLookController
  38851. * @param mesh the mesh that the bone belongs to
  38852. * @param bone the bone that will be looking to the target
  38853. * @param target the target Vector3 to look at
  38854. * @param options optional settings:
  38855. * * maxYaw: the maximum angle the bone will yaw to
  38856. * * minYaw: the minimum angle the bone will yaw to
  38857. * * maxPitch: the maximum angle the bone will pitch to
  38858. * * minPitch: the minimum angle the bone will yaw to
  38859. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38860. * * upAxis: the up axis of the coordinate system
  38861. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38862. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38863. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38864. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38865. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38866. * * adjustRoll: used to make an adjustment to the roll of the bone
  38867. **/
  38868. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38869. maxYaw?: number;
  38870. minYaw?: number;
  38871. maxPitch?: number;
  38872. minPitch?: number;
  38873. slerpAmount?: number;
  38874. upAxis?: Vector3;
  38875. upAxisSpace?: Space;
  38876. yawAxis?: Vector3;
  38877. pitchAxis?: Vector3;
  38878. adjustYaw?: number;
  38879. adjustPitch?: number;
  38880. adjustRoll?: number;
  38881. });
  38882. /**
  38883. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38884. */
  38885. update(): void;
  38886. private _getAngleDiff;
  38887. private _getAngleBetween;
  38888. private _isAngleBetween;
  38889. }
  38890. }
  38891. declare module "babylonjs/Bones/index" {
  38892. export * from "babylonjs/Bones/bone";
  38893. export * from "babylonjs/Bones/boneIKController";
  38894. export * from "babylonjs/Bones/boneLookController";
  38895. export * from "babylonjs/Bones/skeleton";
  38896. }
  38897. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38898. import { Nullable } from "babylonjs/types";
  38899. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38900. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38901. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38902. /**
  38903. * Manage the gamepad inputs to control an arc rotate camera.
  38904. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38905. */
  38906. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38907. /**
  38908. * Defines the camera the input is attached to.
  38909. */
  38910. camera: ArcRotateCamera;
  38911. /**
  38912. * Defines the gamepad the input is gathering event from.
  38913. */
  38914. gamepad: Nullable<Gamepad>;
  38915. /**
  38916. * Defines the gamepad rotation sensiblity.
  38917. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38918. */
  38919. gamepadRotationSensibility: number;
  38920. /**
  38921. * Defines the gamepad move sensiblity.
  38922. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38923. */
  38924. gamepadMoveSensibility: number;
  38925. private _yAxisScale;
  38926. /**
  38927. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38928. */
  38929. invertYAxis: boolean;
  38930. private _onGamepadConnectedObserver;
  38931. private _onGamepadDisconnectedObserver;
  38932. /**
  38933. * Attach the input controls to a specific dom element to get the input from.
  38934. * @param element Defines the element the controls should be listened from
  38935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38936. */
  38937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38938. /**
  38939. * Detach the current controls from the specified dom element.
  38940. * @param element Defines the element to stop listening the inputs from
  38941. */
  38942. detachControl(element: Nullable<HTMLElement>): void;
  38943. /**
  38944. * Update the current camera state depending on the inputs that have been used this frame.
  38945. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38946. */
  38947. checkInputs(): void;
  38948. /**
  38949. * Gets the class name of the current intput.
  38950. * @returns the class name
  38951. */
  38952. getClassName(): string;
  38953. /**
  38954. * Get the friendly name associated with the input class.
  38955. * @returns the input friendly name
  38956. */
  38957. getSimpleName(): string;
  38958. }
  38959. }
  38960. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38961. import { Nullable } from "babylonjs/types";
  38962. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38963. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38964. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38965. interface ArcRotateCameraInputsManager {
  38966. /**
  38967. * Add orientation input support to the input manager.
  38968. * @returns the current input manager
  38969. */
  38970. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38971. }
  38972. }
  38973. /**
  38974. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38975. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38976. */
  38977. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38978. /**
  38979. * Defines the camera the input is attached to.
  38980. */
  38981. camera: ArcRotateCamera;
  38982. /**
  38983. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38984. */
  38985. alphaCorrection: number;
  38986. /**
  38987. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38988. */
  38989. gammaCorrection: number;
  38990. private _alpha;
  38991. private _gamma;
  38992. private _dirty;
  38993. private _deviceOrientationHandler;
  38994. /**
  38995. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38996. */
  38997. constructor();
  38998. /**
  38999. * Attach the input controls to a specific dom element to get the input from.
  39000. * @param element Defines the element the controls should be listened from
  39001. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39002. */
  39003. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39004. /** @hidden */
  39005. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39006. /**
  39007. * Update the current camera state depending on the inputs that have been used this frame.
  39008. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39009. */
  39010. checkInputs(): void;
  39011. /**
  39012. * Detach the current controls from the specified dom element.
  39013. * @param element Defines the element to stop listening the inputs from
  39014. */
  39015. detachControl(element: Nullable<HTMLElement>): void;
  39016. /**
  39017. * Gets the class name of the current intput.
  39018. * @returns the class name
  39019. */
  39020. getClassName(): string;
  39021. /**
  39022. * Get the friendly name associated with the input class.
  39023. * @returns the input friendly name
  39024. */
  39025. getSimpleName(): string;
  39026. }
  39027. }
  39028. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  39029. import { Nullable } from "babylonjs/types";
  39030. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39031. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39032. /**
  39033. * Listen to mouse events to control the camera.
  39034. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39035. */
  39036. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39037. /**
  39038. * Defines the camera the input is attached to.
  39039. */
  39040. camera: FlyCamera;
  39041. /**
  39042. * Defines if touch is enabled. (Default is true.)
  39043. */
  39044. touchEnabled: boolean;
  39045. /**
  39046. * Defines the buttons associated with the input to handle camera rotation.
  39047. */
  39048. buttons: number[];
  39049. /**
  39050. * Assign buttons for Yaw control.
  39051. */
  39052. buttonsYaw: number[];
  39053. /**
  39054. * Assign buttons for Pitch control.
  39055. */
  39056. buttonsPitch: number[];
  39057. /**
  39058. * Assign buttons for Roll control.
  39059. */
  39060. buttonsRoll: number[];
  39061. /**
  39062. * Detect if any button is being pressed while mouse is moved.
  39063. * -1 = Mouse locked.
  39064. * 0 = Left button.
  39065. * 1 = Middle Button.
  39066. * 2 = Right Button.
  39067. */
  39068. activeButton: number;
  39069. /**
  39070. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39071. * Higher values reduce its sensitivity.
  39072. */
  39073. angularSensibility: number;
  39074. private _mousemoveCallback;
  39075. private _observer;
  39076. private _rollObserver;
  39077. private previousPosition;
  39078. private noPreventDefault;
  39079. private element;
  39080. /**
  39081. * Listen to mouse events to control the camera.
  39082. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39083. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39084. */
  39085. constructor(touchEnabled?: boolean);
  39086. /**
  39087. * Attach the mouse control to the HTML DOM element.
  39088. * @param element Defines the element that listens to the input events.
  39089. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39090. */
  39091. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39092. /**
  39093. * Detach the current controls from the specified dom element.
  39094. * @param element Defines the element to stop listening the inputs from
  39095. */
  39096. detachControl(element: Nullable<HTMLElement>): void;
  39097. /**
  39098. * Gets the class name of the current input.
  39099. * @returns the class name.
  39100. */
  39101. getClassName(): string;
  39102. /**
  39103. * Get the friendly name associated with the input class.
  39104. * @returns the input's friendly name.
  39105. */
  39106. getSimpleName(): string;
  39107. private _pointerInput;
  39108. private _onMouseMove;
  39109. /**
  39110. * Rotate camera by mouse offset.
  39111. */
  39112. private rotateCamera;
  39113. }
  39114. }
  39115. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  39116. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39117. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39118. /**
  39119. * Default Inputs manager for the FlyCamera.
  39120. * It groups all the default supported inputs for ease of use.
  39121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39122. */
  39123. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39124. /**
  39125. * Instantiates a new FlyCameraInputsManager.
  39126. * @param camera Defines the camera the inputs belong to.
  39127. */
  39128. constructor(camera: FlyCamera);
  39129. /**
  39130. * Add keyboard input support to the input manager.
  39131. * @returns the new FlyCameraKeyboardMoveInput().
  39132. */
  39133. addKeyboard(): FlyCameraInputsManager;
  39134. /**
  39135. * Add mouse input support to the input manager.
  39136. * @param touchEnabled Enable touch screen support.
  39137. * @returns the new FlyCameraMouseInput().
  39138. */
  39139. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39140. }
  39141. }
  39142. declare module "babylonjs/Cameras/flyCamera" {
  39143. import { Scene } from "babylonjs/scene";
  39144. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  39145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39146. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39147. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  39148. /**
  39149. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39150. * such as in a 3D Space Shooter or a Flight Simulator.
  39151. */
  39152. export class FlyCamera extends TargetCamera {
  39153. /**
  39154. * Define the collision ellipsoid of the camera.
  39155. * This is helpful for simulating a camera body, like a player's body.
  39156. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39157. */
  39158. ellipsoid: Vector3;
  39159. /**
  39160. * Define an offset for the position of the ellipsoid around the camera.
  39161. * This can be helpful if the camera is attached away from the player's body center,
  39162. * such as at its head.
  39163. */
  39164. ellipsoidOffset: Vector3;
  39165. /**
  39166. * Enable or disable collisions of the camera with the rest of the scene objects.
  39167. */
  39168. checkCollisions: boolean;
  39169. /**
  39170. * Enable or disable gravity on the camera.
  39171. */
  39172. applyGravity: boolean;
  39173. /**
  39174. * Define the current direction the camera is moving to.
  39175. */
  39176. cameraDirection: Vector3;
  39177. /**
  39178. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39179. * This overrides and empties cameraRotation.
  39180. */
  39181. rotationQuaternion: Quaternion;
  39182. /**
  39183. * Track Roll to maintain the wanted Rolling when looking around.
  39184. */
  39185. _trackRoll: number;
  39186. /**
  39187. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39188. */
  39189. rollCorrect: number;
  39190. /**
  39191. * Mimic a banked turn, Rolling the camera when Yawing.
  39192. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39193. */
  39194. bankedTurn: boolean;
  39195. /**
  39196. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39197. */
  39198. bankedTurnLimit: number;
  39199. /**
  39200. * Value of 0 disables the banked Roll.
  39201. * Value of 1 is equal to the Yaw angle in radians.
  39202. */
  39203. bankedTurnMultiplier: number;
  39204. /**
  39205. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39206. */
  39207. inputs: FlyCameraInputsManager;
  39208. /**
  39209. * Gets the input sensibility for mouse input.
  39210. * Higher values reduce sensitivity.
  39211. */
  39212. /**
  39213. * Sets the input sensibility for a mouse input.
  39214. * Higher values reduce sensitivity.
  39215. */
  39216. angularSensibility: number;
  39217. /**
  39218. * Get the keys for camera movement forward.
  39219. */
  39220. /**
  39221. * Set the keys for camera movement forward.
  39222. */
  39223. keysForward: number[];
  39224. /**
  39225. * Get the keys for camera movement backward.
  39226. */
  39227. keysBackward: number[];
  39228. /**
  39229. * Get the keys for camera movement up.
  39230. */
  39231. /**
  39232. * Set the keys for camera movement up.
  39233. */
  39234. keysUp: number[];
  39235. /**
  39236. * Get the keys for camera movement down.
  39237. */
  39238. /**
  39239. * Set the keys for camera movement down.
  39240. */
  39241. keysDown: number[];
  39242. /**
  39243. * Get the keys for camera movement left.
  39244. */
  39245. /**
  39246. * Set the keys for camera movement left.
  39247. */
  39248. keysLeft: number[];
  39249. /**
  39250. * Set the keys for camera movement right.
  39251. */
  39252. /**
  39253. * Set the keys for camera movement right.
  39254. */
  39255. keysRight: number[];
  39256. /**
  39257. * Event raised when the camera collides with a mesh in the scene.
  39258. */
  39259. onCollide: (collidedMesh: AbstractMesh) => void;
  39260. private _collider;
  39261. private _needMoveForGravity;
  39262. private _oldPosition;
  39263. private _diffPosition;
  39264. private _newPosition;
  39265. /** @hidden */
  39266. _localDirection: Vector3;
  39267. /** @hidden */
  39268. _transformedDirection: Vector3;
  39269. /**
  39270. * Instantiates a FlyCamera.
  39271. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39272. * such as in a 3D Space Shooter or a Flight Simulator.
  39273. * @param name Define the name of the camera in the scene.
  39274. * @param position Define the starting position of the camera in the scene.
  39275. * @param scene Define the scene the camera belongs to.
  39276. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39277. */
  39278. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39279. /**
  39280. * Attach a control to the HTML DOM element.
  39281. * @param element Defines the element that listens to the input events.
  39282. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39283. */
  39284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39285. /**
  39286. * Detach a control from the HTML DOM element.
  39287. * The camera will stop reacting to that input.
  39288. * @param element Defines the element that listens to the input events.
  39289. */
  39290. detachControl(element: HTMLElement): void;
  39291. private _collisionMask;
  39292. /**
  39293. * Get the mask that the camera ignores in collision events.
  39294. */
  39295. /**
  39296. * Set the mask that the camera ignores in collision events.
  39297. */
  39298. collisionMask: number;
  39299. /** @hidden */
  39300. _collideWithWorld(displacement: Vector3): void;
  39301. /** @hidden */
  39302. private _onCollisionPositionChange;
  39303. /** @hidden */
  39304. _checkInputs(): void;
  39305. /** @hidden */
  39306. _decideIfNeedsToMove(): boolean;
  39307. /** @hidden */
  39308. _updatePosition(): void;
  39309. /**
  39310. * Restore the Roll to its target value at the rate specified.
  39311. * @param rate - Higher means slower restoring.
  39312. * @hidden
  39313. */
  39314. restoreRoll(rate: number): void;
  39315. /**
  39316. * Destroy the camera and release the current resources held by it.
  39317. */
  39318. dispose(): void;
  39319. /**
  39320. * Get the current object class name.
  39321. * @returns the class name.
  39322. */
  39323. getClassName(): string;
  39324. }
  39325. }
  39326. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  39327. import { Nullable } from "babylonjs/types";
  39328. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39329. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39330. /**
  39331. * Listen to keyboard events to control the camera.
  39332. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39333. */
  39334. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39335. /**
  39336. * Defines the camera the input is attached to.
  39337. */
  39338. camera: FlyCamera;
  39339. /**
  39340. * The list of keyboard keys used to control the forward move of the camera.
  39341. */
  39342. keysForward: number[];
  39343. /**
  39344. * The list of keyboard keys used to control the backward move of the camera.
  39345. */
  39346. keysBackward: number[];
  39347. /**
  39348. * The list of keyboard keys used to control the forward move of the camera.
  39349. */
  39350. keysUp: number[];
  39351. /**
  39352. * The list of keyboard keys used to control the backward move of the camera.
  39353. */
  39354. keysDown: number[];
  39355. /**
  39356. * The list of keyboard keys used to control the right strafe move of the camera.
  39357. */
  39358. keysRight: number[];
  39359. /**
  39360. * The list of keyboard keys used to control the left strafe move of the camera.
  39361. */
  39362. keysLeft: number[];
  39363. private _keys;
  39364. private _onCanvasBlurObserver;
  39365. private _onKeyboardObserver;
  39366. private _engine;
  39367. private _scene;
  39368. /**
  39369. * Attach the input controls to a specific dom element to get the input from.
  39370. * @param element Defines the element the controls should be listened from
  39371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39372. */
  39373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39374. /**
  39375. * Detach the current controls from the specified dom element.
  39376. * @param element Defines the element to stop listening the inputs from
  39377. */
  39378. detachControl(element: Nullable<HTMLElement>): void;
  39379. /**
  39380. * Gets the class name of the current intput.
  39381. * @returns the class name
  39382. */
  39383. getClassName(): string;
  39384. /** @hidden */
  39385. _onLostFocus(e: FocusEvent): void;
  39386. /**
  39387. * Get the friendly name associated with the input class.
  39388. * @returns the input friendly name
  39389. */
  39390. getSimpleName(): string;
  39391. /**
  39392. * Update the current camera state depending on the inputs that have been used this frame.
  39393. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39394. */
  39395. checkInputs(): void;
  39396. }
  39397. }
  39398. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39399. import { Nullable } from "babylonjs/types";
  39400. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39401. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39402. /**
  39403. * Manage the mouse wheel inputs to control a follow camera.
  39404. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39405. */
  39406. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39407. /**
  39408. * Defines the camera the input is attached to.
  39409. */
  39410. camera: FollowCamera;
  39411. /**
  39412. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39413. */
  39414. axisControlRadius: boolean;
  39415. /**
  39416. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39417. */
  39418. axisControlHeight: boolean;
  39419. /**
  39420. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39421. */
  39422. axisControlRotation: boolean;
  39423. /**
  39424. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39425. * relation to mouseWheel events.
  39426. */
  39427. wheelPrecision: number;
  39428. /**
  39429. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39430. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39431. */
  39432. wheelDeltaPercentage: number;
  39433. private _wheel;
  39434. private _observer;
  39435. /**
  39436. * Attach the input controls to a specific dom element to get the input from.
  39437. * @param element Defines the element the controls should be listened from
  39438. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39439. */
  39440. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39441. /**
  39442. * Detach the current controls from the specified dom element.
  39443. * @param element Defines the element to stop listening the inputs from
  39444. */
  39445. detachControl(element: Nullable<HTMLElement>): void;
  39446. /**
  39447. * Gets the class name of the current intput.
  39448. * @returns the class name
  39449. */
  39450. getClassName(): string;
  39451. /**
  39452. * Get the friendly name associated with the input class.
  39453. * @returns the input friendly name
  39454. */
  39455. getSimpleName(): string;
  39456. }
  39457. }
  39458. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39459. import { Nullable } from "babylonjs/types";
  39460. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39461. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39462. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39463. /**
  39464. * Manage the pointers inputs to control an follow camera.
  39465. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39466. */
  39467. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39468. /**
  39469. * Defines the camera the input is attached to.
  39470. */
  39471. camera: FollowCamera;
  39472. /**
  39473. * Gets the class name of the current input.
  39474. * @returns the class name
  39475. */
  39476. getClassName(): string;
  39477. /**
  39478. * Defines the pointer angular sensibility along the X axis or how fast is
  39479. * the camera rotating.
  39480. * A negative number will reverse the axis direction.
  39481. */
  39482. angularSensibilityX: number;
  39483. /**
  39484. * Defines the pointer angular sensibility along the Y axis or how fast is
  39485. * the camera rotating.
  39486. * A negative number will reverse the axis direction.
  39487. */
  39488. angularSensibilityY: number;
  39489. /**
  39490. * Defines the pointer pinch precision or how fast is the camera zooming.
  39491. * A negative number will reverse the axis direction.
  39492. */
  39493. pinchPrecision: number;
  39494. /**
  39495. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39496. * from 0.
  39497. * It defines the percentage of current camera.radius to use as delta when
  39498. * pinch zoom is used.
  39499. */
  39500. pinchDeltaPercentage: number;
  39501. /**
  39502. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39503. */
  39504. axisXControlRadius: boolean;
  39505. /**
  39506. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39507. */
  39508. axisXControlHeight: boolean;
  39509. /**
  39510. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39511. */
  39512. axisXControlRotation: boolean;
  39513. /**
  39514. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39515. */
  39516. axisYControlRadius: boolean;
  39517. /**
  39518. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39519. */
  39520. axisYControlHeight: boolean;
  39521. /**
  39522. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39523. */
  39524. axisYControlRotation: boolean;
  39525. /**
  39526. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39527. */
  39528. axisPinchControlRadius: boolean;
  39529. /**
  39530. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39531. */
  39532. axisPinchControlHeight: boolean;
  39533. /**
  39534. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39535. */
  39536. axisPinchControlRotation: boolean;
  39537. /**
  39538. * Log error messages if basic misconfiguration has occurred.
  39539. */
  39540. warningEnable: boolean;
  39541. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39542. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39543. private _warningCounter;
  39544. private _warning;
  39545. }
  39546. }
  39547. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39548. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39549. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39550. /**
  39551. * Default Inputs manager for the FollowCamera.
  39552. * It groups all the default supported inputs for ease of use.
  39553. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39554. */
  39555. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39556. /**
  39557. * Instantiates a new FollowCameraInputsManager.
  39558. * @param camera Defines the camera the inputs belong to
  39559. */
  39560. constructor(camera: FollowCamera);
  39561. /**
  39562. * Add keyboard input support to the input manager.
  39563. * @returns the current input manager
  39564. */
  39565. addKeyboard(): FollowCameraInputsManager;
  39566. /**
  39567. * Add mouse wheel input support to the input manager.
  39568. * @returns the current input manager
  39569. */
  39570. addMouseWheel(): FollowCameraInputsManager;
  39571. /**
  39572. * Add pointers input support to the input manager.
  39573. * @returns the current input manager
  39574. */
  39575. addPointers(): FollowCameraInputsManager;
  39576. /**
  39577. * Add orientation input support to the input manager.
  39578. * @returns the current input manager
  39579. */
  39580. addVRDeviceOrientation(): FollowCameraInputsManager;
  39581. }
  39582. }
  39583. declare module "babylonjs/Cameras/followCamera" {
  39584. import { Nullable } from "babylonjs/types";
  39585. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39586. import { Scene } from "babylonjs/scene";
  39587. import { Vector3 } from "babylonjs/Maths/math.vector";
  39588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39589. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39590. /**
  39591. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39592. * an arc rotate version arcFollowCamera are available.
  39593. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39594. */
  39595. export class FollowCamera extends TargetCamera {
  39596. /**
  39597. * Distance the follow camera should follow an object at
  39598. */
  39599. radius: number;
  39600. /**
  39601. * Minimum allowed distance of the camera to the axis of rotation
  39602. * (The camera can not get closer).
  39603. * This can help limiting how the Camera is able to move in the scene.
  39604. */
  39605. lowerRadiusLimit: Nullable<number>;
  39606. /**
  39607. * Maximum allowed distance of the camera to the axis of rotation
  39608. * (The camera can not get further).
  39609. * This can help limiting how the Camera is able to move in the scene.
  39610. */
  39611. upperRadiusLimit: Nullable<number>;
  39612. /**
  39613. * Define a rotation offset between the camera and the object it follows
  39614. */
  39615. rotationOffset: number;
  39616. /**
  39617. * Minimum allowed angle to camera position relative to target object.
  39618. * This can help limiting how the Camera is able to move in the scene.
  39619. */
  39620. lowerRotationOffsetLimit: Nullable<number>;
  39621. /**
  39622. * Maximum allowed angle to camera position relative to target object.
  39623. * This can help limiting how the Camera is able to move in the scene.
  39624. */
  39625. upperRotationOffsetLimit: Nullable<number>;
  39626. /**
  39627. * Define a height offset between the camera and the object it follows.
  39628. * It can help following an object from the top (like a car chaing a plane)
  39629. */
  39630. heightOffset: number;
  39631. /**
  39632. * Minimum allowed height of camera position relative to target object.
  39633. * This can help limiting how the Camera is able to move in the scene.
  39634. */
  39635. lowerHeightOffsetLimit: Nullable<number>;
  39636. /**
  39637. * Maximum allowed height of camera position relative to target object.
  39638. * This can help limiting how the Camera is able to move in the scene.
  39639. */
  39640. upperHeightOffsetLimit: Nullable<number>;
  39641. /**
  39642. * Define how fast the camera can accelerate to follow it s target.
  39643. */
  39644. cameraAcceleration: number;
  39645. /**
  39646. * Define the speed limit of the camera following an object.
  39647. */
  39648. maxCameraSpeed: number;
  39649. /**
  39650. * Define the target of the camera.
  39651. */
  39652. lockedTarget: Nullable<AbstractMesh>;
  39653. /**
  39654. * Defines the input associated with the camera.
  39655. */
  39656. inputs: FollowCameraInputsManager;
  39657. /**
  39658. * Instantiates the follow camera.
  39659. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39660. * @param name Define the name of the camera in the scene
  39661. * @param position Define the position of the camera
  39662. * @param scene Define the scene the camera belong to
  39663. * @param lockedTarget Define the target of the camera
  39664. */
  39665. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39666. private _follow;
  39667. /**
  39668. * Attached controls to the current camera.
  39669. * @param element Defines the element the controls should be listened from
  39670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39671. */
  39672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39673. /**
  39674. * Detach the current controls from the camera.
  39675. * The camera will stop reacting to inputs.
  39676. * @param element Defines the element to stop listening the inputs from
  39677. */
  39678. detachControl(element: HTMLElement): void;
  39679. /** @hidden */
  39680. _checkInputs(): void;
  39681. private _checkLimits;
  39682. /**
  39683. * Gets the camera class name.
  39684. * @returns the class name
  39685. */
  39686. getClassName(): string;
  39687. }
  39688. /**
  39689. * Arc Rotate version of the follow camera.
  39690. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39691. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39692. */
  39693. export class ArcFollowCamera extends TargetCamera {
  39694. /** The longitudinal angle of the camera */
  39695. alpha: number;
  39696. /** The latitudinal angle of the camera */
  39697. beta: number;
  39698. /** The radius of the camera from its target */
  39699. radius: number;
  39700. /** Define the camera target (the messh it should follow) */
  39701. target: Nullable<AbstractMesh>;
  39702. private _cartesianCoordinates;
  39703. /**
  39704. * Instantiates a new ArcFollowCamera
  39705. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39706. * @param name Define the name of the camera
  39707. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39708. * @param beta Define the rotation angle of the camera around the elevation axis
  39709. * @param radius Define the radius of the camera from its target point
  39710. * @param target Define the target of the camera
  39711. * @param scene Define the scene the camera belongs to
  39712. */
  39713. constructor(name: string,
  39714. /** The longitudinal angle of the camera */
  39715. alpha: number,
  39716. /** The latitudinal angle of the camera */
  39717. beta: number,
  39718. /** The radius of the camera from its target */
  39719. radius: number,
  39720. /** Define the camera target (the messh it should follow) */
  39721. target: Nullable<AbstractMesh>, scene: Scene);
  39722. private _follow;
  39723. /** @hidden */
  39724. _checkInputs(): void;
  39725. /**
  39726. * Returns the class name of the object.
  39727. * It is mostly used internally for serialization purposes.
  39728. */
  39729. getClassName(): string;
  39730. }
  39731. }
  39732. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39733. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39734. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39735. import { Nullable } from "babylonjs/types";
  39736. /**
  39737. * Manage the keyboard inputs to control the movement of a follow camera.
  39738. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39739. */
  39740. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39741. /**
  39742. * Defines the camera the input is attached to.
  39743. */
  39744. camera: FollowCamera;
  39745. /**
  39746. * Defines the list of key codes associated with the up action (increase heightOffset)
  39747. */
  39748. keysHeightOffsetIncr: number[];
  39749. /**
  39750. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39751. */
  39752. keysHeightOffsetDecr: number[];
  39753. /**
  39754. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39755. */
  39756. keysHeightOffsetModifierAlt: boolean;
  39757. /**
  39758. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39759. */
  39760. keysHeightOffsetModifierCtrl: boolean;
  39761. /**
  39762. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39763. */
  39764. keysHeightOffsetModifierShift: boolean;
  39765. /**
  39766. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39767. */
  39768. keysRotationOffsetIncr: number[];
  39769. /**
  39770. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39771. */
  39772. keysRotationOffsetDecr: number[];
  39773. /**
  39774. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39775. */
  39776. keysRotationOffsetModifierAlt: boolean;
  39777. /**
  39778. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39779. */
  39780. keysRotationOffsetModifierCtrl: boolean;
  39781. /**
  39782. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39783. */
  39784. keysRotationOffsetModifierShift: boolean;
  39785. /**
  39786. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39787. */
  39788. keysRadiusIncr: number[];
  39789. /**
  39790. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39791. */
  39792. keysRadiusDecr: number[];
  39793. /**
  39794. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39795. */
  39796. keysRadiusModifierAlt: boolean;
  39797. /**
  39798. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39799. */
  39800. keysRadiusModifierCtrl: boolean;
  39801. /**
  39802. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39803. */
  39804. keysRadiusModifierShift: boolean;
  39805. /**
  39806. * Defines the rate of change of heightOffset.
  39807. */
  39808. heightSensibility: number;
  39809. /**
  39810. * Defines the rate of change of rotationOffset.
  39811. */
  39812. rotationSensibility: number;
  39813. /**
  39814. * Defines the rate of change of radius.
  39815. */
  39816. radiusSensibility: number;
  39817. private _keys;
  39818. private _ctrlPressed;
  39819. private _altPressed;
  39820. private _shiftPressed;
  39821. private _onCanvasBlurObserver;
  39822. private _onKeyboardObserver;
  39823. private _engine;
  39824. private _scene;
  39825. /**
  39826. * Attach the input controls to a specific dom element to get the input from.
  39827. * @param element Defines the element the controls should be listened from
  39828. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39829. */
  39830. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39831. /**
  39832. * Detach the current controls from the specified dom element.
  39833. * @param element Defines the element to stop listening the inputs from
  39834. */
  39835. detachControl(element: Nullable<HTMLElement>): void;
  39836. /**
  39837. * Update the current camera state depending on the inputs that have been used this frame.
  39838. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39839. */
  39840. checkInputs(): void;
  39841. /**
  39842. * Gets the class name of the current input.
  39843. * @returns the class name
  39844. */
  39845. getClassName(): string;
  39846. /**
  39847. * Get the friendly name associated with the input class.
  39848. * @returns the input friendly name
  39849. */
  39850. getSimpleName(): string;
  39851. /**
  39852. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39853. * allow modification of the heightOffset value.
  39854. */
  39855. private _modifierHeightOffset;
  39856. /**
  39857. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39858. * allow modification of the rotationOffset value.
  39859. */
  39860. private _modifierRotationOffset;
  39861. /**
  39862. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39863. * allow modification of the radius value.
  39864. */
  39865. private _modifierRadius;
  39866. }
  39867. }
  39868. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39869. import { Nullable } from "babylonjs/types";
  39870. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39871. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39872. import { Observable } from "babylonjs/Misc/observable";
  39873. module "babylonjs/Cameras/freeCameraInputsManager" {
  39874. interface FreeCameraInputsManager {
  39875. /**
  39876. * @hidden
  39877. */
  39878. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39879. /**
  39880. * Add orientation input support to the input manager.
  39881. * @returns the current input manager
  39882. */
  39883. addDeviceOrientation(): FreeCameraInputsManager;
  39884. }
  39885. }
  39886. /**
  39887. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39888. * Screen rotation is taken into account.
  39889. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39890. */
  39891. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39892. private _camera;
  39893. private _screenOrientationAngle;
  39894. private _constantTranform;
  39895. private _screenQuaternion;
  39896. private _alpha;
  39897. private _beta;
  39898. private _gamma;
  39899. /**
  39900. * Can be used to detect if a device orientation sensor is availible on a device
  39901. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39902. * @returns a promise that will resolve on orientation change
  39903. */
  39904. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39905. /**
  39906. * @hidden
  39907. */
  39908. _onDeviceOrientationChangedObservable: Observable<void>;
  39909. /**
  39910. * Instantiates a new input
  39911. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39912. */
  39913. constructor();
  39914. /**
  39915. * Define the camera controlled by the input.
  39916. */
  39917. camera: FreeCamera;
  39918. /**
  39919. * Attach the input controls to a specific dom element to get the input from.
  39920. * @param element Defines the element the controls should be listened from
  39921. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39922. */
  39923. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39924. private _orientationChanged;
  39925. private _deviceOrientation;
  39926. /**
  39927. * Detach the current controls from the specified dom element.
  39928. * @param element Defines the element to stop listening the inputs from
  39929. */
  39930. detachControl(element: Nullable<HTMLElement>): void;
  39931. /**
  39932. * Update the current camera state depending on the inputs that have been used this frame.
  39933. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39934. */
  39935. checkInputs(): void;
  39936. /**
  39937. * Gets the class name of the current intput.
  39938. * @returns the class name
  39939. */
  39940. getClassName(): string;
  39941. /**
  39942. * Get the friendly name associated with the input class.
  39943. * @returns the input friendly name
  39944. */
  39945. getSimpleName(): string;
  39946. }
  39947. }
  39948. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39949. import { Nullable } from "babylonjs/types";
  39950. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39951. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39952. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39953. /**
  39954. * Manage the gamepad inputs to control a free camera.
  39955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39956. */
  39957. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39958. /**
  39959. * Define the camera the input is attached to.
  39960. */
  39961. camera: FreeCamera;
  39962. /**
  39963. * Define the Gamepad controlling the input
  39964. */
  39965. gamepad: Nullable<Gamepad>;
  39966. /**
  39967. * Defines the gamepad rotation sensiblity.
  39968. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39969. */
  39970. gamepadAngularSensibility: number;
  39971. /**
  39972. * Defines the gamepad move sensiblity.
  39973. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39974. */
  39975. gamepadMoveSensibility: number;
  39976. private _yAxisScale;
  39977. /**
  39978. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39979. */
  39980. invertYAxis: boolean;
  39981. private _onGamepadConnectedObserver;
  39982. private _onGamepadDisconnectedObserver;
  39983. private _cameraTransform;
  39984. private _deltaTransform;
  39985. private _vector3;
  39986. private _vector2;
  39987. /**
  39988. * Attach the input controls to a specific dom element to get the input from.
  39989. * @param element Defines the element the controls should be listened from
  39990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39991. */
  39992. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39993. /**
  39994. * Detach the current controls from the specified dom element.
  39995. * @param element Defines the element to stop listening the inputs from
  39996. */
  39997. detachControl(element: Nullable<HTMLElement>): void;
  39998. /**
  39999. * Update the current camera state depending on the inputs that have been used this frame.
  40000. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40001. */
  40002. checkInputs(): void;
  40003. /**
  40004. * Gets the class name of the current intput.
  40005. * @returns the class name
  40006. */
  40007. getClassName(): string;
  40008. /**
  40009. * Get the friendly name associated with the input class.
  40010. * @returns the input friendly name
  40011. */
  40012. getSimpleName(): string;
  40013. }
  40014. }
  40015. declare module "babylonjs/Misc/virtualJoystick" {
  40016. import { Nullable } from "babylonjs/types";
  40017. import { Vector3 } from "babylonjs/Maths/math.vector";
  40018. /**
  40019. * Defines the potential axis of a Joystick
  40020. */
  40021. export enum JoystickAxis {
  40022. /** X axis */
  40023. X = 0,
  40024. /** Y axis */
  40025. Y = 1,
  40026. /** Z axis */
  40027. Z = 2
  40028. }
  40029. /**
  40030. * Class used to define virtual joystick (used in touch mode)
  40031. */
  40032. export class VirtualJoystick {
  40033. /**
  40034. * Gets or sets a boolean indicating that left and right values must be inverted
  40035. */
  40036. reverseLeftRight: boolean;
  40037. /**
  40038. * Gets or sets a boolean indicating that up and down values must be inverted
  40039. */
  40040. reverseUpDown: boolean;
  40041. /**
  40042. * Gets the offset value for the position (ie. the change of the position value)
  40043. */
  40044. deltaPosition: Vector3;
  40045. /**
  40046. * Gets a boolean indicating if the virtual joystick was pressed
  40047. */
  40048. pressed: boolean;
  40049. /**
  40050. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40051. */
  40052. static Canvas: Nullable<HTMLCanvasElement>;
  40053. private static _globalJoystickIndex;
  40054. private static vjCanvasContext;
  40055. private static vjCanvasWidth;
  40056. private static vjCanvasHeight;
  40057. private static halfWidth;
  40058. private _action;
  40059. private _axisTargetedByLeftAndRight;
  40060. private _axisTargetedByUpAndDown;
  40061. private _joystickSensibility;
  40062. private _inversedSensibility;
  40063. private _joystickPointerID;
  40064. private _joystickColor;
  40065. private _joystickPointerPos;
  40066. private _joystickPreviousPointerPos;
  40067. private _joystickPointerStartPos;
  40068. private _deltaJoystickVector;
  40069. private _leftJoystick;
  40070. private _touches;
  40071. private _onPointerDownHandlerRef;
  40072. private _onPointerMoveHandlerRef;
  40073. private _onPointerUpHandlerRef;
  40074. private _onResize;
  40075. /**
  40076. * Creates a new virtual joystick
  40077. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40078. */
  40079. constructor(leftJoystick?: boolean);
  40080. /**
  40081. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40082. * @param newJoystickSensibility defines the new sensibility
  40083. */
  40084. setJoystickSensibility(newJoystickSensibility: number): void;
  40085. private _onPointerDown;
  40086. private _onPointerMove;
  40087. private _onPointerUp;
  40088. /**
  40089. * Change the color of the virtual joystick
  40090. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40091. */
  40092. setJoystickColor(newColor: string): void;
  40093. /**
  40094. * Defines a callback to call when the joystick is touched
  40095. * @param action defines the callback
  40096. */
  40097. setActionOnTouch(action: () => any): void;
  40098. /**
  40099. * Defines which axis you'd like to control for left & right
  40100. * @param axis defines the axis to use
  40101. */
  40102. setAxisForLeftRight(axis: JoystickAxis): void;
  40103. /**
  40104. * Defines which axis you'd like to control for up & down
  40105. * @param axis defines the axis to use
  40106. */
  40107. setAxisForUpDown(axis: JoystickAxis): void;
  40108. private _drawVirtualJoystick;
  40109. /**
  40110. * Release internal HTML canvas
  40111. */
  40112. releaseCanvas(): void;
  40113. }
  40114. }
  40115. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  40116. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  40117. import { Nullable } from "babylonjs/types";
  40118. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40119. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40120. module "babylonjs/Cameras/freeCameraInputsManager" {
  40121. interface FreeCameraInputsManager {
  40122. /**
  40123. * Add virtual joystick input support to the input manager.
  40124. * @returns the current input manager
  40125. */
  40126. addVirtualJoystick(): FreeCameraInputsManager;
  40127. }
  40128. }
  40129. /**
  40130. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40131. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40132. */
  40133. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40134. /**
  40135. * Defines the camera the input is attached to.
  40136. */
  40137. camera: FreeCamera;
  40138. private _leftjoystick;
  40139. private _rightjoystick;
  40140. /**
  40141. * Gets the left stick of the virtual joystick.
  40142. * @returns The virtual Joystick
  40143. */
  40144. getLeftJoystick(): VirtualJoystick;
  40145. /**
  40146. * Gets the right stick of the virtual joystick.
  40147. * @returns The virtual Joystick
  40148. */
  40149. getRightJoystick(): VirtualJoystick;
  40150. /**
  40151. * Update the current camera state depending on the inputs that have been used this frame.
  40152. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40153. */
  40154. checkInputs(): void;
  40155. /**
  40156. * Attach the input controls to a specific dom element to get the input from.
  40157. * @param element Defines the element the controls should be listened from
  40158. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40159. */
  40160. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40161. /**
  40162. * Detach the current controls from the specified dom element.
  40163. * @param element Defines the element to stop listening the inputs from
  40164. */
  40165. detachControl(element: Nullable<HTMLElement>): void;
  40166. /**
  40167. * Gets the class name of the current intput.
  40168. * @returns the class name
  40169. */
  40170. getClassName(): string;
  40171. /**
  40172. * Get the friendly name associated with the input class.
  40173. * @returns the input friendly name
  40174. */
  40175. getSimpleName(): string;
  40176. }
  40177. }
  40178. declare module "babylonjs/Cameras/Inputs/index" {
  40179. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  40180. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  40181. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  40182. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  40183. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40184. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  40185. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  40186. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  40187. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  40188. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  40189. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40190. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  40191. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  40192. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  40193. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  40194. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40195. }
  40196. declare module "babylonjs/Cameras/touchCamera" {
  40197. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40198. import { Scene } from "babylonjs/scene";
  40199. import { Vector3 } from "babylonjs/Maths/math.vector";
  40200. /**
  40201. * This represents a FPS type of camera controlled by touch.
  40202. * This is like a universal camera minus the Gamepad controls.
  40203. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40204. */
  40205. export class TouchCamera extends FreeCamera {
  40206. /**
  40207. * Defines the touch sensibility for rotation.
  40208. * The higher the faster.
  40209. */
  40210. touchAngularSensibility: number;
  40211. /**
  40212. * Defines the touch sensibility for move.
  40213. * The higher the faster.
  40214. */
  40215. touchMoveSensibility: number;
  40216. /**
  40217. * Instantiates a new touch camera.
  40218. * This represents a FPS type of camera controlled by touch.
  40219. * This is like a universal camera minus the Gamepad controls.
  40220. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40221. * @param name Define the name of the camera in the scene
  40222. * @param position Define the start position of the camera in the scene
  40223. * @param scene Define the scene the camera belongs to
  40224. */
  40225. constructor(name: string, position: Vector3, scene: Scene);
  40226. /**
  40227. * Gets the current object class name.
  40228. * @return the class name
  40229. */
  40230. getClassName(): string;
  40231. /** @hidden */
  40232. _setupInputs(): void;
  40233. }
  40234. }
  40235. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  40236. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40237. import { Scene } from "babylonjs/scene";
  40238. import { Vector3 } from "babylonjs/Maths/math.vector";
  40239. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40240. import { Axis } from "babylonjs/Maths/math.axis";
  40241. /**
  40242. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40243. * being tilted forward or back and left or right.
  40244. */
  40245. export class DeviceOrientationCamera extends FreeCamera {
  40246. private _initialQuaternion;
  40247. private _quaternionCache;
  40248. private _tmpDragQuaternion;
  40249. private _disablePointerInputWhenUsingDeviceOrientation;
  40250. /**
  40251. * Creates a new device orientation camera
  40252. * @param name The name of the camera
  40253. * @param position The start position camera
  40254. * @param scene The scene the camera belongs to
  40255. */
  40256. constructor(name: string, position: Vector3, scene: Scene);
  40257. /**
  40258. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40259. */
  40260. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40261. private _dragFactor;
  40262. /**
  40263. * Enabled turning on the y axis when the orientation sensor is active
  40264. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40265. */
  40266. enableHorizontalDragging(dragFactor?: number): void;
  40267. /**
  40268. * Gets the current instance class name ("DeviceOrientationCamera").
  40269. * This helps avoiding instanceof at run time.
  40270. * @returns the class name
  40271. */
  40272. getClassName(): string;
  40273. /**
  40274. * @hidden
  40275. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40276. */
  40277. _checkInputs(): void;
  40278. /**
  40279. * Reset the camera to its default orientation on the specified axis only.
  40280. * @param axis The axis to reset
  40281. */
  40282. resetToCurrentRotation(axis?: Axis): void;
  40283. }
  40284. }
  40285. declare module "babylonjs/Gamepads/xboxGamepad" {
  40286. import { Observable } from "babylonjs/Misc/observable";
  40287. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40288. /**
  40289. * Defines supported buttons for XBox360 compatible gamepads
  40290. */
  40291. export enum Xbox360Button {
  40292. /** A */
  40293. A = 0,
  40294. /** B */
  40295. B = 1,
  40296. /** X */
  40297. X = 2,
  40298. /** Y */
  40299. Y = 3,
  40300. /** Start */
  40301. Start = 4,
  40302. /** Back */
  40303. Back = 5,
  40304. /** Left button */
  40305. LB = 6,
  40306. /** Right button */
  40307. RB = 7,
  40308. /** Left stick */
  40309. LeftStick = 8,
  40310. /** Right stick */
  40311. RightStick = 9
  40312. }
  40313. /** Defines values for XBox360 DPad */
  40314. export enum Xbox360Dpad {
  40315. /** Up */
  40316. Up = 0,
  40317. /** Down */
  40318. Down = 1,
  40319. /** Left */
  40320. Left = 2,
  40321. /** Right */
  40322. Right = 3
  40323. }
  40324. /**
  40325. * Defines a XBox360 gamepad
  40326. */
  40327. export class Xbox360Pad extends Gamepad {
  40328. private _leftTrigger;
  40329. private _rightTrigger;
  40330. private _onlefttriggerchanged;
  40331. private _onrighttriggerchanged;
  40332. private _onbuttondown;
  40333. private _onbuttonup;
  40334. private _ondpaddown;
  40335. private _ondpadup;
  40336. /** Observable raised when a button is pressed */
  40337. onButtonDownObservable: Observable<Xbox360Button>;
  40338. /** Observable raised when a button is released */
  40339. onButtonUpObservable: Observable<Xbox360Button>;
  40340. /** Observable raised when a pad is pressed */
  40341. onPadDownObservable: Observable<Xbox360Dpad>;
  40342. /** Observable raised when a pad is released */
  40343. onPadUpObservable: Observable<Xbox360Dpad>;
  40344. private _buttonA;
  40345. private _buttonB;
  40346. private _buttonX;
  40347. private _buttonY;
  40348. private _buttonBack;
  40349. private _buttonStart;
  40350. private _buttonLB;
  40351. private _buttonRB;
  40352. private _buttonLeftStick;
  40353. private _buttonRightStick;
  40354. private _dPadUp;
  40355. private _dPadDown;
  40356. private _dPadLeft;
  40357. private _dPadRight;
  40358. private _isXboxOnePad;
  40359. /**
  40360. * Creates a new XBox360 gamepad object
  40361. * @param id defines the id of this gamepad
  40362. * @param index defines its index
  40363. * @param gamepad defines the internal HTML gamepad object
  40364. * @param xboxOne defines if it is a XBox One gamepad
  40365. */
  40366. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40367. /**
  40368. * Defines the callback to call when left trigger is pressed
  40369. * @param callback defines the callback to use
  40370. */
  40371. onlefttriggerchanged(callback: (value: number) => void): void;
  40372. /**
  40373. * Defines the callback to call when right trigger is pressed
  40374. * @param callback defines the callback to use
  40375. */
  40376. onrighttriggerchanged(callback: (value: number) => void): void;
  40377. /**
  40378. * Gets the left trigger value
  40379. */
  40380. /**
  40381. * Sets the left trigger value
  40382. */
  40383. leftTrigger: number;
  40384. /**
  40385. * Gets the right trigger value
  40386. */
  40387. /**
  40388. * Sets the right trigger value
  40389. */
  40390. rightTrigger: number;
  40391. /**
  40392. * Defines the callback to call when a button is pressed
  40393. * @param callback defines the callback to use
  40394. */
  40395. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40396. /**
  40397. * Defines the callback to call when a button is released
  40398. * @param callback defines the callback to use
  40399. */
  40400. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40401. /**
  40402. * Defines the callback to call when a pad is pressed
  40403. * @param callback defines the callback to use
  40404. */
  40405. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40406. /**
  40407. * Defines the callback to call when a pad is released
  40408. * @param callback defines the callback to use
  40409. */
  40410. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40411. private _setButtonValue;
  40412. private _setDPadValue;
  40413. /**
  40414. * Gets the value of the `A` button
  40415. */
  40416. /**
  40417. * Sets the value of the `A` button
  40418. */
  40419. buttonA: number;
  40420. /**
  40421. * Gets the value of the `B` button
  40422. */
  40423. /**
  40424. * Sets the value of the `B` button
  40425. */
  40426. buttonB: number;
  40427. /**
  40428. * Gets the value of the `X` button
  40429. */
  40430. /**
  40431. * Sets the value of the `X` button
  40432. */
  40433. buttonX: number;
  40434. /**
  40435. * Gets the value of the `Y` button
  40436. */
  40437. /**
  40438. * Sets the value of the `Y` button
  40439. */
  40440. buttonY: number;
  40441. /**
  40442. * Gets the value of the `Start` button
  40443. */
  40444. /**
  40445. * Sets the value of the `Start` button
  40446. */
  40447. buttonStart: number;
  40448. /**
  40449. * Gets the value of the `Back` button
  40450. */
  40451. /**
  40452. * Sets the value of the `Back` button
  40453. */
  40454. buttonBack: number;
  40455. /**
  40456. * Gets the value of the `Left` button
  40457. */
  40458. /**
  40459. * Sets the value of the `Left` button
  40460. */
  40461. buttonLB: number;
  40462. /**
  40463. * Gets the value of the `Right` button
  40464. */
  40465. /**
  40466. * Sets the value of the `Right` button
  40467. */
  40468. buttonRB: number;
  40469. /**
  40470. * Gets the value of the Left joystick
  40471. */
  40472. /**
  40473. * Sets the value of the Left joystick
  40474. */
  40475. buttonLeftStick: number;
  40476. /**
  40477. * Gets the value of the Right joystick
  40478. */
  40479. /**
  40480. * Sets the value of the Right joystick
  40481. */
  40482. buttonRightStick: number;
  40483. /**
  40484. * Gets the value of D-pad up
  40485. */
  40486. /**
  40487. * Sets the value of D-pad up
  40488. */
  40489. dPadUp: number;
  40490. /**
  40491. * Gets the value of D-pad down
  40492. */
  40493. /**
  40494. * Sets the value of D-pad down
  40495. */
  40496. dPadDown: number;
  40497. /**
  40498. * Gets the value of D-pad left
  40499. */
  40500. /**
  40501. * Sets the value of D-pad left
  40502. */
  40503. dPadLeft: number;
  40504. /**
  40505. * Gets the value of D-pad right
  40506. */
  40507. /**
  40508. * Sets the value of D-pad right
  40509. */
  40510. dPadRight: number;
  40511. /**
  40512. * Force the gamepad to synchronize with device values
  40513. */
  40514. update(): void;
  40515. /**
  40516. * Disposes the gamepad
  40517. */
  40518. dispose(): void;
  40519. }
  40520. }
  40521. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40522. import { Observable } from "babylonjs/Misc/observable";
  40523. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40524. /**
  40525. * Defines supported buttons for DualShock compatible gamepads
  40526. */
  40527. export enum DualShockButton {
  40528. /** Cross */
  40529. Cross = 0,
  40530. /** Circle */
  40531. Circle = 1,
  40532. /** Square */
  40533. Square = 2,
  40534. /** Triangle */
  40535. Triangle = 3,
  40536. /** Options */
  40537. Options = 4,
  40538. /** Share */
  40539. Share = 5,
  40540. /** L1 */
  40541. L1 = 6,
  40542. /** R1 */
  40543. R1 = 7,
  40544. /** Left stick */
  40545. LeftStick = 8,
  40546. /** Right stick */
  40547. RightStick = 9
  40548. }
  40549. /** Defines values for DualShock DPad */
  40550. export enum DualShockDpad {
  40551. /** Up */
  40552. Up = 0,
  40553. /** Down */
  40554. Down = 1,
  40555. /** Left */
  40556. Left = 2,
  40557. /** Right */
  40558. Right = 3
  40559. }
  40560. /**
  40561. * Defines a DualShock gamepad
  40562. */
  40563. export class DualShockPad extends Gamepad {
  40564. private _leftTrigger;
  40565. private _rightTrigger;
  40566. private _onlefttriggerchanged;
  40567. private _onrighttriggerchanged;
  40568. private _onbuttondown;
  40569. private _onbuttonup;
  40570. private _ondpaddown;
  40571. private _ondpadup;
  40572. /** Observable raised when a button is pressed */
  40573. onButtonDownObservable: Observable<DualShockButton>;
  40574. /** Observable raised when a button is released */
  40575. onButtonUpObservable: Observable<DualShockButton>;
  40576. /** Observable raised when a pad is pressed */
  40577. onPadDownObservable: Observable<DualShockDpad>;
  40578. /** Observable raised when a pad is released */
  40579. onPadUpObservable: Observable<DualShockDpad>;
  40580. private _buttonCross;
  40581. private _buttonCircle;
  40582. private _buttonSquare;
  40583. private _buttonTriangle;
  40584. private _buttonShare;
  40585. private _buttonOptions;
  40586. private _buttonL1;
  40587. private _buttonR1;
  40588. private _buttonLeftStick;
  40589. private _buttonRightStick;
  40590. private _dPadUp;
  40591. private _dPadDown;
  40592. private _dPadLeft;
  40593. private _dPadRight;
  40594. /**
  40595. * Creates a new DualShock gamepad object
  40596. * @param id defines the id of this gamepad
  40597. * @param index defines its index
  40598. * @param gamepad defines the internal HTML gamepad object
  40599. */
  40600. constructor(id: string, index: number, gamepad: any);
  40601. /**
  40602. * Defines the callback to call when left trigger is pressed
  40603. * @param callback defines the callback to use
  40604. */
  40605. onlefttriggerchanged(callback: (value: number) => void): void;
  40606. /**
  40607. * Defines the callback to call when right trigger is pressed
  40608. * @param callback defines the callback to use
  40609. */
  40610. onrighttriggerchanged(callback: (value: number) => void): void;
  40611. /**
  40612. * Gets the left trigger value
  40613. */
  40614. /**
  40615. * Sets the left trigger value
  40616. */
  40617. leftTrigger: number;
  40618. /**
  40619. * Gets the right trigger value
  40620. */
  40621. /**
  40622. * Sets the right trigger value
  40623. */
  40624. rightTrigger: number;
  40625. /**
  40626. * Defines the callback to call when a button is pressed
  40627. * @param callback defines the callback to use
  40628. */
  40629. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40630. /**
  40631. * Defines the callback to call when a button is released
  40632. * @param callback defines the callback to use
  40633. */
  40634. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40635. /**
  40636. * Defines the callback to call when a pad is pressed
  40637. * @param callback defines the callback to use
  40638. */
  40639. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40640. /**
  40641. * Defines the callback to call when a pad is released
  40642. * @param callback defines the callback to use
  40643. */
  40644. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40645. private _setButtonValue;
  40646. private _setDPadValue;
  40647. /**
  40648. * Gets the value of the `Cross` button
  40649. */
  40650. /**
  40651. * Sets the value of the `Cross` button
  40652. */
  40653. buttonCross: number;
  40654. /**
  40655. * Gets the value of the `Circle` button
  40656. */
  40657. /**
  40658. * Sets the value of the `Circle` button
  40659. */
  40660. buttonCircle: number;
  40661. /**
  40662. * Gets the value of the `Square` button
  40663. */
  40664. /**
  40665. * Sets the value of the `Square` button
  40666. */
  40667. buttonSquare: number;
  40668. /**
  40669. * Gets the value of the `Triangle` button
  40670. */
  40671. /**
  40672. * Sets the value of the `Triangle` button
  40673. */
  40674. buttonTriangle: number;
  40675. /**
  40676. * Gets the value of the `Options` button
  40677. */
  40678. /**
  40679. * Sets the value of the `Options` button
  40680. */
  40681. buttonOptions: number;
  40682. /**
  40683. * Gets the value of the `Share` button
  40684. */
  40685. /**
  40686. * Sets the value of the `Share` button
  40687. */
  40688. buttonShare: number;
  40689. /**
  40690. * Gets the value of the `L1` button
  40691. */
  40692. /**
  40693. * Sets the value of the `L1` button
  40694. */
  40695. buttonL1: number;
  40696. /**
  40697. * Gets the value of the `R1` button
  40698. */
  40699. /**
  40700. * Sets the value of the `R1` button
  40701. */
  40702. buttonR1: number;
  40703. /**
  40704. * Gets the value of the Left joystick
  40705. */
  40706. /**
  40707. * Sets the value of the Left joystick
  40708. */
  40709. buttonLeftStick: number;
  40710. /**
  40711. * Gets the value of the Right joystick
  40712. */
  40713. /**
  40714. * Sets the value of the Right joystick
  40715. */
  40716. buttonRightStick: number;
  40717. /**
  40718. * Gets the value of D-pad up
  40719. */
  40720. /**
  40721. * Sets the value of D-pad up
  40722. */
  40723. dPadUp: number;
  40724. /**
  40725. * Gets the value of D-pad down
  40726. */
  40727. /**
  40728. * Sets the value of D-pad down
  40729. */
  40730. dPadDown: number;
  40731. /**
  40732. * Gets the value of D-pad left
  40733. */
  40734. /**
  40735. * Sets the value of D-pad left
  40736. */
  40737. dPadLeft: number;
  40738. /**
  40739. * Gets the value of D-pad right
  40740. */
  40741. /**
  40742. * Sets the value of D-pad right
  40743. */
  40744. dPadRight: number;
  40745. /**
  40746. * Force the gamepad to synchronize with device values
  40747. */
  40748. update(): void;
  40749. /**
  40750. * Disposes the gamepad
  40751. */
  40752. dispose(): void;
  40753. }
  40754. }
  40755. declare module "babylonjs/Gamepads/gamepadManager" {
  40756. import { Observable } from "babylonjs/Misc/observable";
  40757. import { Nullable } from "babylonjs/types";
  40758. import { Scene } from "babylonjs/scene";
  40759. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40760. /**
  40761. * Manager for handling gamepads
  40762. */
  40763. export class GamepadManager {
  40764. private _scene?;
  40765. private _babylonGamepads;
  40766. private _oneGamepadConnected;
  40767. /** @hidden */
  40768. _isMonitoring: boolean;
  40769. private _gamepadEventSupported;
  40770. private _gamepadSupport;
  40771. /**
  40772. * observable to be triggered when the gamepad controller has been connected
  40773. */
  40774. onGamepadConnectedObservable: Observable<Gamepad>;
  40775. /**
  40776. * observable to be triggered when the gamepad controller has been disconnected
  40777. */
  40778. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40779. private _onGamepadConnectedEvent;
  40780. private _onGamepadDisconnectedEvent;
  40781. /**
  40782. * Initializes the gamepad manager
  40783. * @param _scene BabylonJS scene
  40784. */
  40785. constructor(_scene?: Scene | undefined);
  40786. /**
  40787. * The gamepads in the game pad manager
  40788. */
  40789. readonly gamepads: Gamepad[];
  40790. /**
  40791. * Get the gamepad controllers based on type
  40792. * @param type The type of gamepad controller
  40793. * @returns Nullable gamepad
  40794. */
  40795. getGamepadByType(type?: number): Nullable<Gamepad>;
  40796. /**
  40797. * Disposes the gamepad manager
  40798. */
  40799. dispose(): void;
  40800. private _addNewGamepad;
  40801. private _startMonitoringGamepads;
  40802. private _stopMonitoringGamepads;
  40803. /** @hidden */
  40804. _checkGamepadsStatus(): void;
  40805. private _updateGamepadObjects;
  40806. }
  40807. }
  40808. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40809. import { Nullable } from "babylonjs/types";
  40810. import { Scene } from "babylonjs/scene";
  40811. import { ISceneComponent } from "babylonjs/sceneComponent";
  40812. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40813. module "babylonjs/scene" {
  40814. interface Scene {
  40815. /** @hidden */
  40816. _gamepadManager: Nullable<GamepadManager>;
  40817. /**
  40818. * Gets the gamepad manager associated with the scene
  40819. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40820. */
  40821. gamepadManager: GamepadManager;
  40822. }
  40823. }
  40824. module "babylonjs/Cameras/freeCameraInputsManager" {
  40825. /**
  40826. * Interface representing a free camera inputs manager
  40827. */
  40828. interface FreeCameraInputsManager {
  40829. /**
  40830. * Adds gamepad input support to the FreeCameraInputsManager.
  40831. * @returns the FreeCameraInputsManager
  40832. */
  40833. addGamepad(): FreeCameraInputsManager;
  40834. }
  40835. }
  40836. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40837. /**
  40838. * Interface representing an arc rotate camera inputs manager
  40839. */
  40840. interface ArcRotateCameraInputsManager {
  40841. /**
  40842. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40843. * @returns the camera inputs manager
  40844. */
  40845. addGamepad(): ArcRotateCameraInputsManager;
  40846. }
  40847. }
  40848. /**
  40849. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40850. */
  40851. export class GamepadSystemSceneComponent implements ISceneComponent {
  40852. /**
  40853. * The component name helpfull to identify the component in the list of scene components.
  40854. */
  40855. readonly name: string;
  40856. /**
  40857. * The scene the component belongs to.
  40858. */
  40859. scene: Scene;
  40860. /**
  40861. * Creates a new instance of the component for the given scene
  40862. * @param scene Defines the scene to register the component in
  40863. */
  40864. constructor(scene: Scene);
  40865. /**
  40866. * Registers the component in a given scene
  40867. */
  40868. register(): void;
  40869. /**
  40870. * Rebuilds the elements related to this component in case of
  40871. * context lost for instance.
  40872. */
  40873. rebuild(): void;
  40874. /**
  40875. * Disposes the component and the associated ressources
  40876. */
  40877. dispose(): void;
  40878. private _beforeCameraUpdate;
  40879. }
  40880. }
  40881. declare module "babylonjs/Cameras/universalCamera" {
  40882. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40883. import { Scene } from "babylonjs/scene";
  40884. import { Vector3 } from "babylonjs/Maths/math.vector";
  40885. import "babylonjs/Gamepads/gamepadSceneComponent";
  40886. /**
  40887. * 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,
  40888. * which still works and will still be found in many Playgrounds.
  40889. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40890. */
  40891. export class UniversalCamera extends TouchCamera {
  40892. /**
  40893. * Defines the gamepad rotation sensiblity.
  40894. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40895. */
  40896. gamepadAngularSensibility: number;
  40897. /**
  40898. * Defines the gamepad move sensiblity.
  40899. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40900. */
  40901. gamepadMoveSensibility: number;
  40902. /**
  40903. * 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,
  40904. * which still works and will still be found in many Playgrounds.
  40905. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40906. * @param name Define the name of the camera in the scene
  40907. * @param position Define the start position of the camera in the scene
  40908. * @param scene Define the scene the camera belongs to
  40909. */
  40910. constructor(name: string, position: Vector3, scene: Scene);
  40911. /**
  40912. * Gets the current object class name.
  40913. * @return the class name
  40914. */
  40915. getClassName(): string;
  40916. }
  40917. }
  40918. declare module "babylonjs/Cameras/gamepadCamera" {
  40919. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40920. import { Scene } from "babylonjs/scene";
  40921. import { Vector3 } from "babylonjs/Maths/math.vector";
  40922. /**
  40923. * This represents a FPS type of camera. This is only here for back compat purpose.
  40924. * Please use the UniversalCamera instead as both are identical.
  40925. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40926. */
  40927. export class GamepadCamera extends UniversalCamera {
  40928. /**
  40929. * Instantiates a new Gamepad Camera
  40930. * This represents a FPS type of camera. This is only here for back compat purpose.
  40931. * Please use the UniversalCamera instead as both are identical.
  40932. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40933. * @param name Define the name of the camera in the scene
  40934. * @param position Define the start position of the camera in the scene
  40935. * @param scene Define the scene the camera belongs to
  40936. */
  40937. constructor(name: string, position: Vector3, scene: Scene);
  40938. /**
  40939. * Gets the current object class name.
  40940. * @return the class name
  40941. */
  40942. getClassName(): string;
  40943. }
  40944. }
  40945. declare module "babylonjs/Shaders/pass.fragment" {
  40946. /** @hidden */
  40947. export var passPixelShader: {
  40948. name: string;
  40949. shader: string;
  40950. };
  40951. }
  40952. declare module "babylonjs/Shaders/passCube.fragment" {
  40953. /** @hidden */
  40954. export var passCubePixelShader: {
  40955. name: string;
  40956. shader: string;
  40957. };
  40958. }
  40959. declare module "babylonjs/PostProcesses/passPostProcess" {
  40960. import { Nullable } from "babylonjs/types";
  40961. import { Camera } from "babylonjs/Cameras/camera";
  40962. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40963. import { Engine } from "babylonjs/Engines/engine";
  40964. import "babylonjs/Shaders/pass.fragment";
  40965. import "babylonjs/Shaders/passCube.fragment";
  40966. /**
  40967. * PassPostProcess which produces an output the same as it's input
  40968. */
  40969. export class PassPostProcess extends PostProcess {
  40970. /**
  40971. * Creates the PassPostProcess
  40972. * @param name The name of the effect.
  40973. * @param options The required width/height ratio to downsize to before computing the render pass.
  40974. * @param camera The camera to apply the render pass to.
  40975. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40976. * @param engine The engine which the post process will be applied. (default: current engine)
  40977. * @param reusable If the post process can be reused on the same frame. (default: false)
  40978. * @param textureType The type of texture to be used when performing the post processing.
  40979. * @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)
  40980. */
  40981. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40982. }
  40983. /**
  40984. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40985. */
  40986. export class PassCubePostProcess extends PostProcess {
  40987. private _face;
  40988. /**
  40989. * Gets or sets the cube face to display.
  40990. * * 0 is +X
  40991. * * 1 is -X
  40992. * * 2 is +Y
  40993. * * 3 is -Y
  40994. * * 4 is +Z
  40995. * * 5 is -Z
  40996. */
  40997. face: number;
  40998. /**
  40999. * Creates the PassCubePostProcess
  41000. * @param name The name of the effect.
  41001. * @param options The required width/height ratio to downsize to before computing the render pass.
  41002. * @param camera The camera to apply the render pass to.
  41003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41004. * @param engine The engine which the post process will be applied. (default: current engine)
  41005. * @param reusable If the post process can be reused on the same frame. (default: false)
  41006. * @param textureType The type of texture to be used when performing the post processing.
  41007. * @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)
  41008. */
  41009. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41010. }
  41011. }
  41012. declare module "babylonjs/Shaders/anaglyph.fragment" {
  41013. /** @hidden */
  41014. export var anaglyphPixelShader: {
  41015. name: string;
  41016. shader: string;
  41017. };
  41018. }
  41019. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  41020. import { Engine } from "babylonjs/Engines/engine";
  41021. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41022. import { Camera } from "babylonjs/Cameras/camera";
  41023. import "babylonjs/Shaders/anaglyph.fragment";
  41024. /**
  41025. * Postprocess used to generate anaglyphic rendering
  41026. */
  41027. export class AnaglyphPostProcess extends PostProcess {
  41028. private _passedProcess;
  41029. /**
  41030. * Creates a new AnaglyphPostProcess
  41031. * @param name defines postprocess name
  41032. * @param options defines creation options or target ratio scale
  41033. * @param rigCameras defines cameras using this postprocess
  41034. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41035. * @param engine defines hosting engine
  41036. * @param reusable defines if the postprocess will be reused multiple times per frame
  41037. */
  41038. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41039. }
  41040. }
  41041. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  41042. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  41043. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41044. import { Scene } from "babylonjs/scene";
  41045. import { Vector3 } from "babylonjs/Maths/math.vector";
  41046. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41047. /**
  41048. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41049. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41050. */
  41051. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41052. /**
  41053. * Creates a new AnaglyphArcRotateCamera
  41054. * @param name defines camera name
  41055. * @param alpha defines alpha angle (in radians)
  41056. * @param beta defines beta angle (in radians)
  41057. * @param radius defines radius
  41058. * @param target defines camera target
  41059. * @param interaxialDistance defines distance between each color axis
  41060. * @param scene defines the hosting scene
  41061. */
  41062. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41063. /**
  41064. * Gets camera class name
  41065. * @returns AnaglyphArcRotateCamera
  41066. */
  41067. getClassName(): string;
  41068. }
  41069. }
  41070. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  41071. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41072. import { Scene } from "babylonjs/scene";
  41073. import { Vector3 } from "babylonjs/Maths/math.vector";
  41074. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41075. /**
  41076. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41077. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41078. */
  41079. export class AnaglyphFreeCamera extends FreeCamera {
  41080. /**
  41081. * Creates a new AnaglyphFreeCamera
  41082. * @param name defines camera name
  41083. * @param position defines initial position
  41084. * @param interaxialDistance defines distance between each color axis
  41085. * @param scene defines the hosting scene
  41086. */
  41087. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41088. /**
  41089. * Gets camera class name
  41090. * @returns AnaglyphFreeCamera
  41091. */
  41092. getClassName(): string;
  41093. }
  41094. }
  41095. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  41096. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41097. import { Scene } from "babylonjs/scene";
  41098. import { Vector3 } from "babylonjs/Maths/math.vector";
  41099. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41100. /**
  41101. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41102. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41103. */
  41104. export class AnaglyphGamepadCamera extends GamepadCamera {
  41105. /**
  41106. * Creates a new AnaglyphGamepadCamera
  41107. * @param name defines camera name
  41108. * @param position defines initial position
  41109. * @param interaxialDistance defines distance between each color axis
  41110. * @param scene defines the hosting scene
  41111. */
  41112. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41113. /**
  41114. * Gets camera class name
  41115. * @returns AnaglyphGamepadCamera
  41116. */
  41117. getClassName(): string;
  41118. }
  41119. }
  41120. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  41121. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41122. import { Scene } from "babylonjs/scene";
  41123. import { Vector3 } from "babylonjs/Maths/math.vector";
  41124. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41125. /**
  41126. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41127. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41128. */
  41129. export class AnaglyphUniversalCamera extends UniversalCamera {
  41130. /**
  41131. * Creates a new AnaglyphUniversalCamera
  41132. * @param name defines camera name
  41133. * @param position defines initial position
  41134. * @param interaxialDistance defines distance between each color axis
  41135. * @param scene defines the hosting scene
  41136. */
  41137. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41138. /**
  41139. * Gets camera class name
  41140. * @returns AnaglyphUniversalCamera
  41141. */
  41142. getClassName(): string;
  41143. }
  41144. }
  41145. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  41146. /** @hidden */
  41147. export var stereoscopicInterlacePixelShader: {
  41148. name: string;
  41149. shader: string;
  41150. };
  41151. }
  41152. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  41153. import { Camera } from "babylonjs/Cameras/camera";
  41154. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41155. import { Engine } from "babylonjs/Engines/engine";
  41156. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  41157. /**
  41158. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41159. */
  41160. export class StereoscopicInterlacePostProcess extends PostProcess {
  41161. private _stepSize;
  41162. private _passedProcess;
  41163. /**
  41164. * Initializes a StereoscopicInterlacePostProcess
  41165. * @param name The name of the effect.
  41166. * @param rigCameras The rig cameras to be appled to the post process
  41167. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41169. * @param engine The engine which the post process will be applied. (default: current engine)
  41170. * @param reusable If the post process can be reused on the same frame. (default: false)
  41171. */
  41172. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41173. }
  41174. }
  41175. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  41176. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  41177. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41178. import { Scene } from "babylonjs/scene";
  41179. import { Vector3 } from "babylonjs/Maths/math.vector";
  41180. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41181. /**
  41182. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41183. * @see http://doc.babylonjs.com/features/cameras
  41184. */
  41185. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41186. /**
  41187. * Creates a new StereoscopicArcRotateCamera
  41188. * @param name defines camera name
  41189. * @param alpha defines alpha angle (in radians)
  41190. * @param beta defines beta angle (in radians)
  41191. * @param radius defines radius
  41192. * @param target defines camera target
  41193. * @param interaxialDistance defines distance between each color axis
  41194. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41195. * @param scene defines the hosting scene
  41196. */
  41197. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41198. /**
  41199. * Gets camera class name
  41200. * @returns StereoscopicArcRotateCamera
  41201. */
  41202. getClassName(): string;
  41203. }
  41204. }
  41205. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  41206. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41207. import { Scene } from "babylonjs/scene";
  41208. import { Vector3 } from "babylonjs/Maths/math.vector";
  41209. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41210. /**
  41211. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41212. * @see http://doc.babylonjs.com/features/cameras
  41213. */
  41214. export class StereoscopicFreeCamera extends FreeCamera {
  41215. /**
  41216. * Creates a new StereoscopicFreeCamera
  41217. * @param name defines camera name
  41218. * @param position defines initial position
  41219. * @param interaxialDistance defines distance between each color axis
  41220. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41221. * @param scene defines the hosting scene
  41222. */
  41223. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41224. /**
  41225. * Gets camera class name
  41226. * @returns StereoscopicFreeCamera
  41227. */
  41228. getClassName(): string;
  41229. }
  41230. }
  41231. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  41232. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41233. import { Scene } from "babylonjs/scene";
  41234. import { Vector3 } from "babylonjs/Maths/math.vector";
  41235. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41236. /**
  41237. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41238. * @see http://doc.babylonjs.com/features/cameras
  41239. */
  41240. export class StereoscopicGamepadCamera extends GamepadCamera {
  41241. /**
  41242. * Creates a new StereoscopicGamepadCamera
  41243. * @param name defines camera name
  41244. * @param position defines initial position
  41245. * @param interaxialDistance defines distance between each color axis
  41246. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41247. * @param scene defines the hosting scene
  41248. */
  41249. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41250. /**
  41251. * Gets camera class name
  41252. * @returns StereoscopicGamepadCamera
  41253. */
  41254. getClassName(): string;
  41255. }
  41256. }
  41257. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  41258. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41259. import { Scene } from "babylonjs/scene";
  41260. import { Vector3 } from "babylonjs/Maths/math.vector";
  41261. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41262. /**
  41263. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41264. * @see http://doc.babylonjs.com/features/cameras
  41265. */
  41266. export class StereoscopicUniversalCamera extends UniversalCamera {
  41267. /**
  41268. * Creates a new StereoscopicUniversalCamera
  41269. * @param name defines camera name
  41270. * @param position defines initial position
  41271. * @param interaxialDistance defines distance between each color axis
  41272. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41273. * @param scene defines the hosting scene
  41274. */
  41275. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41276. /**
  41277. * Gets camera class name
  41278. * @returns StereoscopicUniversalCamera
  41279. */
  41280. getClassName(): string;
  41281. }
  41282. }
  41283. declare module "babylonjs/Cameras/Stereoscopic/index" {
  41284. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  41285. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  41286. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  41287. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  41288. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  41289. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  41290. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  41291. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  41292. }
  41293. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  41294. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41295. import { Scene } from "babylonjs/scene";
  41296. import { Vector3 } from "babylonjs/Maths/math.vector";
  41297. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41298. /**
  41299. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41300. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41301. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41302. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41303. */
  41304. export class VirtualJoysticksCamera extends FreeCamera {
  41305. /**
  41306. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41307. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41308. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41309. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41310. * @param name Define the name of the camera in the scene
  41311. * @param position Define the start position of the camera in the scene
  41312. * @param scene Define the scene the camera belongs to
  41313. */
  41314. constructor(name: string, position: Vector3, scene: Scene);
  41315. /**
  41316. * Gets the current object class name.
  41317. * @return the class name
  41318. */
  41319. getClassName(): string;
  41320. }
  41321. }
  41322. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  41323. import { Matrix } from "babylonjs/Maths/math.vector";
  41324. /**
  41325. * This represents all the required metrics to create a VR camera.
  41326. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41327. */
  41328. export class VRCameraMetrics {
  41329. /**
  41330. * Define the horizontal resolution off the screen.
  41331. */
  41332. hResolution: number;
  41333. /**
  41334. * Define the vertical resolution off the screen.
  41335. */
  41336. vResolution: number;
  41337. /**
  41338. * Define the horizontal screen size.
  41339. */
  41340. hScreenSize: number;
  41341. /**
  41342. * Define the vertical screen size.
  41343. */
  41344. vScreenSize: number;
  41345. /**
  41346. * Define the vertical screen center position.
  41347. */
  41348. vScreenCenter: number;
  41349. /**
  41350. * Define the distance of the eyes to the screen.
  41351. */
  41352. eyeToScreenDistance: number;
  41353. /**
  41354. * Define the distance between both lenses
  41355. */
  41356. lensSeparationDistance: number;
  41357. /**
  41358. * Define the distance between both viewer's eyes.
  41359. */
  41360. interpupillaryDistance: number;
  41361. /**
  41362. * Define the distortion factor of the VR postprocess.
  41363. * Please, touch with care.
  41364. */
  41365. distortionK: number[];
  41366. /**
  41367. * Define the chromatic aberration correction factors for the VR post process.
  41368. */
  41369. chromaAbCorrection: number[];
  41370. /**
  41371. * Define the scale factor of the post process.
  41372. * The smaller the better but the slower.
  41373. */
  41374. postProcessScaleFactor: number;
  41375. /**
  41376. * Define an offset for the lens center.
  41377. */
  41378. lensCenterOffset: number;
  41379. /**
  41380. * Define if the current vr camera should compensate the distortion of the lense or not.
  41381. */
  41382. compensateDistortion: boolean;
  41383. /**
  41384. * Defines if multiview should be enabled when rendering (Default: false)
  41385. */
  41386. multiviewEnabled: boolean;
  41387. /**
  41388. * Gets the rendering aspect ratio based on the provided resolutions.
  41389. */
  41390. readonly aspectRatio: number;
  41391. /**
  41392. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41393. */
  41394. readonly aspectRatioFov: number;
  41395. /**
  41396. * @hidden
  41397. */
  41398. readonly leftHMatrix: Matrix;
  41399. /**
  41400. * @hidden
  41401. */
  41402. readonly rightHMatrix: Matrix;
  41403. /**
  41404. * @hidden
  41405. */
  41406. readonly leftPreViewMatrix: Matrix;
  41407. /**
  41408. * @hidden
  41409. */
  41410. readonly rightPreViewMatrix: Matrix;
  41411. /**
  41412. * Get the default VRMetrics based on the most generic setup.
  41413. * @returns the default vr metrics
  41414. */
  41415. static GetDefault(): VRCameraMetrics;
  41416. }
  41417. }
  41418. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41419. /** @hidden */
  41420. export var vrDistortionCorrectionPixelShader: {
  41421. name: string;
  41422. shader: string;
  41423. };
  41424. }
  41425. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41426. import { Camera } from "babylonjs/Cameras/camera";
  41427. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41428. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41429. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41430. /**
  41431. * VRDistortionCorrectionPostProcess used for mobile VR
  41432. */
  41433. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41434. private _isRightEye;
  41435. private _distortionFactors;
  41436. private _postProcessScaleFactor;
  41437. private _lensCenterOffset;
  41438. private _scaleIn;
  41439. private _scaleFactor;
  41440. private _lensCenter;
  41441. /**
  41442. * Initializes the VRDistortionCorrectionPostProcess
  41443. * @param name The name of the effect.
  41444. * @param camera The camera to apply the render pass to.
  41445. * @param isRightEye If this is for the right eye distortion
  41446. * @param vrMetrics All the required metrics for the VR camera
  41447. */
  41448. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41449. }
  41450. }
  41451. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41452. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41453. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41454. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41455. import { Scene } from "babylonjs/scene";
  41456. import { Vector3 } from "babylonjs/Maths/math.vector";
  41457. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41458. import "babylonjs/Cameras/RigModes/vrRigMode";
  41459. /**
  41460. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41461. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41462. */
  41463. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41464. /**
  41465. * Creates a new VRDeviceOrientationArcRotateCamera
  41466. * @param name defines camera name
  41467. * @param alpha defines the camera rotation along the logitudinal axis
  41468. * @param beta defines the camera rotation along the latitudinal axis
  41469. * @param radius defines the camera distance from its target
  41470. * @param target defines the camera target
  41471. * @param scene defines the scene the camera belongs to
  41472. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41473. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41474. */
  41475. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41476. /**
  41477. * Gets camera class name
  41478. * @returns VRDeviceOrientationArcRotateCamera
  41479. */
  41480. getClassName(): string;
  41481. }
  41482. }
  41483. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41484. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41485. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41486. import { Scene } from "babylonjs/scene";
  41487. import { Vector3 } from "babylonjs/Maths/math.vector";
  41488. import "babylonjs/Cameras/RigModes/vrRigMode";
  41489. /**
  41490. * Camera used to simulate VR rendering (based on FreeCamera)
  41491. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41492. */
  41493. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41494. /**
  41495. * Creates a new VRDeviceOrientationFreeCamera
  41496. * @param name defines camera name
  41497. * @param position defines the start position of the camera
  41498. * @param scene defines the scene the camera belongs to
  41499. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41500. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41501. */
  41502. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41503. /**
  41504. * Gets camera class name
  41505. * @returns VRDeviceOrientationFreeCamera
  41506. */
  41507. getClassName(): string;
  41508. }
  41509. }
  41510. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41511. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41512. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41513. import { Scene } from "babylonjs/scene";
  41514. import { Vector3 } from "babylonjs/Maths/math.vector";
  41515. import "babylonjs/Gamepads/gamepadSceneComponent";
  41516. /**
  41517. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41518. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41519. */
  41520. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41521. /**
  41522. * Creates a new VRDeviceOrientationGamepadCamera
  41523. * @param name defines camera name
  41524. * @param position defines the start position of the camera
  41525. * @param scene defines the scene the camera belongs to
  41526. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41527. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41528. */
  41529. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41530. /**
  41531. * Gets camera class name
  41532. * @returns VRDeviceOrientationGamepadCamera
  41533. */
  41534. getClassName(): string;
  41535. }
  41536. }
  41537. declare module "babylonjs/Materials/pushMaterial" {
  41538. import { Nullable } from "babylonjs/types";
  41539. import { Scene } from "babylonjs/scene";
  41540. import { Matrix } from "babylonjs/Maths/math.vector";
  41541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41542. import { Mesh } from "babylonjs/Meshes/mesh";
  41543. import { Material } from "babylonjs/Materials/material";
  41544. import { Effect } from "babylonjs/Materials/effect";
  41545. /**
  41546. * Base class of materials working in push mode in babylon JS
  41547. * @hidden
  41548. */
  41549. export class PushMaterial extends Material {
  41550. protected _activeEffect: Effect;
  41551. protected _normalMatrix: Matrix;
  41552. /**
  41553. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41554. * This means that the material can keep using a previous shader while a new one is being compiled.
  41555. * This is mostly used when shader parallel compilation is supported (true by default)
  41556. */
  41557. allowShaderHotSwapping: boolean;
  41558. constructor(name: string, scene: Scene);
  41559. getEffect(): Effect;
  41560. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41561. /**
  41562. * Binds the given world matrix to the active effect
  41563. *
  41564. * @param world the matrix to bind
  41565. */
  41566. bindOnlyWorldMatrix(world: Matrix): void;
  41567. /**
  41568. * Binds the given normal matrix to the active effect
  41569. *
  41570. * @param normalMatrix the matrix to bind
  41571. */
  41572. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41573. bind(world: Matrix, mesh?: Mesh): void;
  41574. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41575. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41576. }
  41577. }
  41578. declare module "babylonjs/Materials/materialFlags" {
  41579. /**
  41580. * This groups all the flags used to control the materials channel.
  41581. */
  41582. export class MaterialFlags {
  41583. private static _DiffuseTextureEnabled;
  41584. /**
  41585. * Are diffuse textures enabled in the application.
  41586. */
  41587. static DiffuseTextureEnabled: boolean;
  41588. private static _AmbientTextureEnabled;
  41589. /**
  41590. * Are ambient textures enabled in the application.
  41591. */
  41592. static AmbientTextureEnabled: boolean;
  41593. private static _OpacityTextureEnabled;
  41594. /**
  41595. * Are opacity textures enabled in the application.
  41596. */
  41597. static OpacityTextureEnabled: boolean;
  41598. private static _ReflectionTextureEnabled;
  41599. /**
  41600. * Are reflection textures enabled in the application.
  41601. */
  41602. static ReflectionTextureEnabled: boolean;
  41603. private static _EmissiveTextureEnabled;
  41604. /**
  41605. * Are emissive textures enabled in the application.
  41606. */
  41607. static EmissiveTextureEnabled: boolean;
  41608. private static _SpecularTextureEnabled;
  41609. /**
  41610. * Are specular textures enabled in the application.
  41611. */
  41612. static SpecularTextureEnabled: boolean;
  41613. private static _BumpTextureEnabled;
  41614. /**
  41615. * Are bump textures enabled in the application.
  41616. */
  41617. static BumpTextureEnabled: boolean;
  41618. private static _LightmapTextureEnabled;
  41619. /**
  41620. * Are lightmap textures enabled in the application.
  41621. */
  41622. static LightmapTextureEnabled: boolean;
  41623. private static _RefractionTextureEnabled;
  41624. /**
  41625. * Are refraction textures enabled in the application.
  41626. */
  41627. static RefractionTextureEnabled: boolean;
  41628. private static _ColorGradingTextureEnabled;
  41629. /**
  41630. * Are color grading textures enabled in the application.
  41631. */
  41632. static ColorGradingTextureEnabled: boolean;
  41633. private static _FresnelEnabled;
  41634. /**
  41635. * Are fresnels enabled in the application.
  41636. */
  41637. static FresnelEnabled: boolean;
  41638. private static _ClearCoatTextureEnabled;
  41639. /**
  41640. * Are clear coat textures enabled in the application.
  41641. */
  41642. static ClearCoatTextureEnabled: boolean;
  41643. private static _ClearCoatBumpTextureEnabled;
  41644. /**
  41645. * Are clear coat bump textures enabled in the application.
  41646. */
  41647. static ClearCoatBumpTextureEnabled: boolean;
  41648. private static _ClearCoatTintTextureEnabled;
  41649. /**
  41650. * Are clear coat tint textures enabled in the application.
  41651. */
  41652. static ClearCoatTintTextureEnabled: boolean;
  41653. private static _SheenTextureEnabled;
  41654. /**
  41655. * Are sheen textures enabled in the application.
  41656. */
  41657. static SheenTextureEnabled: boolean;
  41658. private static _AnisotropicTextureEnabled;
  41659. /**
  41660. * Are anisotropic textures enabled in the application.
  41661. */
  41662. static AnisotropicTextureEnabled: boolean;
  41663. private static _ThicknessTextureEnabled;
  41664. /**
  41665. * Are thickness textures enabled in the application.
  41666. */
  41667. static ThicknessTextureEnabled: boolean;
  41668. }
  41669. }
  41670. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41671. /** @hidden */
  41672. export var defaultFragmentDeclaration: {
  41673. name: string;
  41674. shader: string;
  41675. };
  41676. }
  41677. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41678. /** @hidden */
  41679. export var defaultUboDeclaration: {
  41680. name: string;
  41681. shader: string;
  41682. };
  41683. }
  41684. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41685. /** @hidden */
  41686. export var lightFragmentDeclaration: {
  41687. name: string;
  41688. shader: string;
  41689. };
  41690. }
  41691. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41692. /** @hidden */
  41693. export var lightUboDeclaration: {
  41694. name: string;
  41695. shader: string;
  41696. };
  41697. }
  41698. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41699. /** @hidden */
  41700. export var lightsFragmentFunctions: {
  41701. name: string;
  41702. shader: string;
  41703. };
  41704. }
  41705. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41706. /** @hidden */
  41707. export var shadowsFragmentFunctions: {
  41708. name: string;
  41709. shader: string;
  41710. };
  41711. }
  41712. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41713. /** @hidden */
  41714. export var fresnelFunction: {
  41715. name: string;
  41716. shader: string;
  41717. };
  41718. }
  41719. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41720. /** @hidden */
  41721. export var reflectionFunction: {
  41722. name: string;
  41723. shader: string;
  41724. };
  41725. }
  41726. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41727. /** @hidden */
  41728. export var bumpFragmentFunctions: {
  41729. name: string;
  41730. shader: string;
  41731. };
  41732. }
  41733. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41734. /** @hidden */
  41735. export var logDepthDeclaration: {
  41736. name: string;
  41737. shader: string;
  41738. };
  41739. }
  41740. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41741. /** @hidden */
  41742. export var bumpFragment: {
  41743. name: string;
  41744. shader: string;
  41745. };
  41746. }
  41747. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41748. /** @hidden */
  41749. export var depthPrePass: {
  41750. name: string;
  41751. shader: string;
  41752. };
  41753. }
  41754. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41755. /** @hidden */
  41756. export var lightFragment: {
  41757. name: string;
  41758. shader: string;
  41759. };
  41760. }
  41761. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41762. /** @hidden */
  41763. export var logDepthFragment: {
  41764. name: string;
  41765. shader: string;
  41766. };
  41767. }
  41768. declare module "babylonjs/Shaders/default.fragment" {
  41769. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41770. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41771. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41772. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41773. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41774. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41775. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41776. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41777. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41778. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41779. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41780. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41781. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41782. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41783. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41784. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41785. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41786. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41787. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41788. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41789. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41790. /** @hidden */
  41791. export var defaultPixelShader: {
  41792. name: string;
  41793. shader: string;
  41794. };
  41795. }
  41796. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41797. /** @hidden */
  41798. export var defaultVertexDeclaration: {
  41799. name: string;
  41800. shader: string;
  41801. };
  41802. }
  41803. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41804. /** @hidden */
  41805. export var bumpVertexDeclaration: {
  41806. name: string;
  41807. shader: string;
  41808. };
  41809. }
  41810. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41811. /** @hidden */
  41812. export var bumpVertex: {
  41813. name: string;
  41814. shader: string;
  41815. };
  41816. }
  41817. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41818. /** @hidden */
  41819. export var fogVertex: {
  41820. name: string;
  41821. shader: string;
  41822. };
  41823. }
  41824. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41825. /** @hidden */
  41826. export var shadowsVertex: {
  41827. name: string;
  41828. shader: string;
  41829. };
  41830. }
  41831. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41832. /** @hidden */
  41833. export var pointCloudVertex: {
  41834. name: string;
  41835. shader: string;
  41836. };
  41837. }
  41838. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41839. /** @hidden */
  41840. export var logDepthVertex: {
  41841. name: string;
  41842. shader: string;
  41843. };
  41844. }
  41845. declare module "babylonjs/Shaders/default.vertex" {
  41846. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41847. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41848. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41849. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41850. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41851. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41852. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41853. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41854. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41855. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41856. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41857. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41858. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41859. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41860. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41861. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41862. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41863. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41864. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41865. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41866. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41867. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41868. /** @hidden */
  41869. export var defaultVertexShader: {
  41870. name: string;
  41871. shader: string;
  41872. };
  41873. }
  41874. declare module "babylonjs/Materials/standardMaterial" {
  41875. import { SmartArray } from "babylonjs/Misc/smartArray";
  41876. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41877. import { Nullable } from "babylonjs/types";
  41878. import { Scene } from "babylonjs/scene";
  41879. import { Matrix } from "babylonjs/Maths/math.vector";
  41880. import { Color3 } from "babylonjs/Maths/math.color";
  41881. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41883. import { Mesh } from "babylonjs/Meshes/mesh";
  41884. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41885. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41886. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41887. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41888. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41889. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41890. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41891. import "babylonjs/Shaders/default.fragment";
  41892. import "babylonjs/Shaders/default.vertex";
  41893. /** @hidden */
  41894. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41895. MAINUV1: boolean;
  41896. MAINUV2: boolean;
  41897. DIFFUSE: boolean;
  41898. DIFFUSEDIRECTUV: number;
  41899. AMBIENT: boolean;
  41900. AMBIENTDIRECTUV: number;
  41901. OPACITY: boolean;
  41902. OPACITYDIRECTUV: number;
  41903. OPACITYRGB: boolean;
  41904. REFLECTION: boolean;
  41905. EMISSIVE: boolean;
  41906. EMISSIVEDIRECTUV: number;
  41907. SPECULAR: boolean;
  41908. SPECULARDIRECTUV: number;
  41909. BUMP: boolean;
  41910. BUMPDIRECTUV: number;
  41911. PARALLAX: boolean;
  41912. PARALLAXOCCLUSION: boolean;
  41913. SPECULAROVERALPHA: boolean;
  41914. CLIPPLANE: boolean;
  41915. CLIPPLANE2: boolean;
  41916. CLIPPLANE3: boolean;
  41917. CLIPPLANE4: boolean;
  41918. ALPHATEST: boolean;
  41919. DEPTHPREPASS: boolean;
  41920. ALPHAFROMDIFFUSE: boolean;
  41921. POINTSIZE: boolean;
  41922. FOG: boolean;
  41923. SPECULARTERM: boolean;
  41924. DIFFUSEFRESNEL: boolean;
  41925. OPACITYFRESNEL: boolean;
  41926. REFLECTIONFRESNEL: boolean;
  41927. REFRACTIONFRESNEL: boolean;
  41928. EMISSIVEFRESNEL: boolean;
  41929. FRESNEL: boolean;
  41930. NORMAL: boolean;
  41931. UV1: boolean;
  41932. UV2: boolean;
  41933. VERTEXCOLOR: boolean;
  41934. VERTEXALPHA: boolean;
  41935. NUM_BONE_INFLUENCERS: number;
  41936. BonesPerMesh: number;
  41937. BONETEXTURE: boolean;
  41938. INSTANCES: boolean;
  41939. GLOSSINESS: boolean;
  41940. ROUGHNESS: boolean;
  41941. EMISSIVEASILLUMINATION: boolean;
  41942. LINKEMISSIVEWITHDIFFUSE: boolean;
  41943. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41944. LIGHTMAP: boolean;
  41945. LIGHTMAPDIRECTUV: number;
  41946. OBJECTSPACE_NORMALMAP: boolean;
  41947. USELIGHTMAPASSHADOWMAP: boolean;
  41948. REFLECTIONMAP_3D: boolean;
  41949. REFLECTIONMAP_SPHERICAL: boolean;
  41950. REFLECTIONMAP_PLANAR: boolean;
  41951. REFLECTIONMAP_CUBIC: boolean;
  41952. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41953. REFLECTIONMAP_PROJECTION: boolean;
  41954. REFLECTIONMAP_SKYBOX: boolean;
  41955. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41956. REFLECTIONMAP_EXPLICIT: boolean;
  41957. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41958. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41959. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41960. INVERTCUBICMAP: boolean;
  41961. LOGARITHMICDEPTH: boolean;
  41962. REFRACTION: boolean;
  41963. REFRACTIONMAP_3D: boolean;
  41964. REFLECTIONOVERALPHA: boolean;
  41965. TWOSIDEDLIGHTING: boolean;
  41966. SHADOWFLOAT: boolean;
  41967. MORPHTARGETS: boolean;
  41968. MORPHTARGETS_NORMAL: boolean;
  41969. MORPHTARGETS_TANGENT: boolean;
  41970. MORPHTARGETS_UV: boolean;
  41971. NUM_MORPH_INFLUENCERS: number;
  41972. NONUNIFORMSCALING: boolean;
  41973. PREMULTIPLYALPHA: boolean;
  41974. IMAGEPROCESSING: boolean;
  41975. VIGNETTE: boolean;
  41976. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41977. VIGNETTEBLENDMODEOPAQUE: boolean;
  41978. TONEMAPPING: boolean;
  41979. TONEMAPPING_ACES: boolean;
  41980. CONTRAST: boolean;
  41981. COLORCURVES: boolean;
  41982. COLORGRADING: boolean;
  41983. COLORGRADING3D: boolean;
  41984. SAMPLER3DGREENDEPTH: boolean;
  41985. SAMPLER3DBGRMAP: boolean;
  41986. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41987. MULTIVIEW: boolean;
  41988. /**
  41989. * If the reflection texture on this material is in linear color space
  41990. * @hidden
  41991. */
  41992. IS_REFLECTION_LINEAR: boolean;
  41993. /**
  41994. * If the refraction texture on this material is in linear color space
  41995. * @hidden
  41996. */
  41997. IS_REFRACTION_LINEAR: boolean;
  41998. EXPOSURE: boolean;
  41999. constructor();
  42000. setReflectionMode(modeToEnable: string): void;
  42001. }
  42002. /**
  42003. * This is the default material used in Babylon. It is the best trade off between quality
  42004. * and performances.
  42005. * @see http://doc.babylonjs.com/babylon101/materials
  42006. */
  42007. export class StandardMaterial extends PushMaterial {
  42008. private _diffuseTexture;
  42009. /**
  42010. * The basic texture of the material as viewed under a light.
  42011. */
  42012. diffuseTexture: Nullable<BaseTexture>;
  42013. private _ambientTexture;
  42014. /**
  42015. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  42016. */
  42017. ambientTexture: Nullable<BaseTexture>;
  42018. private _opacityTexture;
  42019. /**
  42020. * Define the transparency of the material from a texture.
  42021. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  42022. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  42023. */
  42024. opacityTexture: Nullable<BaseTexture>;
  42025. private _reflectionTexture;
  42026. /**
  42027. * Define the texture used to display the reflection.
  42028. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42029. */
  42030. reflectionTexture: Nullable<BaseTexture>;
  42031. private _emissiveTexture;
  42032. /**
  42033. * Define texture of the material as if self lit.
  42034. * This will be mixed in the final result even in the absence of light.
  42035. */
  42036. emissiveTexture: Nullable<BaseTexture>;
  42037. private _specularTexture;
  42038. /**
  42039. * Define how the color and intensity of the highlight given by the light in the material.
  42040. */
  42041. specularTexture: Nullable<BaseTexture>;
  42042. private _bumpTexture;
  42043. /**
  42044. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  42045. * 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.
  42046. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  42047. */
  42048. bumpTexture: Nullable<BaseTexture>;
  42049. private _lightmapTexture;
  42050. /**
  42051. * Complex lighting can be computationally expensive to compute at runtime.
  42052. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  42053. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  42054. */
  42055. lightmapTexture: Nullable<BaseTexture>;
  42056. private _refractionTexture;
  42057. /**
  42058. * Define the texture used to display the refraction.
  42059. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42060. */
  42061. refractionTexture: Nullable<BaseTexture>;
  42062. /**
  42063. * The color of the material lit by the environmental background lighting.
  42064. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  42065. */
  42066. ambientColor: Color3;
  42067. /**
  42068. * The basic color of the material as viewed under a light.
  42069. */
  42070. diffuseColor: Color3;
  42071. /**
  42072. * Define how the color and intensity of the highlight given by the light in the material.
  42073. */
  42074. specularColor: Color3;
  42075. /**
  42076. * Define the color of the material as if self lit.
  42077. * This will be mixed in the final result even in the absence of light.
  42078. */
  42079. emissiveColor: Color3;
  42080. /**
  42081. * Defines how sharp are the highlights in the material.
  42082. * The bigger the value the sharper giving a more glossy feeling to the result.
  42083. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  42084. */
  42085. specularPower: number;
  42086. private _useAlphaFromDiffuseTexture;
  42087. /**
  42088. * Does the transparency come from the diffuse texture alpha channel.
  42089. */
  42090. useAlphaFromDiffuseTexture: boolean;
  42091. private _useEmissiveAsIllumination;
  42092. /**
  42093. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  42094. */
  42095. useEmissiveAsIllumination: boolean;
  42096. private _linkEmissiveWithDiffuse;
  42097. /**
  42098. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  42099. * the emissive level when the final color is close to one.
  42100. */
  42101. linkEmissiveWithDiffuse: boolean;
  42102. private _useSpecularOverAlpha;
  42103. /**
  42104. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  42105. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42106. */
  42107. useSpecularOverAlpha: boolean;
  42108. private _useReflectionOverAlpha;
  42109. /**
  42110. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42111. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42112. */
  42113. useReflectionOverAlpha: boolean;
  42114. private _disableLighting;
  42115. /**
  42116. * Does lights from the scene impacts this material.
  42117. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  42118. */
  42119. disableLighting: boolean;
  42120. private _useObjectSpaceNormalMap;
  42121. /**
  42122. * Allows using an object space normal map (instead of tangent space).
  42123. */
  42124. useObjectSpaceNormalMap: boolean;
  42125. private _useParallax;
  42126. /**
  42127. * Is parallax enabled or not.
  42128. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42129. */
  42130. useParallax: boolean;
  42131. private _useParallaxOcclusion;
  42132. /**
  42133. * Is parallax occlusion enabled or not.
  42134. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  42135. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42136. */
  42137. useParallaxOcclusion: boolean;
  42138. /**
  42139. * 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.
  42140. */
  42141. parallaxScaleBias: number;
  42142. private _roughness;
  42143. /**
  42144. * Helps to define how blurry the reflections should appears in the material.
  42145. */
  42146. roughness: number;
  42147. /**
  42148. * In case of refraction, define the value of the index of refraction.
  42149. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42150. */
  42151. indexOfRefraction: number;
  42152. /**
  42153. * Invert the refraction texture alongside the y axis.
  42154. * It can be useful with procedural textures or probe for instance.
  42155. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42156. */
  42157. invertRefractionY: boolean;
  42158. /**
  42159. * Defines the alpha limits in alpha test mode.
  42160. */
  42161. alphaCutOff: number;
  42162. private _useLightmapAsShadowmap;
  42163. /**
  42164. * In case of light mapping, define whether the map contains light or shadow informations.
  42165. */
  42166. useLightmapAsShadowmap: boolean;
  42167. private _diffuseFresnelParameters;
  42168. /**
  42169. * Define the diffuse fresnel parameters of the material.
  42170. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42171. */
  42172. diffuseFresnelParameters: FresnelParameters;
  42173. private _opacityFresnelParameters;
  42174. /**
  42175. * Define the opacity fresnel parameters of the material.
  42176. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42177. */
  42178. opacityFresnelParameters: FresnelParameters;
  42179. private _reflectionFresnelParameters;
  42180. /**
  42181. * Define the reflection fresnel parameters of the material.
  42182. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42183. */
  42184. reflectionFresnelParameters: FresnelParameters;
  42185. private _refractionFresnelParameters;
  42186. /**
  42187. * Define the refraction fresnel parameters of the material.
  42188. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42189. */
  42190. refractionFresnelParameters: FresnelParameters;
  42191. private _emissiveFresnelParameters;
  42192. /**
  42193. * Define the emissive fresnel parameters of the material.
  42194. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42195. */
  42196. emissiveFresnelParameters: FresnelParameters;
  42197. private _useReflectionFresnelFromSpecular;
  42198. /**
  42199. * If true automatically deducts the fresnels values from the material specularity.
  42200. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42201. */
  42202. useReflectionFresnelFromSpecular: boolean;
  42203. private _useGlossinessFromSpecularMapAlpha;
  42204. /**
  42205. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  42206. */
  42207. useGlossinessFromSpecularMapAlpha: boolean;
  42208. private _maxSimultaneousLights;
  42209. /**
  42210. * Defines the maximum number of lights that can be used in the material
  42211. */
  42212. maxSimultaneousLights: number;
  42213. private _invertNormalMapX;
  42214. /**
  42215. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  42216. */
  42217. invertNormalMapX: boolean;
  42218. private _invertNormalMapY;
  42219. /**
  42220. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  42221. */
  42222. invertNormalMapY: boolean;
  42223. private _twoSidedLighting;
  42224. /**
  42225. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42226. */
  42227. twoSidedLighting: boolean;
  42228. /**
  42229. * Default configuration related to image processing available in the standard Material.
  42230. */
  42231. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42232. /**
  42233. * Gets the image processing configuration used either in this material.
  42234. */
  42235. /**
  42236. * Sets the Default image processing configuration used either in the this material.
  42237. *
  42238. * If sets to null, the scene one is in use.
  42239. */
  42240. imageProcessingConfiguration: ImageProcessingConfiguration;
  42241. /**
  42242. * Keep track of the image processing observer to allow dispose and replace.
  42243. */
  42244. private _imageProcessingObserver;
  42245. /**
  42246. * Attaches a new image processing configuration to the Standard Material.
  42247. * @param configuration
  42248. */
  42249. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42250. /**
  42251. * Gets wether the color curves effect is enabled.
  42252. */
  42253. /**
  42254. * Sets wether the color curves effect is enabled.
  42255. */
  42256. cameraColorCurvesEnabled: boolean;
  42257. /**
  42258. * Gets wether the color grading effect is enabled.
  42259. */
  42260. /**
  42261. * Gets wether the color grading effect is enabled.
  42262. */
  42263. cameraColorGradingEnabled: boolean;
  42264. /**
  42265. * Gets wether tonemapping is enabled or not.
  42266. */
  42267. /**
  42268. * Sets wether tonemapping is enabled or not
  42269. */
  42270. cameraToneMappingEnabled: boolean;
  42271. /**
  42272. * The camera exposure used on this material.
  42273. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42274. * This corresponds to a photographic exposure.
  42275. */
  42276. /**
  42277. * The camera exposure used on this material.
  42278. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42279. * This corresponds to a photographic exposure.
  42280. */
  42281. cameraExposure: number;
  42282. /**
  42283. * Gets The camera contrast used on this material.
  42284. */
  42285. /**
  42286. * Sets The camera contrast used on this material.
  42287. */
  42288. cameraContrast: number;
  42289. /**
  42290. * Gets the Color Grading 2D Lookup Texture.
  42291. */
  42292. /**
  42293. * Sets the Color Grading 2D Lookup Texture.
  42294. */
  42295. cameraColorGradingTexture: Nullable<BaseTexture>;
  42296. /**
  42297. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42298. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42299. * 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;
  42300. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42301. */
  42302. /**
  42303. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42304. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42305. * 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;
  42306. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42307. */
  42308. cameraColorCurves: Nullable<ColorCurves>;
  42309. /**
  42310. * Custom callback helping to override the default shader used in the material.
  42311. */
  42312. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  42313. protected _renderTargets: SmartArray<RenderTargetTexture>;
  42314. protected _worldViewProjectionMatrix: Matrix;
  42315. protected _globalAmbientColor: Color3;
  42316. protected _useLogarithmicDepth: boolean;
  42317. protected _rebuildInParallel: boolean;
  42318. /**
  42319. * Instantiates a new standard material.
  42320. * This is the default material used in Babylon. It is the best trade off between quality
  42321. * and performances.
  42322. * @see http://doc.babylonjs.com/babylon101/materials
  42323. * @param name Define the name of the material in the scene
  42324. * @param scene Define the scene the material belong to
  42325. */
  42326. constructor(name: string, scene: Scene);
  42327. /**
  42328. * Gets a boolean indicating that current material needs to register RTT
  42329. */
  42330. readonly hasRenderTargetTextures: boolean;
  42331. /**
  42332. * Gets the current class name of the material e.g. "StandardMaterial"
  42333. * Mainly use in serialization.
  42334. * @returns the class name
  42335. */
  42336. getClassName(): string;
  42337. /**
  42338. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  42339. * You can try switching to logarithmic depth.
  42340. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  42341. */
  42342. useLogarithmicDepth: boolean;
  42343. /**
  42344. * Specifies if the material will require alpha blending
  42345. * @returns a boolean specifying if alpha blending is needed
  42346. */
  42347. needAlphaBlending(): boolean;
  42348. /**
  42349. * Specifies if this material should be rendered in alpha test mode
  42350. * @returns a boolean specifying if an alpha test is needed.
  42351. */
  42352. needAlphaTesting(): boolean;
  42353. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  42354. /**
  42355. * Get the texture used for alpha test purpose.
  42356. * @returns the diffuse texture in case of the standard material.
  42357. */
  42358. getAlphaTestTexture(): Nullable<BaseTexture>;
  42359. /**
  42360. * Get if the submesh is ready to be used and all its information available.
  42361. * Child classes can use it to update shaders
  42362. * @param mesh defines the mesh to check
  42363. * @param subMesh defines which submesh to check
  42364. * @param useInstances specifies that instances should be used
  42365. * @returns a boolean indicating that the submesh is ready or not
  42366. */
  42367. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42368. /**
  42369. * Builds the material UBO layouts.
  42370. * Used internally during the effect preparation.
  42371. */
  42372. buildUniformLayout(): void;
  42373. /**
  42374. * Unbinds the material from the mesh
  42375. */
  42376. unbind(): void;
  42377. /**
  42378. * Binds the submesh to this material by preparing the effect and shader to draw
  42379. * @param world defines the world transformation matrix
  42380. * @param mesh defines the mesh containing the submesh
  42381. * @param subMesh defines the submesh to bind the material to
  42382. */
  42383. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42384. /**
  42385. * Get the list of animatables in the material.
  42386. * @returns the list of animatables object used in the material
  42387. */
  42388. getAnimatables(): IAnimatable[];
  42389. /**
  42390. * Gets the active textures from the material
  42391. * @returns an array of textures
  42392. */
  42393. getActiveTextures(): BaseTexture[];
  42394. /**
  42395. * Specifies if the material uses a texture
  42396. * @param texture defines the texture to check against the material
  42397. * @returns a boolean specifying if the material uses the texture
  42398. */
  42399. hasTexture(texture: BaseTexture): boolean;
  42400. /**
  42401. * Disposes the material
  42402. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42403. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42404. */
  42405. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42406. /**
  42407. * Makes a duplicate of the material, and gives it a new name
  42408. * @param name defines the new name for the duplicated material
  42409. * @returns the cloned material
  42410. */
  42411. clone(name: string): StandardMaterial;
  42412. /**
  42413. * Serializes this material in a JSON representation
  42414. * @returns the serialized material object
  42415. */
  42416. serialize(): any;
  42417. /**
  42418. * Creates a standard material from parsed material data
  42419. * @param source defines the JSON representation of the material
  42420. * @param scene defines the hosting scene
  42421. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42422. * @returns a new standard material
  42423. */
  42424. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42425. /**
  42426. * Are diffuse textures enabled in the application.
  42427. */
  42428. static DiffuseTextureEnabled: boolean;
  42429. /**
  42430. * Are ambient textures enabled in the application.
  42431. */
  42432. static AmbientTextureEnabled: boolean;
  42433. /**
  42434. * Are opacity textures enabled in the application.
  42435. */
  42436. static OpacityTextureEnabled: boolean;
  42437. /**
  42438. * Are reflection textures enabled in the application.
  42439. */
  42440. static ReflectionTextureEnabled: boolean;
  42441. /**
  42442. * Are emissive textures enabled in the application.
  42443. */
  42444. static EmissiveTextureEnabled: boolean;
  42445. /**
  42446. * Are specular textures enabled in the application.
  42447. */
  42448. static SpecularTextureEnabled: boolean;
  42449. /**
  42450. * Are bump textures enabled in the application.
  42451. */
  42452. static BumpTextureEnabled: boolean;
  42453. /**
  42454. * Are lightmap textures enabled in the application.
  42455. */
  42456. static LightmapTextureEnabled: boolean;
  42457. /**
  42458. * Are refraction textures enabled in the application.
  42459. */
  42460. static RefractionTextureEnabled: boolean;
  42461. /**
  42462. * Are color grading textures enabled in the application.
  42463. */
  42464. static ColorGradingTextureEnabled: boolean;
  42465. /**
  42466. * Are fresnels enabled in the application.
  42467. */
  42468. static FresnelEnabled: boolean;
  42469. }
  42470. }
  42471. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42472. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42473. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42474. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42475. /** @hidden */
  42476. export var imageProcessingPixelShader: {
  42477. name: string;
  42478. shader: string;
  42479. };
  42480. }
  42481. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42482. import { Nullable } from "babylonjs/types";
  42483. import { Color4 } from "babylonjs/Maths/math.color";
  42484. import { Camera } from "babylonjs/Cameras/camera";
  42485. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42486. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42487. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42488. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42489. import { Engine } from "babylonjs/Engines/engine";
  42490. import "babylonjs/Shaders/imageProcessing.fragment";
  42491. import "babylonjs/Shaders/postprocess.vertex";
  42492. /**
  42493. * ImageProcessingPostProcess
  42494. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42495. */
  42496. export class ImageProcessingPostProcess extends PostProcess {
  42497. /**
  42498. * Default configuration related to image processing available in the PBR Material.
  42499. */
  42500. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42501. /**
  42502. * Gets the image processing configuration used either in this material.
  42503. */
  42504. /**
  42505. * Sets the Default image processing configuration used either in the this material.
  42506. *
  42507. * If sets to null, the scene one is in use.
  42508. */
  42509. imageProcessingConfiguration: ImageProcessingConfiguration;
  42510. /**
  42511. * Keep track of the image processing observer to allow dispose and replace.
  42512. */
  42513. private _imageProcessingObserver;
  42514. /**
  42515. * Attaches a new image processing configuration to the PBR Material.
  42516. * @param configuration
  42517. */
  42518. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42519. /**
  42520. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42521. */
  42522. /**
  42523. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42524. */
  42525. colorCurves: Nullable<ColorCurves>;
  42526. /**
  42527. * Gets wether the color curves effect is enabled.
  42528. */
  42529. /**
  42530. * Sets wether the color curves effect is enabled.
  42531. */
  42532. colorCurvesEnabled: boolean;
  42533. /**
  42534. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42535. */
  42536. /**
  42537. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42538. */
  42539. colorGradingTexture: Nullable<BaseTexture>;
  42540. /**
  42541. * Gets wether the color grading effect is enabled.
  42542. */
  42543. /**
  42544. * Gets wether the color grading effect is enabled.
  42545. */
  42546. colorGradingEnabled: boolean;
  42547. /**
  42548. * Gets exposure used in the effect.
  42549. */
  42550. /**
  42551. * Sets exposure used in the effect.
  42552. */
  42553. exposure: number;
  42554. /**
  42555. * Gets wether tonemapping is enabled or not.
  42556. */
  42557. /**
  42558. * Sets wether tonemapping is enabled or not
  42559. */
  42560. toneMappingEnabled: boolean;
  42561. /**
  42562. * Gets the type of tone mapping effect.
  42563. */
  42564. /**
  42565. * Sets the type of tone mapping effect.
  42566. */
  42567. toneMappingType: number;
  42568. /**
  42569. * Gets contrast used in the effect.
  42570. */
  42571. /**
  42572. * Sets contrast used in the effect.
  42573. */
  42574. contrast: number;
  42575. /**
  42576. * Gets Vignette stretch size.
  42577. */
  42578. /**
  42579. * Sets Vignette stretch size.
  42580. */
  42581. vignetteStretch: number;
  42582. /**
  42583. * Gets Vignette centre X Offset.
  42584. */
  42585. /**
  42586. * Sets Vignette centre X Offset.
  42587. */
  42588. vignetteCentreX: number;
  42589. /**
  42590. * Gets Vignette centre Y Offset.
  42591. */
  42592. /**
  42593. * Sets Vignette centre Y Offset.
  42594. */
  42595. vignetteCentreY: number;
  42596. /**
  42597. * Gets Vignette weight or intensity of the vignette effect.
  42598. */
  42599. /**
  42600. * Sets Vignette weight or intensity of the vignette effect.
  42601. */
  42602. vignetteWeight: number;
  42603. /**
  42604. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42605. * if vignetteEnabled is set to true.
  42606. */
  42607. /**
  42608. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42609. * if vignetteEnabled is set to true.
  42610. */
  42611. vignetteColor: Color4;
  42612. /**
  42613. * Gets Camera field of view used by the Vignette effect.
  42614. */
  42615. /**
  42616. * Sets Camera field of view used by the Vignette effect.
  42617. */
  42618. vignetteCameraFov: number;
  42619. /**
  42620. * Gets the vignette blend mode allowing different kind of effect.
  42621. */
  42622. /**
  42623. * Sets the vignette blend mode allowing different kind of effect.
  42624. */
  42625. vignetteBlendMode: number;
  42626. /**
  42627. * Gets wether the vignette effect is enabled.
  42628. */
  42629. /**
  42630. * Sets wether the vignette effect is enabled.
  42631. */
  42632. vignetteEnabled: boolean;
  42633. private _fromLinearSpace;
  42634. /**
  42635. * Gets wether the input of the processing is in Gamma or Linear Space.
  42636. */
  42637. /**
  42638. * Sets wether the input of the processing is in Gamma or Linear Space.
  42639. */
  42640. fromLinearSpace: boolean;
  42641. /**
  42642. * Defines cache preventing GC.
  42643. */
  42644. private _defines;
  42645. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42646. /**
  42647. * "ImageProcessingPostProcess"
  42648. * @returns "ImageProcessingPostProcess"
  42649. */
  42650. getClassName(): string;
  42651. protected _updateParameters(): void;
  42652. dispose(camera?: Camera): void;
  42653. }
  42654. }
  42655. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42656. import { Scene } from "babylonjs/scene";
  42657. import { Color3 } from "babylonjs/Maths/math.color";
  42658. import { Mesh } from "babylonjs/Meshes/mesh";
  42659. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42660. import { Nullable } from "babylonjs/types";
  42661. /**
  42662. * Class containing static functions to help procedurally build meshes
  42663. */
  42664. export class GroundBuilder {
  42665. /**
  42666. * Creates a ground mesh
  42667. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42668. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42670. * @param name defines the name of the mesh
  42671. * @param options defines the options used to create the mesh
  42672. * @param scene defines the hosting scene
  42673. * @returns the ground mesh
  42674. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42675. */
  42676. static CreateGround(name: string, options: {
  42677. width?: number;
  42678. height?: number;
  42679. subdivisions?: number;
  42680. subdivisionsX?: number;
  42681. subdivisionsY?: number;
  42682. updatable?: boolean;
  42683. }, scene: any): Mesh;
  42684. /**
  42685. * Creates a tiled ground mesh
  42686. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42687. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42688. * * 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
  42689. * * 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
  42690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42691. * @param name defines the name of the mesh
  42692. * @param options defines the options used to create the mesh
  42693. * @param scene defines the hosting scene
  42694. * @returns the tiled ground mesh
  42695. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42696. */
  42697. static CreateTiledGround(name: string, options: {
  42698. xmin: number;
  42699. zmin: number;
  42700. xmax: number;
  42701. zmax: number;
  42702. subdivisions?: {
  42703. w: number;
  42704. h: number;
  42705. };
  42706. precision?: {
  42707. w: number;
  42708. h: number;
  42709. };
  42710. updatable?: boolean;
  42711. }, scene?: Nullable<Scene>): Mesh;
  42712. /**
  42713. * Creates a ground mesh from a height map
  42714. * * The parameter `url` sets the URL of the height map image resource.
  42715. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42716. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42717. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42718. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42719. * * 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.
  42720. * * 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).
  42721. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42723. * @param name defines the name of the mesh
  42724. * @param url defines the url to the height map
  42725. * @param options defines the options used to create the mesh
  42726. * @param scene defines the hosting scene
  42727. * @returns the ground mesh
  42728. * @see https://doc.babylonjs.com/babylon101/height_map
  42729. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42730. */
  42731. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42732. width?: number;
  42733. height?: number;
  42734. subdivisions?: number;
  42735. minHeight?: number;
  42736. maxHeight?: number;
  42737. colorFilter?: Color3;
  42738. alphaFilter?: number;
  42739. updatable?: boolean;
  42740. onReady?: (mesh: GroundMesh) => void;
  42741. }, scene?: Nullable<Scene>): GroundMesh;
  42742. }
  42743. }
  42744. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42745. import { Vector4 } from "babylonjs/Maths/math.vector";
  42746. import { Mesh } from "babylonjs/Meshes/mesh";
  42747. /**
  42748. * Class containing static functions to help procedurally build meshes
  42749. */
  42750. export class TorusBuilder {
  42751. /**
  42752. * Creates a torus mesh
  42753. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42754. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42755. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42757. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42759. * @param name defines the name of the mesh
  42760. * @param options defines the options used to create the mesh
  42761. * @param scene defines the hosting scene
  42762. * @returns the torus mesh
  42763. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42764. */
  42765. static CreateTorus(name: string, options: {
  42766. diameter?: number;
  42767. thickness?: number;
  42768. tessellation?: number;
  42769. updatable?: boolean;
  42770. sideOrientation?: number;
  42771. frontUVs?: Vector4;
  42772. backUVs?: Vector4;
  42773. }, scene: any): Mesh;
  42774. }
  42775. }
  42776. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42777. import { Vector4 } from "babylonjs/Maths/math.vector";
  42778. import { Color4 } from "babylonjs/Maths/math.color";
  42779. import { Mesh } from "babylonjs/Meshes/mesh";
  42780. /**
  42781. * Class containing static functions to help procedurally build meshes
  42782. */
  42783. export class CylinderBuilder {
  42784. /**
  42785. * Creates a cylinder or a cone mesh
  42786. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42787. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42788. * * 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.
  42789. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42790. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42791. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42792. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42793. * * 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).
  42794. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42795. * * 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).
  42796. * * 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
  42797. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42798. * * 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
  42799. * * 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.
  42800. * * If `enclose` is false, a ring surface is one element.
  42801. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42802. * * 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
  42803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42804. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42806. * @param name defines the name of the mesh
  42807. * @param options defines the options used to create the mesh
  42808. * @param scene defines the hosting scene
  42809. * @returns the cylinder mesh
  42810. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42811. */
  42812. static CreateCylinder(name: string, options: {
  42813. height?: number;
  42814. diameterTop?: number;
  42815. diameterBottom?: number;
  42816. diameter?: number;
  42817. tessellation?: number;
  42818. subdivisions?: number;
  42819. arc?: number;
  42820. faceColors?: Color4[];
  42821. faceUV?: Vector4[];
  42822. updatable?: boolean;
  42823. hasRings?: boolean;
  42824. enclose?: boolean;
  42825. cap?: number;
  42826. sideOrientation?: number;
  42827. frontUVs?: Vector4;
  42828. backUVs?: Vector4;
  42829. }, scene: any): Mesh;
  42830. }
  42831. }
  42832. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42833. import { Observable } from "babylonjs/Misc/observable";
  42834. import { Nullable } from "babylonjs/types";
  42835. import { Camera } from "babylonjs/Cameras/camera";
  42836. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42837. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42838. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42839. import { Scene } from "babylonjs/scene";
  42840. import { Vector3 } from "babylonjs/Maths/math.vector";
  42841. import { Color3 } from "babylonjs/Maths/math.color";
  42842. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42844. import { Mesh } from "babylonjs/Meshes/mesh";
  42845. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42846. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42847. import "babylonjs/Meshes/Builders/groundBuilder";
  42848. import "babylonjs/Meshes/Builders/torusBuilder";
  42849. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42850. import "babylonjs/Gamepads/gamepadSceneComponent";
  42851. import "babylonjs/Animations/animatable";
  42852. /**
  42853. * Options to modify the vr teleportation behavior.
  42854. */
  42855. export interface VRTeleportationOptions {
  42856. /**
  42857. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42858. */
  42859. floorMeshName?: string;
  42860. /**
  42861. * A list of meshes to be used as the teleportation floor. (default: empty)
  42862. */
  42863. floorMeshes?: Mesh[];
  42864. }
  42865. /**
  42866. * Options to modify the vr experience helper's behavior.
  42867. */
  42868. export interface VRExperienceHelperOptions extends WebVROptions {
  42869. /**
  42870. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42871. */
  42872. createDeviceOrientationCamera?: boolean;
  42873. /**
  42874. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42875. */
  42876. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42877. /**
  42878. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42879. */
  42880. laserToggle?: boolean;
  42881. /**
  42882. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42883. */
  42884. floorMeshes?: Mesh[];
  42885. /**
  42886. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42887. */
  42888. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42889. }
  42890. /**
  42891. * Event containing information after VR has been entered
  42892. */
  42893. export class OnAfterEnteringVRObservableEvent {
  42894. /**
  42895. * If entering vr was successful
  42896. */
  42897. success: boolean;
  42898. }
  42899. /**
  42900. * Helps to quickly add VR support to an existing scene.
  42901. * See http://doc.babylonjs.com/how_to/webvr_helper
  42902. */
  42903. export class VRExperienceHelper {
  42904. /** Options to modify the vr experience helper's behavior. */
  42905. webVROptions: VRExperienceHelperOptions;
  42906. private _scene;
  42907. private _position;
  42908. private _btnVR;
  42909. private _btnVRDisplayed;
  42910. private _webVRsupported;
  42911. private _webVRready;
  42912. private _webVRrequesting;
  42913. private _webVRpresenting;
  42914. private _hasEnteredVR;
  42915. private _fullscreenVRpresenting;
  42916. private _inputElement;
  42917. private _webVRCamera;
  42918. private _vrDeviceOrientationCamera;
  42919. private _deviceOrientationCamera;
  42920. private _existingCamera;
  42921. private _onKeyDown;
  42922. private _onVrDisplayPresentChange;
  42923. private _onVRDisplayChanged;
  42924. private _onVRRequestPresentStart;
  42925. private _onVRRequestPresentComplete;
  42926. /**
  42927. * 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)
  42928. */
  42929. enableGazeEvenWhenNoPointerLock: boolean;
  42930. /**
  42931. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42932. */
  42933. exitVROnDoubleTap: boolean;
  42934. /**
  42935. * Observable raised right before entering VR.
  42936. */
  42937. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42938. /**
  42939. * Observable raised when entering VR has completed.
  42940. */
  42941. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42942. /**
  42943. * Observable raised when exiting VR.
  42944. */
  42945. onExitingVRObservable: Observable<VRExperienceHelper>;
  42946. /**
  42947. * Observable raised when controller mesh is loaded.
  42948. */
  42949. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42950. /** Return this.onEnteringVRObservable
  42951. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42952. */
  42953. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42954. /** Return this.onExitingVRObservable
  42955. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42956. */
  42957. readonly onExitingVR: Observable<VRExperienceHelper>;
  42958. /** Return this.onControllerMeshLoadedObservable
  42959. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42960. */
  42961. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42962. private _rayLength;
  42963. private _useCustomVRButton;
  42964. private _teleportationRequested;
  42965. private _teleportActive;
  42966. private _floorMeshName;
  42967. private _floorMeshesCollection;
  42968. private _rotationAllowed;
  42969. private _teleportBackwardsVector;
  42970. private _teleportationTarget;
  42971. private _isDefaultTeleportationTarget;
  42972. private _postProcessMove;
  42973. private _teleportationFillColor;
  42974. private _teleportationBorderColor;
  42975. private _rotationAngle;
  42976. private _haloCenter;
  42977. private _cameraGazer;
  42978. private _padSensibilityUp;
  42979. private _padSensibilityDown;
  42980. private _leftController;
  42981. private _rightController;
  42982. /**
  42983. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42984. */
  42985. onNewMeshSelected: Observable<AbstractMesh>;
  42986. /**
  42987. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42988. * This observable will provide the mesh and the controller used to select the mesh
  42989. */
  42990. onMeshSelectedWithController: Observable<{
  42991. mesh: AbstractMesh;
  42992. controller: WebVRController;
  42993. }>;
  42994. /**
  42995. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42996. */
  42997. onNewMeshPicked: Observable<PickingInfo>;
  42998. private _circleEase;
  42999. /**
  43000. * Observable raised before camera teleportation
  43001. */
  43002. onBeforeCameraTeleport: Observable<Vector3>;
  43003. /**
  43004. * Observable raised after camera teleportation
  43005. */
  43006. onAfterCameraTeleport: Observable<Vector3>;
  43007. /**
  43008. * Observable raised when current selected mesh gets unselected
  43009. */
  43010. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43011. private _raySelectionPredicate;
  43012. /**
  43013. * To be optionaly changed by user to define custom ray selection
  43014. */
  43015. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43016. /**
  43017. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43018. */
  43019. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43020. /**
  43021. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43022. */
  43023. teleportationEnabled: boolean;
  43024. private _defaultHeight;
  43025. private _teleportationInitialized;
  43026. private _interactionsEnabled;
  43027. private _interactionsRequested;
  43028. private _displayGaze;
  43029. private _displayLaserPointer;
  43030. /**
  43031. * The mesh used to display where the user is going to teleport.
  43032. */
  43033. /**
  43034. * Sets the mesh to be used to display where the user is going to teleport.
  43035. */
  43036. teleportationTarget: Mesh;
  43037. /**
  43038. * 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
  43039. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43040. * See http://doc.babylonjs.com/resources/baking_transformations
  43041. */
  43042. gazeTrackerMesh: Mesh;
  43043. /**
  43044. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43045. */
  43046. updateGazeTrackerScale: boolean;
  43047. /**
  43048. * If the gaze trackers color should be updated when selecting meshes
  43049. */
  43050. updateGazeTrackerColor: boolean;
  43051. /**
  43052. * If the controller laser color should be updated when selecting meshes
  43053. */
  43054. updateControllerLaserColor: boolean;
  43055. /**
  43056. * The gaze tracking mesh corresponding to the left controller
  43057. */
  43058. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  43059. /**
  43060. * The gaze tracking mesh corresponding to the right controller
  43061. */
  43062. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  43063. /**
  43064. * If the ray of the gaze should be displayed.
  43065. */
  43066. /**
  43067. * Sets if the ray of the gaze should be displayed.
  43068. */
  43069. displayGaze: boolean;
  43070. /**
  43071. * If the ray of the LaserPointer should be displayed.
  43072. */
  43073. /**
  43074. * Sets if the ray of the LaserPointer should be displayed.
  43075. */
  43076. displayLaserPointer: boolean;
  43077. /**
  43078. * The deviceOrientationCamera used as the camera when not in VR.
  43079. */
  43080. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  43081. /**
  43082. * Based on the current WebVR support, returns the current VR camera used.
  43083. */
  43084. readonly currentVRCamera: Nullable<Camera>;
  43085. /**
  43086. * The webVRCamera which is used when in VR.
  43087. */
  43088. readonly webVRCamera: WebVRFreeCamera;
  43089. /**
  43090. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43091. */
  43092. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  43093. /**
  43094. * The html button that is used to trigger entering into VR.
  43095. */
  43096. readonly vrButton: Nullable<HTMLButtonElement>;
  43097. private readonly _teleportationRequestInitiated;
  43098. /**
  43099. * Defines wether or not Pointer lock should be requested when switching to
  43100. * full screen.
  43101. */
  43102. requestPointerLockOnFullScreen: boolean;
  43103. /**
  43104. * Instantiates a VRExperienceHelper.
  43105. * Helps to quickly add VR support to an existing scene.
  43106. * @param scene The scene the VRExperienceHelper belongs to.
  43107. * @param webVROptions Options to modify the vr experience helper's behavior.
  43108. */
  43109. constructor(scene: Scene,
  43110. /** Options to modify the vr experience helper's behavior. */
  43111. webVROptions?: VRExperienceHelperOptions);
  43112. private _onDefaultMeshLoaded;
  43113. private _onResize;
  43114. private _onFullscreenChange;
  43115. /**
  43116. * Gets a value indicating if we are currently in VR mode.
  43117. */
  43118. readonly isInVRMode: boolean;
  43119. private onVrDisplayPresentChange;
  43120. private onVRDisplayChanged;
  43121. private moveButtonToBottomRight;
  43122. private displayVRButton;
  43123. private updateButtonVisibility;
  43124. private _cachedAngularSensibility;
  43125. /**
  43126. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  43127. * Otherwise, will use the fullscreen API.
  43128. */
  43129. enterVR(): void;
  43130. /**
  43131. * Attempt to exit VR, or fullscreen.
  43132. */
  43133. exitVR(): void;
  43134. /**
  43135. * The position of the vr experience helper.
  43136. */
  43137. /**
  43138. * Sets the position of the vr experience helper.
  43139. */
  43140. position: Vector3;
  43141. /**
  43142. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43143. */
  43144. enableInteractions(): void;
  43145. private readonly _noControllerIsActive;
  43146. private beforeRender;
  43147. private _isTeleportationFloor;
  43148. /**
  43149. * Adds a floor mesh to be used for teleportation.
  43150. * @param floorMesh the mesh to be used for teleportation.
  43151. */
  43152. addFloorMesh(floorMesh: Mesh): void;
  43153. /**
  43154. * Removes a floor mesh from being used for teleportation.
  43155. * @param floorMesh the mesh to be removed.
  43156. */
  43157. removeFloorMesh(floorMesh: Mesh): void;
  43158. /**
  43159. * Enables interactions and teleportation using the VR controllers and gaze.
  43160. * @param vrTeleportationOptions options to modify teleportation behavior.
  43161. */
  43162. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43163. private _onNewGamepadConnected;
  43164. private _tryEnableInteractionOnController;
  43165. private _onNewGamepadDisconnected;
  43166. private _enableInteractionOnController;
  43167. private _checkTeleportWithRay;
  43168. private _checkRotate;
  43169. private _checkTeleportBackwards;
  43170. private _enableTeleportationOnController;
  43171. private _createTeleportationCircles;
  43172. private _displayTeleportationTarget;
  43173. private _hideTeleportationTarget;
  43174. private _rotateCamera;
  43175. private _moveTeleportationSelectorTo;
  43176. private _workingVector;
  43177. private _workingQuaternion;
  43178. private _workingMatrix;
  43179. /**
  43180. * Teleports the users feet to the desired location
  43181. * @param location The location where the user's feet should be placed
  43182. */
  43183. teleportCamera(location: Vector3): void;
  43184. private _convertNormalToDirectionOfRay;
  43185. private _castRayAndSelectObject;
  43186. private _notifySelectedMeshUnselected;
  43187. /**
  43188. * Sets the color of the laser ray from the vr controllers.
  43189. * @param color new color for the ray.
  43190. */
  43191. changeLaserColor(color: Color3): void;
  43192. /**
  43193. * Sets the color of the ray from the vr headsets gaze.
  43194. * @param color new color for the ray.
  43195. */
  43196. changeGazeColor(color: Color3): void;
  43197. /**
  43198. * Exits VR and disposes of the vr experience helper
  43199. */
  43200. dispose(): void;
  43201. /**
  43202. * Gets the name of the VRExperienceHelper class
  43203. * @returns "VRExperienceHelper"
  43204. */
  43205. getClassName(): string;
  43206. }
  43207. }
  43208. declare module "babylonjs/Cameras/VR/index" {
  43209. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  43210. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  43211. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43212. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  43213. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  43214. export * from "babylonjs/Cameras/VR/webVRCamera";
  43215. }
  43216. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43217. import { Nullable } from "babylonjs/types";
  43218. import { IDisposable } from "babylonjs/scene";
  43219. /**
  43220. * States of the webXR experience
  43221. */
  43222. export enum WebXRState {
  43223. /**
  43224. * Transitioning to being in XR mode
  43225. */
  43226. ENTERING_XR = 0,
  43227. /**
  43228. * Transitioning to non XR mode
  43229. */
  43230. EXITING_XR = 1,
  43231. /**
  43232. * In XR mode and presenting
  43233. */
  43234. IN_XR = 2,
  43235. /**
  43236. * Not entered XR mode
  43237. */
  43238. NOT_IN_XR = 3
  43239. }
  43240. /**
  43241. * Abstraction of the XR render target
  43242. */
  43243. export interface WebXRRenderTarget extends IDisposable {
  43244. /**
  43245. * xrpresent context of the canvas which can be used to display/mirror xr content
  43246. */
  43247. canvasContext: WebGLRenderingContext;
  43248. /**
  43249. * xr layer for the canvas
  43250. */
  43251. xrLayer: Nullable<XRWebGLLayer>;
  43252. /**
  43253. * Initializes the xr layer for the session
  43254. * @param xrSession xr session
  43255. * @returns a promise that will resolve once the XR Layer has been created
  43256. */
  43257. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43258. }
  43259. }
  43260. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43261. import { Nullable } from "babylonjs/types";
  43262. import { Observable } from "babylonjs/Misc/observable";
  43263. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43264. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43265. /**
  43266. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43267. */
  43268. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43269. private _engine;
  43270. private _canvas;
  43271. /**
  43272. * xrpresent context of the canvas which can be used to display/mirror xr content
  43273. */
  43274. canvasContext: WebGLRenderingContext;
  43275. /**
  43276. * xr layer for the canvas
  43277. */
  43278. xrLayer: Nullable<XRWebGLLayer>;
  43279. /**
  43280. * Initializes the xr layer for the session
  43281. * @param xrSession xr session
  43282. * @returns a promise that will resolve once the XR Layer has been created
  43283. */
  43284. initializeXRLayerAsync(xrSession: any): any;
  43285. /**
  43286. * Initializes the canvas to be added/removed upon entering/exiting xr
  43287. * @param engine the Babylon engine
  43288. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43289. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43290. */
  43291. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>);
  43292. /**
  43293. * Disposes of the object
  43294. */
  43295. dispose(): void;
  43296. private _setManagedOutputCanvas;
  43297. private _addCanvas;
  43298. private _removeCanvas;
  43299. }
  43300. }
  43301. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43302. import { Observable } from "babylonjs/Misc/observable";
  43303. import { Nullable } from "babylonjs/types";
  43304. import { IDisposable, Scene } from "babylonjs/scene";
  43305. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43306. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43307. /**
  43308. * Manages an XRSession to work with Babylon's engine
  43309. * @see https://doc.babylonjs.com/how_to/webxr
  43310. */
  43311. export class WebXRSessionManager implements IDisposable {
  43312. private scene;
  43313. /**
  43314. * Fires every time a new xrFrame arrives which can be used to update the camera
  43315. */
  43316. onXRFrameObservable: Observable<any>;
  43317. /**
  43318. * Fires when the xr session is ended either by the device or manually done
  43319. */
  43320. onXRSessionEnded: Observable<any>;
  43321. /**
  43322. * Underlying xr session
  43323. */
  43324. session: XRSession;
  43325. /**
  43326. * Type of reference space used when creating the session
  43327. */
  43328. referenceSpace: XRReferenceSpace;
  43329. /**
  43330. * Current XR frame
  43331. */
  43332. currentFrame: Nullable<XRFrame>;
  43333. private _xrNavigator;
  43334. private baseLayer;
  43335. private _rttProvider;
  43336. private _sessionEnded;
  43337. /**
  43338. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43339. * @param scene The scene which the session should be created for
  43340. */
  43341. constructor(scene: Scene);
  43342. /**
  43343. * Initializes the manager
  43344. * After initialization enterXR can be called to start an XR session
  43345. * @returns Promise which resolves after it is initialized
  43346. */
  43347. initializeAsync(): Promise<void>;
  43348. /**
  43349. * Initializes an xr session
  43350. * @param xrSessionMode mode to initialize
  43351. * @param optionalFeatures defines optional values to pass to the session builder
  43352. * @returns a promise which will resolve once the session has been initialized
  43353. */
  43354. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  43355. /**
  43356. * Sets the reference space on the xr session
  43357. * @param referenceSpace space to set
  43358. * @returns a promise that will resolve once the reference space has been set
  43359. */
  43360. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43361. /**
  43362. * Updates the render state of the session
  43363. * @param state state to set
  43364. * @returns a promise that resolves once the render state has been updated
  43365. */
  43366. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43367. /**
  43368. * Starts rendering to the xr layer
  43369. * @returns a promise that will resolve once rendering has started
  43370. */
  43371. startRenderingToXRAsync(): Promise<void>;
  43372. /**
  43373. * Gets the correct render target texture to be rendered this frame for this eye
  43374. * @param eye the eye for which to get the render target
  43375. * @returns the render target for the specified eye
  43376. */
  43377. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43378. /**
  43379. * Stops the xrSession and restores the renderloop
  43380. * @returns Promise which resolves after it exits XR
  43381. */
  43382. exitXRAsync(): Promise<void>;
  43383. /**
  43384. * Checks if a session would be supported for the creation options specified
  43385. * @param sessionMode session mode to check if supported eg. immersive-vr
  43386. * @returns true if supported
  43387. */
  43388. supportsSessionAsync(sessionMode: XRSessionMode): any;
  43389. /**
  43390. * Creates a WebXRRenderTarget object for the XR session
  43391. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43392. * @returns a WebXR render target to which the session can render
  43393. */
  43394. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  43395. /**
  43396. * @hidden
  43397. * Converts the render layer of xrSession to a render target
  43398. * @param session session to create render target for
  43399. * @param scene scene the new render target should be created for
  43400. */
  43401. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43402. /**
  43403. * Disposes of the session manager
  43404. */
  43405. dispose(): void;
  43406. }
  43407. }
  43408. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43409. import { Scene } from "babylonjs/scene";
  43410. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43411. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43412. /**
  43413. * WebXR Camera which holds the views for the xrSession
  43414. * @see https://doc.babylonjs.com/how_to/webxr
  43415. */
  43416. export class WebXRCamera extends FreeCamera {
  43417. private static _TmpMatrix;
  43418. /**
  43419. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43420. * @param name the name of the camera
  43421. * @param scene the scene to add the camera to
  43422. */
  43423. constructor(name: string, scene: Scene);
  43424. private _updateNumberOfRigCameras;
  43425. /** @hidden */
  43426. _updateForDualEyeDebugging(): void;
  43427. /**
  43428. * Updates the cameras position from the current pose information of the XR session
  43429. * @param xrSessionManager the session containing pose information
  43430. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43431. */
  43432. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43433. }
  43434. }
  43435. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43436. import { Observable } from "babylonjs/Misc/observable";
  43437. import { IDisposable, Scene } from "babylonjs/scene";
  43438. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43440. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43441. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43442. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43443. /**
  43444. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43445. * @see https://doc.babylonjs.com/how_to/webxr
  43446. */
  43447. export class WebXRExperienceHelper implements IDisposable {
  43448. private scene;
  43449. /**
  43450. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  43451. */
  43452. container: AbstractMesh;
  43453. /**
  43454. * Camera used to render xr content
  43455. */
  43456. camera: WebXRCamera;
  43457. /**
  43458. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43459. */
  43460. state: WebXRState;
  43461. private _setState;
  43462. private static _TmpVector;
  43463. /**
  43464. * Fires when the state of the experience helper has changed
  43465. */
  43466. onStateChangedObservable: Observable<WebXRState>;
  43467. /** Session manager used to keep track of xr session */
  43468. sessionManager: WebXRSessionManager;
  43469. private _nonVRCamera;
  43470. private _originalSceneAutoClear;
  43471. private _supported;
  43472. /**
  43473. * Creates the experience helper
  43474. * @param scene the scene to attach the experience helper to
  43475. * @returns a promise for the experience helper
  43476. */
  43477. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43478. /**
  43479. * Creates a WebXRExperienceHelper
  43480. * @param scene The scene the helper should be created in
  43481. */
  43482. private constructor();
  43483. /**
  43484. * Exits XR mode and returns the scene to its original state
  43485. * @returns promise that resolves after xr mode has exited
  43486. */
  43487. exitXRAsync(): Promise<void>;
  43488. /**
  43489. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43490. * @param sessionMode options for the XR session
  43491. * @param referenceSpaceType frame of reference of the XR session
  43492. * @param renderTarget the output canvas that will be used to enter XR mode
  43493. * @returns promise that resolves after xr mode has entered
  43494. */
  43495. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  43496. /**
  43497. * Updates the global position of the camera by moving the camera's container
  43498. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43499. * @param position The desired global position of the camera
  43500. */
  43501. setPositionOfCameraUsingContainer(position: Vector3): void;
  43502. /**
  43503. * Rotates the xr camera by rotating the camera's container around the camera's position
  43504. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43505. * @param rotation the desired quaternion rotation to apply to the camera
  43506. */
  43507. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43508. /**
  43509. * Disposes of the experience helper
  43510. */
  43511. dispose(): void;
  43512. }
  43513. }
  43514. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43515. import { Nullable } from "babylonjs/types";
  43516. import { Observable } from "babylonjs/Misc/observable";
  43517. import { IDisposable, Scene } from "babylonjs/scene";
  43518. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43519. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43520. /**
  43521. * Button which can be used to enter a different mode of XR
  43522. */
  43523. export class WebXREnterExitUIButton {
  43524. /** button element */
  43525. element: HTMLElement;
  43526. /** XR initialization options for the button */
  43527. sessionMode: XRSessionMode;
  43528. /** Reference space type */
  43529. referenceSpaceType: XRReferenceSpaceType;
  43530. /**
  43531. * Creates a WebXREnterExitUIButton
  43532. * @param element button element
  43533. * @param sessionMode XR initialization session mode
  43534. * @param referenceSpaceType the type of reference space to be used
  43535. */
  43536. constructor(
  43537. /** button element */
  43538. element: HTMLElement,
  43539. /** XR initialization options for the button */
  43540. sessionMode: XRSessionMode,
  43541. /** Reference space type */
  43542. referenceSpaceType: XRReferenceSpaceType);
  43543. /**
  43544. * Overwritable function which can be used to update the button's visuals when the state changes
  43545. * @param activeButton the current active button in the UI
  43546. */
  43547. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43548. }
  43549. /**
  43550. * Options to create the webXR UI
  43551. */
  43552. export class WebXREnterExitUIOptions {
  43553. /**
  43554. * Context to enter xr with
  43555. */
  43556. renderTarget?: Nullable<WebXRRenderTarget>;
  43557. /**
  43558. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43559. */
  43560. customButtons?: Array<WebXREnterExitUIButton>;
  43561. }
  43562. /**
  43563. * UI to allow the user to enter/exit XR mode
  43564. */
  43565. export class WebXREnterExitUI implements IDisposable {
  43566. private scene;
  43567. private _overlay;
  43568. private _buttons;
  43569. private _activeButton;
  43570. /**
  43571. * Fired every time the active button is changed.
  43572. *
  43573. * When xr is entered via a button that launches xr that button will be the callback parameter
  43574. *
  43575. * When exiting xr the callback parameter will be null)
  43576. */
  43577. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43578. /**
  43579. * Creates UI to allow the user to enter/exit XR mode
  43580. * @param scene the scene to add the ui to
  43581. * @param helper the xr experience helper to enter/exit xr with
  43582. * @param options options to configure the UI
  43583. * @returns the created ui
  43584. */
  43585. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43586. private constructor();
  43587. private _updateButtons;
  43588. /**
  43589. * Disposes of the object
  43590. */
  43591. dispose(): void;
  43592. }
  43593. }
  43594. declare module "babylonjs/Cameras/XR/webXRController" {
  43595. import { Nullable } from "babylonjs/types";
  43596. import { Observable } from "babylonjs/Misc/observable";
  43597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43598. import { Ray } from "babylonjs/Culling/ray";
  43599. import { Scene } from "babylonjs/scene";
  43600. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43601. /**
  43602. * Represents an XR input
  43603. */
  43604. export class WebXRController {
  43605. private scene;
  43606. /** The underlying input source for the controller */
  43607. inputSource: XRInputSource;
  43608. private parentContainer;
  43609. /**
  43610. * 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
  43611. */
  43612. grip?: AbstractMesh;
  43613. /**
  43614. * Pointer which can be used to select objects or attach a visible laser to
  43615. */
  43616. pointer: AbstractMesh;
  43617. private _gamepadMode;
  43618. /**
  43619. * If available, this is the gamepad object related to this controller.
  43620. * Using this object it is possible to get click events and trackpad changes of the
  43621. * webxr controller that is currently being used.
  43622. */
  43623. gamepadController?: WebVRController;
  43624. /**
  43625. * Event that fires when the controller is removed/disposed
  43626. */
  43627. onDisposeObservable: Observable<{}>;
  43628. private _tmpMatrix;
  43629. private _tmpQuaternion;
  43630. private _tmpVector;
  43631. /**
  43632. * Creates the controller
  43633. * @see https://doc.babylonjs.com/how_to/webxr
  43634. * @param scene the scene which the controller should be associated to
  43635. * @param inputSource the underlying input source for the controller
  43636. * @param parentContainer parent that the controller meshes should be children of
  43637. */
  43638. constructor(scene: Scene,
  43639. /** The underlying input source for the controller */
  43640. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43641. /**
  43642. * Updates the controller pose based on the given XRFrame
  43643. * @param xrFrame xr frame to update the pose with
  43644. * @param referenceSpace reference space to use
  43645. */
  43646. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43647. /**
  43648. * Gets a world space ray coming from the controller
  43649. * @param result the resulting ray
  43650. */
  43651. getWorldPointerRayToRef(result: Ray): void;
  43652. /**
  43653. * Get the scene associated with this controller
  43654. * @returns the scene object
  43655. */
  43656. getScene(): Scene;
  43657. /**
  43658. * Disposes of the object
  43659. */
  43660. dispose(): void;
  43661. }
  43662. }
  43663. declare module "babylonjs/Cameras/XR/webXRInput" {
  43664. import { Observable } from "babylonjs/Misc/observable";
  43665. import { IDisposable } from "babylonjs/scene";
  43666. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43667. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43668. /**
  43669. * XR input used to track XR inputs such as controllers/rays
  43670. */
  43671. export class WebXRInput implements IDisposable {
  43672. /**
  43673. * Base experience the input listens to
  43674. */
  43675. baseExperience: WebXRExperienceHelper;
  43676. /**
  43677. * XR controllers being tracked
  43678. */
  43679. controllers: Array<WebXRController>;
  43680. private _frameObserver;
  43681. private _stateObserver;
  43682. /**
  43683. * Event when a controller has been connected/added
  43684. */
  43685. onControllerAddedObservable: Observable<WebXRController>;
  43686. /**
  43687. * Event when a controller has been removed/disconnected
  43688. */
  43689. onControllerRemovedObservable: Observable<WebXRController>;
  43690. /**
  43691. * Initializes the WebXRInput
  43692. * @param baseExperience experience helper which the input should be created for
  43693. */
  43694. constructor(
  43695. /**
  43696. * Base experience the input listens to
  43697. */
  43698. baseExperience: WebXRExperienceHelper);
  43699. private _onInputSourcesChange;
  43700. private _addAndRemoveControllers;
  43701. /**
  43702. * Disposes of the object
  43703. */
  43704. dispose(): void;
  43705. }
  43706. }
  43707. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43709. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43710. /**
  43711. * Enables teleportation
  43712. */
  43713. export class WebXRControllerTeleportation {
  43714. private _teleportationFillColor;
  43715. private _teleportationBorderColor;
  43716. private _tmpRay;
  43717. private _tmpVector;
  43718. /**
  43719. * Creates a WebXRControllerTeleportation
  43720. * @param input input manager to add teleportation to
  43721. * @param floorMeshes floormeshes which can be teleported to
  43722. */
  43723. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43724. }
  43725. }
  43726. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43727. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43728. /**
  43729. * Handles pointer input automatically for the pointer of XR controllers
  43730. */
  43731. export class WebXRControllerPointerSelection {
  43732. private static _idCounter;
  43733. private _tmpRay;
  43734. /**
  43735. * Creates a WebXRControllerPointerSelection
  43736. * @param input input manager to setup pointer selection
  43737. */
  43738. constructor(input: WebXRInput);
  43739. private _convertNormalToDirectionOfRay;
  43740. private _updatePointerDistance;
  43741. }
  43742. }
  43743. declare module "babylonjs/Loading/sceneLoader" {
  43744. import { Observable } from "babylonjs/Misc/observable";
  43745. import { Nullable } from "babylonjs/types";
  43746. import { Scene } from "babylonjs/scene";
  43747. import { Engine } from "babylonjs/Engines/engine";
  43748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43749. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43750. import { AssetContainer } from "babylonjs/assetContainer";
  43751. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43752. import { Skeleton } from "babylonjs/Bones/skeleton";
  43753. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43754. import { WebRequest } from "babylonjs/Misc/webRequest";
  43755. /**
  43756. * Class used to represent data loading progression
  43757. */
  43758. export class SceneLoaderProgressEvent {
  43759. /** defines if data length to load can be evaluated */
  43760. readonly lengthComputable: boolean;
  43761. /** defines the loaded data length */
  43762. readonly loaded: number;
  43763. /** defines the data length to load */
  43764. readonly total: number;
  43765. /**
  43766. * Create a new progress event
  43767. * @param lengthComputable defines if data length to load can be evaluated
  43768. * @param loaded defines the loaded data length
  43769. * @param total defines the data length to load
  43770. */
  43771. constructor(
  43772. /** defines if data length to load can be evaluated */
  43773. lengthComputable: boolean,
  43774. /** defines the loaded data length */
  43775. loaded: number,
  43776. /** defines the data length to load */
  43777. total: number);
  43778. /**
  43779. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43780. * @param event defines the source event
  43781. * @returns a new SceneLoaderProgressEvent
  43782. */
  43783. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43784. }
  43785. /**
  43786. * Interface used by SceneLoader plugins to define supported file extensions
  43787. */
  43788. export interface ISceneLoaderPluginExtensions {
  43789. /**
  43790. * Defines the list of supported extensions
  43791. */
  43792. [extension: string]: {
  43793. isBinary: boolean;
  43794. };
  43795. }
  43796. /**
  43797. * Interface used by SceneLoader plugin factory
  43798. */
  43799. export interface ISceneLoaderPluginFactory {
  43800. /**
  43801. * Defines the name of the factory
  43802. */
  43803. name: string;
  43804. /**
  43805. * Function called to create a new plugin
  43806. * @return the new plugin
  43807. */
  43808. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43809. /**
  43810. * The callback that returns true if the data can be directly loaded.
  43811. * @param data string containing the file data
  43812. * @returns if the data can be loaded directly
  43813. */
  43814. canDirectLoad?(data: string): boolean;
  43815. }
  43816. /**
  43817. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43818. */
  43819. export interface ISceneLoaderPluginBase {
  43820. /**
  43821. * The friendly name of this plugin.
  43822. */
  43823. name: string;
  43824. /**
  43825. * The file extensions supported by this plugin.
  43826. */
  43827. extensions: string | ISceneLoaderPluginExtensions;
  43828. /**
  43829. * The callback called when loading from a url.
  43830. * @param scene scene loading this url
  43831. * @param url url to load
  43832. * @param onSuccess callback called when the file successfully loads
  43833. * @param onProgress callback called while file is loading (if the server supports this mode)
  43834. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43835. * @param onError callback called when the file fails to load
  43836. * @returns a file request object
  43837. */
  43838. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43839. /**
  43840. * The callback called when loading from a file object.
  43841. * @param scene scene loading this file
  43842. * @param file defines the file to load
  43843. * @param onSuccess defines the callback to call when data is loaded
  43844. * @param onProgress defines the callback to call during loading process
  43845. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43846. * @param onError defines the callback to call when an error occurs
  43847. * @returns a file request object
  43848. */
  43849. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43850. /**
  43851. * The callback that returns true if the data can be directly loaded.
  43852. * @param data string containing the file data
  43853. * @returns if the data can be loaded directly
  43854. */
  43855. canDirectLoad?(data: string): boolean;
  43856. /**
  43857. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43858. * @param scene scene loading this data
  43859. * @param data string containing the data
  43860. * @returns data to pass to the plugin
  43861. */
  43862. directLoad?(scene: Scene, data: string): any;
  43863. /**
  43864. * The callback that allows custom handling of the root url based on the response url.
  43865. * @param rootUrl the original root url
  43866. * @param responseURL the response url if available
  43867. * @returns the new root url
  43868. */
  43869. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43870. }
  43871. /**
  43872. * Interface used to define a SceneLoader plugin
  43873. */
  43874. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43875. /**
  43876. * Import meshes into a scene.
  43877. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43878. * @param scene The scene to import into
  43879. * @param data The data to import
  43880. * @param rootUrl The root url for scene and resources
  43881. * @param meshes The meshes array to import into
  43882. * @param particleSystems The particle systems array to import into
  43883. * @param skeletons The skeletons array to import into
  43884. * @param onError The callback when import fails
  43885. * @returns True if successful or false otherwise
  43886. */
  43887. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43888. /**
  43889. * Load into a scene.
  43890. * @param scene The scene to load into
  43891. * @param data The data to import
  43892. * @param rootUrl The root url for scene and resources
  43893. * @param onError The callback when import fails
  43894. * @returns True if successful or false otherwise
  43895. */
  43896. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43897. /**
  43898. * Load into an asset container.
  43899. * @param scene The scene to load into
  43900. * @param data The data to import
  43901. * @param rootUrl The root url for scene and resources
  43902. * @param onError The callback when import fails
  43903. * @returns The loaded asset container
  43904. */
  43905. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43906. }
  43907. /**
  43908. * Interface used to define an async SceneLoader plugin
  43909. */
  43910. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43911. /**
  43912. * Import meshes into a scene.
  43913. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43914. * @param scene The scene to import into
  43915. * @param data The data to import
  43916. * @param rootUrl The root url for scene and resources
  43917. * @param onProgress The callback when the load progresses
  43918. * @param fileName Defines the name of the file to load
  43919. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43920. */
  43921. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43922. meshes: AbstractMesh[];
  43923. particleSystems: IParticleSystem[];
  43924. skeletons: Skeleton[];
  43925. animationGroups: AnimationGroup[];
  43926. }>;
  43927. /**
  43928. * Load into a scene.
  43929. * @param scene The scene to load into
  43930. * @param data The data to import
  43931. * @param rootUrl The root url for scene and resources
  43932. * @param onProgress The callback when the load progresses
  43933. * @param fileName Defines the name of the file to load
  43934. * @returns Nothing
  43935. */
  43936. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43937. /**
  43938. * Load into an asset container.
  43939. * @param scene The scene to load into
  43940. * @param data The data to import
  43941. * @param rootUrl The root url for scene and resources
  43942. * @param onProgress The callback when the load progresses
  43943. * @param fileName Defines the name of the file to load
  43944. * @returns The loaded asset container
  43945. */
  43946. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43947. }
  43948. /**
  43949. * Class used to load scene from various file formats using registered plugins
  43950. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43951. */
  43952. export class SceneLoader {
  43953. /**
  43954. * No logging while loading
  43955. */
  43956. static readonly NO_LOGGING: number;
  43957. /**
  43958. * Minimal logging while loading
  43959. */
  43960. static readonly MINIMAL_LOGGING: number;
  43961. /**
  43962. * Summary logging while loading
  43963. */
  43964. static readonly SUMMARY_LOGGING: number;
  43965. /**
  43966. * Detailled logging while loading
  43967. */
  43968. static readonly DETAILED_LOGGING: number;
  43969. /**
  43970. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43971. */
  43972. static ForceFullSceneLoadingForIncremental: boolean;
  43973. /**
  43974. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43975. */
  43976. static ShowLoadingScreen: boolean;
  43977. /**
  43978. * Defines the current logging level (while loading the scene)
  43979. * @ignorenaming
  43980. */
  43981. static loggingLevel: number;
  43982. /**
  43983. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43984. */
  43985. static CleanBoneMatrixWeights: boolean;
  43986. /**
  43987. * Event raised when a plugin is used to load a scene
  43988. */
  43989. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43990. private static _registeredPlugins;
  43991. private static _getDefaultPlugin;
  43992. private static _getPluginForExtension;
  43993. private static _getPluginForDirectLoad;
  43994. private static _getPluginForFilename;
  43995. private static _getDirectLoad;
  43996. private static _loadData;
  43997. private static _getFileInfo;
  43998. /**
  43999. * Gets a plugin that can load the given extension
  44000. * @param extension defines the extension to load
  44001. * @returns a plugin or null if none works
  44002. */
  44003. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44004. /**
  44005. * Gets a boolean indicating that the given extension can be loaded
  44006. * @param extension defines the extension to load
  44007. * @returns true if the extension is supported
  44008. */
  44009. static IsPluginForExtensionAvailable(extension: string): boolean;
  44010. /**
  44011. * Adds a new plugin to the list of registered plugins
  44012. * @param plugin defines the plugin to add
  44013. */
  44014. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44015. /**
  44016. * Import meshes into a scene
  44017. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44018. * @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)
  44019. * @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)
  44020. * @param scene the instance of BABYLON.Scene to append to
  44021. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44022. * @param onProgress a callback with a progress event for each file being loaded
  44023. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44024. * @param pluginExtension the extension used to determine the plugin
  44025. * @returns The loaded plugin
  44026. */
  44027. 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>;
  44028. /**
  44029. * Import meshes into a scene
  44030. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44031. * @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)
  44032. * @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)
  44033. * @param scene the instance of BABYLON.Scene to append to
  44034. * @param onProgress a callback with a progress event for each file being loaded
  44035. * @param pluginExtension the extension used to determine the plugin
  44036. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44037. */
  44038. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44039. meshes: AbstractMesh[];
  44040. particleSystems: IParticleSystem[];
  44041. skeletons: Skeleton[];
  44042. animationGroups: AnimationGroup[];
  44043. }>;
  44044. /**
  44045. * Load a scene
  44046. * @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)
  44047. * @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)
  44048. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44049. * @param onSuccess a callback with the scene when import succeeds
  44050. * @param onProgress a callback with a progress event for each file being loaded
  44051. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44052. * @param pluginExtension the extension used to determine the plugin
  44053. * @returns The loaded plugin
  44054. */
  44055. 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>;
  44056. /**
  44057. * Load a scene
  44058. * @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)
  44059. * @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)
  44060. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44061. * @param onProgress a callback with a progress event for each file being loaded
  44062. * @param pluginExtension the extension used to determine the plugin
  44063. * @returns The loaded scene
  44064. */
  44065. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44066. /**
  44067. * Append a scene
  44068. * @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)
  44069. * @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)
  44070. * @param scene is the instance of BABYLON.Scene to append to
  44071. * @param onSuccess a callback with the scene when import succeeds
  44072. * @param onProgress a callback with a progress event for each file being loaded
  44073. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44074. * @param pluginExtension the extension used to determine the plugin
  44075. * @returns The loaded plugin
  44076. */
  44077. 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>;
  44078. /**
  44079. * Append a scene
  44080. * @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)
  44081. * @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)
  44082. * @param scene is the instance of BABYLON.Scene to append to
  44083. * @param onProgress a callback with a progress event for each file being loaded
  44084. * @param pluginExtension the extension used to determine the plugin
  44085. * @returns The given scene
  44086. */
  44087. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44088. /**
  44089. * Load a scene into an asset container
  44090. * @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)
  44091. * @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)
  44092. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44093. * @param onSuccess a callback with the scene when import succeeds
  44094. * @param onProgress a callback with a progress event for each file being loaded
  44095. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44096. * @param pluginExtension the extension used to determine the plugin
  44097. * @returns The loaded plugin
  44098. */
  44099. 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>;
  44100. /**
  44101. * Load a scene into an asset container
  44102. * @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)
  44103. * @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)
  44104. * @param scene is the instance of Scene to append to
  44105. * @param onProgress a callback with a progress event for each file being loaded
  44106. * @param pluginExtension the extension used to determine the plugin
  44107. * @returns The loaded asset container
  44108. */
  44109. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44110. }
  44111. }
  44112. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44113. import { Scene } from "babylonjs/scene";
  44114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44115. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44116. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44117. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44118. /**
  44119. * Generic Controller
  44120. */
  44121. export class GenericController extends WebVRController {
  44122. /**
  44123. * Base Url for the controller model.
  44124. */
  44125. static readonly MODEL_BASE_URL: string;
  44126. /**
  44127. * File name for the controller model.
  44128. */
  44129. static readonly MODEL_FILENAME: string;
  44130. /**
  44131. * Creates a new GenericController from a gamepad
  44132. * @param vrGamepad the gamepad that the controller should be created from
  44133. */
  44134. constructor(vrGamepad: any);
  44135. /**
  44136. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44137. * @param scene scene in which to add meshes
  44138. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44139. */
  44140. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44141. /**
  44142. * Called once for each button that changed state since the last frame
  44143. * @param buttonIdx Which button index changed
  44144. * @param state New state of the button
  44145. * @param changes Which properties on the state changed since last frame
  44146. */
  44147. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44148. }
  44149. }
  44150. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44151. import { Observable } from "babylonjs/Misc/observable";
  44152. import { Scene } from "babylonjs/scene";
  44153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44154. import { Ray } from "babylonjs/Culling/ray";
  44155. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44156. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44157. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44158. /**
  44159. * Defines the WindowsMotionController object that the state of the windows motion controller
  44160. */
  44161. export class WindowsMotionController extends WebVRController {
  44162. /**
  44163. * The base url used to load the left and right controller models
  44164. */
  44165. static MODEL_BASE_URL: string;
  44166. /**
  44167. * The name of the left controller model file
  44168. */
  44169. static MODEL_LEFT_FILENAME: string;
  44170. /**
  44171. * The name of the right controller model file
  44172. */
  44173. static MODEL_RIGHT_FILENAME: string;
  44174. /**
  44175. * The controller name prefix for this controller type
  44176. */
  44177. static readonly GAMEPAD_ID_PREFIX: string;
  44178. /**
  44179. * The controller id pattern for this controller type
  44180. */
  44181. private static readonly GAMEPAD_ID_PATTERN;
  44182. private _loadedMeshInfo;
  44183. private readonly _mapping;
  44184. /**
  44185. * Fired when the trackpad on this controller is clicked
  44186. */
  44187. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44188. /**
  44189. * Fired when the trackpad on this controller is modified
  44190. */
  44191. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44192. /**
  44193. * The current x and y values of this controller's trackpad
  44194. */
  44195. trackpad: StickValues;
  44196. /**
  44197. * Creates a new WindowsMotionController from a gamepad
  44198. * @param vrGamepad the gamepad that the controller should be created from
  44199. */
  44200. constructor(vrGamepad: any);
  44201. /**
  44202. * Fired when the trigger on this controller is modified
  44203. */
  44204. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44205. /**
  44206. * Fired when the menu button on this controller is modified
  44207. */
  44208. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44209. /**
  44210. * Fired when the grip button on this controller is modified
  44211. */
  44212. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44213. /**
  44214. * Fired when the thumbstick button on this controller is modified
  44215. */
  44216. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44217. /**
  44218. * Fired when the touchpad button on this controller is modified
  44219. */
  44220. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44221. /**
  44222. * Fired when the touchpad values on this controller are modified
  44223. */
  44224. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44225. private _updateTrackpad;
  44226. /**
  44227. * Called once per frame by the engine.
  44228. */
  44229. update(): void;
  44230. /**
  44231. * Called once for each button that changed state since the last frame
  44232. * @param buttonIdx Which button index changed
  44233. * @param state New state of the button
  44234. * @param changes Which properties on the state changed since last frame
  44235. */
  44236. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44237. /**
  44238. * Moves the buttons on the controller mesh based on their current state
  44239. * @param buttonName the name of the button to move
  44240. * @param buttonValue the value of the button which determines the buttons new position
  44241. */
  44242. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44243. /**
  44244. * Moves the axis on the controller mesh based on its current state
  44245. * @param axis the index of the axis
  44246. * @param axisValue the value of the axis which determines the meshes new position
  44247. * @hidden
  44248. */
  44249. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44250. /**
  44251. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44252. * @param scene scene in which to add meshes
  44253. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44254. */
  44255. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44256. /**
  44257. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44258. * can be transformed by button presses and axes values, based on this._mapping.
  44259. *
  44260. * @param scene scene in which the meshes exist
  44261. * @param meshes list of meshes that make up the controller model to process
  44262. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44263. */
  44264. private processModel;
  44265. private createMeshInfo;
  44266. /**
  44267. * Gets the ray of the controller in the direction the controller is pointing
  44268. * @param length the length the resulting ray should be
  44269. * @returns a ray in the direction the controller is pointing
  44270. */
  44271. getForwardRay(length?: number): Ray;
  44272. /**
  44273. * Disposes of the controller
  44274. */
  44275. dispose(): void;
  44276. }
  44277. }
  44278. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44279. import { Observable } from "babylonjs/Misc/observable";
  44280. import { Scene } from "babylonjs/scene";
  44281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44282. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44283. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44284. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44285. /**
  44286. * Oculus Touch Controller
  44287. */
  44288. export class OculusTouchController extends WebVRController {
  44289. /**
  44290. * Base Url for the controller model.
  44291. */
  44292. static MODEL_BASE_URL: string;
  44293. /**
  44294. * File name for the left controller model.
  44295. */
  44296. static MODEL_LEFT_FILENAME: string;
  44297. /**
  44298. * File name for the right controller model.
  44299. */
  44300. static MODEL_RIGHT_FILENAME: string;
  44301. /**
  44302. * Base Url for the Quest controller model.
  44303. */
  44304. static QUEST_MODEL_BASE_URL: string;
  44305. /**
  44306. * @hidden
  44307. * If the controllers are running on a device that needs the updated Quest controller models
  44308. */
  44309. static _IsQuest: boolean;
  44310. /**
  44311. * Fired when the secondary trigger on this controller is modified
  44312. */
  44313. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44314. /**
  44315. * Fired when the thumb rest on this controller is modified
  44316. */
  44317. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44318. /**
  44319. * Creates a new OculusTouchController from a gamepad
  44320. * @param vrGamepad the gamepad that the controller should be created from
  44321. */
  44322. constructor(vrGamepad: any);
  44323. /**
  44324. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44325. * @param scene scene in which to add meshes
  44326. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44327. */
  44328. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44329. /**
  44330. * Fired when the A button on this controller is modified
  44331. */
  44332. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44333. /**
  44334. * Fired when the B button on this controller is modified
  44335. */
  44336. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44337. /**
  44338. * Fired when the X button on this controller is modified
  44339. */
  44340. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44341. /**
  44342. * Fired when the Y button on this controller is modified
  44343. */
  44344. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44345. /**
  44346. * Called once for each button that changed state since the last frame
  44347. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44348. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44349. * 2) secondary trigger (same)
  44350. * 3) A (right) X (left), touch, pressed = value
  44351. * 4) B / Y
  44352. * 5) thumb rest
  44353. * @param buttonIdx Which button index changed
  44354. * @param state New state of the button
  44355. * @param changes Which properties on the state changed since last frame
  44356. */
  44357. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44358. }
  44359. }
  44360. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44361. import { Scene } from "babylonjs/scene";
  44362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44363. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44364. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44365. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44366. import { Observable } from "babylonjs/Misc/observable";
  44367. /**
  44368. * Vive Controller
  44369. */
  44370. export class ViveController extends WebVRController {
  44371. /**
  44372. * Base Url for the controller model.
  44373. */
  44374. static MODEL_BASE_URL: string;
  44375. /**
  44376. * File name for the controller model.
  44377. */
  44378. static MODEL_FILENAME: string;
  44379. /**
  44380. * Creates a new ViveController from a gamepad
  44381. * @param vrGamepad the gamepad that the controller should be created from
  44382. */
  44383. constructor(vrGamepad: any);
  44384. /**
  44385. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44386. * @param scene scene in which to add meshes
  44387. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44388. */
  44389. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44390. /**
  44391. * Fired when the left button on this controller is modified
  44392. */
  44393. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44394. /**
  44395. * Fired when the right button on this controller is modified
  44396. */
  44397. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44398. /**
  44399. * Fired when the menu button on this controller is modified
  44400. */
  44401. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44402. /**
  44403. * Called once for each button that changed state since the last frame
  44404. * Vive mapping:
  44405. * 0: touchpad
  44406. * 1: trigger
  44407. * 2: left AND right buttons
  44408. * 3: menu button
  44409. * @param buttonIdx Which button index changed
  44410. * @param state New state of the button
  44411. * @param changes Which properties on the state changed since last frame
  44412. */
  44413. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44414. }
  44415. }
  44416. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44417. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44418. /**
  44419. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44420. */
  44421. export class WebXRControllerModelLoader {
  44422. /**
  44423. * Creates the WebXRControllerModelLoader
  44424. * @param input xr input that creates the controllers
  44425. */
  44426. constructor(input: WebXRInput);
  44427. }
  44428. }
  44429. declare module "babylonjs/Cameras/XR/index" {
  44430. export * from "babylonjs/Cameras/XR/webXRCamera";
  44431. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44432. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44433. export * from "babylonjs/Cameras/XR/webXRInput";
  44434. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44435. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44436. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44437. export * from "babylonjs/Cameras/XR/webXRController";
  44438. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44439. export * from "babylonjs/Cameras/XR/webXRTypes";
  44440. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44441. }
  44442. declare module "babylonjs/Cameras/RigModes/index" {
  44443. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44444. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44445. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44446. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44447. }
  44448. declare module "babylonjs/Cameras/index" {
  44449. export * from "babylonjs/Cameras/Inputs/index";
  44450. export * from "babylonjs/Cameras/cameraInputsManager";
  44451. export * from "babylonjs/Cameras/camera";
  44452. export * from "babylonjs/Cameras/targetCamera";
  44453. export * from "babylonjs/Cameras/freeCamera";
  44454. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44455. export * from "babylonjs/Cameras/touchCamera";
  44456. export * from "babylonjs/Cameras/arcRotateCamera";
  44457. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44458. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44459. export * from "babylonjs/Cameras/flyCamera";
  44460. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44461. export * from "babylonjs/Cameras/followCamera";
  44462. export * from "babylonjs/Cameras/followCameraInputsManager";
  44463. export * from "babylonjs/Cameras/gamepadCamera";
  44464. export * from "babylonjs/Cameras/Stereoscopic/index";
  44465. export * from "babylonjs/Cameras/universalCamera";
  44466. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44467. export * from "babylonjs/Cameras/VR/index";
  44468. export * from "babylonjs/Cameras/XR/index";
  44469. export * from "babylonjs/Cameras/RigModes/index";
  44470. }
  44471. declare module "babylonjs/Collisions/index" {
  44472. export * from "babylonjs/Collisions/collider";
  44473. export * from "babylonjs/Collisions/collisionCoordinator";
  44474. export * from "babylonjs/Collisions/pickingInfo";
  44475. export * from "babylonjs/Collisions/intersectionInfo";
  44476. export * from "babylonjs/Collisions/meshCollisionData";
  44477. }
  44478. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44479. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44480. import { Vector3 } from "babylonjs/Maths/math.vector";
  44481. import { Ray } from "babylonjs/Culling/ray";
  44482. import { Plane } from "babylonjs/Maths/math.plane";
  44483. /**
  44484. * Contains an array of blocks representing the octree
  44485. */
  44486. export interface IOctreeContainer<T> {
  44487. /**
  44488. * Blocks within the octree
  44489. */
  44490. blocks: Array<OctreeBlock<T>>;
  44491. }
  44492. /**
  44493. * Class used to store a cell in an octree
  44494. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44495. */
  44496. export class OctreeBlock<T> {
  44497. /**
  44498. * Gets the content of the current block
  44499. */
  44500. entries: T[];
  44501. /**
  44502. * Gets the list of block children
  44503. */
  44504. blocks: Array<OctreeBlock<T>>;
  44505. private _depth;
  44506. private _maxDepth;
  44507. private _capacity;
  44508. private _minPoint;
  44509. private _maxPoint;
  44510. private _boundingVectors;
  44511. private _creationFunc;
  44512. /**
  44513. * Creates a new block
  44514. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44515. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44516. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44517. * @param depth defines the current depth of this block in the octree
  44518. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44519. * @param creationFunc defines a callback to call when an element is added to the block
  44520. */
  44521. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44522. /**
  44523. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44524. */
  44525. readonly capacity: number;
  44526. /**
  44527. * Gets the minimum vector (in world space) of the block's bounding box
  44528. */
  44529. readonly minPoint: Vector3;
  44530. /**
  44531. * Gets the maximum vector (in world space) of the block's bounding box
  44532. */
  44533. readonly maxPoint: Vector3;
  44534. /**
  44535. * Add a new element to this block
  44536. * @param entry defines the element to add
  44537. */
  44538. addEntry(entry: T): void;
  44539. /**
  44540. * Remove an element from this block
  44541. * @param entry defines the element to remove
  44542. */
  44543. removeEntry(entry: T): void;
  44544. /**
  44545. * Add an array of elements to this block
  44546. * @param entries defines the array of elements to add
  44547. */
  44548. addEntries(entries: T[]): void;
  44549. /**
  44550. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44551. * @param frustumPlanes defines the frustum planes to test
  44552. * @param selection defines the array to store current content if selection is positive
  44553. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44554. */
  44555. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44556. /**
  44557. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44558. * @param sphereCenter defines the bounding sphere center
  44559. * @param sphereRadius defines the bounding sphere radius
  44560. * @param selection defines the array to store current content if selection is positive
  44561. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44562. */
  44563. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44564. /**
  44565. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44566. * @param ray defines the ray to test with
  44567. * @param selection defines the array to store current content if selection is positive
  44568. */
  44569. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44570. /**
  44571. * Subdivide the content into child blocks (this block will then be empty)
  44572. */
  44573. createInnerBlocks(): void;
  44574. /**
  44575. * @hidden
  44576. */
  44577. 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;
  44578. }
  44579. }
  44580. declare module "babylonjs/Culling/Octrees/octree" {
  44581. import { SmartArray } from "babylonjs/Misc/smartArray";
  44582. import { Vector3 } from "babylonjs/Maths/math.vector";
  44583. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44585. import { Ray } from "babylonjs/Culling/ray";
  44586. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44587. import { Plane } from "babylonjs/Maths/math.plane";
  44588. /**
  44589. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44590. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44591. */
  44592. export class Octree<T> {
  44593. /** 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.) */
  44594. maxDepth: number;
  44595. /**
  44596. * Blocks within the octree containing objects
  44597. */
  44598. blocks: Array<OctreeBlock<T>>;
  44599. /**
  44600. * Content stored in the octree
  44601. */
  44602. dynamicContent: T[];
  44603. private _maxBlockCapacity;
  44604. private _selectionContent;
  44605. private _creationFunc;
  44606. /**
  44607. * Creates a octree
  44608. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44609. * @param creationFunc function to be used to instatiate the octree
  44610. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44611. * @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.)
  44612. */
  44613. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44614. /** 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.) */
  44615. maxDepth?: number);
  44616. /**
  44617. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44618. * @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);
  44619. * @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);
  44620. * @param entries meshes to be added to the octree blocks
  44621. */
  44622. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44623. /**
  44624. * Adds a mesh to the octree
  44625. * @param entry Mesh to add to the octree
  44626. */
  44627. addMesh(entry: T): void;
  44628. /**
  44629. * Remove an element from the octree
  44630. * @param entry defines the element to remove
  44631. */
  44632. removeMesh(entry: T): void;
  44633. /**
  44634. * Selects an array of meshes within the frustum
  44635. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44636. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44637. * @returns array of meshes within the frustum
  44638. */
  44639. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44640. /**
  44641. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44642. * @param sphereCenter defines the bounding sphere center
  44643. * @param sphereRadius defines the bounding sphere radius
  44644. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44645. * @returns an array of objects that intersect the sphere
  44646. */
  44647. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44648. /**
  44649. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44650. * @param ray defines the ray to test with
  44651. * @returns array of intersected objects
  44652. */
  44653. intersectsRay(ray: Ray): SmartArray<T>;
  44654. /**
  44655. * Adds a mesh into the octree block if it intersects the block
  44656. */
  44657. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44658. /**
  44659. * Adds a submesh into the octree block if it intersects the block
  44660. */
  44661. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44662. }
  44663. }
  44664. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44665. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44666. import { Scene } from "babylonjs/scene";
  44667. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44668. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44669. import { Ray } from "babylonjs/Culling/ray";
  44670. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44671. import { Collider } from "babylonjs/Collisions/collider";
  44672. module "babylonjs/scene" {
  44673. interface Scene {
  44674. /**
  44675. * @hidden
  44676. * Backing Filed
  44677. */
  44678. _selectionOctree: Octree<AbstractMesh>;
  44679. /**
  44680. * Gets the octree used to boost mesh selection (picking)
  44681. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44682. */
  44683. selectionOctree: Octree<AbstractMesh>;
  44684. /**
  44685. * Creates or updates the octree used to boost selection (picking)
  44686. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44687. * @param maxCapacity defines the maximum capacity per leaf
  44688. * @param maxDepth defines the maximum depth of the octree
  44689. * @returns an octree of AbstractMesh
  44690. */
  44691. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44692. }
  44693. }
  44694. module "babylonjs/Meshes/abstractMesh" {
  44695. interface AbstractMesh {
  44696. /**
  44697. * @hidden
  44698. * Backing Field
  44699. */
  44700. _submeshesOctree: Octree<SubMesh>;
  44701. /**
  44702. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44703. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44704. * @param maxCapacity defines the maximum size of each block (64 by default)
  44705. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44706. * @returns the new octree
  44707. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44708. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44709. */
  44710. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44711. }
  44712. }
  44713. /**
  44714. * Defines the octree scene component responsible to manage any octrees
  44715. * in a given scene.
  44716. */
  44717. export class OctreeSceneComponent {
  44718. /**
  44719. * The component name help to identify the component in the list of scene components.
  44720. */
  44721. readonly name: string;
  44722. /**
  44723. * The scene the component belongs to.
  44724. */
  44725. scene: Scene;
  44726. /**
  44727. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44728. */
  44729. readonly checksIsEnabled: boolean;
  44730. /**
  44731. * Creates a new instance of the component for the given scene
  44732. * @param scene Defines the scene to register the component in
  44733. */
  44734. constructor(scene: Scene);
  44735. /**
  44736. * Registers the component in a given scene
  44737. */
  44738. register(): void;
  44739. /**
  44740. * Return the list of active meshes
  44741. * @returns the list of active meshes
  44742. */
  44743. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44744. /**
  44745. * Return the list of active sub meshes
  44746. * @param mesh The mesh to get the candidates sub meshes from
  44747. * @returns the list of active sub meshes
  44748. */
  44749. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44750. private _tempRay;
  44751. /**
  44752. * Return the list of sub meshes intersecting with a given local ray
  44753. * @param mesh defines the mesh to find the submesh for
  44754. * @param localRay defines the ray in local space
  44755. * @returns the list of intersecting sub meshes
  44756. */
  44757. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44758. /**
  44759. * Return the list of sub meshes colliding with a collider
  44760. * @param mesh defines the mesh to find the submesh for
  44761. * @param collider defines the collider to evaluate the collision against
  44762. * @returns the list of colliding sub meshes
  44763. */
  44764. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44765. /**
  44766. * Rebuilds the elements related to this component in case of
  44767. * context lost for instance.
  44768. */
  44769. rebuild(): void;
  44770. /**
  44771. * Disposes the component and the associated ressources.
  44772. */
  44773. dispose(): void;
  44774. }
  44775. }
  44776. declare module "babylonjs/Culling/Octrees/index" {
  44777. export * from "babylonjs/Culling/Octrees/octree";
  44778. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44779. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44780. }
  44781. declare module "babylonjs/Culling/index" {
  44782. export * from "babylonjs/Culling/boundingBox";
  44783. export * from "babylonjs/Culling/boundingInfo";
  44784. export * from "babylonjs/Culling/boundingSphere";
  44785. export * from "babylonjs/Culling/Octrees/index";
  44786. export * from "babylonjs/Culling/ray";
  44787. }
  44788. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44789. import { IDisposable, Scene } from "babylonjs/scene";
  44790. import { Nullable } from "babylonjs/types";
  44791. import { Observable } from "babylonjs/Misc/observable";
  44792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44793. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44794. import { Camera } from "babylonjs/Cameras/camera";
  44795. /**
  44796. * Renders a layer on top of an existing scene
  44797. */
  44798. export class UtilityLayerRenderer implements IDisposable {
  44799. /** the original scene that will be rendered on top of */
  44800. originalScene: Scene;
  44801. private _pointerCaptures;
  44802. private _lastPointerEvents;
  44803. private static _DefaultUtilityLayer;
  44804. private static _DefaultKeepDepthUtilityLayer;
  44805. private _sharedGizmoLight;
  44806. private _renderCamera;
  44807. /**
  44808. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44809. * @returns the camera that is used when rendering the utility layer
  44810. */
  44811. getRenderCamera(): Nullable<Camera>;
  44812. /**
  44813. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44814. * @param cam the camera that should be used when rendering the utility layer
  44815. */
  44816. setRenderCamera(cam: Nullable<Camera>): void;
  44817. /**
  44818. * @hidden
  44819. * Light which used by gizmos to get light shading
  44820. */
  44821. _getSharedGizmoLight(): HemisphericLight;
  44822. /**
  44823. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44824. */
  44825. pickUtilitySceneFirst: boolean;
  44826. /**
  44827. * 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)
  44828. */
  44829. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44830. /**
  44831. * 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)
  44832. */
  44833. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44834. /**
  44835. * The scene that is rendered on top of the original scene
  44836. */
  44837. utilityLayerScene: Scene;
  44838. /**
  44839. * If the utility layer should automatically be rendered on top of existing scene
  44840. */
  44841. shouldRender: boolean;
  44842. /**
  44843. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44844. */
  44845. onlyCheckPointerDownEvents: boolean;
  44846. /**
  44847. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44848. */
  44849. processAllEvents: boolean;
  44850. /**
  44851. * Observable raised when the pointer move from the utility layer scene to the main scene
  44852. */
  44853. onPointerOutObservable: Observable<number>;
  44854. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44855. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44856. private _afterRenderObserver;
  44857. private _sceneDisposeObserver;
  44858. private _originalPointerObserver;
  44859. /**
  44860. * Instantiates a UtilityLayerRenderer
  44861. * @param originalScene the original scene that will be rendered on top of
  44862. * @param handleEvents boolean indicating if the utility layer should handle events
  44863. */
  44864. constructor(
  44865. /** the original scene that will be rendered on top of */
  44866. originalScene: Scene, handleEvents?: boolean);
  44867. private _notifyObservers;
  44868. /**
  44869. * Renders the utility layers scene on top of the original scene
  44870. */
  44871. render(): void;
  44872. /**
  44873. * Disposes of the renderer
  44874. */
  44875. dispose(): void;
  44876. private _updateCamera;
  44877. }
  44878. }
  44879. declare module "babylonjs/Gizmos/gizmo" {
  44880. import { Nullable } from "babylonjs/types";
  44881. import { IDisposable } from "babylonjs/scene";
  44882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44883. import { Mesh } from "babylonjs/Meshes/mesh";
  44884. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44885. /**
  44886. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44887. */
  44888. export class Gizmo implements IDisposable {
  44889. /** The utility layer the gizmo will be added to */
  44890. gizmoLayer: UtilityLayerRenderer;
  44891. /**
  44892. * The root mesh of the gizmo
  44893. */
  44894. _rootMesh: Mesh;
  44895. private _attachedMesh;
  44896. /**
  44897. * Ratio for the scale of the gizmo (Default: 1)
  44898. */
  44899. scaleRatio: number;
  44900. /**
  44901. * If a custom mesh has been set (Default: false)
  44902. */
  44903. protected _customMeshSet: boolean;
  44904. /**
  44905. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44906. * * When set, interactions will be enabled
  44907. */
  44908. attachedMesh: Nullable<AbstractMesh>;
  44909. /**
  44910. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44911. * @param mesh The mesh to replace the default mesh of the gizmo
  44912. */
  44913. setCustomMesh(mesh: Mesh): void;
  44914. /**
  44915. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44916. */
  44917. updateGizmoRotationToMatchAttachedMesh: boolean;
  44918. /**
  44919. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44920. */
  44921. updateGizmoPositionToMatchAttachedMesh: boolean;
  44922. /**
  44923. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44924. */
  44925. updateScale: boolean;
  44926. protected _interactionsEnabled: boolean;
  44927. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44928. private _beforeRenderObserver;
  44929. private _tempVector;
  44930. /**
  44931. * Creates a gizmo
  44932. * @param gizmoLayer The utility layer the gizmo will be added to
  44933. */
  44934. constructor(
  44935. /** The utility layer the gizmo will be added to */
  44936. gizmoLayer?: UtilityLayerRenderer);
  44937. /**
  44938. * Updates the gizmo to match the attached mesh's position/rotation
  44939. */
  44940. protected _update(): void;
  44941. /**
  44942. * Disposes of the gizmo
  44943. */
  44944. dispose(): void;
  44945. }
  44946. }
  44947. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44948. import { Observable } from "babylonjs/Misc/observable";
  44949. import { Nullable } from "babylonjs/types";
  44950. import { Vector3 } from "babylonjs/Maths/math.vector";
  44951. import { Color3 } from "babylonjs/Maths/math.color";
  44952. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44953. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44954. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44955. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44956. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44957. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44958. import { Scene } from "babylonjs/scene";
  44959. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44960. /**
  44961. * Single plane drag gizmo
  44962. */
  44963. export class PlaneDragGizmo extends Gizmo {
  44964. /**
  44965. * Drag behavior responsible for the gizmos dragging interactions
  44966. */
  44967. dragBehavior: PointerDragBehavior;
  44968. private _pointerObserver;
  44969. /**
  44970. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44971. */
  44972. snapDistance: number;
  44973. /**
  44974. * Event that fires each time the gizmo snaps to a new location.
  44975. * * snapDistance is the the change in distance
  44976. */
  44977. onSnapObservable: Observable<{
  44978. snapDistance: number;
  44979. }>;
  44980. private _plane;
  44981. private _coloredMaterial;
  44982. private _hoverMaterial;
  44983. private _isEnabled;
  44984. private _parent;
  44985. /** @hidden */
  44986. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44987. /** @hidden */
  44988. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44989. /**
  44990. * Creates a PlaneDragGizmo
  44991. * @param gizmoLayer The utility layer the gizmo will be added to
  44992. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44993. * @param color The color of the gizmo
  44994. */
  44995. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44996. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44997. /**
  44998. * If the gizmo is enabled
  44999. */
  45000. isEnabled: boolean;
  45001. /**
  45002. * Disposes of the gizmo
  45003. */
  45004. dispose(): void;
  45005. }
  45006. }
  45007. declare module "babylonjs/Gizmos/positionGizmo" {
  45008. import { Observable } from "babylonjs/Misc/observable";
  45009. import { Nullable } from "babylonjs/types";
  45010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45011. import { Mesh } from "babylonjs/Meshes/mesh";
  45012. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45013. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  45014. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  45015. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45016. /**
  45017. * Gizmo that enables dragging a mesh along 3 axis
  45018. */
  45019. export class PositionGizmo extends Gizmo {
  45020. /**
  45021. * Internal gizmo used for interactions on the x axis
  45022. */
  45023. xGizmo: AxisDragGizmo;
  45024. /**
  45025. * Internal gizmo used for interactions on the y axis
  45026. */
  45027. yGizmo: AxisDragGizmo;
  45028. /**
  45029. * Internal gizmo used for interactions on the z axis
  45030. */
  45031. zGizmo: AxisDragGizmo;
  45032. /**
  45033. * Internal gizmo used for interactions on the yz plane
  45034. */
  45035. xPlaneGizmo: PlaneDragGizmo;
  45036. /**
  45037. * Internal gizmo used for interactions on the xz plane
  45038. */
  45039. yPlaneGizmo: PlaneDragGizmo;
  45040. /**
  45041. * Internal gizmo used for interactions on the xy plane
  45042. */
  45043. zPlaneGizmo: PlaneDragGizmo;
  45044. /**
  45045. * private variables
  45046. */
  45047. private _meshAttached;
  45048. private _updateGizmoRotationToMatchAttachedMesh;
  45049. private _snapDistance;
  45050. private _scaleRatio;
  45051. /** Fires an event when any of it's sub gizmos are dragged */
  45052. onDragStartObservable: Observable<unknown>;
  45053. /** Fires an event when any of it's sub gizmos are released from dragging */
  45054. onDragEndObservable: Observable<unknown>;
  45055. /**
  45056. * If set to true, planar drag is enabled
  45057. */
  45058. private _planarGizmoEnabled;
  45059. attachedMesh: Nullable<AbstractMesh>;
  45060. /**
  45061. * Creates a PositionGizmo
  45062. * @param gizmoLayer The utility layer the gizmo will be added to
  45063. */
  45064. constructor(gizmoLayer?: UtilityLayerRenderer);
  45065. /**
  45066. * If the planar drag gizmo is enabled
  45067. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45068. */
  45069. planarGizmoEnabled: boolean;
  45070. updateGizmoRotationToMatchAttachedMesh: boolean;
  45071. /**
  45072. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45073. */
  45074. snapDistance: number;
  45075. /**
  45076. * Ratio for the scale of the gizmo (Default: 1)
  45077. */
  45078. scaleRatio: number;
  45079. /**
  45080. * Disposes of the gizmo
  45081. */
  45082. dispose(): void;
  45083. /**
  45084. * CustomMeshes are not supported by this gizmo
  45085. * @param mesh The mesh to replace the default mesh of the gizmo
  45086. */
  45087. setCustomMesh(mesh: Mesh): void;
  45088. }
  45089. }
  45090. declare module "babylonjs/Gizmos/axisDragGizmo" {
  45091. import { Observable } from "babylonjs/Misc/observable";
  45092. import { Nullable } from "babylonjs/types";
  45093. import { Vector3 } from "babylonjs/Maths/math.vector";
  45094. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45096. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45097. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45098. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45099. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45100. import { Scene } from "babylonjs/scene";
  45101. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45102. import { Color3 } from "babylonjs/Maths/math.color";
  45103. /**
  45104. * Single axis drag gizmo
  45105. */
  45106. export class AxisDragGizmo extends Gizmo {
  45107. /**
  45108. * Drag behavior responsible for the gizmos dragging interactions
  45109. */
  45110. dragBehavior: PointerDragBehavior;
  45111. private _pointerObserver;
  45112. /**
  45113. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45114. */
  45115. snapDistance: number;
  45116. /**
  45117. * Event that fires each time the gizmo snaps to a new location.
  45118. * * snapDistance is the the change in distance
  45119. */
  45120. onSnapObservable: Observable<{
  45121. snapDistance: number;
  45122. }>;
  45123. private _isEnabled;
  45124. private _parent;
  45125. private _arrow;
  45126. private _coloredMaterial;
  45127. private _hoverMaterial;
  45128. /** @hidden */
  45129. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45130. /** @hidden */
  45131. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45132. /**
  45133. * Creates an AxisDragGizmo
  45134. * @param gizmoLayer The utility layer the gizmo will be added to
  45135. * @param dragAxis The axis which the gizmo will be able to drag on
  45136. * @param color The color of the gizmo
  45137. */
  45138. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45139. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45140. /**
  45141. * If the gizmo is enabled
  45142. */
  45143. isEnabled: boolean;
  45144. /**
  45145. * Disposes of the gizmo
  45146. */
  45147. dispose(): void;
  45148. }
  45149. }
  45150. declare module "babylonjs/Debug/axesViewer" {
  45151. import { Vector3 } from "babylonjs/Maths/math.vector";
  45152. import { Nullable } from "babylonjs/types";
  45153. import { Scene } from "babylonjs/scene";
  45154. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45155. /**
  45156. * The Axes viewer will show 3 axes in a specific point in space
  45157. */
  45158. export class AxesViewer {
  45159. private _xAxis;
  45160. private _yAxis;
  45161. private _zAxis;
  45162. private _scaleLinesFactor;
  45163. private _instanced;
  45164. /**
  45165. * Gets the hosting scene
  45166. */
  45167. scene: Scene;
  45168. /**
  45169. * Gets or sets a number used to scale line length
  45170. */
  45171. scaleLines: number;
  45172. /** Gets the node hierarchy used to render x-axis */
  45173. readonly xAxis: TransformNode;
  45174. /** Gets the node hierarchy used to render y-axis */
  45175. readonly yAxis: TransformNode;
  45176. /** Gets the node hierarchy used to render z-axis */
  45177. readonly zAxis: TransformNode;
  45178. /**
  45179. * Creates a new AxesViewer
  45180. * @param scene defines the hosting scene
  45181. * @param scaleLines defines a number used to scale line length (1 by default)
  45182. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45183. * @param xAxis defines the node hierarchy used to render the x-axis
  45184. * @param yAxis defines the node hierarchy used to render the y-axis
  45185. * @param zAxis defines the node hierarchy used to render the z-axis
  45186. */
  45187. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45188. /**
  45189. * Force the viewer to update
  45190. * @param position defines the position of the viewer
  45191. * @param xaxis defines the x axis of the viewer
  45192. * @param yaxis defines the y axis of the viewer
  45193. * @param zaxis defines the z axis of the viewer
  45194. */
  45195. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45196. /**
  45197. * Creates an instance of this axes viewer.
  45198. * @returns a new axes viewer with instanced meshes
  45199. */
  45200. createInstance(): AxesViewer;
  45201. /** Releases resources */
  45202. dispose(): void;
  45203. private static _SetRenderingGroupId;
  45204. }
  45205. }
  45206. declare module "babylonjs/Debug/boneAxesViewer" {
  45207. import { Nullable } from "babylonjs/types";
  45208. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  45209. import { Vector3 } from "babylonjs/Maths/math.vector";
  45210. import { Mesh } from "babylonjs/Meshes/mesh";
  45211. import { Bone } from "babylonjs/Bones/bone";
  45212. import { Scene } from "babylonjs/scene";
  45213. /**
  45214. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45215. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45216. */
  45217. export class BoneAxesViewer extends AxesViewer {
  45218. /**
  45219. * Gets or sets the target mesh where to display the axes viewer
  45220. */
  45221. mesh: Nullable<Mesh>;
  45222. /**
  45223. * Gets or sets the target bone where to display the axes viewer
  45224. */
  45225. bone: Nullable<Bone>;
  45226. /** Gets current position */
  45227. pos: Vector3;
  45228. /** Gets direction of X axis */
  45229. xaxis: Vector3;
  45230. /** Gets direction of Y axis */
  45231. yaxis: Vector3;
  45232. /** Gets direction of Z axis */
  45233. zaxis: Vector3;
  45234. /**
  45235. * Creates a new BoneAxesViewer
  45236. * @param scene defines the hosting scene
  45237. * @param bone defines the target bone
  45238. * @param mesh defines the target mesh
  45239. * @param scaleLines defines a scaling factor for line length (1 by default)
  45240. */
  45241. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45242. /**
  45243. * Force the viewer to update
  45244. */
  45245. update(): void;
  45246. /** Releases resources */
  45247. dispose(): void;
  45248. }
  45249. }
  45250. declare module "babylonjs/Debug/debugLayer" {
  45251. import { Scene } from "babylonjs/scene";
  45252. /**
  45253. * Interface used to define scene explorer extensibility option
  45254. */
  45255. export interface IExplorerExtensibilityOption {
  45256. /**
  45257. * Define the option label
  45258. */
  45259. label: string;
  45260. /**
  45261. * Defines the action to execute on click
  45262. */
  45263. action: (entity: any) => void;
  45264. }
  45265. /**
  45266. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45267. */
  45268. export interface IExplorerExtensibilityGroup {
  45269. /**
  45270. * Defines a predicate to test if a given type mut be extended
  45271. */
  45272. predicate: (entity: any) => boolean;
  45273. /**
  45274. * Gets the list of options added to a type
  45275. */
  45276. entries: IExplorerExtensibilityOption[];
  45277. }
  45278. /**
  45279. * Interface used to define the options to use to create the Inspector
  45280. */
  45281. export interface IInspectorOptions {
  45282. /**
  45283. * Display in overlay mode (default: false)
  45284. */
  45285. overlay?: boolean;
  45286. /**
  45287. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45288. */
  45289. globalRoot?: HTMLElement;
  45290. /**
  45291. * Display the Scene explorer
  45292. */
  45293. showExplorer?: boolean;
  45294. /**
  45295. * Display the property inspector
  45296. */
  45297. showInspector?: boolean;
  45298. /**
  45299. * Display in embed mode (both panes on the right)
  45300. */
  45301. embedMode?: boolean;
  45302. /**
  45303. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45304. */
  45305. handleResize?: boolean;
  45306. /**
  45307. * Allow the panes to popup (default: true)
  45308. */
  45309. enablePopup?: boolean;
  45310. /**
  45311. * Allow the panes to be closed by users (default: true)
  45312. */
  45313. enableClose?: boolean;
  45314. /**
  45315. * Optional list of extensibility entries
  45316. */
  45317. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45318. /**
  45319. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45320. */
  45321. inspectorURL?: string;
  45322. }
  45323. module "babylonjs/scene" {
  45324. interface Scene {
  45325. /**
  45326. * @hidden
  45327. * Backing field
  45328. */
  45329. _debugLayer: DebugLayer;
  45330. /**
  45331. * Gets the debug layer (aka Inspector) associated with the scene
  45332. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45333. */
  45334. debugLayer: DebugLayer;
  45335. }
  45336. }
  45337. /**
  45338. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45339. * what is happening in your scene
  45340. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45341. */
  45342. export class DebugLayer {
  45343. /**
  45344. * Define the url to get the inspector script from.
  45345. * By default it uses the babylonjs CDN.
  45346. * @ignoreNaming
  45347. */
  45348. static InspectorURL: string;
  45349. private _scene;
  45350. private BJSINSPECTOR;
  45351. private _onPropertyChangedObservable?;
  45352. /**
  45353. * Observable triggered when a property is changed through the inspector.
  45354. */
  45355. readonly onPropertyChangedObservable: any;
  45356. /**
  45357. * Instantiates a new debug layer.
  45358. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45359. * what is happening in your scene
  45360. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45361. * @param scene Defines the scene to inspect
  45362. */
  45363. constructor(scene: Scene);
  45364. /** Creates the inspector window. */
  45365. private _createInspector;
  45366. /**
  45367. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45368. * @param entity defines the entity to select
  45369. * @param lineContainerTitle defines the specific block to highlight
  45370. */
  45371. select(entity: any, lineContainerTitle?: string): void;
  45372. /** Get the inspector from bundle or global */
  45373. private _getGlobalInspector;
  45374. /**
  45375. * Get if the inspector is visible or not.
  45376. * @returns true if visible otherwise, false
  45377. */
  45378. isVisible(): boolean;
  45379. /**
  45380. * Hide the inspector and close its window.
  45381. */
  45382. hide(): void;
  45383. /**
  45384. * Launch the debugLayer.
  45385. * @param config Define the configuration of the inspector
  45386. * @return a promise fulfilled when the debug layer is visible
  45387. */
  45388. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45389. }
  45390. }
  45391. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45392. import { Nullable } from "babylonjs/types";
  45393. import { Scene } from "babylonjs/scene";
  45394. import { Vector4 } from "babylonjs/Maths/math.vector";
  45395. import { Color4 } from "babylonjs/Maths/math.color";
  45396. import { Mesh } from "babylonjs/Meshes/mesh";
  45397. /**
  45398. * Class containing static functions to help procedurally build meshes
  45399. */
  45400. export class BoxBuilder {
  45401. /**
  45402. * Creates a box mesh
  45403. * * The parameter `size` sets the size (float) of each box side (default 1)
  45404. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45405. * * 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)
  45406. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45410. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45411. * @param name defines the name of the mesh
  45412. * @param options defines the options used to create the mesh
  45413. * @param scene defines the hosting scene
  45414. * @returns the box mesh
  45415. */
  45416. static CreateBox(name: string, options: {
  45417. size?: number;
  45418. width?: number;
  45419. height?: number;
  45420. depth?: number;
  45421. faceUV?: Vector4[];
  45422. faceColors?: Color4[];
  45423. sideOrientation?: number;
  45424. frontUVs?: Vector4;
  45425. backUVs?: Vector4;
  45426. wrap?: boolean;
  45427. topBaseAt?: number;
  45428. bottomBaseAt?: number;
  45429. updatable?: boolean;
  45430. }, scene?: Nullable<Scene>): Mesh;
  45431. }
  45432. }
  45433. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45434. import { Vector4 } from "babylonjs/Maths/math.vector";
  45435. import { Mesh } from "babylonjs/Meshes/mesh";
  45436. import { Scene } from "babylonjs/scene";
  45437. import { Nullable } from "babylonjs/types";
  45438. /**
  45439. * Class containing static functions to help procedurally build meshes
  45440. */
  45441. export class SphereBuilder {
  45442. /**
  45443. * Creates a sphere mesh
  45444. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45445. * * 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`)
  45446. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45447. * * 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
  45448. * * 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)
  45449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45452. * @param name defines the name of the mesh
  45453. * @param options defines the options used to create the mesh
  45454. * @param scene defines the hosting scene
  45455. * @returns the sphere mesh
  45456. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45457. */
  45458. static CreateSphere(name: string, options: {
  45459. segments?: number;
  45460. diameter?: number;
  45461. diameterX?: number;
  45462. diameterY?: number;
  45463. diameterZ?: number;
  45464. arc?: number;
  45465. slice?: number;
  45466. sideOrientation?: number;
  45467. frontUVs?: Vector4;
  45468. backUVs?: Vector4;
  45469. updatable?: boolean;
  45470. }, scene?: Nullable<Scene>): Mesh;
  45471. }
  45472. }
  45473. declare module "babylonjs/Debug/physicsViewer" {
  45474. import { Nullable } from "babylonjs/types";
  45475. import { Scene } from "babylonjs/scene";
  45476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45477. import { Mesh } from "babylonjs/Meshes/mesh";
  45478. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45479. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45480. /**
  45481. * Used to show the physics impostor around the specific mesh
  45482. */
  45483. export class PhysicsViewer {
  45484. /** @hidden */
  45485. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45486. /** @hidden */
  45487. protected _meshes: Array<Nullable<AbstractMesh>>;
  45488. /** @hidden */
  45489. protected _scene: Nullable<Scene>;
  45490. /** @hidden */
  45491. protected _numMeshes: number;
  45492. /** @hidden */
  45493. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45494. private _renderFunction;
  45495. private _utilityLayer;
  45496. private _debugBoxMesh;
  45497. private _debugSphereMesh;
  45498. private _debugCylinderMesh;
  45499. private _debugMaterial;
  45500. private _debugMeshMeshes;
  45501. /**
  45502. * Creates a new PhysicsViewer
  45503. * @param scene defines the hosting scene
  45504. */
  45505. constructor(scene: Scene);
  45506. /** @hidden */
  45507. protected _updateDebugMeshes(): void;
  45508. /**
  45509. * Renders a specified physic impostor
  45510. * @param impostor defines the impostor to render
  45511. * @param targetMesh defines the mesh represented by the impostor
  45512. * @returns the new debug mesh used to render the impostor
  45513. */
  45514. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45515. /**
  45516. * Hides a specified physic impostor
  45517. * @param impostor defines the impostor to hide
  45518. */
  45519. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45520. private _getDebugMaterial;
  45521. private _getDebugBoxMesh;
  45522. private _getDebugSphereMesh;
  45523. private _getDebugCylinderMesh;
  45524. private _getDebugMeshMesh;
  45525. private _getDebugMesh;
  45526. /** Releases all resources */
  45527. dispose(): void;
  45528. }
  45529. }
  45530. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45531. import { Vector3 } from "babylonjs/Maths/math.vector";
  45532. import { Color4 } from "babylonjs/Maths/math.color";
  45533. import { Nullable } from "babylonjs/types";
  45534. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45535. import { Scene } from "babylonjs/scene";
  45536. /**
  45537. * Class containing static functions to help procedurally build meshes
  45538. */
  45539. export class LinesBuilder {
  45540. /**
  45541. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45542. * * 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
  45543. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45544. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45545. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45546. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45547. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45548. * * 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
  45549. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45551. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45552. * @param name defines the name of the new line system
  45553. * @param options defines the options used to create the line system
  45554. * @param scene defines the hosting scene
  45555. * @returns a new line system mesh
  45556. */
  45557. static CreateLineSystem(name: string, options: {
  45558. lines: Vector3[][];
  45559. updatable?: boolean;
  45560. instance?: Nullable<LinesMesh>;
  45561. colors?: Nullable<Color4[][]>;
  45562. useVertexAlpha?: boolean;
  45563. }, scene: Nullable<Scene>): LinesMesh;
  45564. /**
  45565. * Creates a line mesh
  45566. * 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
  45567. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45568. * * The parameter `points` is an array successive Vector3
  45569. * * 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
  45570. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45571. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45572. * * When updating an instance, remember that only point positions can change, not the number of points
  45573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45574. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45575. * @param name defines the name of the new line system
  45576. * @param options defines the options used to create the line system
  45577. * @param scene defines the hosting scene
  45578. * @returns a new line mesh
  45579. */
  45580. static CreateLines(name: string, options: {
  45581. points: Vector3[];
  45582. updatable?: boolean;
  45583. instance?: Nullable<LinesMesh>;
  45584. colors?: Color4[];
  45585. useVertexAlpha?: boolean;
  45586. }, scene?: Nullable<Scene>): LinesMesh;
  45587. /**
  45588. * Creates a dashed line mesh
  45589. * * 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
  45590. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45591. * * The parameter `points` is an array successive Vector3
  45592. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45593. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45594. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45595. * * 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
  45596. * * When updating an instance, remember that only point positions can change, not the number of points
  45597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45598. * @param name defines the name of the mesh
  45599. * @param options defines the options used to create the mesh
  45600. * @param scene defines the hosting scene
  45601. * @returns the dashed line mesh
  45602. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45603. */
  45604. static CreateDashedLines(name: string, options: {
  45605. points: Vector3[];
  45606. dashSize?: number;
  45607. gapSize?: number;
  45608. dashNb?: number;
  45609. updatable?: boolean;
  45610. instance?: LinesMesh;
  45611. }, scene?: Nullable<Scene>): LinesMesh;
  45612. }
  45613. }
  45614. declare module "babylonjs/Debug/rayHelper" {
  45615. import { Nullable } from "babylonjs/types";
  45616. import { Ray } from "babylonjs/Culling/ray";
  45617. import { Vector3 } from "babylonjs/Maths/math.vector";
  45618. import { Color3 } from "babylonjs/Maths/math.color";
  45619. import { Scene } from "babylonjs/scene";
  45620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45621. import "babylonjs/Meshes/Builders/linesBuilder";
  45622. /**
  45623. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45624. * in order to better appreciate the issue one might have.
  45625. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45626. */
  45627. export class RayHelper {
  45628. /**
  45629. * Defines the ray we are currently tryin to visualize.
  45630. */
  45631. ray: Nullable<Ray>;
  45632. private _renderPoints;
  45633. private _renderLine;
  45634. private _renderFunction;
  45635. private _scene;
  45636. private _updateToMeshFunction;
  45637. private _attachedToMesh;
  45638. private _meshSpaceDirection;
  45639. private _meshSpaceOrigin;
  45640. /**
  45641. * Helper function to create a colored helper in a scene in one line.
  45642. * @param ray Defines the ray we are currently tryin to visualize
  45643. * @param scene Defines the scene the ray is used in
  45644. * @param color Defines the color we want to see the ray in
  45645. * @returns The newly created ray helper.
  45646. */
  45647. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45648. /**
  45649. * Instantiate a new ray helper.
  45650. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45651. * in order to better appreciate the issue one might have.
  45652. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45653. * @param ray Defines the ray we are currently tryin to visualize
  45654. */
  45655. constructor(ray: Ray);
  45656. /**
  45657. * Shows the ray we are willing to debug.
  45658. * @param scene Defines the scene the ray needs to be rendered in
  45659. * @param color Defines the color the ray needs to be rendered in
  45660. */
  45661. show(scene: Scene, color?: Color3): void;
  45662. /**
  45663. * Hides the ray we are debugging.
  45664. */
  45665. hide(): void;
  45666. private _render;
  45667. /**
  45668. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45669. * @param mesh Defines the mesh we want the helper attached to
  45670. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45671. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45672. * @param length Defines the length of the ray
  45673. */
  45674. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45675. /**
  45676. * Detach the ray helper from the mesh it has previously been attached to.
  45677. */
  45678. detachFromMesh(): void;
  45679. private _updateToMesh;
  45680. /**
  45681. * Dispose the helper and release its associated resources.
  45682. */
  45683. dispose(): void;
  45684. }
  45685. }
  45686. declare module "babylonjs/Debug/skeletonViewer" {
  45687. import { Color3 } from "babylonjs/Maths/math.color";
  45688. import { Scene } from "babylonjs/scene";
  45689. import { Nullable } from "babylonjs/types";
  45690. import { Skeleton } from "babylonjs/Bones/skeleton";
  45691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45692. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45693. /**
  45694. * Class used to render a debug view of a given skeleton
  45695. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45696. */
  45697. export class SkeletonViewer {
  45698. /** defines the skeleton to render */
  45699. skeleton: Skeleton;
  45700. /** defines the mesh attached to the skeleton */
  45701. mesh: AbstractMesh;
  45702. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45703. autoUpdateBonesMatrices: boolean;
  45704. /** defines the rendering group id to use with the viewer */
  45705. renderingGroupId: number;
  45706. /** Gets or sets the color used to render the skeleton */
  45707. color: Color3;
  45708. private _scene;
  45709. private _debugLines;
  45710. private _debugMesh;
  45711. private _isEnabled;
  45712. private _renderFunction;
  45713. private _utilityLayer;
  45714. /**
  45715. * Returns the mesh used to render the bones
  45716. */
  45717. readonly debugMesh: Nullable<LinesMesh>;
  45718. /**
  45719. * Creates a new SkeletonViewer
  45720. * @param skeleton defines the skeleton to render
  45721. * @param mesh defines the mesh attached to the skeleton
  45722. * @param scene defines the hosting scene
  45723. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45724. * @param renderingGroupId defines the rendering group id to use with the viewer
  45725. */
  45726. constructor(
  45727. /** defines the skeleton to render */
  45728. skeleton: Skeleton,
  45729. /** defines the mesh attached to the skeleton */
  45730. mesh: AbstractMesh, scene: Scene,
  45731. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45732. autoUpdateBonesMatrices?: boolean,
  45733. /** defines the rendering group id to use with the viewer */
  45734. renderingGroupId?: number);
  45735. /** Gets or sets a boolean indicating if the viewer is enabled */
  45736. isEnabled: boolean;
  45737. private _getBonePosition;
  45738. private _getLinesForBonesWithLength;
  45739. private _getLinesForBonesNoLength;
  45740. /** Update the viewer to sync with current skeleton state */
  45741. update(): void;
  45742. /** Release associated resources */
  45743. dispose(): void;
  45744. }
  45745. }
  45746. declare module "babylonjs/Debug/index" {
  45747. export * from "babylonjs/Debug/axesViewer";
  45748. export * from "babylonjs/Debug/boneAxesViewer";
  45749. export * from "babylonjs/Debug/debugLayer";
  45750. export * from "babylonjs/Debug/physicsViewer";
  45751. export * from "babylonjs/Debug/rayHelper";
  45752. export * from "babylonjs/Debug/skeletonViewer";
  45753. }
  45754. declare module "babylonjs/Engines/nullEngine" {
  45755. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45756. import { Scene } from "babylonjs/scene";
  45757. import { Engine } from "babylonjs/Engines/engine";
  45758. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45759. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45760. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45761. import { Effect } from "babylonjs/Materials/effect";
  45762. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45763. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45764. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45765. /**
  45766. * Options to create the null engine
  45767. */
  45768. export class NullEngineOptions {
  45769. /**
  45770. * Render width (Default: 512)
  45771. */
  45772. renderWidth: number;
  45773. /**
  45774. * Render height (Default: 256)
  45775. */
  45776. renderHeight: number;
  45777. /**
  45778. * Texture size (Default: 512)
  45779. */
  45780. textureSize: number;
  45781. /**
  45782. * If delta time between frames should be constant
  45783. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45784. */
  45785. deterministicLockstep: boolean;
  45786. /**
  45787. * Maximum about of steps between frames (Default: 4)
  45788. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45789. */
  45790. lockstepMaxSteps: number;
  45791. }
  45792. /**
  45793. * The null engine class provides support for headless version of babylon.js.
  45794. * This can be used in server side scenario or for testing purposes
  45795. */
  45796. export class NullEngine extends Engine {
  45797. private _options;
  45798. /**
  45799. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45800. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45801. * @returns true if engine is in deterministic lock step mode
  45802. */
  45803. isDeterministicLockStep(): boolean;
  45804. /**
  45805. * Gets the max steps when engine is running in deterministic lock step
  45806. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45807. * @returns the max steps
  45808. */
  45809. getLockstepMaxSteps(): number;
  45810. /**
  45811. * Gets the current hardware scaling level.
  45812. * By default the hardware scaling level is computed from the window device ratio.
  45813. * 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.
  45814. * @returns a number indicating the current hardware scaling level
  45815. */
  45816. getHardwareScalingLevel(): number;
  45817. constructor(options?: NullEngineOptions);
  45818. /**
  45819. * Creates a vertex buffer
  45820. * @param vertices the data for the vertex buffer
  45821. * @returns the new WebGL static buffer
  45822. */
  45823. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45824. /**
  45825. * Creates a new index buffer
  45826. * @param indices defines the content of the index buffer
  45827. * @param updatable defines if the index buffer must be updatable
  45828. * @returns a new webGL buffer
  45829. */
  45830. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45831. /**
  45832. * Clear the current render buffer or the current render target (if any is set up)
  45833. * @param color defines the color to use
  45834. * @param backBuffer defines if the back buffer must be cleared
  45835. * @param depth defines if the depth buffer must be cleared
  45836. * @param stencil defines if the stencil buffer must be cleared
  45837. */
  45838. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45839. /**
  45840. * Gets the current render width
  45841. * @param useScreen defines if screen size must be used (or the current render target if any)
  45842. * @returns a number defining the current render width
  45843. */
  45844. getRenderWidth(useScreen?: boolean): number;
  45845. /**
  45846. * Gets the current render height
  45847. * @param useScreen defines if screen size must be used (or the current render target if any)
  45848. * @returns a number defining the current render height
  45849. */
  45850. getRenderHeight(useScreen?: boolean): number;
  45851. /**
  45852. * Set the WebGL's viewport
  45853. * @param viewport defines the viewport element to be used
  45854. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45855. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45856. */
  45857. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45858. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45859. /**
  45860. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45861. * @param pipelineContext defines the pipeline context to use
  45862. * @param uniformsNames defines the list of uniform names
  45863. * @returns an array of webGL uniform locations
  45864. */
  45865. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45866. /**
  45867. * Gets the lsit of active attributes for a given webGL program
  45868. * @param pipelineContext defines the pipeline context to use
  45869. * @param attributesNames defines the list of attribute names to get
  45870. * @returns an array of indices indicating the offset of each attribute
  45871. */
  45872. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45873. /**
  45874. * Binds an effect to the webGL context
  45875. * @param effect defines the effect to bind
  45876. */
  45877. bindSamplers(effect: Effect): void;
  45878. /**
  45879. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45880. * @param effect defines the effect to activate
  45881. */
  45882. enableEffect(effect: Effect): void;
  45883. /**
  45884. * Set various states to the webGL context
  45885. * @param culling defines backface culling state
  45886. * @param zOffset defines the value to apply to zOffset (0 by default)
  45887. * @param force defines if states must be applied even if cache is up to date
  45888. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45889. */
  45890. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45891. /**
  45892. * Set the value of an uniform to an array of int32
  45893. * @param uniform defines the webGL uniform location where to store the value
  45894. * @param array defines the array of int32 to store
  45895. */
  45896. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45897. /**
  45898. * Set the value of an uniform to an array of int32 (stored as vec2)
  45899. * @param uniform defines the webGL uniform location where to store the value
  45900. * @param array defines the array of int32 to store
  45901. */
  45902. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45903. /**
  45904. * Set the value of an uniform to an array of int32 (stored as vec3)
  45905. * @param uniform defines the webGL uniform location where to store the value
  45906. * @param array defines the array of int32 to store
  45907. */
  45908. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45909. /**
  45910. * Set the value of an uniform to an array of int32 (stored as vec4)
  45911. * @param uniform defines the webGL uniform location where to store the value
  45912. * @param array defines the array of int32 to store
  45913. */
  45914. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45915. /**
  45916. * Set the value of an uniform to an array of float32
  45917. * @param uniform defines the webGL uniform location where to store the value
  45918. * @param array defines the array of float32 to store
  45919. */
  45920. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45921. /**
  45922. * Set the value of an uniform to an array of float32 (stored as vec2)
  45923. * @param uniform defines the webGL uniform location where to store the value
  45924. * @param array defines the array of float32 to store
  45925. */
  45926. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45927. /**
  45928. * Set the value of an uniform to an array of float32 (stored as vec3)
  45929. * @param uniform defines the webGL uniform location where to store the value
  45930. * @param array defines the array of float32 to store
  45931. */
  45932. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45933. /**
  45934. * Set the value of an uniform to an array of float32 (stored as vec4)
  45935. * @param uniform defines the webGL uniform location where to store the value
  45936. * @param array defines the array of float32 to store
  45937. */
  45938. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45939. /**
  45940. * Set the value of an uniform to an array of number
  45941. * @param uniform defines the webGL uniform location where to store the value
  45942. * @param array defines the array of number to store
  45943. */
  45944. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45945. /**
  45946. * Set the value of an uniform to an array of number (stored as vec2)
  45947. * @param uniform defines the webGL uniform location where to store the value
  45948. * @param array defines the array of number to store
  45949. */
  45950. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45951. /**
  45952. * Set the value of an uniform to an array of number (stored as vec3)
  45953. * @param uniform defines the webGL uniform location where to store the value
  45954. * @param array defines the array of number to store
  45955. */
  45956. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45957. /**
  45958. * Set the value of an uniform to an array of number (stored as vec4)
  45959. * @param uniform defines the webGL uniform location where to store the value
  45960. * @param array defines the array of number to store
  45961. */
  45962. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45963. /**
  45964. * Set the value of an uniform to an array of float32 (stored as matrices)
  45965. * @param uniform defines the webGL uniform location where to store the value
  45966. * @param matrices defines the array of float32 to store
  45967. */
  45968. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45969. /**
  45970. * Set the value of an uniform to a matrix (3x3)
  45971. * @param uniform defines the webGL uniform location where to store the value
  45972. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45973. */
  45974. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45975. /**
  45976. * Set the value of an uniform to a matrix (2x2)
  45977. * @param uniform defines the webGL uniform location where to store the value
  45978. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45979. */
  45980. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45981. /**
  45982. * Set the value of an uniform to a number (float)
  45983. * @param uniform defines the webGL uniform location where to store the value
  45984. * @param value defines the float number to store
  45985. */
  45986. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45987. /**
  45988. * Set the value of an uniform to a vec2
  45989. * @param uniform defines the webGL uniform location where to store the value
  45990. * @param x defines the 1st component of the value
  45991. * @param y defines the 2nd component of the value
  45992. */
  45993. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45994. /**
  45995. * Set the value of an uniform to a vec3
  45996. * @param uniform defines the webGL uniform location where to store the value
  45997. * @param x defines the 1st component of the value
  45998. * @param y defines the 2nd component of the value
  45999. * @param z defines the 3rd component of the value
  46000. */
  46001. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46002. /**
  46003. * Set the value of an uniform to a boolean
  46004. * @param uniform defines the webGL uniform location where to store the value
  46005. * @param bool defines the boolean to store
  46006. */
  46007. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46008. /**
  46009. * Set the value of an uniform to a vec4
  46010. * @param uniform defines the webGL uniform location where to store the value
  46011. * @param x defines the 1st component of the value
  46012. * @param y defines the 2nd component of the value
  46013. * @param z defines the 3rd component of the value
  46014. * @param w defines the 4th component of the value
  46015. */
  46016. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46017. /**
  46018. * Sets the current alpha mode
  46019. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46020. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46021. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46022. */
  46023. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46024. /**
  46025. * Bind webGl buffers directly to the webGL context
  46026. * @param vertexBuffers defines the vertex buffer to bind
  46027. * @param indexBuffer defines the index buffer to bind
  46028. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46029. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46030. * @param effect defines the effect associated with the vertex buffer
  46031. */
  46032. bindBuffers(vertexBuffers: {
  46033. [key: string]: VertexBuffer;
  46034. }, indexBuffer: DataBuffer, effect: Effect): void;
  46035. /**
  46036. * Force the entire cache to be cleared
  46037. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46038. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46039. */
  46040. wipeCaches(bruteForce?: boolean): void;
  46041. /**
  46042. * Send a draw order
  46043. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46044. * @param indexStart defines the starting index
  46045. * @param indexCount defines the number of index to draw
  46046. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46047. */
  46048. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46049. /**
  46050. * Draw a list of indexed primitives
  46051. * @param fillMode defines the primitive to use
  46052. * @param indexStart defines the starting index
  46053. * @param indexCount defines the number of index to draw
  46054. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46055. */
  46056. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46057. /**
  46058. * Draw a list of unindexed primitives
  46059. * @param fillMode defines the primitive to use
  46060. * @param verticesStart defines the index of first vertex to draw
  46061. * @param verticesCount defines the count of vertices to draw
  46062. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46063. */
  46064. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46065. /** @hidden */
  46066. _createTexture(): WebGLTexture;
  46067. /** @hidden */
  46068. _releaseTexture(texture: InternalTexture): void;
  46069. /**
  46070. * Usually called from Texture.ts.
  46071. * Passed information to create a WebGLTexture
  46072. * @param urlArg defines a value which contains one of the following:
  46073. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46074. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46075. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46076. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46077. * @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)
  46078. * @param scene needed for loading to the correct scene
  46079. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46080. * @param onLoad optional callback to be called upon successful completion
  46081. * @param onError optional callback to be called upon failure
  46082. * @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
  46083. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46084. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46085. * @param forcedExtension defines the extension to use to pick the right loader
  46086. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46087. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46088. */
  46089. 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;
  46090. /**
  46091. * Creates a new render target texture
  46092. * @param size defines the size of the texture
  46093. * @param options defines the options used to create the texture
  46094. * @returns a new render target texture stored in an InternalTexture
  46095. */
  46096. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46097. /**
  46098. * Update the sampling mode of a given texture
  46099. * @param samplingMode defines the required sampling mode
  46100. * @param texture defines the texture to update
  46101. */
  46102. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46103. /**
  46104. * Binds the frame buffer to the specified texture.
  46105. * @param texture The texture to render to or null for the default canvas
  46106. * @param faceIndex The face of the texture to render to in case of cube texture
  46107. * @param requiredWidth The width of the target to render to
  46108. * @param requiredHeight The height of the target to render to
  46109. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46110. * @param depthStencilTexture The depth stencil texture to use to render
  46111. * @param lodLevel defines le lod level to bind to the frame buffer
  46112. */
  46113. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46114. /**
  46115. * Unbind the current render target texture from the webGL context
  46116. * @param texture defines the render target texture to unbind
  46117. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46118. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46119. */
  46120. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46121. /**
  46122. * Creates a dynamic vertex buffer
  46123. * @param vertices the data for the dynamic vertex buffer
  46124. * @returns the new WebGL dynamic buffer
  46125. */
  46126. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46127. /**
  46128. * Update the content of a dynamic texture
  46129. * @param texture defines the texture to update
  46130. * @param canvas defines the canvas containing the source
  46131. * @param invertY defines if data must be stored with Y axis inverted
  46132. * @param premulAlpha defines if alpha is stored as premultiplied
  46133. * @param format defines the format of the data
  46134. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46135. */
  46136. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46137. /**
  46138. * Gets a boolean indicating if all created effects are ready
  46139. * @returns true if all effects are ready
  46140. */
  46141. areAllEffectsReady(): boolean;
  46142. /**
  46143. * @hidden
  46144. * Get the current error code of the webGL context
  46145. * @returns the error code
  46146. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46147. */
  46148. getError(): number;
  46149. /** @hidden */
  46150. _getUnpackAlignement(): number;
  46151. /** @hidden */
  46152. _unpackFlipY(value: boolean): void;
  46153. /**
  46154. * Update a dynamic index buffer
  46155. * @param indexBuffer defines the target index buffer
  46156. * @param indices defines the data to update
  46157. * @param offset defines the offset in the target index buffer where update should start
  46158. */
  46159. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46160. /**
  46161. * Updates a dynamic vertex buffer.
  46162. * @param vertexBuffer the vertex buffer to update
  46163. * @param vertices the data used to update the vertex buffer
  46164. * @param byteOffset the byte offset of the data (optional)
  46165. * @param byteLength the byte length of the data (optional)
  46166. */
  46167. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46168. /** @hidden */
  46169. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46170. /** @hidden */
  46171. _bindTexture(channel: number, texture: InternalTexture): void;
  46172. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46173. /**
  46174. * 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
  46175. */
  46176. releaseEffects(): void;
  46177. displayLoadingUI(): void;
  46178. hideLoadingUI(): void;
  46179. /** @hidden */
  46180. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46181. /** @hidden */
  46182. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46183. /** @hidden */
  46184. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46185. /** @hidden */
  46186. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46187. }
  46188. }
  46189. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  46190. import { Nullable, int } from "babylonjs/types";
  46191. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  46192. /** @hidden */
  46193. export class _OcclusionDataStorage {
  46194. /** @hidden */
  46195. occlusionInternalRetryCounter: number;
  46196. /** @hidden */
  46197. isOcclusionQueryInProgress: boolean;
  46198. /** @hidden */
  46199. isOccluded: boolean;
  46200. /** @hidden */
  46201. occlusionRetryCount: number;
  46202. /** @hidden */
  46203. occlusionType: number;
  46204. /** @hidden */
  46205. occlusionQueryAlgorithmType: number;
  46206. }
  46207. module "babylonjs/Engines/engine" {
  46208. interface Engine {
  46209. /**
  46210. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46211. * @return the new query
  46212. */
  46213. createQuery(): WebGLQuery;
  46214. /**
  46215. * Delete and release a webGL query
  46216. * @param query defines the query to delete
  46217. * @return the current engine
  46218. */
  46219. deleteQuery(query: WebGLQuery): Engine;
  46220. /**
  46221. * Check if a given query has resolved and got its value
  46222. * @param query defines the query to check
  46223. * @returns true if the query got its value
  46224. */
  46225. isQueryResultAvailable(query: WebGLQuery): boolean;
  46226. /**
  46227. * Gets the value of a given query
  46228. * @param query defines the query to check
  46229. * @returns the value of the query
  46230. */
  46231. getQueryResult(query: WebGLQuery): number;
  46232. /**
  46233. * Initiates an occlusion query
  46234. * @param algorithmType defines the algorithm to use
  46235. * @param query defines the query to use
  46236. * @returns the current engine
  46237. * @see http://doc.babylonjs.com/features/occlusionquery
  46238. */
  46239. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46240. /**
  46241. * Ends an occlusion query
  46242. * @see http://doc.babylonjs.com/features/occlusionquery
  46243. * @param algorithmType defines the algorithm to use
  46244. * @returns the current engine
  46245. */
  46246. endOcclusionQuery(algorithmType: number): Engine;
  46247. /**
  46248. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46249. * Please note that only one query can be issued at a time
  46250. * @returns a time token used to track the time span
  46251. */
  46252. startTimeQuery(): Nullable<_TimeToken>;
  46253. /**
  46254. * Ends a time query
  46255. * @param token defines the token used to measure the time span
  46256. * @returns the time spent (in ns)
  46257. */
  46258. endTimeQuery(token: _TimeToken): int;
  46259. /** @hidden */
  46260. _currentNonTimestampToken: Nullable<_TimeToken>;
  46261. /** @hidden */
  46262. _createTimeQuery(): WebGLQuery;
  46263. /** @hidden */
  46264. _deleteTimeQuery(query: WebGLQuery): void;
  46265. /** @hidden */
  46266. _getGlAlgorithmType(algorithmType: number): number;
  46267. /** @hidden */
  46268. _getTimeQueryResult(query: WebGLQuery): any;
  46269. /** @hidden */
  46270. _getTimeQueryAvailability(query: WebGLQuery): any;
  46271. }
  46272. }
  46273. module "babylonjs/Meshes/abstractMesh" {
  46274. interface AbstractMesh {
  46275. /**
  46276. * Backing filed
  46277. * @hidden
  46278. */
  46279. __occlusionDataStorage: _OcclusionDataStorage;
  46280. /**
  46281. * Access property
  46282. * @hidden
  46283. */
  46284. _occlusionDataStorage: _OcclusionDataStorage;
  46285. /**
  46286. * 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.
  46287. * The default value is -1 which means don't break the query and wait till the result
  46288. * @see http://doc.babylonjs.com/features/occlusionquery
  46289. */
  46290. occlusionRetryCount: number;
  46291. /**
  46292. * 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:
  46293. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46294. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46295. * * 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.
  46296. * @see http://doc.babylonjs.com/features/occlusionquery
  46297. */
  46298. occlusionType: number;
  46299. /**
  46300. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46301. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46302. * * 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.
  46303. * @see http://doc.babylonjs.com/features/occlusionquery
  46304. */
  46305. occlusionQueryAlgorithmType: number;
  46306. /**
  46307. * 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
  46308. * @see http://doc.babylonjs.com/features/occlusionquery
  46309. */
  46310. isOccluded: boolean;
  46311. /**
  46312. * Flag to check the progress status of the query
  46313. * @see http://doc.babylonjs.com/features/occlusionquery
  46314. */
  46315. isOcclusionQueryInProgress: boolean;
  46316. }
  46317. }
  46318. }
  46319. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  46320. import { Nullable } from "babylonjs/types";
  46321. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46322. /** @hidden */
  46323. export var _forceTransformFeedbackToBundle: boolean;
  46324. module "babylonjs/Engines/engine" {
  46325. interface Engine {
  46326. /**
  46327. * Creates a webGL transform feedback object
  46328. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46329. * @returns the webGL transform feedback object
  46330. */
  46331. createTransformFeedback(): WebGLTransformFeedback;
  46332. /**
  46333. * Delete a webGL transform feedback object
  46334. * @param value defines the webGL transform feedback object to delete
  46335. */
  46336. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46337. /**
  46338. * Bind a webGL transform feedback object to the webgl context
  46339. * @param value defines the webGL transform feedback object to bind
  46340. */
  46341. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46342. /**
  46343. * Begins a transform feedback operation
  46344. * @param usePoints defines if points or triangles must be used
  46345. */
  46346. beginTransformFeedback(usePoints: boolean): void;
  46347. /**
  46348. * Ends a transform feedback operation
  46349. */
  46350. endTransformFeedback(): void;
  46351. /**
  46352. * Specify the varyings to use with transform feedback
  46353. * @param program defines the associated webGL program
  46354. * @param value defines the list of strings representing the varying names
  46355. */
  46356. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46357. /**
  46358. * Bind a webGL buffer for a transform feedback operation
  46359. * @param value defines the webGL buffer to bind
  46360. */
  46361. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46362. }
  46363. }
  46364. }
  46365. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46366. import { Scene } from "babylonjs/scene";
  46367. import { Engine } from "babylonjs/Engines/engine";
  46368. import { Texture } from "babylonjs/Materials/Textures/texture";
  46369. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46370. import "babylonjs/Engines/Extensions/engine.multiRender";
  46371. /**
  46372. * Creation options of the multi render target texture.
  46373. */
  46374. export interface IMultiRenderTargetOptions {
  46375. /**
  46376. * Define if the texture needs to create mip maps after render.
  46377. */
  46378. generateMipMaps?: boolean;
  46379. /**
  46380. * Define the types of all the draw buffers we want to create
  46381. */
  46382. types?: number[];
  46383. /**
  46384. * Define the sampling modes of all the draw buffers we want to create
  46385. */
  46386. samplingModes?: number[];
  46387. /**
  46388. * Define if a depth buffer is required
  46389. */
  46390. generateDepthBuffer?: boolean;
  46391. /**
  46392. * Define if a stencil buffer is required
  46393. */
  46394. generateStencilBuffer?: boolean;
  46395. /**
  46396. * Define if a depth texture is required instead of a depth buffer
  46397. */
  46398. generateDepthTexture?: boolean;
  46399. /**
  46400. * Define the number of desired draw buffers
  46401. */
  46402. textureCount?: number;
  46403. /**
  46404. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46405. */
  46406. doNotChangeAspectRatio?: boolean;
  46407. /**
  46408. * Define the default type of the buffers we are creating
  46409. */
  46410. defaultType?: number;
  46411. }
  46412. /**
  46413. * A multi render target, like a render target provides the ability to render to a texture.
  46414. * Unlike the render target, it can render to several draw buffers in one draw.
  46415. * This is specially interesting in deferred rendering or for any effects requiring more than
  46416. * just one color from a single pass.
  46417. */
  46418. export class MultiRenderTarget extends RenderTargetTexture {
  46419. private _internalTextures;
  46420. private _textures;
  46421. private _multiRenderTargetOptions;
  46422. /**
  46423. * Get if draw buffers are currently supported by the used hardware and browser.
  46424. */
  46425. readonly isSupported: boolean;
  46426. /**
  46427. * Get the list of textures generated by the multi render target.
  46428. */
  46429. readonly textures: Texture[];
  46430. /**
  46431. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46432. */
  46433. readonly depthTexture: Texture;
  46434. /**
  46435. * Set the wrapping mode on U of all the textures we are rendering to.
  46436. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46437. */
  46438. wrapU: number;
  46439. /**
  46440. * Set the wrapping mode on V of all the textures we are rendering to.
  46441. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46442. */
  46443. wrapV: number;
  46444. /**
  46445. * Instantiate a new multi render target texture.
  46446. * A multi render target, like a render target provides the ability to render to a texture.
  46447. * Unlike the render target, it can render to several draw buffers in one draw.
  46448. * This is specially interesting in deferred rendering or for any effects requiring more than
  46449. * just one color from a single pass.
  46450. * @param name Define the name of the texture
  46451. * @param size Define the size of the buffers to render to
  46452. * @param count Define the number of target we are rendering into
  46453. * @param scene Define the scene the texture belongs to
  46454. * @param options Define the options used to create the multi render target
  46455. */
  46456. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46457. /** @hidden */
  46458. _rebuild(): void;
  46459. private _createInternalTextures;
  46460. private _createTextures;
  46461. /**
  46462. * Define the number of samples used if MSAA is enabled.
  46463. */
  46464. samples: number;
  46465. /**
  46466. * Resize all the textures in the multi render target.
  46467. * Be carrefull as it will recreate all the data in the new texture.
  46468. * @param size Define the new size
  46469. */
  46470. resize(size: any): void;
  46471. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46472. /**
  46473. * Dispose the render targets and their associated resources
  46474. */
  46475. dispose(): void;
  46476. /**
  46477. * Release all the underlying texture used as draw buffers.
  46478. */
  46479. releaseInternalTextures(): void;
  46480. }
  46481. }
  46482. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46483. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46484. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46485. import { Nullable } from "babylonjs/types";
  46486. module "babylonjs/Engines/thinEngine" {
  46487. interface ThinEngine {
  46488. /**
  46489. * Unbind a list of render target textures from the webGL context
  46490. * This is used only when drawBuffer extension or webGL2 are active
  46491. * @param textures defines the render target textures to unbind
  46492. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46493. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46494. */
  46495. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46496. /**
  46497. * Create a multi render target texture
  46498. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46499. * @param size defines the size of the texture
  46500. * @param options defines the creation options
  46501. * @returns the cube texture as an InternalTexture
  46502. */
  46503. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46504. /**
  46505. * Update the sample count for a given multiple render target texture
  46506. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46507. * @param textures defines the textures to update
  46508. * @param samples defines the sample count to set
  46509. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46510. */
  46511. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46512. }
  46513. }
  46514. }
  46515. declare module "babylonjs/Engines/Extensions/engine.views" {
  46516. import { Camera } from "babylonjs/Cameras/camera";
  46517. import { Nullable } from "babylonjs/types";
  46518. /**
  46519. * Class used to define an additional view for the engine
  46520. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46521. */
  46522. export class EngineView {
  46523. /** Defines the canvas where to render the view */
  46524. target: HTMLCanvasElement;
  46525. /** Defines an optional camera used to render the view (will use active camera else) */
  46526. camera?: Camera;
  46527. }
  46528. module "babylonjs/Engines/engine" {
  46529. interface Engine {
  46530. /**
  46531. * Gets or sets the HTML element to use for attaching events
  46532. */
  46533. inputElement: Nullable<HTMLElement>;
  46534. /**
  46535. * Gets the current engine view
  46536. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46537. */
  46538. activeView: Nullable<EngineView>;
  46539. /** Gets or sets the list of views */
  46540. views: EngineView[];
  46541. /**
  46542. * Register a new child canvas
  46543. * @param canvas defines the canvas to register
  46544. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46545. * @returns the associated view
  46546. */
  46547. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46548. /**
  46549. * Remove a registered child canvas
  46550. * @param canvas defines the canvas to remove
  46551. * @returns the current engine
  46552. */
  46553. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46554. }
  46555. }
  46556. }
  46557. declare module "babylonjs/Engines/Extensions/index" {
  46558. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46559. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46560. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46561. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46562. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46563. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46564. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46565. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46566. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46567. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46568. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46569. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46570. export * from "babylonjs/Engines/Extensions/engine.views";
  46571. }
  46572. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46573. import { Nullable } from "babylonjs/types";
  46574. /**
  46575. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46576. */
  46577. export interface CubeMapInfo {
  46578. /**
  46579. * The pixel array for the front face.
  46580. * This is stored in format, left to right, up to down format.
  46581. */
  46582. front: Nullable<ArrayBufferView>;
  46583. /**
  46584. * The pixel array for the back face.
  46585. * This is stored in format, left to right, up to down format.
  46586. */
  46587. back: Nullable<ArrayBufferView>;
  46588. /**
  46589. * The pixel array for the left face.
  46590. * This is stored in format, left to right, up to down format.
  46591. */
  46592. left: Nullable<ArrayBufferView>;
  46593. /**
  46594. * The pixel array for the right face.
  46595. * This is stored in format, left to right, up to down format.
  46596. */
  46597. right: Nullable<ArrayBufferView>;
  46598. /**
  46599. * The pixel array for the up face.
  46600. * This is stored in format, left to right, up to down format.
  46601. */
  46602. up: Nullable<ArrayBufferView>;
  46603. /**
  46604. * The pixel array for the down face.
  46605. * This is stored in format, left to right, up to down format.
  46606. */
  46607. down: Nullable<ArrayBufferView>;
  46608. /**
  46609. * The size of the cubemap stored.
  46610. *
  46611. * Each faces will be size * size pixels.
  46612. */
  46613. size: number;
  46614. /**
  46615. * The format of the texture.
  46616. *
  46617. * RGBA, RGB.
  46618. */
  46619. format: number;
  46620. /**
  46621. * The type of the texture data.
  46622. *
  46623. * UNSIGNED_INT, FLOAT.
  46624. */
  46625. type: number;
  46626. /**
  46627. * Specifies whether the texture is in gamma space.
  46628. */
  46629. gammaSpace: boolean;
  46630. }
  46631. /**
  46632. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46633. */
  46634. export class PanoramaToCubeMapTools {
  46635. private static FACE_FRONT;
  46636. private static FACE_BACK;
  46637. private static FACE_RIGHT;
  46638. private static FACE_LEFT;
  46639. private static FACE_DOWN;
  46640. private static FACE_UP;
  46641. /**
  46642. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46643. *
  46644. * @param float32Array The source data.
  46645. * @param inputWidth The width of the input panorama.
  46646. * @param inputHeight The height of the input panorama.
  46647. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46648. * @return The cubemap data
  46649. */
  46650. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46651. private static CreateCubemapTexture;
  46652. private static CalcProjectionSpherical;
  46653. }
  46654. }
  46655. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46656. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46657. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46658. import { Nullable } from "babylonjs/types";
  46659. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46660. /**
  46661. * Helper class dealing with the extraction of spherical polynomial dataArray
  46662. * from a cube map.
  46663. */
  46664. export class CubeMapToSphericalPolynomialTools {
  46665. private static FileFaces;
  46666. /**
  46667. * Converts a texture to the according Spherical Polynomial data.
  46668. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46669. *
  46670. * @param texture The texture to extract the information from.
  46671. * @return The Spherical Polynomial data.
  46672. */
  46673. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46674. /**
  46675. * Converts a cubemap to the according Spherical Polynomial data.
  46676. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46677. *
  46678. * @param cubeInfo The Cube map to extract the information from.
  46679. * @return The Spherical Polynomial data.
  46680. */
  46681. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46682. }
  46683. }
  46684. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46685. import { Nullable } from "babylonjs/types";
  46686. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46687. module "babylonjs/Materials/Textures/baseTexture" {
  46688. interface BaseTexture {
  46689. /**
  46690. * Get the polynomial representation of the texture data.
  46691. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46692. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46693. */
  46694. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46695. }
  46696. }
  46697. }
  46698. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46699. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46700. /** @hidden */
  46701. export var rgbdEncodePixelShader: {
  46702. name: string;
  46703. shader: string;
  46704. };
  46705. }
  46706. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46707. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46708. /** @hidden */
  46709. export var rgbdDecodePixelShader: {
  46710. name: string;
  46711. shader: string;
  46712. };
  46713. }
  46714. declare module "babylonjs/Misc/environmentTextureTools" {
  46715. import { Nullable } from "babylonjs/types";
  46716. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46717. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46718. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46719. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46720. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46721. import "babylonjs/Shaders/rgbdEncode.fragment";
  46722. import "babylonjs/Shaders/rgbdDecode.fragment";
  46723. /**
  46724. * Raw texture data and descriptor sufficient for WebGL texture upload
  46725. */
  46726. export interface EnvironmentTextureInfo {
  46727. /**
  46728. * Version of the environment map
  46729. */
  46730. version: number;
  46731. /**
  46732. * Width of image
  46733. */
  46734. width: number;
  46735. /**
  46736. * Irradiance information stored in the file.
  46737. */
  46738. irradiance: any;
  46739. /**
  46740. * Specular information stored in the file.
  46741. */
  46742. specular: any;
  46743. }
  46744. /**
  46745. * Defines One Image in the file. It requires only the position in the file
  46746. * as well as the length.
  46747. */
  46748. interface BufferImageData {
  46749. /**
  46750. * Length of the image data.
  46751. */
  46752. length: number;
  46753. /**
  46754. * Position of the data from the null terminator delimiting the end of the JSON.
  46755. */
  46756. position: number;
  46757. }
  46758. /**
  46759. * Defines the specular data enclosed in the file.
  46760. * This corresponds to the version 1 of the data.
  46761. */
  46762. export interface EnvironmentTextureSpecularInfoV1 {
  46763. /**
  46764. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46765. */
  46766. specularDataPosition?: number;
  46767. /**
  46768. * This contains all the images data needed to reconstruct the cubemap.
  46769. */
  46770. mipmaps: Array<BufferImageData>;
  46771. /**
  46772. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46773. */
  46774. lodGenerationScale: number;
  46775. }
  46776. /**
  46777. * Sets of helpers addressing the serialization and deserialization of environment texture
  46778. * stored in a BabylonJS env file.
  46779. * Those files are usually stored as .env files.
  46780. */
  46781. export class EnvironmentTextureTools {
  46782. /**
  46783. * Magic number identifying the env file.
  46784. */
  46785. private static _MagicBytes;
  46786. /**
  46787. * Gets the environment info from an env file.
  46788. * @param data The array buffer containing the .env bytes.
  46789. * @returns the environment file info (the json header) if successfully parsed.
  46790. */
  46791. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46792. /**
  46793. * Creates an environment texture from a loaded cube texture.
  46794. * @param texture defines the cube texture to convert in env file
  46795. * @return a promise containing the environment data if succesfull.
  46796. */
  46797. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46798. /**
  46799. * Creates a JSON representation of the spherical data.
  46800. * @param texture defines the texture containing the polynomials
  46801. * @return the JSON representation of the spherical info
  46802. */
  46803. private static _CreateEnvTextureIrradiance;
  46804. /**
  46805. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46806. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46807. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46808. * @return the views described by info providing access to the underlying buffer
  46809. */
  46810. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46811. /**
  46812. * Uploads the texture info contained in the env file to the GPU.
  46813. * @param texture defines the internal texture to upload to
  46814. * @param arrayBuffer defines the buffer cotaining the data to load
  46815. * @param info defines the texture info retrieved through the GetEnvInfo method
  46816. * @returns a promise
  46817. */
  46818. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46819. private static _OnImageReadyAsync;
  46820. /**
  46821. * Uploads the levels of image data to the GPU.
  46822. * @param texture defines the internal texture to upload to
  46823. * @param imageData defines the array buffer views of image data [mipmap][face]
  46824. * @returns a promise
  46825. */
  46826. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46827. /**
  46828. * Uploads spherical polynomials information to the texture.
  46829. * @param texture defines the texture we are trying to upload the information to
  46830. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46831. */
  46832. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46833. /** @hidden */
  46834. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46835. }
  46836. }
  46837. declare module "babylonjs/Maths/math.vertexFormat" {
  46838. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46839. /**
  46840. * Contains position and normal vectors for a vertex
  46841. */
  46842. export class PositionNormalVertex {
  46843. /** the position of the vertex (defaut: 0,0,0) */
  46844. position: Vector3;
  46845. /** the normal of the vertex (defaut: 0,1,0) */
  46846. normal: Vector3;
  46847. /**
  46848. * Creates a PositionNormalVertex
  46849. * @param position the position of the vertex (defaut: 0,0,0)
  46850. * @param normal the normal of the vertex (defaut: 0,1,0)
  46851. */
  46852. constructor(
  46853. /** the position of the vertex (defaut: 0,0,0) */
  46854. position?: Vector3,
  46855. /** the normal of the vertex (defaut: 0,1,0) */
  46856. normal?: Vector3);
  46857. /**
  46858. * Clones the PositionNormalVertex
  46859. * @returns the cloned PositionNormalVertex
  46860. */
  46861. clone(): PositionNormalVertex;
  46862. }
  46863. /**
  46864. * Contains position, normal and uv vectors for a vertex
  46865. */
  46866. export class PositionNormalTextureVertex {
  46867. /** the position of the vertex (defaut: 0,0,0) */
  46868. position: Vector3;
  46869. /** the normal of the vertex (defaut: 0,1,0) */
  46870. normal: Vector3;
  46871. /** the uv of the vertex (default: 0,0) */
  46872. uv: Vector2;
  46873. /**
  46874. * Creates a PositionNormalTextureVertex
  46875. * @param position the position of the vertex (defaut: 0,0,0)
  46876. * @param normal the normal of the vertex (defaut: 0,1,0)
  46877. * @param uv the uv of the vertex (default: 0,0)
  46878. */
  46879. constructor(
  46880. /** the position of the vertex (defaut: 0,0,0) */
  46881. position?: Vector3,
  46882. /** the normal of the vertex (defaut: 0,1,0) */
  46883. normal?: Vector3,
  46884. /** the uv of the vertex (default: 0,0) */
  46885. uv?: Vector2);
  46886. /**
  46887. * Clones the PositionNormalTextureVertex
  46888. * @returns the cloned PositionNormalTextureVertex
  46889. */
  46890. clone(): PositionNormalTextureVertex;
  46891. }
  46892. }
  46893. declare module "babylonjs/Maths/math" {
  46894. export * from "babylonjs/Maths/math.axis";
  46895. export * from "babylonjs/Maths/math.color";
  46896. export * from "babylonjs/Maths/math.constants";
  46897. export * from "babylonjs/Maths/math.frustum";
  46898. export * from "babylonjs/Maths/math.path";
  46899. export * from "babylonjs/Maths/math.plane";
  46900. export * from "babylonjs/Maths/math.size";
  46901. export * from "babylonjs/Maths/math.vector";
  46902. export * from "babylonjs/Maths/math.vertexFormat";
  46903. export * from "babylonjs/Maths/math.viewport";
  46904. }
  46905. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46906. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46907. /** @hidden */
  46908. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46909. private _genericAttributeLocation;
  46910. private _varyingLocationCount;
  46911. private _varyingLocationMap;
  46912. private _replacements;
  46913. private _textureCount;
  46914. private _uniforms;
  46915. lineProcessor(line: string): string;
  46916. attributeProcessor(attribute: string): string;
  46917. varyingProcessor(varying: string, isFragment: boolean): string;
  46918. uniformProcessor(uniform: string): string;
  46919. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46920. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46921. }
  46922. }
  46923. declare module "babylonjs/Engines/nativeEngine" {
  46924. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46925. import { Engine } from "babylonjs/Engines/engine";
  46926. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46927. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46928. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46929. import { Effect } from "babylonjs/Materials/effect";
  46930. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46931. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46932. import { Scene } from "babylonjs/scene";
  46933. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46934. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46935. /**
  46936. * Container for accessors for natively-stored mesh data buffers.
  46937. */
  46938. class NativeDataBuffer extends DataBuffer {
  46939. /**
  46940. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46941. */
  46942. nativeIndexBuffer?: any;
  46943. /**
  46944. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46945. */
  46946. nativeVertexBuffer?: any;
  46947. }
  46948. /** @hidden */
  46949. class NativeTexture extends InternalTexture {
  46950. getInternalTexture(): InternalTexture;
  46951. getViewCount(): number;
  46952. }
  46953. /** @hidden */
  46954. export class NativeEngine extends Engine {
  46955. private readonly _native;
  46956. getHardwareScalingLevel(): number;
  46957. constructor();
  46958. /**
  46959. * Can be used to override the current requestAnimationFrame requester.
  46960. * @hidden
  46961. */
  46962. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  46963. /**
  46964. * Override default engine behavior.
  46965. * @param color
  46966. * @param backBuffer
  46967. * @param depth
  46968. * @param stencil
  46969. */
  46970. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  46971. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46972. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46973. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46974. recordVertexArrayObject(vertexBuffers: {
  46975. [key: string]: VertexBuffer;
  46976. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46977. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46978. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46979. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46980. /**
  46981. * Draw a list of indexed primitives
  46982. * @param fillMode defines the primitive to use
  46983. * @param indexStart defines the starting index
  46984. * @param indexCount defines the number of index to draw
  46985. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46986. */
  46987. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46988. /**
  46989. * Draw a list of unindexed primitives
  46990. * @param fillMode defines the primitive to use
  46991. * @param verticesStart defines the index of first vertex to draw
  46992. * @param verticesCount defines the count of vertices to draw
  46993. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46994. */
  46995. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46996. createPipelineContext(): IPipelineContext;
  46997. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46998. /** @hidden */
  46999. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47000. /** @hidden */
  47001. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47002. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47003. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47004. protected _setProgram(program: WebGLProgram): void;
  47005. _releaseEffect(effect: Effect): void;
  47006. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47007. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47008. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47009. bindSamplers(effect: Effect): void;
  47010. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47011. getRenderWidth(useScreen?: boolean): number;
  47012. getRenderHeight(useScreen?: boolean): number;
  47013. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47014. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47015. /**
  47016. * Set the z offset to apply to current rendering
  47017. * @param value defines the offset to apply
  47018. */
  47019. setZOffset(value: number): void;
  47020. /**
  47021. * Gets the current value of the zOffset
  47022. * @returns the current zOffset state
  47023. */
  47024. getZOffset(): number;
  47025. /**
  47026. * Enable or disable depth buffering
  47027. * @param enable defines the state to set
  47028. */
  47029. setDepthBuffer(enable: boolean): void;
  47030. /**
  47031. * Gets a boolean indicating if depth writing is enabled
  47032. * @returns the current depth writing state
  47033. */
  47034. getDepthWrite(): boolean;
  47035. /**
  47036. * Enable or disable depth writing
  47037. * @param enable defines the state to set
  47038. */
  47039. setDepthWrite(enable: boolean): void;
  47040. /**
  47041. * Enable or disable color writing
  47042. * @param enable defines the state to set
  47043. */
  47044. setColorWrite(enable: boolean): void;
  47045. /**
  47046. * Gets a boolean indicating if color writing is enabled
  47047. * @returns the current color writing state
  47048. */
  47049. getColorWrite(): boolean;
  47050. /**
  47051. * Sets alpha constants used by some alpha blending modes
  47052. * @param r defines the red component
  47053. * @param g defines the green component
  47054. * @param b defines the blue component
  47055. * @param a defines the alpha component
  47056. */
  47057. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47058. /**
  47059. * Sets the current alpha mode
  47060. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47061. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47062. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47063. */
  47064. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47065. /**
  47066. * Gets the current alpha mode
  47067. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47068. * @returns the current alpha mode
  47069. */
  47070. getAlphaMode(): number;
  47071. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47072. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47073. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47074. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47075. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47076. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47077. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47078. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47079. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47080. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47081. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47082. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47083. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47084. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47085. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47086. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47087. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47088. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47089. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47090. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47091. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47092. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47093. wipeCaches(bruteForce?: boolean): void;
  47094. _createTexture(): WebGLTexture;
  47095. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47096. /**
  47097. * Usually called from BABYLON.Texture.ts.
  47098. * Passed information to create a WebGLTexture
  47099. * @param urlArg defines a value which contains one of the following:
  47100. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47101. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47102. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47103. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47104. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47105. * @param scene needed for loading to the correct scene
  47106. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47107. * @param onLoad optional callback to be called upon successful completion
  47108. * @param onError optional callback to be called upon failure
  47109. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47110. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47111. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47112. * @param forcedExtension defines the extension to use to pick the right loader
  47113. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47114. */
  47115. 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;
  47116. /**
  47117. * Creates a cube texture
  47118. * @param rootUrl defines the url where the files to load is located
  47119. * @param scene defines the current scene
  47120. * @param files defines the list of files to load (1 per face)
  47121. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47122. * @param onLoad defines an optional callback raised when the texture is loaded
  47123. * @param onError defines an optional callback raised if there is an issue to load the texture
  47124. * @param format defines the format of the data
  47125. * @param forcedExtension defines the extension to use to pick the right loader
  47126. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47127. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47128. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47129. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47130. * @returns the cube texture as an InternalTexture
  47131. */
  47132. 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;
  47133. private _getSamplingFilter;
  47134. private static _GetNativeTextureFormat;
  47135. createRenderTargetTexture(size: number | {
  47136. width: number;
  47137. height: number;
  47138. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47139. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47140. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47141. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47142. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47143. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47144. /**
  47145. * Updates a dynamic vertex buffer.
  47146. * @param vertexBuffer the vertex buffer to update
  47147. * @param data the data used to update the vertex buffer
  47148. * @param byteOffset the byte offset of the data (optional)
  47149. * @param byteLength the byte length of the data (optional)
  47150. */
  47151. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47152. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47153. private _updateAnisotropicLevel;
  47154. private _getAddressMode;
  47155. /** @hidden */
  47156. _bindTexture(channel: number, texture: InternalTexture): void;
  47157. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47158. releaseEffects(): void;
  47159. /** @hidden */
  47160. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47161. /** @hidden */
  47162. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47163. /** @hidden */
  47164. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47165. /** @hidden */
  47166. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47167. }
  47168. }
  47169. declare module "babylonjs/Engines/index" {
  47170. export * from "babylonjs/Engines/constants";
  47171. export * from "babylonjs/Engines/engineCapabilities";
  47172. export * from "babylonjs/Engines/instancingAttributeInfo";
  47173. export * from "babylonjs/Engines/thinEngine";
  47174. export * from "babylonjs/Engines/engine";
  47175. export * from "babylonjs/Engines/engineStore";
  47176. export * from "babylonjs/Engines/nullEngine";
  47177. export * from "babylonjs/Engines/Extensions/index";
  47178. export * from "babylonjs/Engines/IPipelineContext";
  47179. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  47180. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47181. export * from "babylonjs/Engines/nativeEngine";
  47182. }
  47183. declare module "babylonjs/Events/clipboardEvents" {
  47184. /**
  47185. * Gather the list of clipboard event types as constants.
  47186. */
  47187. export class ClipboardEventTypes {
  47188. /**
  47189. * The clipboard event is fired when a copy command is active (pressed).
  47190. */
  47191. static readonly COPY: number;
  47192. /**
  47193. * The clipboard event is fired when a cut command is active (pressed).
  47194. */
  47195. static readonly CUT: number;
  47196. /**
  47197. * The clipboard event is fired when a paste command is active (pressed).
  47198. */
  47199. static readonly PASTE: number;
  47200. }
  47201. /**
  47202. * This class is used to store clipboard related info for the onClipboardObservable event.
  47203. */
  47204. export class ClipboardInfo {
  47205. /**
  47206. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47207. */
  47208. type: number;
  47209. /**
  47210. * Defines the related dom event
  47211. */
  47212. event: ClipboardEvent;
  47213. /**
  47214. *Creates an instance of ClipboardInfo.
  47215. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47216. * @param event Defines the related dom event
  47217. */
  47218. constructor(
  47219. /**
  47220. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47221. */
  47222. type: number,
  47223. /**
  47224. * Defines the related dom event
  47225. */
  47226. event: ClipboardEvent);
  47227. /**
  47228. * Get the clipboard event's type from the keycode.
  47229. * @param keyCode Defines the keyCode for the current keyboard event.
  47230. * @return {number}
  47231. */
  47232. static GetTypeFromCharacter(keyCode: number): number;
  47233. }
  47234. }
  47235. declare module "babylonjs/Events/index" {
  47236. export * from "babylonjs/Events/keyboardEvents";
  47237. export * from "babylonjs/Events/pointerEvents";
  47238. export * from "babylonjs/Events/clipboardEvents";
  47239. }
  47240. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  47241. import { Scene } from "babylonjs/scene";
  47242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47243. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47244. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47245. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47246. /**
  47247. * Google Daydream controller
  47248. */
  47249. export class DaydreamController extends WebVRController {
  47250. /**
  47251. * Base Url for the controller model.
  47252. */
  47253. static MODEL_BASE_URL: string;
  47254. /**
  47255. * File name for the controller model.
  47256. */
  47257. static MODEL_FILENAME: string;
  47258. /**
  47259. * Gamepad Id prefix used to identify Daydream Controller.
  47260. */
  47261. static readonly GAMEPAD_ID_PREFIX: string;
  47262. /**
  47263. * Creates a new DaydreamController from a gamepad
  47264. * @param vrGamepad the gamepad that the controller should be created from
  47265. */
  47266. constructor(vrGamepad: any);
  47267. /**
  47268. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47269. * @param scene scene in which to add meshes
  47270. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47271. */
  47272. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47273. /**
  47274. * Called once for each button that changed state since the last frame
  47275. * @param buttonIdx Which button index changed
  47276. * @param state New state of the button
  47277. * @param changes Which properties on the state changed since last frame
  47278. */
  47279. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47280. }
  47281. }
  47282. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  47283. import { Scene } from "babylonjs/scene";
  47284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47285. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47286. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47287. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47288. /**
  47289. * Gear VR Controller
  47290. */
  47291. export class GearVRController extends WebVRController {
  47292. /**
  47293. * Base Url for the controller model.
  47294. */
  47295. static MODEL_BASE_URL: string;
  47296. /**
  47297. * File name for the controller model.
  47298. */
  47299. static MODEL_FILENAME: string;
  47300. /**
  47301. * Gamepad Id prefix used to identify this controller.
  47302. */
  47303. static readonly GAMEPAD_ID_PREFIX: string;
  47304. private readonly _buttonIndexToObservableNameMap;
  47305. /**
  47306. * Creates a new GearVRController from a gamepad
  47307. * @param vrGamepad the gamepad that the controller should be created from
  47308. */
  47309. constructor(vrGamepad: any);
  47310. /**
  47311. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47312. * @param scene scene in which to add meshes
  47313. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47314. */
  47315. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47316. /**
  47317. * Called once for each button that changed state since the last frame
  47318. * @param buttonIdx Which button index changed
  47319. * @param state New state of the button
  47320. * @param changes Which properties on the state changed since last frame
  47321. */
  47322. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47323. }
  47324. }
  47325. declare module "babylonjs/Gamepads/Controllers/index" {
  47326. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  47327. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  47328. export * from "babylonjs/Gamepads/Controllers/genericController";
  47329. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  47330. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47331. export * from "babylonjs/Gamepads/Controllers/viveController";
  47332. export * from "babylonjs/Gamepads/Controllers/webVRController";
  47333. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  47334. }
  47335. declare module "babylonjs/Gamepads/index" {
  47336. export * from "babylonjs/Gamepads/Controllers/index";
  47337. export * from "babylonjs/Gamepads/gamepad";
  47338. export * from "babylonjs/Gamepads/gamepadManager";
  47339. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  47340. export * from "babylonjs/Gamepads/xboxGamepad";
  47341. export * from "babylonjs/Gamepads/dualShockGamepad";
  47342. }
  47343. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  47344. import { Scene } from "babylonjs/scene";
  47345. import { Vector4 } from "babylonjs/Maths/math.vector";
  47346. import { Color4 } from "babylonjs/Maths/math.color";
  47347. import { Mesh } from "babylonjs/Meshes/mesh";
  47348. import { Nullable } from "babylonjs/types";
  47349. /**
  47350. * Class containing static functions to help procedurally build meshes
  47351. */
  47352. export class PolyhedronBuilder {
  47353. /**
  47354. * Creates a polyhedron mesh
  47355. * * 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
  47356. * * The parameter `size` (positive float, default 1) sets the polygon size
  47357. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47358. * * 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`
  47359. * * 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
  47360. * * 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)`)
  47361. * * 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
  47362. * * 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
  47363. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47364. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47366. * @param name defines the name of the mesh
  47367. * @param options defines the options used to create the mesh
  47368. * @param scene defines the hosting scene
  47369. * @returns the polyhedron mesh
  47370. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47371. */
  47372. static CreatePolyhedron(name: string, options: {
  47373. type?: number;
  47374. size?: number;
  47375. sizeX?: number;
  47376. sizeY?: number;
  47377. sizeZ?: number;
  47378. custom?: any;
  47379. faceUV?: Vector4[];
  47380. faceColors?: Color4[];
  47381. flat?: boolean;
  47382. updatable?: boolean;
  47383. sideOrientation?: number;
  47384. frontUVs?: Vector4;
  47385. backUVs?: Vector4;
  47386. }, scene?: Nullable<Scene>): Mesh;
  47387. }
  47388. }
  47389. declare module "babylonjs/Gizmos/scaleGizmo" {
  47390. import { Observable } from "babylonjs/Misc/observable";
  47391. import { Nullable } from "babylonjs/types";
  47392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47393. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47394. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47395. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47396. /**
  47397. * Gizmo that enables scaling a mesh along 3 axis
  47398. */
  47399. export class ScaleGizmo extends Gizmo {
  47400. /**
  47401. * Internal gizmo used for interactions on the x axis
  47402. */
  47403. xGizmo: AxisScaleGizmo;
  47404. /**
  47405. * Internal gizmo used for interactions on the y axis
  47406. */
  47407. yGizmo: AxisScaleGizmo;
  47408. /**
  47409. * Internal gizmo used for interactions on the z axis
  47410. */
  47411. zGizmo: AxisScaleGizmo;
  47412. /**
  47413. * Internal gizmo used to scale all axis equally
  47414. */
  47415. uniformScaleGizmo: AxisScaleGizmo;
  47416. private _meshAttached;
  47417. private _updateGizmoRotationToMatchAttachedMesh;
  47418. private _snapDistance;
  47419. private _scaleRatio;
  47420. private _uniformScalingMesh;
  47421. private _octahedron;
  47422. /** Fires an event when any of it's sub gizmos are dragged */
  47423. onDragStartObservable: Observable<unknown>;
  47424. /** Fires an event when any of it's sub gizmos are released from dragging */
  47425. onDragEndObservable: Observable<unknown>;
  47426. attachedMesh: Nullable<AbstractMesh>;
  47427. /**
  47428. * Creates a ScaleGizmo
  47429. * @param gizmoLayer The utility layer the gizmo will be added to
  47430. */
  47431. constructor(gizmoLayer?: UtilityLayerRenderer);
  47432. updateGizmoRotationToMatchAttachedMesh: boolean;
  47433. /**
  47434. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47435. */
  47436. snapDistance: number;
  47437. /**
  47438. * Ratio for the scale of the gizmo (Default: 1)
  47439. */
  47440. scaleRatio: number;
  47441. /**
  47442. * Disposes of the gizmo
  47443. */
  47444. dispose(): void;
  47445. }
  47446. }
  47447. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  47448. import { Observable } from "babylonjs/Misc/observable";
  47449. import { Nullable } from "babylonjs/types";
  47450. import { Vector3 } from "babylonjs/Maths/math.vector";
  47451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47452. import { Mesh } from "babylonjs/Meshes/mesh";
  47453. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47454. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47455. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47456. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47457. import { Color3 } from "babylonjs/Maths/math.color";
  47458. /**
  47459. * Single axis scale gizmo
  47460. */
  47461. export class AxisScaleGizmo extends Gizmo {
  47462. /**
  47463. * Drag behavior responsible for the gizmos dragging interactions
  47464. */
  47465. dragBehavior: PointerDragBehavior;
  47466. private _pointerObserver;
  47467. /**
  47468. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47469. */
  47470. snapDistance: number;
  47471. /**
  47472. * Event that fires each time the gizmo snaps to a new location.
  47473. * * snapDistance is the the change in distance
  47474. */
  47475. onSnapObservable: Observable<{
  47476. snapDistance: number;
  47477. }>;
  47478. /**
  47479. * If the scaling operation should be done on all axis (default: false)
  47480. */
  47481. uniformScaling: boolean;
  47482. private _isEnabled;
  47483. private _parent;
  47484. private _arrow;
  47485. private _coloredMaterial;
  47486. private _hoverMaterial;
  47487. /**
  47488. * Creates an AxisScaleGizmo
  47489. * @param gizmoLayer The utility layer the gizmo will be added to
  47490. * @param dragAxis The axis which the gizmo will be able to scale on
  47491. * @param color The color of the gizmo
  47492. */
  47493. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47494. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47495. /**
  47496. * If the gizmo is enabled
  47497. */
  47498. isEnabled: boolean;
  47499. /**
  47500. * Disposes of the gizmo
  47501. */
  47502. dispose(): void;
  47503. /**
  47504. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47505. * @param mesh The mesh to replace the default mesh of the gizmo
  47506. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47507. */
  47508. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47509. }
  47510. }
  47511. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  47512. import { Observable } from "babylonjs/Misc/observable";
  47513. import { Nullable } from "babylonjs/types";
  47514. import { Vector3 } from "babylonjs/Maths/math.vector";
  47515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47516. import { Mesh } from "babylonjs/Meshes/mesh";
  47517. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47518. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47519. import { Color3 } from "babylonjs/Maths/math.color";
  47520. import "babylonjs/Meshes/Builders/boxBuilder";
  47521. /**
  47522. * Bounding box gizmo
  47523. */
  47524. export class BoundingBoxGizmo extends Gizmo {
  47525. private _lineBoundingBox;
  47526. private _rotateSpheresParent;
  47527. private _scaleBoxesParent;
  47528. private _boundingDimensions;
  47529. private _renderObserver;
  47530. private _pointerObserver;
  47531. private _scaleDragSpeed;
  47532. private _tmpQuaternion;
  47533. private _tmpVector;
  47534. private _tmpRotationMatrix;
  47535. /**
  47536. * 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)
  47537. */
  47538. ignoreChildren: boolean;
  47539. /**
  47540. * 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)
  47541. */
  47542. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47543. /**
  47544. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47545. */
  47546. rotationSphereSize: number;
  47547. /**
  47548. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47549. */
  47550. scaleBoxSize: number;
  47551. /**
  47552. * 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)
  47553. */
  47554. fixedDragMeshScreenSize: boolean;
  47555. /**
  47556. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47557. */
  47558. fixedDragMeshScreenSizeDistanceFactor: number;
  47559. /**
  47560. * Fired when a rotation sphere or scale box is dragged
  47561. */
  47562. onDragStartObservable: Observable<{}>;
  47563. /**
  47564. * Fired when a scale box is dragged
  47565. */
  47566. onScaleBoxDragObservable: Observable<{}>;
  47567. /**
  47568. * Fired when a scale box drag is ended
  47569. */
  47570. onScaleBoxDragEndObservable: Observable<{}>;
  47571. /**
  47572. * Fired when a rotation sphere is dragged
  47573. */
  47574. onRotationSphereDragObservable: Observable<{}>;
  47575. /**
  47576. * Fired when a rotation sphere drag is ended
  47577. */
  47578. onRotationSphereDragEndObservable: Observable<{}>;
  47579. /**
  47580. * 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)
  47581. */
  47582. scalePivot: Nullable<Vector3>;
  47583. /**
  47584. * Mesh used as a pivot to rotate the attached mesh
  47585. */
  47586. private _anchorMesh;
  47587. private _existingMeshScale;
  47588. private _dragMesh;
  47589. private pointerDragBehavior;
  47590. private coloredMaterial;
  47591. private hoverColoredMaterial;
  47592. /**
  47593. * Sets the color of the bounding box gizmo
  47594. * @param color the color to set
  47595. */
  47596. setColor(color: Color3): void;
  47597. /**
  47598. * Creates an BoundingBoxGizmo
  47599. * @param gizmoLayer The utility layer the gizmo will be added to
  47600. * @param color The color of the gizmo
  47601. */
  47602. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47603. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47604. private _selectNode;
  47605. /**
  47606. * Updates the bounding box information for the Gizmo
  47607. */
  47608. updateBoundingBox(): void;
  47609. private _updateRotationSpheres;
  47610. private _updateScaleBoxes;
  47611. /**
  47612. * Enables rotation on the specified axis and disables rotation on the others
  47613. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47614. */
  47615. setEnabledRotationAxis(axis: string): void;
  47616. /**
  47617. * Enables/disables scaling
  47618. * @param enable if scaling should be enabled
  47619. */
  47620. setEnabledScaling(enable: boolean): void;
  47621. private _updateDummy;
  47622. /**
  47623. * Enables a pointer drag behavior on the bounding box of the gizmo
  47624. */
  47625. enableDragBehavior(): void;
  47626. /**
  47627. * Disposes of the gizmo
  47628. */
  47629. dispose(): void;
  47630. /**
  47631. * 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)
  47632. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47633. * @returns the bounding box mesh with the passed in mesh as a child
  47634. */
  47635. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47636. /**
  47637. * CustomMeshes are not supported by this gizmo
  47638. * @param mesh The mesh to replace the default mesh of the gizmo
  47639. */
  47640. setCustomMesh(mesh: Mesh): void;
  47641. }
  47642. }
  47643. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47644. import { Observable } from "babylonjs/Misc/observable";
  47645. import { Nullable } from "babylonjs/types";
  47646. import { Vector3 } from "babylonjs/Maths/math.vector";
  47647. import { Color3 } from "babylonjs/Maths/math.color";
  47648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47649. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47650. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47651. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47652. import "babylonjs/Meshes/Builders/linesBuilder";
  47653. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47654. /**
  47655. * Single plane rotation gizmo
  47656. */
  47657. export class PlaneRotationGizmo extends Gizmo {
  47658. /**
  47659. * Drag behavior responsible for the gizmos dragging interactions
  47660. */
  47661. dragBehavior: PointerDragBehavior;
  47662. private _pointerObserver;
  47663. /**
  47664. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47665. */
  47666. snapDistance: number;
  47667. /**
  47668. * Event that fires each time the gizmo snaps to a new location.
  47669. * * snapDistance is the the change in distance
  47670. */
  47671. onSnapObservable: Observable<{
  47672. snapDistance: number;
  47673. }>;
  47674. private _isEnabled;
  47675. private _parent;
  47676. /**
  47677. * Creates a PlaneRotationGizmo
  47678. * @param gizmoLayer The utility layer the gizmo will be added to
  47679. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47680. * @param color The color of the gizmo
  47681. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47682. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47683. */
  47684. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47685. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47686. /**
  47687. * If the gizmo is enabled
  47688. */
  47689. isEnabled: boolean;
  47690. /**
  47691. * Disposes of the gizmo
  47692. */
  47693. dispose(): void;
  47694. }
  47695. }
  47696. declare module "babylonjs/Gizmos/rotationGizmo" {
  47697. import { Observable } from "babylonjs/Misc/observable";
  47698. import { Nullable } from "babylonjs/types";
  47699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47700. import { Mesh } from "babylonjs/Meshes/mesh";
  47701. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47702. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47703. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47704. /**
  47705. * Gizmo that enables rotating a mesh along 3 axis
  47706. */
  47707. export class RotationGizmo extends Gizmo {
  47708. /**
  47709. * Internal gizmo used for interactions on the x axis
  47710. */
  47711. xGizmo: PlaneRotationGizmo;
  47712. /**
  47713. * Internal gizmo used for interactions on the y axis
  47714. */
  47715. yGizmo: PlaneRotationGizmo;
  47716. /**
  47717. * Internal gizmo used for interactions on the z axis
  47718. */
  47719. zGizmo: PlaneRotationGizmo;
  47720. /** Fires an event when any of it's sub gizmos are dragged */
  47721. onDragStartObservable: Observable<unknown>;
  47722. /** Fires an event when any of it's sub gizmos are released from dragging */
  47723. onDragEndObservable: Observable<unknown>;
  47724. private _meshAttached;
  47725. attachedMesh: Nullable<AbstractMesh>;
  47726. /**
  47727. * Creates a RotationGizmo
  47728. * @param gizmoLayer The utility layer the gizmo will be added to
  47729. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47730. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47731. */
  47732. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47733. updateGizmoRotationToMatchAttachedMesh: boolean;
  47734. /**
  47735. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47736. */
  47737. snapDistance: number;
  47738. /**
  47739. * Ratio for the scale of the gizmo (Default: 1)
  47740. */
  47741. scaleRatio: number;
  47742. /**
  47743. * Disposes of the gizmo
  47744. */
  47745. dispose(): void;
  47746. /**
  47747. * CustomMeshes are not supported by this gizmo
  47748. * @param mesh The mesh to replace the default mesh of the gizmo
  47749. */
  47750. setCustomMesh(mesh: Mesh): void;
  47751. }
  47752. }
  47753. declare module "babylonjs/Gizmos/gizmoManager" {
  47754. import { Observable } from "babylonjs/Misc/observable";
  47755. import { Nullable } from "babylonjs/types";
  47756. import { Scene, IDisposable } from "babylonjs/scene";
  47757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47758. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47759. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47760. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47761. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47762. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47763. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47764. /**
  47765. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47766. */
  47767. export class GizmoManager implements IDisposable {
  47768. private scene;
  47769. /**
  47770. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47771. */
  47772. gizmos: {
  47773. positionGizmo: Nullable<PositionGizmo>;
  47774. rotationGizmo: Nullable<RotationGizmo>;
  47775. scaleGizmo: Nullable<ScaleGizmo>;
  47776. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47777. };
  47778. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47779. clearGizmoOnEmptyPointerEvent: boolean;
  47780. /** Fires an event when the manager is attached to a mesh */
  47781. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47782. private _gizmosEnabled;
  47783. private _pointerObserver;
  47784. private _attachedMesh;
  47785. private _boundingBoxColor;
  47786. private _defaultUtilityLayer;
  47787. private _defaultKeepDepthUtilityLayer;
  47788. /**
  47789. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47790. */
  47791. boundingBoxDragBehavior: SixDofDragBehavior;
  47792. /**
  47793. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47794. */
  47795. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47796. /**
  47797. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47798. */
  47799. usePointerToAttachGizmos: boolean;
  47800. /**
  47801. * Utility layer that the bounding box gizmo belongs to
  47802. */
  47803. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47804. /**
  47805. * Utility layer that all gizmos besides bounding box belong to
  47806. */
  47807. readonly utilityLayer: UtilityLayerRenderer;
  47808. /**
  47809. * Instatiates a gizmo manager
  47810. * @param scene the scene to overlay the gizmos on top of
  47811. */
  47812. constructor(scene: Scene);
  47813. /**
  47814. * Attaches a set of gizmos to the specified mesh
  47815. * @param mesh The mesh the gizmo's should be attached to
  47816. */
  47817. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47818. /**
  47819. * If the position gizmo is enabled
  47820. */
  47821. positionGizmoEnabled: boolean;
  47822. /**
  47823. * If the rotation gizmo is enabled
  47824. */
  47825. rotationGizmoEnabled: boolean;
  47826. /**
  47827. * If the scale gizmo is enabled
  47828. */
  47829. scaleGizmoEnabled: boolean;
  47830. /**
  47831. * If the boundingBox gizmo is enabled
  47832. */
  47833. boundingBoxGizmoEnabled: boolean;
  47834. /**
  47835. * Disposes of the gizmo manager
  47836. */
  47837. dispose(): void;
  47838. }
  47839. }
  47840. declare module "babylonjs/Lights/directionalLight" {
  47841. import { Camera } from "babylonjs/Cameras/camera";
  47842. import { Scene } from "babylonjs/scene";
  47843. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47844. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47845. import { Light } from "babylonjs/Lights/light";
  47846. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47847. import { Effect } from "babylonjs/Materials/effect";
  47848. /**
  47849. * A directional light is defined by a direction (what a surprise!).
  47850. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47851. * 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.
  47852. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47853. */
  47854. export class DirectionalLight extends ShadowLight {
  47855. private _shadowFrustumSize;
  47856. /**
  47857. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47858. */
  47859. /**
  47860. * Specifies a fix frustum size for the shadow generation.
  47861. */
  47862. shadowFrustumSize: number;
  47863. private _shadowOrthoScale;
  47864. /**
  47865. * Gets the shadow projection scale against the optimal computed one.
  47866. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47867. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47868. */
  47869. /**
  47870. * Sets the shadow projection scale against the optimal computed one.
  47871. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47872. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47873. */
  47874. shadowOrthoScale: number;
  47875. /**
  47876. * Automatically compute the projection matrix to best fit (including all the casters)
  47877. * on each frame.
  47878. */
  47879. autoUpdateExtends: boolean;
  47880. private _orthoLeft;
  47881. private _orthoRight;
  47882. private _orthoTop;
  47883. private _orthoBottom;
  47884. /**
  47885. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47886. * The directional light is emitted from everywhere in the given direction.
  47887. * It can cast shadows.
  47888. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47889. * @param name The friendly name of the light
  47890. * @param direction The direction of the light
  47891. * @param scene The scene the light belongs to
  47892. */
  47893. constructor(name: string, direction: Vector3, scene: Scene);
  47894. /**
  47895. * Returns the string "DirectionalLight".
  47896. * @return The class name
  47897. */
  47898. getClassName(): string;
  47899. /**
  47900. * Returns the integer 1.
  47901. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47902. */
  47903. getTypeID(): number;
  47904. /**
  47905. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47906. * Returns the DirectionalLight Shadow projection matrix.
  47907. */
  47908. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47909. /**
  47910. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47911. * Returns the DirectionalLight Shadow projection matrix.
  47912. */
  47913. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47914. /**
  47915. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47916. * Returns the DirectionalLight Shadow projection matrix.
  47917. */
  47918. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47919. protected _buildUniformLayout(): void;
  47920. /**
  47921. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47922. * @param effect The effect to update
  47923. * @param lightIndex The index of the light in the effect to update
  47924. * @returns The directional light
  47925. */
  47926. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47927. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47928. /**
  47929. * Gets the minZ used for shadow according to both the scene and the light.
  47930. *
  47931. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47932. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47933. * @param activeCamera The camera we are returning the min for
  47934. * @returns the depth min z
  47935. */
  47936. getDepthMinZ(activeCamera: Camera): number;
  47937. /**
  47938. * Gets the maxZ used for shadow according to both the scene and the light.
  47939. *
  47940. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47941. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47942. * @param activeCamera The camera we are returning the max for
  47943. * @returns the depth max z
  47944. */
  47945. getDepthMaxZ(activeCamera: Camera): number;
  47946. /**
  47947. * Prepares the list of defines specific to the light type.
  47948. * @param defines the list of defines
  47949. * @param lightIndex defines the index of the light for the effect
  47950. */
  47951. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47952. }
  47953. }
  47954. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47955. import { Mesh } from "babylonjs/Meshes/mesh";
  47956. /**
  47957. * Class containing static functions to help procedurally build meshes
  47958. */
  47959. export class HemisphereBuilder {
  47960. /**
  47961. * Creates a hemisphere mesh
  47962. * @param name defines the name of the mesh
  47963. * @param options defines the options used to create the mesh
  47964. * @param scene defines the hosting scene
  47965. * @returns the hemisphere mesh
  47966. */
  47967. static CreateHemisphere(name: string, options: {
  47968. segments?: number;
  47969. diameter?: number;
  47970. sideOrientation?: number;
  47971. }, scene: any): Mesh;
  47972. }
  47973. }
  47974. declare module "babylonjs/Lights/spotLight" {
  47975. import { Nullable } from "babylonjs/types";
  47976. import { Scene } from "babylonjs/scene";
  47977. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47979. import { Effect } from "babylonjs/Materials/effect";
  47980. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47981. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47982. /**
  47983. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47984. * These values define a cone of light starting from the position, emitting toward the direction.
  47985. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47986. * and the exponent defines the speed of the decay of the light with distance (reach).
  47987. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47988. */
  47989. export class SpotLight extends ShadowLight {
  47990. private _angle;
  47991. private _innerAngle;
  47992. private _cosHalfAngle;
  47993. private _lightAngleScale;
  47994. private _lightAngleOffset;
  47995. /**
  47996. * Gets the cone angle of the spot light in Radians.
  47997. */
  47998. /**
  47999. * Sets the cone angle of the spot light in Radians.
  48000. */
  48001. angle: number;
  48002. /**
  48003. * Only used in gltf falloff mode, this defines the angle where
  48004. * the directional falloff will start before cutting at angle which could be seen
  48005. * as outer angle.
  48006. */
  48007. /**
  48008. * Only used in gltf falloff mode, this defines the angle where
  48009. * the directional falloff will start before cutting at angle which could be seen
  48010. * as outer angle.
  48011. */
  48012. innerAngle: number;
  48013. private _shadowAngleScale;
  48014. /**
  48015. * Allows scaling the angle of the light for shadow generation only.
  48016. */
  48017. /**
  48018. * Allows scaling the angle of the light for shadow generation only.
  48019. */
  48020. shadowAngleScale: number;
  48021. /**
  48022. * The light decay speed with the distance from the emission spot.
  48023. */
  48024. exponent: number;
  48025. private _projectionTextureMatrix;
  48026. /**
  48027. * Allows reading the projecton texture
  48028. */
  48029. readonly projectionTextureMatrix: Matrix;
  48030. protected _projectionTextureLightNear: number;
  48031. /**
  48032. * Gets the near clip of the Spotlight for texture projection.
  48033. */
  48034. /**
  48035. * Sets the near clip of the Spotlight for texture projection.
  48036. */
  48037. projectionTextureLightNear: number;
  48038. protected _projectionTextureLightFar: number;
  48039. /**
  48040. * Gets the far clip of the Spotlight for texture projection.
  48041. */
  48042. /**
  48043. * Sets the far clip of the Spotlight for texture projection.
  48044. */
  48045. projectionTextureLightFar: number;
  48046. protected _projectionTextureUpDirection: Vector3;
  48047. /**
  48048. * Gets the Up vector of the Spotlight for texture projection.
  48049. */
  48050. /**
  48051. * Sets the Up vector of the Spotlight for texture projection.
  48052. */
  48053. projectionTextureUpDirection: Vector3;
  48054. private _projectionTexture;
  48055. /**
  48056. * Gets the projection texture of the light.
  48057. */
  48058. /**
  48059. * Sets the projection texture of the light.
  48060. */
  48061. projectionTexture: Nullable<BaseTexture>;
  48062. private _projectionTextureViewLightDirty;
  48063. private _projectionTextureProjectionLightDirty;
  48064. private _projectionTextureDirty;
  48065. private _projectionTextureViewTargetVector;
  48066. private _projectionTextureViewLightMatrix;
  48067. private _projectionTextureProjectionLightMatrix;
  48068. private _projectionTextureScalingMatrix;
  48069. /**
  48070. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48071. * It can cast shadows.
  48072. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48073. * @param name The light friendly name
  48074. * @param position The position of the spot light in the scene
  48075. * @param direction The direction of the light in the scene
  48076. * @param angle The cone angle of the light in Radians
  48077. * @param exponent The light decay speed with the distance from the emission spot
  48078. * @param scene The scene the lights belongs to
  48079. */
  48080. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48081. /**
  48082. * Returns the string "SpotLight".
  48083. * @returns the class name
  48084. */
  48085. getClassName(): string;
  48086. /**
  48087. * Returns the integer 2.
  48088. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48089. */
  48090. getTypeID(): number;
  48091. /**
  48092. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48093. */
  48094. protected _setDirection(value: Vector3): void;
  48095. /**
  48096. * Overrides the position setter to recompute the projection texture view light Matrix.
  48097. */
  48098. protected _setPosition(value: Vector3): void;
  48099. /**
  48100. * 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.
  48101. * Returns the SpotLight.
  48102. */
  48103. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48104. protected _computeProjectionTextureViewLightMatrix(): void;
  48105. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48106. /**
  48107. * Main function for light texture projection matrix computing.
  48108. */
  48109. protected _computeProjectionTextureMatrix(): void;
  48110. protected _buildUniformLayout(): void;
  48111. private _computeAngleValues;
  48112. /**
  48113. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48114. * @param effect The effect to update
  48115. * @param lightIndex The index of the light in the effect to update
  48116. * @returns The spot light
  48117. */
  48118. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48119. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48120. /**
  48121. * Disposes the light and the associated resources.
  48122. */
  48123. dispose(): void;
  48124. /**
  48125. * Prepares the list of defines specific to the light type.
  48126. * @param defines the list of defines
  48127. * @param lightIndex defines the index of the light for the effect
  48128. */
  48129. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48130. }
  48131. }
  48132. declare module "babylonjs/Gizmos/lightGizmo" {
  48133. import { Nullable } from "babylonjs/types";
  48134. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48135. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48136. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48137. import { Light } from "babylonjs/Lights/light";
  48138. /**
  48139. * Gizmo that enables viewing a light
  48140. */
  48141. export class LightGizmo extends Gizmo {
  48142. private _lightMesh;
  48143. private _material;
  48144. private cachedPosition;
  48145. private cachedForward;
  48146. /**
  48147. * Creates a LightGizmo
  48148. * @param gizmoLayer The utility layer the gizmo will be added to
  48149. */
  48150. constructor(gizmoLayer?: UtilityLayerRenderer);
  48151. private _light;
  48152. /**
  48153. * The light that the gizmo is attached to
  48154. */
  48155. light: Nullable<Light>;
  48156. /**
  48157. * Gets the material used to render the light gizmo
  48158. */
  48159. readonly material: StandardMaterial;
  48160. /**
  48161. * @hidden
  48162. * Updates the gizmo to match the attached mesh's position/rotation
  48163. */
  48164. protected _update(): void;
  48165. private static _Scale;
  48166. /**
  48167. * Creates the lines for a light mesh
  48168. */
  48169. private static _createLightLines;
  48170. /**
  48171. * Disposes of the light gizmo
  48172. */
  48173. dispose(): void;
  48174. private static _CreateHemisphericLightMesh;
  48175. private static _CreatePointLightMesh;
  48176. private static _CreateSpotLightMesh;
  48177. private static _CreateDirectionalLightMesh;
  48178. }
  48179. }
  48180. declare module "babylonjs/Gizmos/index" {
  48181. export * from "babylonjs/Gizmos/axisDragGizmo";
  48182. export * from "babylonjs/Gizmos/axisScaleGizmo";
  48183. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  48184. export * from "babylonjs/Gizmos/gizmo";
  48185. export * from "babylonjs/Gizmos/gizmoManager";
  48186. export * from "babylonjs/Gizmos/planeRotationGizmo";
  48187. export * from "babylonjs/Gizmos/positionGizmo";
  48188. export * from "babylonjs/Gizmos/rotationGizmo";
  48189. export * from "babylonjs/Gizmos/scaleGizmo";
  48190. export * from "babylonjs/Gizmos/lightGizmo";
  48191. export * from "babylonjs/Gizmos/planeDragGizmo";
  48192. }
  48193. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  48194. /** @hidden */
  48195. export var backgroundFragmentDeclaration: {
  48196. name: string;
  48197. shader: string;
  48198. };
  48199. }
  48200. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  48201. /** @hidden */
  48202. export var backgroundUboDeclaration: {
  48203. name: string;
  48204. shader: string;
  48205. };
  48206. }
  48207. declare module "babylonjs/Shaders/background.fragment" {
  48208. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  48209. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48210. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48211. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48212. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48213. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48214. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48215. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  48216. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48217. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48218. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48219. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48220. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48221. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48222. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48223. /** @hidden */
  48224. export var backgroundPixelShader: {
  48225. name: string;
  48226. shader: string;
  48227. };
  48228. }
  48229. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  48230. /** @hidden */
  48231. export var backgroundVertexDeclaration: {
  48232. name: string;
  48233. shader: string;
  48234. };
  48235. }
  48236. declare module "babylonjs/Shaders/background.vertex" {
  48237. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  48238. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48239. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48240. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48241. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48242. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48243. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48244. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48245. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48246. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48247. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48248. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48249. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48250. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48251. /** @hidden */
  48252. export var backgroundVertexShader: {
  48253. name: string;
  48254. shader: string;
  48255. };
  48256. }
  48257. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  48258. import { Nullable, int, float } from "babylonjs/types";
  48259. import { Scene } from "babylonjs/scene";
  48260. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48261. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48263. import { Mesh } from "babylonjs/Meshes/mesh";
  48264. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48265. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48266. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48267. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48268. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  48269. import { Color3 } from "babylonjs/Maths/math.color";
  48270. import "babylonjs/Shaders/background.fragment";
  48271. import "babylonjs/Shaders/background.vertex";
  48272. /**
  48273. * Background material used to create an efficient environement around your scene.
  48274. */
  48275. export class BackgroundMaterial extends PushMaterial {
  48276. /**
  48277. * Standard reflectance value at parallel view angle.
  48278. */
  48279. static StandardReflectance0: number;
  48280. /**
  48281. * Standard reflectance value at grazing angle.
  48282. */
  48283. static StandardReflectance90: number;
  48284. protected _primaryColor: Color3;
  48285. /**
  48286. * Key light Color (multiply against the environement texture)
  48287. */
  48288. primaryColor: Color3;
  48289. protected __perceptualColor: Nullable<Color3>;
  48290. /**
  48291. * Experimental Internal Use Only.
  48292. *
  48293. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48294. * This acts as a helper to set the primary color to a more "human friendly" value.
  48295. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48296. * output color as close as possible from the chosen value.
  48297. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48298. * part of lighting setup.)
  48299. */
  48300. _perceptualColor: Nullable<Color3>;
  48301. protected _primaryColorShadowLevel: float;
  48302. /**
  48303. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48304. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48305. */
  48306. primaryColorShadowLevel: float;
  48307. protected _primaryColorHighlightLevel: float;
  48308. /**
  48309. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48310. * The primary color is used at the level chosen to define what the white area would look.
  48311. */
  48312. primaryColorHighlightLevel: float;
  48313. protected _reflectionTexture: Nullable<BaseTexture>;
  48314. /**
  48315. * Reflection Texture used in the material.
  48316. * Should be author in a specific way for the best result (refer to the documentation).
  48317. */
  48318. reflectionTexture: Nullable<BaseTexture>;
  48319. protected _reflectionBlur: float;
  48320. /**
  48321. * Reflection Texture level of blur.
  48322. *
  48323. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48324. * texture twice.
  48325. */
  48326. reflectionBlur: float;
  48327. protected _diffuseTexture: Nullable<BaseTexture>;
  48328. /**
  48329. * Diffuse Texture used in the material.
  48330. * Should be author in a specific way for the best result (refer to the documentation).
  48331. */
  48332. diffuseTexture: Nullable<BaseTexture>;
  48333. protected _shadowLights: Nullable<IShadowLight[]>;
  48334. /**
  48335. * Specify the list of lights casting shadow on the material.
  48336. * All scene shadow lights will be included if null.
  48337. */
  48338. shadowLights: Nullable<IShadowLight[]>;
  48339. protected _shadowLevel: float;
  48340. /**
  48341. * Helps adjusting the shadow to a softer level if required.
  48342. * 0 means black shadows and 1 means no shadows.
  48343. */
  48344. shadowLevel: float;
  48345. protected _sceneCenter: Vector3;
  48346. /**
  48347. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48348. * It is usually zero but might be interesting to modify according to your setup.
  48349. */
  48350. sceneCenter: Vector3;
  48351. protected _opacityFresnel: boolean;
  48352. /**
  48353. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48354. * This helps ensuring a nice transition when the camera goes under the ground.
  48355. */
  48356. opacityFresnel: boolean;
  48357. protected _reflectionFresnel: boolean;
  48358. /**
  48359. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48360. * This helps adding a mirror texture on the ground.
  48361. */
  48362. reflectionFresnel: boolean;
  48363. protected _reflectionFalloffDistance: number;
  48364. /**
  48365. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48366. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48367. */
  48368. reflectionFalloffDistance: number;
  48369. protected _reflectionAmount: number;
  48370. /**
  48371. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48372. */
  48373. reflectionAmount: number;
  48374. protected _reflectionReflectance0: number;
  48375. /**
  48376. * This specifies the weight of the reflection at grazing angle.
  48377. */
  48378. reflectionReflectance0: number;
  48379. protected _reflectionReflectance90: number;
  48380. /**
  48381. * This specifies the weight of the reflection at a perpendicular point of view.
  48382. */
  48383. reflectionReflectance90: number;
  48384. /**
  48385. * Sets the reflection reflectance fresnel values according to the default standard
  48386. * empirically know to work well :-)
  48387. */
  48388. reflectionStandardFresnelWeight: number;
  48389. protected _useRGBColor: boolean;
  48390. /**
  48391. * Helps to directly use the maps channels instead of their level.
  48392. */
  48393. useRGBColor: boolean;
  48394. protected _enableNoise: boolean;
  48395. /**
  48396. * This helps reducing the banding effect that could occur on the background.
  48397. */
  48398. enableNoise: boolean;
  48399. /**
  48400. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48401. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48402. * Recommended to be keep at 1.0 except for special cases.
  48403. */
  48404. fovMultiplier: number;
  48405. private _fovMultiplier;
  48406. /**
  48407. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48408. */
  48409. useEquirectangularFOV: boolean;
  48410. private _maxSimultaneousLights;
  48411. /**
  48412. * Number of Simultaneous lights allowed on the material.
  48413. */
  48414. maxSimultaneousLights: int;
  48415. /**
  48416. * Default configuration related to image processing available in the Background Material.
  48417. */
  48418. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48419. /**
  48420. * Keep track of the image processing observer to allow dispose and replace.
  48421. */
  48422. private _imageProcessingObserver;
  48423. /**
  48424. * Attaches a new image processing configuration to the PBR Material.
  48425. * @param configuration (if null the scene configuration will be use)
  48426. */
  48427. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48428. /**
  48429. * Gets the image processing configuration used either in this material.
  48430. */
  48431. /**
  48432. * Sets the Default image processing configuration used either in the this material.
  48433. *
  48434. * If sets to null, the scene one is in use.
  48435. */
  48436. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  48437. /**
  48438. * Gets wether the color curves effect is enabled.
  48439. */
  48440. /**
  48441. * Sets wether the color curves effect is enabled.
  48442. */
  48443. cameraColorCurvesEnabled: boolean;
  48444. /**
  48445. * Gets wether the color grading effect is enabled.
  48446. */
  48447. /**
  48448. * Gets wether the color grading effect is enabled.
  48449. */
  48450. cameraColorGradingEnabled: boolean;
  48451. /**
  48452. * Gets wether tonemapping is enabled or not.
  48453. */
  48454. /**
  48455. * Sets wether tonemapping is enabled or not
  48456. */
  48457. cameraToneMappingEnabled: boolean;
  48458. /**
  48459. * The camera exposure used on this material.
  48460. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48461. * This corresponds to a photographic exposure.
  48462. */
  48463. /**
  48464. * The camera exposure used on this material.
  48465. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48466. * This corresponds to a photographic exposure.
  48467. */
  48468. cameraExposure: float;
  48469. /**
  48470. * Gets The camera contrast used on this material.
  48471. */
  48472. /**
  48473. * Sets The camera contrast used on this material.
  48474. */
  48475. cameraContrast: float;
  48476. /**
  48477. * Gets the Color Grading 2D Lookup Texture.
  48478. */
  48479. /**
  48480. * Sets the Color Grading 2D Lookup Texture.
  48481. */
  48482. cameraColorGradingTexture: Nullable<BaseTexture>;
  48483. /**
  48484. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48485. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48486. * 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;
  48487. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48488. */
  48489. /**
  48490. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48491. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48492. * 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;
  48493. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48494. */
  48495. cameraColorCurves: Nullable<ColorCurves>;
  48496. /**
  48497. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48498. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48499. */
  48500. switchToBGR: boolean;
  48501. private _renderTargets;
  48502. private _reflectionControls;
  48503. private _white;
  48504. private _primaryShadowColor;
  48505. private _primaryHighlightColor;
  48506. /**
  48507. * Instantiates a Background Material in the given scene
  48508. * @param name The friendly name of the material
  48509. * @param scene The scene to add the material to
  48510. */
  48511. constructor(name: string, scene: Scene);
  48512. /**
  48513. * Gets a boolean indicating that current material needs to register RTT
  48514. */
  48515. readonly hasRenderTargetTextures: boolean;
  48516. /**
  48517. * The entire material has been created in order to prevent overdraw.
  48518. * @returns false
  48519. */
  48520. needAlphaTesting(): boolean;
  48521. /**
  48522. * The entire material has been created in order to prevent overdraw.
  48523. * @returns true if blending is enable
  48524. */
  48525. needAlphaBlending(): boolean;
  48526. /**
  48527. * Checks wether the material is ready to be rendered for a given mesh.
  48528. * @param mesh The mesh to render
  48529. * @param subMesh The submesh to check against
  48530. * @param useInstances Specify wether or not the material is used with instances
  48531. * @returns true if all the dependencies are ready (Textures, Effects...)
  48532. */
  48533. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48534. /**
  48535. * Compute the primary color according to the chosen perceptual color.
  48536. */
  48537. private _computePrimaryColorFromPerceptualColor;
  48538. /**
  48539. * Compute the highlights and shadow colors according to their chosen levels.
  48540. */
  48541. private _computePrimaryColors;
  48542. /**
  48543. * Build the uniform buffer used in the material.
  48544. */
  48545. buildUniformLayout(): void;
  48546. /**
  48547. * Unbind the material.
  48548. */
  48549. unbind(): void;
  48550. /**
  48551. * Bind only the world matrix to the material.
  48552. * @param world The world matrix to bind.
  48553. */
  48554. bindOnlyWorldMatrix(world: Matrix): void;
  48555. /**
  48556. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48557. * @param world The world matrix to bind.
  48558. * @param subMesh The submesh to bind for.
  48559. */
  48560. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48561. /**
  48562. * Checks to see if a texture is used in the material.
  48563. * @param texture - Base texture to use.
  48564. * @returns - Boolean specifying if a texture is used in the material.
  48565. */
  48566. hasTexture(texture: BaseTexture): boolean;
  48567. /**
  48568. * Dispose the material.
  48569. * @param forceDisposeEffect Force disposal of the associated effect.
  48570. * @param forceDisposeTextures Force disposal of the associated textures.
  48571. */
  48572. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48573. /**
  48574. * Clones the material.
  48575. * @param name The cloned name.
  48576. * @returns The cloned material.
  48577. */
  48578. clone(name: string): BackgroundMaterial;
  48579. /**
  48580. * Serializes the current material to its JSON representation.
  48581. * @returns The JSON representation.
  48582. */
  48583. serialize(): any;
  48584. /**
  48585. * Gets the class name of the material
  48586. * @returns "BackgroundMaterial"
  48587. */
  48588. getClassName(): string;
  48589. /**
  48590. * Parse a JSON input to create back a background material.
  48591. * @param source The JSON data to parse
  48592. * @param scene The scene to create the parsed material in
  48593. * @param rootUrl The root url of the assets the material depends upon
  48594. * @returns the instantiated BackgroundMaterial.
  48595. */
  48596. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48597. }
  48598. }
  48599. declare module "babylonjs/Helpers/environmentHelper" {
  48600. import { Observable } from "babylonjs/Misc/observable";
  48601. import { Nullable } from "babylonjs/types";
  48602. import { Scene } from "babylonjs/scene";
  48603. import { Vector3 } from "babylonjs/Maths/math.vector";
  48604. import { Color3 } from "babylonjs/Maths/math.color";
  48605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48606. import { Mesh } from "babylonjs/Meshes/mesh";
  48607. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48608. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48609. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48610. import "babylonjs/Meshes/Builders/planeBuilder";
  48611. import "babylonjs/Meshes/Builders/boxBuilder";
  48612. /**
  48613. * Represents the different options available during the creation of
  48614. * a Environment helper.
  48615. *
  48616. * This can control the default ground, skybox and image processing setup of your scene.
  48617. */
  48618. export interface IEnvironmentHelperOptions {
  48619. /**
  48620. * Specifies wether or not to create a ground.
  48621. * True by default.
  48622. */
  48623. createGround: boolean;
  48624. /**
  48625. * Specifies the ground size.
  48626. * 15 by default.
  48627. */
  48628. groundSize: number;
  48629. /**
  48630. * The texture used on the ground for the main color.
  48631. * Comes from the BabylonJS CDN by default.
  48632. *
  48633. * Remarks: Can be either a texture or a url.
  48634. */
  48635. groundTexture: string | BaseTexture;
  48636. /**
  48637. * The color mixed in the ground texture by default.
  48638. * BabylonJS clearColor by default.
  48639. */
  48640. groundColor: Color3;
  48641. /**
  48642. * Specifies the ground opacity.
  48643. * 1 by default.
  48644. */
  48645. groundOpacity: number;
  48646. /**
  48647. * Enables the ground to receive shadows.
  48648. * True by default.
  48649. */
  48650. enableGroundShadow: boolean;
  48651. /**
  48652. * Helps preventing the shadow to be fully black on the ground.
  48653. * 0.5 by default.
  48654. */
  48655. groundShadowLevel: number;
  48656. /**
  48657. * Creates a mirror texture attach to the ground.
  48658. * false by default.
  48659. */
  48660. enableGroundMirror: boolean;
  48661. /**
  48662. * Specifies the ground mirror size ratio.
  48663. * 0.3 by default as the default kernel is 64.
  48664. */
  48665. groundMirrorSizeRatio: number;
  48666. /**
  48667. * Specifies the ground mirror blur kernel size.
  48668. * 64 by default.
  48669. */
  48670. groundMirrorBlurKernel: number;
  48671. /**
  48672. * Specifies the ground mirror visibility amount.
  48673. * 1 by default
  48674. */
  48675. groundMirrorAmount: number;
  48676. /**
  48677. * Specifies the ground mirror reflectance weight.
  48678. * This uses the standard weight of the background material to setup the fresnel effect
  48679. * of the mirror.
  48680. * 1 by default.
  48681. */
  48682. groundMirrorFresnelWeight: number;
  48683. /**
  48684. * Specifies the ground mirror Falloff distance.
  48685. * This can helps reducing the size of the reflection.
  48686. * 0 by Default.
  48687. */
  48688. groundMirrorFallOffDistance: number;
  48689. /**
  48690. * Specifies the ground mirror texture type.
  48691. * Unsigned Int by Default.
  48692. */
  48693. groundMirrorTextureType: number;
  48694. /**
  48695. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48696. * the shown objects.
  48697. */
  48698. groundYBias: number;
  48699. /**
  48700. * Specifies wether or not to create a skybox.
  48701. * True by default.
  48702. */
  48703. createSkybox: boolean;
  48704. /**
  48705. * Specifies the skybox size.
  48706. * 20 by default.
  48707. */
  48708. skyboxSize: number;
  48709. /**
  48710. * The texture used on the skybox for the main color.
  48711. * Comes from the BabylonJS CDN by default.
  48712. *
  48713. * Remarks: Can be either a texture or a url.
  48714. */
  48715. skyboxTexture: string | BaseTexture;
  48716. /**
  48717. * The color mixed in the skybox texture by default.
  48718. * BabylonJS clearColor by default.
  48719. */
  48720. skyboxColor: Color3;
  48721. /**
  48722. * The background rotation around the Y axis of the scene.
  48723. * This helps aligning the key lights of your scene with the background.
  48724. * 0 by default.
  48725. */
  48726. backgroundYRotation: number;
  48727. /**
  48728. * Compute automatically the size of the elements to best fit with the scene.
  48729. */
  48730. sizeAuto: boolean;
  48731. /**
  48732. * Default position of the rootMesh if autoSize is not true.
  48733. */
  48734. rootPosition: Vector3;
  48735. /**
  48736. * Sets up the image processing in the scene.
  48737. * true by default.
  48738. */
  48739. setupImageProcessing: boolean;
  48740. /**
  48741. * The texture used as your environment texture in the scene.
  48742. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48743. *
  48744. * Remarks: Can be either a texture or a url.
  48745. */
  48746. environmentTexture: string | BaseTexture;
  48747. /**
  48748. * The value of the exposure to apply to the scene.
  48749. * 0.6 by default if setupImageProcessing is true.
  48750. */
  48751. cameraExposure: number;
  48752. /**
  48753. * The value of the contrast to apply to the scene.
  48754. * 1.6 by default if setupImageProcessing is true.
  48755. */
  48756. cameraContrast: number;
  48757. /**
  48758. * Specifies wether or not tonemapping should be enabled in the scene.
  48759. * true by default if setupImageProcessing is true.
  48760. */
  48761. toneMappingEnabled: boolean;
  48762. }
  48763. /**
  48764. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48765. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48766. * It also helps with the default setup of your imageProcessing configuration.
  48767. */
  48768. export class EnvironmentHelper {
  48769. /**
  48770. * Default ground texture URL.
  48771. */
  48772. private static _groundTextureCDNUrl;
  48773. /**
  48774. * Default skybox texture URL.
  48775. */
  48776. private static _skyboxTextureCDNUrl;
  48777. /**
  48778. * Default environment texture URL.
  48779. */
  48780. private static _environmentTextureCDNUrl;
  48781. /**
  48782. * Creates the default options for the helper.
  48783. */
  48784. private static _getDefaultOptions;
  48785. private _rootMesh;
  48786. /**
  48787. * Gets the root mesh created by the helper.
  48788. */
  48789. readonly rootMesh: Mesh;
  48790. private _skybox;
  48791. /**
  48792. * Gets the skybox created by the helper.
  48793. */
  48794. readonly skybox: Nullable<Mesh>;
  48795. private _skyboxTexture;
  48796. /**
  48797. * Gets the skybox texture created by the helper.
  48798. */
  48799. readonly skyboxTexture: Nullable<BaseTexture>;
  48800. private _skyboxMaterial;
  48801. /**
  48802. * Gets the skybox material created by the helper.
  48803. */
  48804. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48805. private _ground;
  48806. /**
  48807. * Gets the ground mesh created by the helper.
  48808. */
  48809. readonly ground: Nullable<Mesh>;
  48810. private _groundTexture;
  48811. /**
  48812. * Gets the ground texture created by the helper.
  48813. */
  48814. readonly groundTexture: Nullable<BaseTexture>;
  48815. private _groundMirror;
  48816. /**
  48817. * Gets the ground mirror created by the helper.
  48818. */
  48819. readonly groundMirror: Nullable<MirrorTexture>;
  48820. /**
  48821. * Gets the ground mirror render list to helps pushing the meshes
  48822. * you wish in the ground reflection.
  48823. */
  48824. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48825. private _groundMaterial;
  48826. /**
  48827. * Gets the ground material created by the helper.
  48828. */
  48829. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48830. /**
  48831. * Stores the creation options.
  48832. */
  48833. private readonly _scene;
  48834. private _options;
  48835. /**
  48836. * This observable will be notified with any error during the creation of the environment,
  48837. * mainly texture creation errors.
  48838. */
  48839. onErrorObservable: Observable<{
  48840. message?: string;
  48841. exception?: any;
  48842. }>;
  48843. /**
  48844. * constructor
  48845. * @param options Defines the options we want to customize the helper
  48846. * @param scene The scene to add the material to
  48847. */
  48848. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48849. /**
  48850. * Updates the background according to the new options
  48851. * @param options
  48852. */
  48853. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48854. /**
  48855. * Sets the primary color of all the available elements.
  48856. * @param color the main color to affect to the ground and the background
  48857. */
  48858. setMainColor(color: Color3): void;
  48859. /**
  48860. * Setup the image processing according to the specified options.
  48861. */
  48862. private _setupImageProcessing;
  48863. /**
  48864. * Setup the environment texture according to the specified options.
  48865. */
  48866. private _setupEnvironmentTexture;
  48867. /**
  48868. * Setup the background according to the specified options.
  48869. */
  48870. private _setupBackground;
  48871. /**
  48872. * Get the scene sizes according to the setup.
  48873. */
  48874. private _getSceneSize;
  48875. /**
  48876. * Setup the ground according to the specified options.
  48877. */
  48878. private _setupGround;
  48879. /**
  48880. * Setup the ground material according to the specified options.
  48881. */
  48882. private _setupGroundMaterial;
  48883. /**
  48884. * Setup the ground diffuse texture according to the specified options.
  48885. */
  48886. private _setupGroundDiffuseTexture;
  48887. /**
  48888. * Setup the ground mirror texture according to the specified options.
  48889. */
  48890. private _setupGroundMirrorTexture;
  48891. /**
  48892. * Setup the ground to receive the mirror texture.
  48893. */
  48894. private _setupMirrorInGroundMaterial;
  48895. /**
  48896. * Setup the skybox according to the specified options.
  48897. */
  48898. private _setupSkybox;
  48899. /**
  48900. * Setup the skybox material according to the specified options.
  48901. */
  48902. private _setupSkyboxMaterial;
  48903. /**
  48904. * Setup the skybox reflection texture according to the specified options.
  48905. */
  48906. private _setupSkyboxReflectionTexture;
  48907. private _errorHandler;
  48908. /**
  48909. * Dispose all the elements created by the Helper.
  48910. */
  48911. dispose(): void;
  48912. }
  48913. }
  48914. declare module "babylonjs/Helpers/photoDome" {
  48915. import { Observable } from "babylonjs/Misc/observable";
  48916. import { Nullable } from "babylonjs/types";
  48917. import { Scene } from "babylonjs/scene";
  48918. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48919. import { Mesh } from "babylonjs/Meshes/mesh";
  48920. import { Texture } from "babylonjs/Materials/Textures/texture";
  48921. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48922. import "babylonjs/Meshes/Builders/sphereBuilder";
  48923. /**
  48924. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48925. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48926. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48927. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48928. */
  48929. export class PhotoDome extends TransformNode {
  48930. /**
  48931. * Define the image as a Monoscopic panoramic 360 image.
  48932. */
  48933. static readonly MODE_MONOSCOPIC: number;
  48934. /**
  48935. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48936. */
  48937. static readonly MODE_TOPBOTTOM: number;
  48938. /**
  48939. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48940. */
  48941. static readonly MODE_SIDEBYSIDE: number;
  48942. private _useDirectMapping;
  48943. /**
  48944. * The texture being displayed on the sphere
  48945. */
  48946. protected _photoTexture: Texture;
  48947. /**
  48948. * Gets or sets the texture being displayed on the sphere
  48949. */
  48950. photoTexture: Texture;
  48951. /**
  48952. * Observable raised when an error occured while loading the 360 image
  48953. */
  48954. onLoadErrorObservable: Observable<string>;
  48955. /**
  48956. * The skybox material
  48957. */
  48958. protected _material: BackgroundMaterial;
  48959. /**
  48960. * The surface used for the skybox
  48961. */
  48962. protected _mesh: Mesh;
  48963. /**
  48964. * Gets the mesh used for the skybox.
  48965. */
  48966. readonly mesh: Mesh;
  48967. /**
  48968. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48969. * Also see the options.resolution property.
  48970. */
  48971. fovMultiplier: number;
  48972. private _imageMode;
  48973. /**
  48974. * Gets or set the current video mode for the video. It can be:
  48975. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48976. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48977. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48978. */
  48979. imageMode: number;
  48980. /**
  48981. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48982. * @param name Element's name, child elements will append suffixes for their own names.
  48983. * @param urlsOfPhoto defines the url of the photo to display
  48984. * @param options defines an object containing optional or exposed sub element properties
  48985. * @param onError defines a callback called when an error occured while loading the texture
  48986. */
  48987. constructor(name: string, urlOfPhoto: string, options: {
  48988. resolution?: number;
  48989. size?: number;
  48990. useDirectMapping?: boolean;
  48991. faceForward?: boolean;
  48992. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48993. private _onBeforeCameraRenderObserver;
  48994. private _changeImageMode;
  48995. /**
  48996. * Releases resources associated with this node.
  48997. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48998. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48999. */
  49000. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49001. }
  49002. }
  49003. declare module "babylonjs/Misc/rgbdTextureTools" {
  49004. import "babylonjs/Shaders/rgbdDecode.fragment";
  49005. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49006. import { Texture } from "babylonjs/Materials/Textures/texture";
  49007. /**
  49008. * Class used to host RGBD texture specific utilities
  49009. */
  49010. export class RGBDTextureTools {
  49011. /**
  49012. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49013. * @param texture the texture to expand.
  49014. */
  49015. static ExpandRGBDTexture(texture: Texture): void;
  49016. }
  49017. }
  49018. declare module "babylonjs/Misc/brdfTextureTools" {
  49019. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49020. import { Scene } from "babylonjs/scene";
  49021. /**
  49022. * Class used to host texture specific utilities
  49023. */
  49024. export class BRDFTextureTools {
  49025. /**
  49026. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49027. * @param scene defines the hosting scene
  49028. * @returns the environment BRDF texture
  49029. */
  49030. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49031. private static _environmentBRDFBase64Texture;
  49032. }
  49033. }
  49034. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  49035. import { Nullable } from "babylonjs/types";
  49036. import { Color3 } from "babylonjs/Maths/math.color";
  49037. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49038. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49039. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49040. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49041. import { Engine } from "babylonjs/Engines/engine";
  49042. import { Scene } from "babylonjs/scene";
  49043. /**
  49044. * @hidden
  49045. */
  49046. export interface IMaterialClearCoatDefines {
  49047. CLEARCOAT: boolean;
  49048. CLEARCOAT_DEFAULTIOR: boolean;
  49049. CLEARCOAT_TEXTURE: boolean;
  49050. CLEARCOAT_TEXTUREDIRECTUV: number;
  49051. CLEARCOAT_BUMP: boolean;
  49052. CLEARCOAT_BUMPDIRECTUV: number;
  49053. CLEARCOAT_TINT: boolean;
  49054. CLEARCOAT_TINT_TEXTURE: boolean;
  49055. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49056. /** @hidden */
  49057. _areTexturesDirty: boolean;
  49058. }
  49059. /**
  49060. * Define the code related to the clear coat parameters of the pbr material.
  49061. */
  49062. export class PBRClearCoatConfiguration {
  49063. /**
  49064. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49065. * The default fits with a polyurethane material.
  49066. */
  49067. private static readonly _DefaultIndexOfRefraction;
  49068. private _isEnabled;
  49069. /**
  49070. * Defines if the clear coat is enabled in the material.
  49071. */
  49072. isEnabled: boolean;
  49073. /**
  49074. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49075. */
  49076. intensity: number;
  49077. /**
  49078. * Defines the clear coat layer roughness.
  49079. */
  49080. roughness: number;
  49081. private _indexOfRefraction;
  49082. /**
  49083. * Defines the index of refraction of the clear coat.
  49084. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49085. * The default fits with a polyurethane material.
  49086. * Changing the default value is more performance intensive.
  49087. */
  49088. indexOfRefraction: number;
  49089. private _texture;
  49090. /**
  49091. * Stores the clear coat values in a texture.
  49092. */
  49093. texture: Nullable<BaseTexture>;
  49094. private _bumpTexture;
  49095. /**
  49096. * Define the clear coat specific bump texture.
  49097. */
  49098. bumpTexture: Nullable<BaseTexture>;
  49099. private _isTintEnabled;
  49100. /**
  49101. * Defines if the clear coat tint is enabled in the material.
  49102. */
  49103. isTintEnabled: boolean;
  49104. /**
  49105. * Defines the clear coat tint of the material.
  49106. * This is only use if tint is enabled
  49107. */
  49108. tintColor: Color3;
  49109. /**
  49110. * Defines the distance at which the tint color should be found in the
  49111. * clear coat media.
  49112. * This is only use if tint is enabled
  49113. */
  49114. tintColorAtDistance: number;
  49115. /**
  49116. * Defines the clear coat layer thickness.
  49117. * This is only use if tint is enabled
  49118. */
  49119. tintThickness: number;
  49120. private _tintTexture;
  49121. /**
  49122. * Stores the clear tint values in a texture.
  49123. * rgb is tint
  49124. * a is a thickness factor
  49125. */
  49126. tintTexture: Nullable<BaseTexture>;
  49127. /** @hidden */
  49128. private _internalMarkAllSubMeshesAsTexturesDirty;
  49129. /** @hidden */
  49130. _markAllSubMeshesAsTexturesDirty(): void;
  49131. /**
  49132. * Instantiate a new istance of clear coat configuration.
  49133. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49134. */
  49135. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49136. /**
  49137. * Gets wehter the submesh is ready to be used or not.
  49138. * @param defines the list of "defines" to update.
  49139. * @param scene defines the scene the material belongs to.
  49140. * @param engine defines the engine the material belongs to.
  49141. * @param disableBumpMap defines wether the material disables bump or not.
  49142. * @returns - boolean indicating that the submesh is ready or not.
  49143. */
  49144. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49145. /**
  49146. * Checks to see if a texture is used in the material.
  49147. * @param defines the list of "defines" to update.
  49148. * @param scene defines the scene to the material belongs to.
  49149. */
  49150. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49151. /**
  49152. * Binds the material data.
  49153. * @param uniformBuffer defines the Uniform buffer to fill in.
  49154. * @param scene defines the scene the material belongs to.
  49155. * @param engine defines the engine the material belongs to.
  49156. * @param disableBumpMap defines wether the material disables bump or not.
  49157. * @param isFrozen defines wether the material is frozen or not.
  49158. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49159. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49160. */
  49161. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49162. /**
  49163. * Checks to see if a texture is used in the material.
  49164. * @param texture - Base texture to use.
  49165. * @returns - Boolean specifying if a texture is used in the material.
  49166. */
  49167. hasTexture(texture: BaseTexture): boolean;
  49168. /**
  49169. * Returns an array of the actively used textures.
  49170. * @param activeTextures Array of BaseTextures
  49171. */
  49172. getActiveTextures(activeTextures: BaseTexture[]): void;
  49173. /**
  49174. * Returns the animatable textures.
  49175. * @param animatables Array of animatable textures.
  49176. */
  49177. getAnimatables(animatables: IAnimatable[]): void;
  49178. /**
  49179. * Disposes the resources of the material.
  49180. * @param forceDisposeTextures - Forces the disposal of all textures.
  49181. */
  49182. dispose(forceDisposeTextures?: boolean): void;
  49183. /**
  49184. * Get the current class name of the texture useful for serialization or dynamic coding.
  49185. * @returns "PBRClearCoatConfiguration"
  49186. */
  49187. getClassName(): string;
  49188. /**
  49189. * Add fallbacks to the effect fallbacks list.
  49190. * @param defines defines the Base texture to use.
  49191. * @param fallbacks defines the current fallback list.
  49192. * @param currentRank defines the current fallback rank.
  49193. * @returns the new fallback rank.
  49194. */
  49195. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49196. /**
  49197. * Add the required uniforms to the current list.
  49198. * @param uniforms defines the current uniform list.
  49199. */
  49200. static AddUniforms(uniforms: string[]): void;
  49201. /**
  49202. * Add the required samplers to the current list.
  49203. * @param samplers defines the current sampler list.
  49204. */
  49205. static AddSamplers(samplers: string[]): void;
  49206. /**
  49207. * Add the required uniforms to the current buffer.
  49208. * @param uniformBuffer defines the current uniform buffer.
  49209. */
  49210. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49211. /**
  49212. * Makes a duplicate of the current configuration into another one.
  49213. * @param clearCoatConfiguration define the config where to copy the info
  49214. */
  49215. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49216. /**
  49217. * Serializes this clear coat configuration.
  49218. * @returns - An object with the serialized config.
  49219. */
  49220. serialize(): any;
  49221. /**
  49222. * Parses a anisotropy Configuration from a serialized object.
  49223. * @param source - Serialized object.
  49224. * @param scene Defines the scene we are parsing for
  49225. * @param rootUrl Defines the rootUrl to load from
  49226. */
  49227. parse(source: any, scene: Scene, rootUrl: string): void;
  49228. }
  49229. }
  49230. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  49231. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49232. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49233. import { Vector2 } from "babylonjs/Maths/math.vector";
  49234. import { Scene } from "babylonjs/scene";
  49235. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49236. import { Nullable } from "babylonjs/types";
  49237. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49238. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49239. /**
  49240. * @hidden
  49241. */
  49242. export interface IMaterialAnisotropicDefines {
  49243. ANISOTROPIC: boolean;
  49244. ANISOTROPIC_TEXTURE: boolean;
  49245. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49246. MAINUV1: boolean;
  49247. _areTexturesDirty: boolean;
  49248. _needUVs: boolean;
  49249. }
  49250. /**
  49251. * Define the code related to the anisotropic parameters of the pbr material.
  49252. */
  49253. export class PBRAnisotropicConfiguration {
  49254. private _isEnabled;
  49255. /**
  49256. * Defines if the anisotropy is enabled in the material.
  49257. */
  49258. isEnabled: boolean;
  49259. /**
  49260. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49261. */
  49262. intensity: number;
  49263. /**
  49264. * Defines if the effect is along the tangents, bitangents or in between.
  49265. * By default, the effect is "strectching" the highlights along the tangents.
  49266. */
  49267. direction: Vector2;
  49268. private _texture;
  49269. /**
  49270. * Stores the anisotropy values in a texture.
  49271. * rg is direction (like normal from -1 to 1)
  49272. * b is a intensity
  49273. */
  49274. texture: Nullable<BaseTexture>;
  49275. /** @hidden */
  49276. private _internalMarkAllSubMeshesAsTexturesDirty;
  49277. /** @hidden */
  49278. _markAllSubMeshesAsTexturesDirty(): void;
  49279. /**
  49280. * Instantiate a new istance of anisotropy configuration.
  49281. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49282. */
  49283. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49284. /**
  49285. * Specifies that the submesh is ready to be used.
  49286. * @param defines the list of "defines" to update.
  49287. * @param scene defines the scene the material belongs to.
  49288. * @returns - boolean indicating that the submesh is ready or not.
  49289. */
  49290. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49291. /**
  49292. * Checks to see if a texture is used in the material.
  49293. * @param defines the list of "defines" to update.
  49294. * @param mesh the mesh we are preparing the defines for.
  49295. * @param scene defines the scene the material belongs to.
  49296. */
  49297. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49298. /**
  49299. * Binds the material data.
  49300. * @param uniformBuffer defines the Uniform buffer to fill in.
  49301. * @param scene defines the scene the material belongs to.
  49302. * @param isFrozen defines wether the material is frozen or not.
  49303. */
  49304. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49305. /**
  49306. * Checks to see if a texture is used in the material.
  49307. * @param texture - Base texture to use.
  49308. * @returns - Boolean specifying if a texture is used in the material.
  49309. */
  49310. hasTexture(texture: BaseTexture): boolean;
  49311. /**
  49312. * Returns an array of the actively used textures.
  49313. * @param activeTextures Array of BaseTextures
  49314. */
  49315. getActiveTextures(activeTextures: BaseTexture[]): void;
  49316. /**
  49317. * Returns the animatable textures.
  49318. * @param animatables Array of animatable textures.
  49319. */
  49320. getAnimatables(animatables: IAnimatable[]): void;
  49321. /**
  49322. * Disposes the resources of the material.
  49323. * @param forceDisposeTextures - Forces the disposal of all textures.
  49324. */
  49325. dispose(forceDisposeTextures?: boolean): void;
  49326. /**
  49327. * Get the current class name of the texture useful for serialization or dynamic coding.
  49328. * @returns "PBRAnisotropicConfiguration"
  49329. */
  49330. getClassName(): string;
  49331. /**
  49332. * Add fallbacks to the effect fallbacks list.
  49333. * @param defines defines the Base texture to use.
  49334. * @param fallbacks defines the current fallback list.
  49335. * @param currentRank defines the current fallback rank.
  49336. * @returns the new fallback rank.
  49337. */
  49338. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49339. /**
  49340. * Add the required uniforms to the current list.
  49341. * @param uniforms defines the current uniform list.
  49342. */
  49343. static AddUniforms(uniforms: string[]): void;
  49344. /**
  49345. * Add the required uniforms to the current buffer.
  49346. * @param uniformBuffer defines the current uniform buffer.
  49347. */
  49348. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49349. /**
  49350. * Add the required samplers to the current list.
  49351. * @param samplers defines the current sampler list.
  49352. */
  49353. static AddSamplers(samplers: string[]): void;
  49354. /**
  49355. * Makes a duplicate of the current configuration into another one.
  49356. * @param anisotropicConfiguration define the config where to copy the info
  49357. */
  49358. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49359. /**
  49360. * Serializes this anisotropy configuration.
  49361. * @returns - An object with the serialized config.
  49362. */
  49363. serialize(): any;
  49364. /**
  49365. * Parses a anisotropy Configuration from a serialized object.
  49366. * @param source - Serialized object.
  49367. * @param scene Defines the scene we are parsing for
  49368. * @param rootUrl Defines the rootUrl to load from
  49369. */
  49370. parse(source: any, scene: Scene, rootUrl: string): void;
  49371. }
  49372. }
  49373. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  49374. import { Scene } from "babylonjs/scene";
  49375. /**
  49376. * @hidden
  49377. */
  49378. export interface IMaterialBRDFDefines {
  49379. BRDF_V_HEIGHT_CORRELATED: boolean;
  49380. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49381. SPHERICAL_HARMONICS: boolean;
  49382. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49383. /** @hidden */
  49384. _areMiscDirty: boolean;
  49385. }
  49386. /**
  49387. * Define the code related to the BRDF parameters of the pbr material.
  49388. */
  49389. export class PBRBRDFConfiguration {
  49390. /**
  49391. * Default value used for the energy conservation.
  49392. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49393. */
  49394. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49395. /**
  49396. * Default value used for the Smith Visibility Height Correlated mode.
  49397. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49398. */
  49399. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49400. /**
  49401. * Default value used for the IBL diffuse part.
  49402. * This can help switching back to the polynomials mode globally which is a tiny bit
  49403. * less GPU intensive at the drawback of a lower quality.
  49404. */
  49405. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49406. /**
  49407. * Default value used for activating energy conservation for the specular workflow.
  49408. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49409. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49410. */
  49411. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49412. private _useEnergyConservation;
  49413. /**
  49414. * Defines if the material uses energy conservation.
  49415. */
  49416. useEnergyConservation: boolean;
  49417. private _useSmithVisibilityHeightCorrelated;
  49418. /**
  49419. * LEGACY Mode set to false
  49420. * Defines if the material uses height smith correlated visibility term.
  49421. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49422. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49423. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49424. * Not relying on height correlated will also disable energy conservation.
  49425. */
  49426. useSmithVisibilityHeightCorrelated: boolean;
  49427. private _useSphericalHarmonics;
  49428. /**
  49429. * LEGACY Mode set to false
  49430. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49431. * diffuse part of the IBL.
  49432. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49433. * to the ground truth.
  49434. */
  49435. useSphericalHarmonics: boolean;
  49436. private _useSpecularGlossinessInputEnergyConservation;
  49437. /**
  49438. * Defines if the material uses energy conservation, when the specular workflow is active.
  49439. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49440. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49441. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49442. */
  49443. useSpecularGlossinessInputEnergyConservation: boolean;
  49444. /** @hidden */
  49445. private _internalMarkAllSubMeshesAsMiscDirty;
  49446. /** @hidden */
  49447. _markAllSubMeshesAsMiscDirty(): void;
  49448. /**
  49449. * Instantiate a new istance of clear coat configuration.
  49450. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49451. */
  49452. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49453. /**
  49454. * Checks to see if a texture is used in the material.
  49455. * @param defines the list of "defines" to update.
  49456. */
  49457. prepareDefines(defines: IMaterialBRDFDefines): void;
  49458. /**
  49459. * Get the current class name of the texture useful for serialization or dynamic coding.
  49460. * @returns "PBRClearCoatConfiguration"
  49461. */
  49462. getClassName(): string;
  49463. /**
  49464. * Makes a duplicate of the current configuration into another one.
  49465. * @param brdfConfiguration define the config where to copy the info
  49466. */
  49467. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49468. /**
  49469. * Serializes this BRDF configuration.
  49470. * @returns - An object with the serialized config.
  49471. */
  49472. serialize(): any;
  49473. /**
  49474. * Parses a anisotropy Configuration from a serialized object.
  49475. * @param source - Serialized object.
  49476. * @param scene Defines the scene we are parsing for
  49477. * @param rootUrl Defines the rootUrl to load from
  49478. */
  49479. parse(source: any, scene: Scene, rootUrl: string): void;
  49480. }
  49481. }
  49482. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  49483. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49484. import { Color3 } from "babylonjs/Maths/math.color";
  49485. import { Scene } from "babylonjs/scene";
  49486. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49487. import { Nullable } from "babylonjs/types";
  49488. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49489. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49490. /**
  49491. * @hidden
  49492. */
  49493. export interface IMaterialSheenDefines {
  49494. SHEEN: boolean;
  49495. SHEEN_TEXTURE: boolean;
  49496. SHEEN_TEXTUREDIRECTUV: number;
  49497. SHEEN_LINKWITHALBEDO: boolean;
  49498. /** @hidden */
  49499. _areTexturesDirty: boolean;
  49500. }
  49501. /**
  49502. * Define the code related to the Sheen parameters of the pbr material.
  49503. */
  49504. export class PBRSheenConfiguration {
  49505. private _isEnabled;
  49506. /**
  49507. * Defines if the material uses sheen.
  49508. */
  49509. isEnabled: boolean;
  49510. private _linkSheenWithAlbedo;
  49511. /**
  49512. * Defines if the sheen is linked to the sheen color.
  49513. */
  49514. linkSheenWithAlbedo: boolean;
  49515. /**
  49516. * Defines the sheen intensity.
  49517. */
  49518. intensity: number;
  49519. /**
  49520. * Defines the sheen color.
  49521. */
  49522. color: Color3;
  49523. private _texture;
  49524. /**
  49525. * Stores the sheen tint values in a texture.
  49526. * rgb is tint
  49527. * a is a intensity
  49528. */
  49529. texture: Nullable<BaseTexture>;
  49530. /** @hidden */
  49531. private _internalMarkAllSubMeshesAsTexturesDirty;
  49532. /** @hidden */
  49533. _markAllSubMeshesAsTexturesDirty(): void;
  49534. /**
  49535. * Instantiate a new istance of clear coat configuration.
  49536. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49537. */
  49538. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49539. /**
  49540. * Specifies that the submesh is ready to be used.
  49541. * @param defines the list of "defines" to update.
  49542. * @param scene defines the scene the material belongs to.
  49543. * @returns - boolean indicating that the submesh is ready or not.
  49544. */
  49545. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49546. /**
  49547. * Checks to see if a texture is used in the material.
  49548. * @param defines the list of "defines" to update.
  49549. * @param scene defines the scene the material belongs to.
  49550. */
  49551. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49552. /**
  49553. * Binds the material data.
  49554. * @param uniformBuffer defines the Uniform buffer to fill in.
  49555. * @param scene defines the scene the material belongs to.
  49556. * @param isFrozen defines wether the material is frozen or not.
  49557. */
  49558. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49559. /**
  49560. * Checks to see if a texture is used in the material.
  49561. * @param texture - Base texture to use.
  49562. * @returns - Boolean specifying if a texture is used in the material.
  49563. */
  49564. hasTexture(texture: BaseTexture): boolean;
  49565. /**
  49566. * Returns an array of the actively used textures.
  49567. * @param activeTextures Array of BaseTextures
  49568. */
  49569. getActiveTextures(activeTextures: BaseTexture[]): void;
  49570. /**
  49571. * Returns the animatable textures.
  49572. * @param animatables Array of animatable textures.
  49573. */
  49574. getAnimatables(animatables: IAnimatable[]): void;
  49575. /**
  49576. * Disposes the resources of the material.
  49577. * @param forceDisposeTextures - Forces the disposal of all textures.
  49578. */
  49579. dispose(forceDisposeTextures?: boolean): void;
  49580. /**
  49581. * Get the current class name of the texture useful for serialization or dynamic coding.
  49582. * @returns "PBRSheenConfiguration"
  49583. */
  49584. getClassName(): string;
  49585. /**
  49586. * Add fallbacks to the effect fallbacks list.
  49587. * @param defines defines the Base texture to use.
  49588. * @param fallbacks defines the current fallback list.
  49589. * @param currentRank defines the current fallback rank.
  49590. * @returns the new fallback rank.
  49591. */
  49592. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49593. /**
  49594. * Add the required uniforms to the current list.
  49595. * @param uniforms defines the current uniform list.
  49596. */
  49597. static AddUniforms(uniforms: string[]): void;
  49598. /**
  49599. * Add the required uniforms to the current buffer.
  49600. * @param uniformBuffer defines the current uniform buffer.
  49601. */
  49602. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49603. /**
  49604. * Add the required samplers to the current list.
  49605. * @param samplers defines the current sampler list.
  49606. */
  49607. static AddSamplers(samplers: string[]): void;
  49608. /**
  49609. * Makes a duplicate of the current configuration into another one.
  49610. * @param sheenConfiguration define the config where to copy the info
  49611. */
  49612. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49613. /**
  49614. * Serializes this BRDF configuration.
  49615. * @returns - An object with the serialized config.
  49616. */
  49617. serialize(): any;
  49618. /**
  49619. * Parses a anisotropy Configuration from a serialized object.
  49620. * @param source - Serialized object.
  49621. * @param scene Defines the scene we are parsing for
  49622. * @param rootUrl Defines the rootUrl to load from
  49623. */
  49624. parse(source: any, scene: Scene, rootUrl: string): void;
  49625. }
  49626. }
  49627. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49628. import { Nullable } from "babylonjs/types";
  49629. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49630. import { Color3 } from "babylonjs/Maths/math.color";
  49631. import { SmartArray } from "babylonjs/Misc/smartArray";
  49632. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49633. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49634. import { Effect } from "babylonjs/Materials/effect";
  49635. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49636. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49637. import { Engine } from "babylonjs/Engines/engine";
  49638. import { Scene } from "babylonjs/scene";
  49639. /**
  49640. * @hidden
  49641. */
  49642. export interface IMaterialSubSurfaceDefines {
  49643. SUBSURFACE: boolean;
  49644. SS_REFRACTION: boolean;
  49645. SS_TRANSLUCENCY: boolean;
  49646. SS_SCATERRING: boolean;
  49647. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49648. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49649. SS_REFRACTIONMAP_3D: boolean;
  49650. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49651. SS_LODINREFRACTIONALPHA: boolean;
  49652. SS_GAMMAREFRACTION: boolean;
  49653. SS_RGBDREFRACTION: boolean;
  49654. SS_LINEARSPECULARREFRACTION: boolean;
  49655. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49656. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49657. /** @hidden */
  49658. _areTexturesDirty: boolean;
  49659. }
  49660. /**
  49661. * Define the code related to the sub surface parameters of the pbr material.
  49662. */
  49663. export class PBRSubSurfaceConfiguration {
  49664. private _isRefractionEnabled;
  49665. /**
  49666. * Defines if the refraction is enabled in the material.
  49667. */
  49668. isRefractionEnabled: boolean;
  49669. private _isTranslucencyEnabled;
  49670. /**
  49671. * Defines if the translucency is enabled in the material.
  49672. */
  49673. isTranslucencyEnabled: boolean;
  49674. private _isScatteringEnabled;
  49675. /**
  49676. * Defines the refraction intensity of the material.
  49677. * The refraction when enabled replaces the Diffuse part of the material.
  49678. * The intensity helps transitionning between diffuse and refraction.
  49679. */
  49680. refractionIntensity: number;
  49681. /**
  49682. * Defines the translucency intensity of the material.
  49683. * When translucency has been enabled, this defines how much of the "translucency"
  49684. * is addded to the diffuse part of the material.
  49685. */
  49686. translucencyIntensity: number;
  49687. /**
  49688. * Defines the scattering intensity of the material.
  49689. * When scattering has been enabled, this defines how much of the "scattered light"
  49690. * is addded to the diffuse part of the material.
  49691. */
  49692. scatteringIntensity: number;
  49693. private _thicknessTexture;
  49694. /**
  49695. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49696. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49697. * 0 would mean minimumThickness
  49698. * 1 would mean maximumThickness
  49699. * The other channels might be use as a mask to vary the different effects intensity.
  49700. */
  49701. thicknessTexture: Nullable<BaseTexture>;
  49702. private _refractionTexture;
  49703. /**
  49704. * Defines the texture to use for refraction.
  49705. */
  49706. refractionTexture: Nullable<BaseTexture>;
  49707. private _indexOfRefraction;
  49708. /**
  49709. * Defines the index of refraction used in the material.
  49710. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49711. */
  49712. indexOfRefraction: number;
  49713. private _invertRefractionY;
  49714. /**
  49715. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49716. */
  49717. invertRefractionY: boolean;
  49718. private _linkRefractionWithTransparency;
  49719. /**
  49720. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49721. * Materials half opaque for instance using refraction could benefit from this control.
  49722. */
  49723. linkRefractionWithTransparency: boolean;
  49724. /**
  49725. * Defines the minimum thickness stored in the thickness map.
  49726. * If no thickness map is defined, this value will be used to simulate thickness.
  49727. */
  49728. minimumThickness: number;
  49729. /**
  49730. * Defines the maximum thickness stored in the thickness map.
  49731. */
  49732. maximumThickness: number;
  49733. /**
  49734. * Defines the volume tint of the material.
  49735. * This is used for both translucency and scattering.
  49736. */
  49737. tintColor: Color3;
  49738. /**
  49739. * Defines the distance at which the tint color should be found in the media.
  49740. * This is used for refraction only.
  49741. */
  49742. tintColorAtDistance: number;
  49743. /**
  49744. * Defines how far each channel transmit through the media.
  49745. * It is defined as a color to simplify it selection.
  49746. */
  49747. diffusionDistance: Color3;
  49748. private _useMaskFromThicknessTexture;
  49749. /**
  49750. * Stores the intensity of the different subsurface effects in the thickness texture.
  49751. * * the green channel is the translucency intensity.
  49752. * * the blue channel is the scattering intensity.
  49753. * * the alpha channel is the refraction intensity.
  49754. */
  49755. useMaskFromThicknessTexture: boolean;
  49756. /** @hidden */
  49757. private _internalMarkAllSubMeshesAsTexturesDirty;
  49758. /** @hidden */
  49759. _markAllSubMeshesAsTexturesDirty(): void;
  49760. /**
  49761. * Instantiate a new istance of sub surface configuration.
  49762. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49763. */
  49764. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49765. /**
  49766. * Gets wehter the submesh is ready to be used or not.
  49767. * @param defines the list of "defines" to update.
  49768. * @param scene defines the scene the material belongs to.
  49769. * @returns - boolean indicating that the submesh is ready or not.
  49770. */
  49771. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49772. /**
  49773. * Checks to see if a texture is used in the material.
  49774. * @param defines the list of "defines" to update.
  49775. * @param scene defines the scene to the material belongs to.
  49776. */
  49777. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49778. /**
  49779. * Binds the material data.
  49780. * @param uniformBuffer defines the Uniform buffer to fill in.
  49781. * @param scene defines the scene the material belongs to.
  49782. * @param engine defines the engine the material belongs to.
  49783. * @param isFrozen defines wether the material is frozen or not.
  49784. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49785. */
  49786. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49787. /**
  49788. * Unbinds the material from the mesh.
  49789. * @param activeEffect defines the effect that should be unbound from.
  49790. * @returns true if unbound, otherwise false
  49791. */
  49792. unbind(activeEffect: Effect): boolean;
  49793. /**
  49794. * Returns the texture used for refraction or null if none is used.
  49795. * @param scene defines the scene the material belongs to.
  49796. * @returns - Refraction texture if present. If no refraction texture and refraction
  49797. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49798. */
  49799. private _getRefractionTexture;
  49800. /**
  49801. * Returns true if alpha blending should be disabled.
  49802. */
  49803. readonly disableAlphaBlending: boolean;
  49804. /**
  49805. * Fills the list of render target textures.
  49806. * @param renderTargets the list of render targets to update
  49807. */
  49808. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49809. /**
  49810. * Checks to see if a texture is used in the material.
  49811. * @param texture - Base texture to use.
  49812. * @returns - Boolean specifying if a texture is used in the material.
  49813. */
  49814. hasTexture(texture: BaseTexture): boolean;
  49815. /**
  49816. * Gets a boolean indicating that current material needs to register RTT
  49817. * @returns true if this uses a render target otherwise false.
  49818. */
  49819. hasRenderTargetTextures(): boolean;
  49820. /**
  49821. * Returns an array of the actively used textures.
  49822. * @param activeTextures Array of BaseTextures
  49823. */
  49824. getActiveTextures(activeTextures: BaseTexture[]): void;
  49825. /**
  49826. * Returns the animatable textures.
  49827. * @param animatables Array of animatable textures.
  49828. */
  49829. getAnimatables(animatables: IAnimatable[]): void;
  49830. /**
  49831. * Disposes the resources of the material.
  49832. * @param forceDisposeTextures - Forces the disposal of all textures.
  49833. */
  49834. dispose(forceDisposeTextures?: boolean): void;
  49835. /**
  49836. * Get the current class name of the texture useful for serialization or dynamic coding.
  49837. * @returns "PBRSubSurfaceConfiguration"
  49838. */
  49839. getClassName(): string;
  49840. /**
  49841. * Add fallbacks to the effect fallbacks list.
  49842. * @param defines defines the Base texture to use.
  49843. * @param fallbacks defines the current fallback list.
  49844. * @param currentRank defines the current fallback rank.
  49845. * @returns the new fallback rank.
  49846. */
  49847. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49848. /**
  49849. * Add the required uniforms to the current list.
  49850. * @param uniforms defines the current uniform list.
  49851. */
  49852. static AddUniforms(uniforms: string[]): void;
  49853. /**
  49854. * Add the required samplers to the current list.
  49855. * @param samplers defines the current sampler list.
  49856. */
  49857. static AddSamplers(samplers: string[]): void;
  49858. /**
  49859. * Add the required uniforms to the current buffer.
  49860. * @param uniformBuffer defines the current uniform buffer.
  49861. */
  49862. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49863. /**
  49864. * Makes a duplicate of the current configuration into another one.
  49865. * @param configuration define the config where to copy the info
  49866. */
  49867. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49868. /**
  49869. * Serializes this Sub Surface configuration.
  49870. * @returns - An object with the serialized config.
  49871. */
  49872. serialize(): any;
  49873. /**
  49874. * Parses a anisotropy Configuration from a serialized object.
  49875. * @param source - Serialized object.
  49876. * @param scene Defines the scene we are parsing for
  49877. * @param rootUrl Defines the rootUrl to load from
  49878. */
  49879. parse(source: any, scene: Scene, rootUrl: string): void;
  49880. }
  49881. }
  49882. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49883. /** @hidden */
  49884. export var pbrFragmentDeclaration: {
  49885. name: string;
  49886. shader: string;
  49887. };
  49888. }
  49889. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49890. /** @hidden */
  49891. export var pbrUboDeclaration: {
  49892. name: string;
  49893. shader: string;
  49894. };
  49895. }
  49896. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49897. /** @hidden */
  49898. export var pbrFragmentExtraDeclaration: {
  49899. name: string;
  49900. shader: string;
  49901. };
  49902. }
  49903. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49904. /** @hidden */
  49905. export var pbrFragmentSamplersDeclaration: {
  49906. name: string;
  49907. shader: string;
  49908. };
  49909. }
  49910. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49911. /** @hidden */
  49912. export var pbrHelperFunctions: {
  49913. name: string;
  49914. shader: string;
  49915. };
  49916. }
  49917. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49918. /** @hidden */
  49919. export var harmonicsFunctions: {
  49920. name: string;
  49921. shader: string;
  49922. };
  49923. }
  49924. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49925. /** @hidden */
  49926. export var pbrDirectLightingSetupFunctions: {
  49927. name: string;
  49928. shader: string;
  49929. };
  49930. }
  49931. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49932. /** @hidden */
  49933. export var pbrDirectLightingFalloffFunctions: {
  49934. name: string;
  49935. shader: string;
  49936. };
  49937. }
  49938. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49939. /** @hidden */
  49940. export var pbrBRDFFunctions: {
  49941. name: string;
  49942. shader: string;
  49943. };
  49944. }
  49945. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49946. /** @hidden */
  49947. export var pbrDirectLightingFunctions: {
  49948. name: string;
  49949. shader: string;
  49950. };
  49951. }
  49952. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49953. /** @hidden */
  49954. export var pbrIBLFunctions: {
  49955. name: string;
  49956. shader: string;
  49957. };
  49958. }
  49959. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49960. /** @hidden */
  49961. export var pbrDebug: {
  49962. name: string;
  49963. shader: string;
  49964. };
  49965. }
  49966. declare module "babylonjs/Shaders/pbr.fragment" {
  49967. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49968. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49969. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49970. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49971. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49972. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49973. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49974. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49975. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49976. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49977. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49978. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49979. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49980. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49981. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49982. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49983. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49984. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49985. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49986. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49987. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49988. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49989. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49990. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49991. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49992. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49993. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49994. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49995. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49996. /** @hidden */
  49997. export var pbrPixelShader: {
  49998. name: string;
  49999. shader: string;
  50000. };
  50001. }
  50002. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  50003. /** @hidden */
  50004. export var pbrVertexDeclaration: {
  50005. name: string;
  50006. shader: string;
  50007. };
  50008. }
  50009. declare module "babylonjs/Shaders/pbr.vertex" {
  50010. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  50011. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50012. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50013. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50014. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50015. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50016. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  50017. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50018. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50019. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50020. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50021. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50022. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50023. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50024. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50025. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50026. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50027. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  50028. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50029. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50030. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50031. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  50032. /** @hidden */
  50033. export var pbrVertexShader: {
  50034. name: string;
  50035. shader: string;
  50036. };
  50037. }
  50038. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  50039. import { Nullable } from "babylonjs/types";
  50040. import { Scene } from "babylonjs/scene";
  50041. import { Matrix } from "babylonjs/Maths/math.vector";
  50042. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50044. import { Mesh } from "babylonjs/Meshes/mesh";
  50045. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  50046. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  50047. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  50048. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  50049. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  50050. import { Color3 } from "babylonjs/Maths/math.color";
  50051. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  50052. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  50053. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  50054. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50055. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50056. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50057. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  50058. import "babylonjs/Shaders/pbr.fragment";
  50059. import "babylonjs/Shaders/pbr.vertex";
  50060. /**
  50061. * Manages the defines for the PBR Material.
  50062. * @hidden
  50063. */
  50064. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50065. PBR: boolean;
  50066. MAINUV1: boolean;
  50067. MAINUV2: boolean;
  50068. UV1: boolean;
  50069. UV2: boolean;
  50070. ALBEDO: boolean;
  50071. ALBEDODIRECTUV: number;
  50072. VERTEXCOLOR: boolean;
  50073. AMBIENT: boolean;
  50074. AMBIENTDIRECTUV: number;
  50075. AMBIENTINGRAYSCALE: boolean;
  50076. OPACITY: boolean;
  50077. VERTEXALPHA: boolean;
  50078. OPACITYDIRECTUV: number;
  50079. OPACITYRGB: boolean;
  50080. ALPHATEST: boolean;
  50081. DEPTHPREPASS: boolean;
  50082. ALPHABLEND: boolean;
  50083. ALPHAFROMALBEDO: boolean;
  50084. ALPHATESTVALUE: string;
  50085. SPECULAROVERALPHA: boolean;
  50086. RADIANCEOVERALPHA: boolean;
  50087. ALPHAFRESNEL: boolean;
  50088. LINEARALPHAFRESNEL: boolean;
  50089. PREMULTIPLYALPHA: boolean;
  50090. EMISSIVE: boolean;
  50091. EMISSIVEDIRECTUV: number;
  50092. REFLECTIVITY: boolean;
  50093. REFLECTIVITYDIRECTUV: number;
  50094. SPECULARTERM: boolean;
  50095. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50096. MICROSURFACEAUTOMATIC: boolean;
  50097. LODBASEDMICROSFURACE: boolean;
  50098. MICROSURFACEMAP: boolean;
  50099. MICROSURFACEMAPDIRECTUV: number;
  50100. METALLICWORKFLOW: boolean;
  50101. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50102. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50103. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50104. AOSTOREINMETALMAPRED: boolean;
  50105. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50106. ENVIRONMENTBRDF: boolean;
  50107. ENVIRONMENTBRDF_RGBD: boolean;
  50108. NORMAL: boolean;
  50109. TANGENT: boolean;
  50110. BUMP: boolean;
  50111. BUMPDIRECTUV: number;
  50112. OBJECTSPACE_NORMALMAP: boolean;
  50113. PARALLAX: boolean;
  50114. PARALLAXOCCLUSION: boolean;
  50115. NORMALXYSCALE: boolean;
  50116. LIGHTMAP: boolean;
  50117. LIGHTMAPDIRECTUV: number;
  50118. USELIGHTMAPASSHADOWMAP: boolean;
  50119. GAMMALIGHTMAP: boolean;
  50120. RGBDLIGHTMAP: boolean;
  50121. REFLECTION: boolean;
  50122. REFLECTIONMAP_3D: boolean;
  50123. REFLECTIONMAP_SPHERICAL: boolean;
  50124. REFLECTIONMAP_PLANAR: boolean;
  50125. REFLECTIONMAP_CUBIC: boolean;
  50126. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50127. REFLECTIONMAP_PROJECTION: boolean;
  50128. REFLECTIONMAP_SKYBOX: boolean;
  50129. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50130. REFLECTIONMAP_EXPLICIT: boolean;
  50131. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50132. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50133. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50134. INVERTCUBICMAP: boolean;
  50135. USESPHERICALFROMREFLECTIONMAP: boolean;
  50136. USEIRRADIANCEMAP: boolean;
  50137. SPHERICAL_HARMONICS: boolean;
  50138. USESPHERICALINVERTEX: boolean;
  50139. REFLECTIONMAP_OPPOSITEZ: boolean;
  50140. LODINREFLECTIONALPHA: boolean;
  50141. GAMMAREFLECTION: boolean;
  50142. RGBDREFLECTION: boolean;
  50143. LINEARSPECULARREFLECTION: boolean;
  50144. RADIANCEOCCLUSION: boolean;
  50145. HORIZONOCCLUSION: boolean;
  50146. INSTANCES: boolean;
  50147. NUM_BONE_INFLUENCERS: number;
  50148. BonesPerMesh: number;
  50149. BONETEXTURE: boolean;
  50150. NONUNIFORMSCALING: boolean;
  50151. MORPHTARGETS: boolean;
  50152. MORPHTARGETS_NORMAL: boolean;
  50153. MORPHTARGETS_TANGENT: boolean;
  50154. MORPHTARGETS_UV: boolean;
  50155. NUM_MORPH_INFLUENCERS: number;
  50156. IMAGEPROCESSING: boolean;
  50157. VIGNETTE: boolean;
  50158. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50159. VIGNETTEBLENDMODEOPAQUE: boolean;
  50160. TONEMAPPING: boolean;
  50161. TONEMAPPING_ACES: boolean;
  50162. CONTRAST: boolean;
  50163. COLORCURVES: boolean;
  50164. COLORGRADING: boolean;
  50165. COLORGRADING3D: boolean;
  50166. SAMPLER3DGREENDEPTH: boolean;
  50167. SAMPLER3DBGRMAP: boolean;
  50168. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50169. EXPOSURE: boolean;
  50170. MULTIVIEW: boolean;
  50171. USEPHYSICALLIGHTFALLOFF: boolean;
  50172. USEGLTFLIGHTFALLOFF: boolean;
  50173. TWOSIDEDLIGHTING: boolean;
  50174. SHADOWFLOAT: boolean;
  50175. CLIPPLANE: boolean;
  50176. CLIPPLANE2: boolean;
  50177. CLIPPLANE3: boolean;
  50178. CLIPPLANE4: boolean;
  50179. POINTSIZE: boolean;
  50180. FOG: boolean;
  50181. LOGARITHMICDEPTH: boolean;
  50182. FORCENORMALFORWARD: boolean;
  50183. SPECULARAA: boolean;
  50184. CLEARCOAT: boolean;
  50185. CLEARCOAT_DEFAULTIOR: boolean;
  50186. CLEARCOAT_TEXTURE: boolean;
  50187. CLEARCOAT_TEXTUREDIRECTUV: number;
  50188. CLEARCOAT_BUMP: boolean;
  50189. CLEARCOAT_BUMPDIRECTUV: number;
  50190. CLEARCOAT_TINT: boolean;
  50191. CLEARCOAT_TINT_TEXTURE: boolean;
  50192. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50193. ANISOTROPIC: boolean;
  50194. ANISOTROPIC_TEXTURE: boolean;
  50195. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50196. BRDF_V_HEIGHT_CORRELATED: boolean;
  50197. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50198. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50199. SHEEN: boolean;
  50200. SHEEN_TEXTURE: boolean;
  50201. SHEEN_TEXTUREDIRECTUV: number;
  50202. SHEEN_LINKWITHALBEDO: boolean;
  50203. SUBSURFACE: boolean;
  50204. SS_REFRACTION: boolean;
  50205. SS_TRANSLUCENCY: boolean;
  50206. SS_SCATERRING: boolean;
  50207. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50208. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50209. SS_REFRACTIONMAP_3D: boolean;
  50210. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50211. SS_LODINREFRACTIONALPHA: boolean;
  50212. SS_GAMMAREFRACTION: boolean;
  50213. SS_RGBDREFRACTION: boolean;
  50214. SS_LINEARSPECULARREFRACTION: boolean;
  50215. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50216. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50217. UNLIT: boolean;
  50218. DEBUGMODE: number;
  50219. /**
  50220. * Initializes the PBR Material defines.
  50221. */
  50222. constructor();
  50223. /**
  50224. * Resets the PBR Material defines.
  50225. */
  50226. reset(): void;
  50227. }
  50228. /**
  50229. * The Physically based material base class of BJS.
  50230. *
  50231. * This offers the main features of a standard PBR material.
  50232. * For more information, please refer to the documentation :
  50233. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50234. */
  50235. export abstract class PBRBaseMaterial extends PushMaterial {
  50236. /**
  50237. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50238. */
  50239. static readonly PBRMATERIAL_OPAQUE: number;
  50240. /**
  50241. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50242. */
  50243. static readonly PBRMATERIAL_ALPHATEST: number;
  50244. /**
  50245. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50246. */
  50247. static readonly PBRMATERIAL_ALPHABLEND: number;
  50248. /**
  50249. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50250. * They are also discarded below the alpha cutoff threshold to improve performances.
  50251. */
  50252. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50253. /**
  50254. * Defines the default value of how much AO map is occluding the analytical lights
  50255. * (point spot...).
  50256. */
  50257. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50258. /**
  50259. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50260. */
  50261. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50262. /**
  50263. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50264. * to enhance interoperability with other engines.
  50265. */
  50266. static readonly LIGHTFALLOFF_GLTF: number;
  50267. /**
  50268. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50269. * to enhance interoperability with other materials.
  50270. */
  50271. static readonly LIGHTFALLOFF_STANDARD: number;
  50272. /**
  50273. * Intensity of the direct lights e.g. the four lights available in your scene.
  50274. * This impacts both the direct diffuse and specular highlights.
  50275. */
  50276. protected _directIntensity: number;
  50277. /**
  50278. * Intensity of the emissive part of the material.
  50279. * This helps controlling the emissive effect without modifying the emissive color.
  50280. */
  50281. protected _emissiveIntensity: number;
  50282. /**
  50283. * Intensity of the environment e.g. how much the environment will light the object
  50284. * either through harmonics for rough material or through the refelction for shiny ones.
  50285. */
  50286. protected _environmentIntensity: number;
  50287. /**
  50288. * This is a special control allowing the reduction of the specular highlights coming from the
  50289. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50290. */
  50291. protected _specularIntensity: number;
  50292. /**
  50293. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50294. */
  50295. private _lightingInfos;
  50296. /**
  50297. * Debug Control allowing disabling the bump map on this material.
  50298. */
  50299. protected _disableBumpMap: boolean;
  50300. /**
  50301. * AKA Diffuse Texture in standard nomenclature.
  50302. */
  50303. protected _albedoTexture: Nullable<BaseTexture>;
  50304. /**
  50305. * AKA Occlusion Texture in other nomenclature.
  50306. */
  50307. protected _ambientTexture: Nullable<BaseTexture>;
  50308. /**
  50309. * AKA Occlusion Texture Intensity in other nomenclature.
  50310. */
  50311. protected _ambientTextureStrength: number;
  50312. /**
  50313. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50314. * 1 means it completely occludes it
  50315. * 0 mean it has no impact
  50316. */
  50317. protected _ambientTextureImpactOnAnalyticalLights: number;
  50318. /**
  50319. * Stores the alpha values in a texture.
  50320. */
  50321. protected _opacityTexture: Nullable<BaseTexture>;
  50322. /**
  50323. * Stores the reflection values in a texture.
  50324. */
  50325. protected _reflectionTexture: Nullable<BaseTexture>;
  50326. /**
  50327. * Stores the emissive values in a texture.
  50328. */
  50329. protected _emissiveTexture: Nullable<BaseTexture>;
  50330. /**
  50331. * AKA Specular texture in other nomenclature.
  50332. */
  50333. protected _reflectivityTexture: Nullable<BaseTexture>;
  50334. /**
  50335. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50336. */
  50337. protected _metallicTexture: Nullable<BaseTexture>;
  50338. /**
  50339. * Specifies the metallic scalar of the metallic/roughness workflow.
  50340. * Can also be used to scale the metalness values of the metallic texture.
  50341. */
  50342. protected _metallic: Nullable<number>;
  50343. /**
  50344. * Specifies the roughness scalar of the metallic/roughness workflow.
  50345. * Can also be used to scale the roughness values of the metallic texture.
  50346. */
  50347. protected _roughness: Nullable<number>;
  50348. /**
  50349. * Specifies the an F0 factor to help configuring the material F0.
  50350. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50351. * to 0.5 the previously hard coded value stays the same.
  50352. * Can also be used to scale the F0 values of the metallic texture.
  50353. */
  50354. protected _metallicF0Factor: number;
  50355. /**
  50356. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50357. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50358. * your expectation as it multiplies with the texture data.
  50359. */
  50360. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50361. /**
  50362. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50363. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50364. */
  50365. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50366. /**
  50367. * Stores surface normal data used to displace a mesh in a texture.
  50368. */
  50369. protected _bumpTexture: Nullable<BaseTexture>;
  50370. /**
  50371. * Stores the pre-calculated light information of a mesh in a texture.
  50372. */
  50373. protected _lightmapTexture: Nullable<BaseTexture>;
  50374. /**
  50375. * The color of a material in ambient lighting.
  50376. */
  50377. protected _ambientColor: Color3;
  50378. /**
  50379. * AKA Diffuse Color in other nomenclature.
  50380. */
  50381. protected _albedoColor: Color3;
  50382. /**
  50383. * AKA Specular Color in other nomenclature.
  50384. */
  50385. protected _reflectivityColor: Color3;
  50386. /**
  50387. * The color applied when light is reflected from a material.
  50388. */
  50389. protected _reflectionColor: Color3;
  50390. /**
  50391. * The color applied when light is emitted from a material.
  50392. */
  50393. protected _emissiveColor: Color3;
  50394. /**
  50395. * AKA Glossiness in other nomenclature.
  50396. */
  50397. protected _microSurface: number;
  50398. /**
  50399. * Specifies that the material will use the light map as a show map.
  50400. */
  50401. protected _useLightmapAsShadowmap: boolean;
  50402. /**
  50403. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50404. * makes the reflect vector face the model (under horizon).
  50405. */
  50406. protected _useHorizonOcclusion: boolean;
  50407. /**
  50408. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50409. * too much the area relying on ambient texture to define their ambient occlusion.
  50410. */
  50411. protected _useRadianceOcclusion: boolean;
  50412. /**
  50413. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50414. */
  50415. protected _useAlphaFromAlbedoTexture: boolean;
  50416. /**
  50417. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50418. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50419. */
  50420. protected _useSpecularOverAlpha: boolean;
  50421. /**
  50422. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50423. */
  50424. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50425. /**
  50426. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50427. */
  50428. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50429. /**
  50430. * Specifies if the metallic texture contains the roughness information in its green channel.
  50431. */
  50432. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50433. /**
  50434. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50435. */
  50436. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50437. /**
  50438. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50439. */
  50440. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50441. /**
  50442. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50443. */
  50444. protected _useAmbientInGrayScale: boolean;
  50445. /**
  50446. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50447. * The material will try to infer what glossiness each pixel should be.
  50448. */
  50449. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50450. /**
  50451. * Defines the falloff type used in this material.
  50452. * It by default is Physical.
  50453. */
  50454. protected _lightFalloff: number;
  50455. /**
  50456. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50457. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50458. */
  50459. protected _useRadianceOverAlpha: boolean;
  50460. /**
  50461. * Allows using an object space normal map (instead of tangent space).
  50462. */
  50463. protected _useObjectSpaceNormalMap: boolean;
  50464. /**
  50465. * Allows using the bump map in parallax mode.
  50466. */
  50467. protected _useParallax: boolean;
  50468. /**
  50469. * Allows using the bump map in parallax occlusion mode.
  50470. */
  50471. protected _useParallaxOcclusion: boolean;
  50472. /**
  50473. * Controls the scale bias of the parallax mode.
  50474. */
  50475. protected _parallaxScaleBias: number;
  50476. /**
  50477. * If sets to true, disables all the lights affecting the material.
  50478. */
  50479. protected _disableLighting: boolean;
  50480. /**
  50481. * Number of Simultaneous lights allowed on the material.
  50482. */
  50483. protected _maxSimultaneousLights: number;
  50484. /**
  50485. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50486. */
  50487. protected _invertNormalMapX: boolean;
  50488. /**
  50489. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50490. */
  50491. protected _invertNormalMapY: boolean;
  50492. /**
  50493. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50494. */
  50495. protected _twoSidedLighting: boolean;
  50496. /**
  50497. * Defines the alpha limits in alpha test mode.
  50498. */
  50499. protected _alphaCutOff: number;
  50500. /**
  50501. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50502. */
  50503. protected _forceAlphaTest: boolean;
  50504. /**
  50505. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50506. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50507. */
  50508. protected _useAlphaFresnel: boolean;
  50509. /**
  50510. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50511. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50512. */
  50513. protected _useLinearAlphaFresnel: boolean;
  50514. /**
  50515. * The transparency mode of the material.
  50516. */
  50517. protected _transparencyMode: Nullable<number>;
  50518. /**
  50519. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50520. * from cos thetav and roughness:
  50521. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50522. */
  50523. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50524. /**
  50525. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50526. */
  50527. protected _forceIrradianceInFragment: boolean;
  50528. /**
  50529. * Force normal to face away from face.
  50530. */
  50531. protected _forceNormalForward: boolean;
  50532. /**
  50533. * Enables specular anti aliasing in the PBR shader.
  50534. * It will both interacts on the Geometry for analytical and IBL lighting.
  50535. * It also prefilter the roughness map based on the bump values.
  50536. */
  50537. protected _enableSpecularAntiAliasing: boolean;
  50538. /**
  50539. * Default configuration related to image processing available in the PBR Material.
  50540. */
  50541. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50542. /**
  50543. * Keep track of the image processing observer to allow dispose and replace.
  50544. */
  50545. private _imageProcessingObserver;
  50546. /**
  50547. * Attaches a new image processing configuration to the PBR Material.
  50548. * @param configuration
  50549. */
  50550. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50551. /**
  50552. * Stores the available render targets.
  50553. */
  50554. private _renderTargets;
  50555. /**
  50556. * Sets the global ambient color for the material used in lighting calculations.
  50557. */
  50558. private _globalAmbientColor;
  50559. /**
  50560. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50561. */
  50562. private _useLogarithmicDepth;
  50563. /**
  50564. * If set to true, no lighting calculations will be applied.
  50565. */
  50566. private _unlit;
  50567. private _debugMode;
  50568. /**
  50569. * @hidden
  50570. * This is reserved for the inspector.
  50571. * Defines the material debug mode.
  50572. * It helps seeing only some components of the material while troubleshooting.
  50573. */
  50574. debugMode: number;
  50575. /**
  50576. * @hidden
  50577. * This is reserved for the inspector.
  50578. * Specify from where on screen the debug mode should start.
  50579. * The value goes from -1 (full screen) to 1 (not visible)
  50580. * It helps with side by side comparison against the final render
  50581. * This defaults to -1
  50582. */
  50583. private debugLimit;
  50584. /**
  50585. * @hidden
  50586. * This is reserved for the inspector.
  50587. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50588. * You can use the factor to better multiply the final value.
  50589. */
  50590. private debugFactor;
  50591. /**
  50592. * Defines the clear coat layer parameters for the material.
  50593. */
  50594. readonly clearCoat: PBRClearCoatConfiguration;
  50595. /**
  50596. * Defines the anisotropic parameters for the material.
  50597. */
  50598. readonly anisotropy: PBRAnisotropicConfiguration;
  50599. /**
  50600. * Defines the BRDF parameters for the material.
  50601. */
  50602. readonly brdf: PBRBRDFConfiguration;
  50603. /**
  50604. * Defines the Sheen parameters for the material.
  50605. */
  50606. readonly sheen: PBRSheenConfiguration;
  50607. /**
  50608. * Defines the SubSurface parameters for the material.
  50609. */
  50610. readonly subSurface: PBRSubSurfaceConfiguration;
  50611. /**
  50612. * Custom callback helping to override the default shader used in the material.
  50613. */
  50614. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50615. protected _rebuildInParallel: boolean;
  50616. /**
  50617. * Instantiates a new PBRMaterial instance.
  50618. *
  50619. * @param name The material name
  50620. * @param scene The scene the material will be use in.
  50621. */
  50622. constructor(name: string, scene: Scene);
  50623. /**
  50624. * Gets a boolean indicating that current material needs to register RTT
  50625. */
  50626. readonly hasRenderTargetTextures: boolean;
  50627. /**
  50628. * Gets the name of the material class.
  50629. */
  50630. getClassName(): string;
  50631. /**
  50632. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50633. */
  50634. /**
  50635. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50636. */
  50637. useLogarithmicDepth: boolean;
  50638. /**
  50639. * Gets the current transparency mode.
  50640. */
  50641. /**
  50642. * Sets the transparency mode of the material.
  50643. *
  50644. * | Value | Type | Description |
  50645. * | ----- | ----------------------------------- | ----------- |
  50646. * | 0 | OPAQUE | |
  50647. * | 1 | ALPHATEST | |
  50648. * | 2 | ALPHABLEND | |
  50649. * | 3 | ALPHATESTANDBLEND | |
  50650. *
  50651. */
  50652. transparencyMode: Nullable<number>;
  50653. /**
  50654. * Returns true if alpha blending should be disabled.
  50655. */
  50656. private readonly _disableAlphaBlending;
  50657. /**
  50658. * Specifies whether or not this material should be rendered in alpha blend mode.
  50659. */
  50660. needAlphaBlending(): boolean;
  50661. /**
  50662. * Specifies if the mesh will require alpha blending.
  50663. * @param mesh - BJS mesh.
  50664. */
  50665. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50666. /**
  50667. * Specifies whether or not this material should be rendered in alpha test mode.
  50668. */
  50669. needAlphaTesting(): boolean;
  50670. /**
  50671. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50672. */
  50673. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50674. /**
  50675. * Gets the texture used for the alpha test.
  50676. */
  50677. getAlphaTestTexture(): Nullable<BaseTexture>;
  50678. /**
  50679. * Specifies that the submesh is ready to be used.
  50680. * @param mesh - BJS mesh.
  50681. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50682. * @param useInstances - Specifies that instances should be used.
  50683. * @returns - boolean indicating that the submesh is ready or not.
  50684. */
  50685. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50686. /**
  50687. * Specifies if the material uses metallic roughness workflow.
  50688. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50689. */
  50690. isMetallicWorkflow(): boolean;
  50691. private _prepareEffect;
  50692. private _prepareDefines;
  50693. /**
  50694. * Force shader compilation
  50695. */
  50696. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  50697. /**
  50698. * Initializes the uniform buffer layout for the shader.
  50699. */
  50700. buildUniformLayout(): void;
  50701. /**
  50702. * Unbinds the material from the mesh
  50703. */
  50704. unbind(): void;
  50705. /**
  50706. * Binds the submesh data.
  50707. * @param world - The world matrix.
  50708. * @param mesh - The BJS mesh.
  50709. * @param subMesh - A submesh of the BJS mesh.
  50710. */
  50711. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50712. /**
  50713. * Returns the animatable textures.
  50714. * @returns - Array of animatable textures.
  50715. */
  50716. getAnimatables(): IAnimatable[];
  50717. /**
  50718. * Returns the texture used for reflections.
  50719. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50720. */
  50721. private _getReflectionTexture;
  50722. /**
  50723. * Returns an array of the actively used textures.
  50724. * @returns - Array of BaseTextures
  50725. */
  50726. getActiveTextures(): BaseTexture[];
  50727. /**
  50728. * Checks to see if a texture is used in the material.
  50729. * @param texture - Base texture to use.
  50730. * @returns - Boolean specifying if a texture is used in the material.
  50731. */
  50732. hasTexture(texture: BaseTexture): boolean;
  50733. /**
  50734. * Disposes the resources of the material.
  50735. * @param forceDisposeEffect - Forces the disposal of effects.
  50736. * @param forceDisposeTextures - Forces the disposal of all textures.
  50737. */
  50738. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50739. }
  50740. }
  50741. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50742. import { Nullable } from "babylonjs/types";
  50743. import { Scene } from "babylonjs/scene";
  50744. import { Color3 } from "babylonjs/Maths/math.color";
  50745. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50746. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50747. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50748. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50749. /**
  50750. * The Physically based material of BJS.
  50751. *
  50752. * This offers the main features of a standard PBR material.
  50753. * For more information, please refer to the documentation :
  50754. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50755. */
  50756. export class PBRMaterial extends PBRBaseMaterial {
  50757. /**
  50758. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50759. */
  50760. static readonly PBRMATERIAL_OPAQUE: number;
  50761. /**
  50762. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50763. */
  50764. static readonly PBRMATERIAL_ALPHATEST: number;
  50765. /**
  50766. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50767. */
  50768. static readonly PBRMATERIAL_ALPHABLEND: number;
  50769. /**
  50770. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50771. * They are also discarded below the alpha cutoff threshold to improve performances.
  50772. */
  50773. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50774. /**
  50775. * Defines the default value of how much AO map is occluding the analytical lights
  50776. * (point spot...).
  50777. */
  50778. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50779. /**
  50780. * Intensity of the direct lights e.g. the four lights available in your scene.
  50781. * This impacts both the direct diffuse and specular highlights.
  50782. */
  50783. directIntensity: number;
  50784. /**
  50785. * Intensity of the emissive part of the material.
  50786. * This helps controlling the emissive effect without modifying the emissive color.
  50787. */
  50788. emissiveIntensity: number;
  50789. /**
  50790. * Intensity of the environment e.g. how much the environment will light the object
  50791. * either through harmonics for rough material or through the refelction for shiny ones.
  50792. */
  50793. environmentIntensity: number;
  50794. /**
  50795. * This is a special control allowing the reduction of the specular highlights coming from the
  50796. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50797. */
  50798. specularIntensity: number;
  50799. /**
  50800. * Debug Control allowing disabling the bump map on this material.
  50801. */
  50802. disableBumpMap: boolean;
  50803. /**
  50804. * AKA Diffuse Texture in standard nomenclature.
  50805. */
  50806. albedoTexture: BaseTexture;
  50807. /**
  50808. * AKA Occlusion Texture in other nomenclature.
  50809. */
  50810. ambientTexture: BaseTexture;
  50811. /**
  50812. * AKA Occlusion Texture Intensity in other nomenclature.
  50813. */
  50814. ambientTextureStrength: number;
  50815. /**
  50816. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50817. * 1 means it completely occludes it
  50818. * 0 mean it has no impact
  50819. */
  50820. ambientTextureImpactOnAnalyticalLights: number;
  50821. /**
  50822. * Stores the alpha values in a texture.
  50823. */
  50824. opacityTexture: BaseTexture;
  50825. /**
  50826. * Stores the reflection values in a texture.
  50827. */
  50828. reflectionTexture: Nullable<BaseTexture>;
  50829. /**
  50830. * Stores the emissive values in a texture.
  50831. */
  50832. emissiveTexture: BaseTexture;
  50833. /**
  50834. * AKA Specular texture in other nomenclature.
  50835. */
  50836. reflectivityTexture: BaseTexture;
  50837. /**
  50838. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50839. */
  50840. metallicTexture: BaseTexture;
  50841. /**
  50842. * Specifies the metallic scalar of the metallic/roughness workflow.
  50843. * Can also be used to scale the metalness values of the metallic texture.
  50844. */
  50845. metallic: Nullable<number>;
  50846. /**
  50847. * Specifies the roughness scalar of the metallic/roughness workflow.
  50848. * Can also be used to scale the roughness values of the metallic texture.
  50849. */
  50850. roughness: Nullable<number>;
  50851. /**
  50852. * Specifies the an F0 factor to help configuring the material F0.
  50853. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50854. * to 0.5 the previously hard coded value stays the same.
  50855. * Can also be used to scale the F0 values of the metallic texture.
  50856. */
  50857. metallicF0Factor: number;
  50858. /**
  50859. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50860. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50861. * your expectation as it multiplies with the texture data.
  50862. */
  50863. useMetallicF0FactorFromMetallicTexture: boolean;
  50864. /**
  50865. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50866. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50867. */
  50868. microSurfaceTexture: BaseTexture;
  50869. /**
  50870. * Stores surface normal data used to displace a mesh in a texture.
  50871. */
  50872. bumpTexture: BaseTexture;
  50873. /**
  50874. * Stores the pre-calculated light information of a mesh in a texture.
  50875. */
  50876. lightmapTexture: BaseTexture;
  50877. /**
  50878. * Stores the refracted light information in a texture.
  50879. */
  50880. refractionTexture: Nullable<BaseTexture>;
  50881. /**
  50882. * The color of a material in ambient lighting.
  50883. */
  50884. ambientColor: Color3;
  50885. /**
  50886. * AKA Diffuse Color in other nomenclature.
  50887. */
  50888. albedoColor: Color3;
  50889. /**
  50890. * AKA Specular Color in other nomenclature.
  50891. */
  50892. reflectivityColor: Color3;
  50893. /**
  50894. * The color reflected from the material.
  50895. */
  50896. reflectionColor: Color3;
  50897. /**
  50898. * The color emitted from the material.
  50899. */
  50900. emissiveColor: Color3;
  50901. /**
  50902. * AKA Glossiness in other nomenclature.
  50903. */
  50904. microSurface: number;
  50905. /**
  50906. * source material index of refraction (IOR)' / 'destination material IOR.
  50907. */
  50908. indexOfRefraction: number;
  50909. /**
  50910. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50911. */
  50912. invertRefractionY: boolean;
  50913. /**
  50914. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50915. * Materials half opaque for instance using refraction could benefit from this control.
  50916. */
  50917. linkRefractionWithTransparency: boolean;
  50918. /**
  50919. * If true, the light map contains occlusion information instead of lighting info.
  50920. */
  50921. useLightmapAsShadowmap: boolean;
  50922. /**
  50923. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50924. */
  50925. useAlphaFromAlbedoTexture: boolean;
  50926. /**
  50927. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50928. */
  50929. forceAlphaTest: boolean;
  50930. /**
  50931. * Defines the alpha limits in alpha test mode.
  50932. */
  50933. alphaCutOff: number;
  50934. /**
  50935. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50936. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50937. */
  50938. useSpecularOverAlpha: boolean;
  50939. /**
  50940. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50941. */
  50942. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50943. /**
  50944. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50945. */
  50946. useRoughnessFromMetallicTextureAlpha: boolean;
  50947. /**
  50948. * Specifies if the metallic texture contains the roughness information in its green channel.
  50949. */
  50950. useRoughnessFromMetallicTextureGreen: boolean;
  50951. /**
  50952. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50953. */
  50954. useMetallnessFromMetallicTextureBlue: boolean;
  50955. /**
  50956. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50957. */
  50958. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50959. /**
  50960. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50961. */
  50962. useAmbientInGrayScale: boolean;
  50963. /**
  50964. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50965. * The material will try to infer what glossiness each pixel should be.
  50966. */
  50967. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50968. /**
  50969. * BJS is using an harcoded light falloff based on a manually sets up range.
  50970. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50971. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50972. */
  50973. /**
  50974. * BJS is using an harcoded light falloff based on a manually sets up range.
  50975. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50976. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50977. */
  50978. usePhysicalLightFalloff: boolean;
  50979. /**
  50980. * In order to support the falloff compatibility with gltf, a special mode has been added
  50981. * to reproduce the gltf light falloff.
  50982. */
  50983. /**
  50984. * In order to support the falloff compatibility with gltf, a special mode has been added
  50985. * to reproduce the gltf light falloff.
  50986. */
  50987. useGLTFLightFalloff: boolean;
  50988. /**
  50989. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50990. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50991. */
  50992. useRadianceOverAlpha: boolean;
  50993. /**
  50994. * Allows using an object space normal map (instead of tangent space).
  50995. */
  50996. useObjectSpaceNormalMap: boolean;
  50997. /**
  50998. * Allows using the bump map in parallax mode.
  50999. */
  51000. useParallax: boolean;
  51001. /**
  51002. * Allows using the bump map in parallax occlusion mode.
  51003. */
  51004. useParallaxOcclusion: boolean;
  51005. /**
  51006. * Controls the scale bias of the parallax mode.
  51007. */
  51008. parallaxScaleBias: number;
  51009. /**
  51010. * If sets to true, disables all the lights affecting the material.
  51011. */
  51012. disableLighting: boolean;
  51013. /**
  51014. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51015. */
  51016. forceIrradianceInFragment: boolean;
  51017. /**
  51018. * Number of Simultaneous lights allowed on the material.
  51019. */
  51020. maxSimultaneousLights: number;
  51021. /**
  51022. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51023. */
  51024. invertNormalMapX: boolean;
  51025. /**
  51026. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51027. */
  51028. invertNormalMapY: boolean;
  51029. /**
  51030. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51031. */
  51032. twoSidedLighting: boolean;
  51033. /**
  51034. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51035. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51036. */
  51037. useAlphaFresnel: boolean;
  51038. /**
  51039. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51040. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51041. */
  51042. useLinearAlphaFresnel: boolean;
  51043. /**
  51044. * Let user defines the brdf lookup texture used for IBL.
  51045. * A default 8bit version is embedded but you could point at :
  51046. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51047. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51048. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51049. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51050. */
  51051. environmentBRDFTexture: Nullable<BaseTexture>;
  51052. /**
  51053. * Force normal to face away from face.
  51054. */
  51055. forceNormalForward: boolean;
  51056. /**
  51057. * Enables specular anti aliasing in the PBR shader.
  51058. * It will both interacts on the Geometry for analytical and IBL lighting.
  51059. * It also prefilter the roughness map based on the bump values.
  51060. */
  51061. enableSpecularAntiAliasing: boolean;
  51062. /**
  51063. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51064. * makes the reflect vector face the model (under horizon).
  51065. */
  51066. useHorizonOcclusion: boolean;
  51067. /**
  51068. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51069. * too much the area relying on ambient texture to define their ambient occlusion.
  51070. */
  51071. useRadianceOcclusion: boolean;
  51072. /**
  51073. * If set to true, no lighting calculations will be applied.
  51074. */
  51075. unlit: boolean;
  51076. /**
  51077. * Gets the image processing configuration used either in this material.
  51078. */
  51079. /**
  51080. * Sets the Default image processing configuration used either in the this material.
  51081. *
  51082. * If sets to null, the scene one is in use.
  51083. */
  51084. imageProcessingConfiguration: ImageProcessingConfiguration;
  51085. /**
  51086. * Gets wether the color curves effect is enabled.
  51087. */
  51088. /**
  51089. * Sets wether the color curves effect is enabled.
  51090. */
  51091. cameraColorCurvesEnabled: boolean;
  51092. /**
  51093. * Gets wether the color grading effect is enabled.
  51094. */
  51095. /**
  51096. * Gets wether the color grading effect is enabled.
  51097. */
  51098. cameraColorGradingEnabled: boolean;
  51099. /**
  51100. * Gets wether tonemapping is enabled or not.
  51101. */
  51102. /**
  51103. * Sets wether tonemapping is enabled or not
  51104. */
  51105. cameraToneMappingEnabled: boolean;
  51106. /**
  51107. * The camera exposure used on this material.
  51108. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51109. * This corresponds to a photographic exposure.
  51110. */
  51111. /**
  51112. * The camera exposure used on this material.
  51113. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51114. * This corresponds to a photographic exposure.
  51115. */
  51116. cameraExposure: number;
  51117. /**
  51118. * Gets The camera contrast used on this material.
  51119. */
  51120. /**
  51121. * Sets The camera contrast used on this material.
  51122. */
  51123. cameraContrast: number;
  51124. /**
  51125. * Gets the Color Grading 2D Lookup Texture.
  51126. */
  51127. /**
  51128. * Sets the Color Grading 2D Lookup Texture.
  51129. */
  51130. cameraColorGradingTexture: Nullable<BaseTexture>;
  51131. /**
  51132. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51133. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51134. * 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;
  51135. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51136. */
  51137. /**
  51138. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51139. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51140. * 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;
  51141. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51142. */
  51143. cameraColorCurves: Nullable<ColorCurves>;
  51144. /**
  51145. * Instantiates a new PBRMaterial instance.
  51146. *
  51147. * @param name The material name
  51148. * @param scene The scene the material will be use in.
  51149. */
  51150. constructor(name: string, scene: Scene);
  51151. /**
  51152. * Returns the name of this material class.
  51153. */
  51154. getClassName(): string;
  51155. /**
  51156. * Makes a duplicate of the current material.
  51157. * @param name - name to use for the new material.
  51158. */
  51159. clone(name: string): PBRMaterial;
  51160. /**
  51161. * Serializes this PBR Material.
  51162. * @returns - An object with the serialized material.
  51163. */
  51164. serialize(): any;
  51165. /**
  51166. * Parses a PBR Material from a serialized object.
  51167. * @param source - Serialized object.
  51168. * @param scene - BJS scene instance.
  51169. * @param rootUrl - url for the scene object
  51170. * @returns - PBRMaterial
  51171. */
  51172. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51173. }
  51174. }
  51175. declare module "babylonjs/Misc/dds" {
  51176. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51177. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51178. import { Nullable } from "babylonjs/types";
  51179. import { Scene } from "babylonjs/scene";
  51180. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  51181. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51182. /**
  51183. * Direct draw surface info
  51184. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51185. */
  51186. export interface DDSInfo {
  51187. /**
  51188. * Width of the texture
  51189. */
  51190. width: number;
  51191. /**
  51192. * Width of the texture
  51193. */
  51194. height: number;
  51195. /**
  51196. * Number of Mipmaps for the texture
  51197. * @see https://en.wikipedia.org/wiki/Mipmap
  51198. */
  51199. mipmapCount: number;
  51200. /**
  51201. * If the textures format is a known fourCC format
  51202. * @see https://www.fourcc.org/
  51203. */
  51204. isFourCC: boolean;
  51205. /**
  51206. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51207. */
  51208. isRGB: boolean;
  51209. /**
  51210. * If the texture is a lumincance format
  51211. */
  51212. isLuminance: boolean;
  51213. /**
  51214. * If this is a cube texture
  51215. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51216. */
  51217. isCube: boolean;
  51218. /**
  51219. * If the texture is a compressed format eg. FOURCC_DXT1
  51220. */
  51221. isCompressed: boolean;
  51222. /**
  51223. * The dxgiFormat of the texture
  51224. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51225. */
  51226. dxgiFormat: number;
  51227. /**
  51228. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51229. */
  51230. textureType: number;
  51231. /**
  51232. * Sphericle polynomial created for the dds texture
  51233. */
  51234. sphericalPolynomial?: SphericalPolynomial;
  51235. }
  51236. /**
  51237. * Class used to provide DDS decompression tools
  51238. */
  51239. export class DDSTools {
  51240. /**
  51241. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51242. */
  51243. static StoreLODInAlphaChannel: boolean;
  51244. /**
  51245. * Gets DDS information from an array buffer
  51246. * @param arrayBuffer defines the array buffer to read data from
  51247. * @returns the DDS information
  51248. */
  51249. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  51250. private static _FloatView;
  51251. private static _Int32View;
  51252. private static _ToHalfFloat;
  51253. private static _FromHalfFloat;
  51254. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51255. private static _GetHalfFloatRGBAArrayBuffer;
  51256. private static _GetFloatRGBAArrayBuffer;
  51257. private static _GetFloatAsUIntRGBAArrayBuffer;
  51258. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51259. private static _GetRGBAArrayBuffer;
  51260. private static _ExtractLongWordOrder;
  51261. private static _GetRGBArrayBuffer;
  51262. private static _GetLuminanceArrayBuffer;
  51263. /**
  51264. * Uploads DDS Levels to a Babylon Texture
  51265. * @hidden
  51266. */
  51267. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51268. }
  51269. module "babylonjs/Engines/thinEngine" {
  51270. interface ThinEngine {
  51271. /**
  51272. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51273. * @param rootUrl defines the url where the file to load is located
  51274. * @param scene defines the current scene
  51275. * @param lodScale defines scale to apply to the mip map selection
  51276. * @param lodOffset defines offset to apply to the mip map selection
  51277. * @param onLoad defines an optional callback raised when the texture is loaded
  51278. * @param onError defines an optional callback raised if there is an issue to load the texture
  51279. * @param format defines the format of the data
  51280. * @param forcedExtension defines the extension to use to pick the right loader
  51281. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51282. * @returns the cube texture as an InternalTexture
  51283. */
  51284. 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;
  51285. }
  51286. }
  51287. }
  51288. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  51289. import { Nullable } from "babylonjs/types";
  51290. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51291. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51292. /**
  51293. * Implementation of the DDS Texture Loader.
  51294. * @hidden
  51295. */
  51296. export class _DDSTextureLoader implements IInternalTextureLoader {
  51297. /**
  51298. * Defines wether the loader supports cascade loading the different faces.
  51299. */
  51300. readonly supportCascades: boolean;
  51301. /**
  51302. * This returns if the loader support the current file information.
  51303. * @param extension defines the file extension of the file being loaded
  51304. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51305. * @param fallback defines the fallback internal texture if any
  51306. * @param isBase64 defines whether the texture is encoded as a base64
  51307. * @param isBuffer defines whether the texture data are stored as a buffer
  51308. * @returns true if the loader can load the specified file
  51309. */
  51310. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51311. /**
  51312. * Transform the url before loading if required.
  51313. * @param rootUrl the url of the texture
  51314. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51315. * @returns the transformed texture
  51316. */
  51317. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51318. /**
  51319. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51320. * @param rootUrl the url of the texture
  51321. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51322. * @returns the fallback texture
  51323. */
  51324. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51325. /**
  51326. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51327. * @param data contains the texture data
  51328. * @param texture defines the BabylonJS internal texture
  51329. * @param createPolynomials will be true if polynomials have been requested
  51330. * @param onLoad defines the callback to trigger once the texture is ready
  51331. * @param onError defines the callback to trigger in case of error
  51332. */
  51333. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51334. /**
  51335. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51336. * @param data contains the texture data
  51337. * @param texture defines the BabylonJS internal texture
  51338. * @param callback defines the method to call once ready to upload
  51339. */
  51340. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51341. }
  51342. }
  51343. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  51344. import { Nullable } from "babylonjs/types";
  51345. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51346. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51347. /**
  51348. * Implementation of the ENV Texture Loader.
  51349. * @hidden
  51350. */
  51351. export class _ENVTextureLoader implements IInternalTextureLoader {
  51352. /**
  51353. * Defines wether the loader supports cascade loading the different faces.
  51354. */
  51355. readonly supportCascades: boolean;
  51356. /**
  51357. * This returns if the loader support the current file information.
  51358. * @param extension defines the file extension of the file being loaded
  51359. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51360. * @param fallback defines the fallback internal texture if any
  51361. * @param isBase64 defines whether the texture is encoded as a base64
  51362. * @param isBuffer defines whether the texture data are stored as a buffer
  51363. * @returns true if the loader can load the specified file
  51364. */
  51365. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51366. /**
  51367. * Transform the url before loading if required.
  51368. * @param rootUrl the url of the texture
  51369. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51370. * @returns the transformed texture
  51371. */
  51372. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51373. /**
  51374. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51375. * @param rootUrl the url of the texture
  51376. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51377. * @returns the fallback texture
  51378. */
  51379. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51380. /**
  51381. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51382. * @param data contains the texture data
  51383. * @param texture defines the BabylonJS internal texture
  51384. * @param createPolynomials will be true if polynomials have been requested
  51385. * @param onLoad defines the callback to trigger once the texture is ready
  51386. * @param onError defines the callback to trigger in case of error
  51387. */
  51388. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51389. /**
  51390. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51391. * @param data contains the texture data
  51392. * @param texture defines the BabylonJS internal texture
  51393. * @param callback defines the method to call once ready to upload
  51394. */
  51395. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51396. }
  51397. }
  51398. declare module "babylonjs/Misc/khronosTextureContainer" {
  51399. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51400. /**
  51401. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51402. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51403. */
  51404. export class KhronosTextureContainer {
  51405. /** contents of the KTX container file */
  51406. arrayBuffer: any;
  51407. private static HEADER_LEN;
  51408. private static COMPRESSED_2D;
  51409. private static COMPRESSED_3D;
  51410. private static TEX_2D;
  51411. private static TEX_3D;
  51412. /**
  51413. * Gets the openGL type
  51414. */
  51415. glType: number;
  51416. /**
  51417. * Gets the openGL type size
  51418. */
  51419. glTypeSize: number;
  51420. /**
  51421. * Gets the openGL format
  51422. */
  51423. glFormat: number;
  51424. /**
  51425. * Gets the openGL internal format
  51426. */
  51427. glInternalFormat: number;
  51428. /**
  51429. * Gets the base internal format
  51430. */
  51431. glBaseInternalFormat: number;
  51432. /**
  51433. * Gets image width in pixel
  51434. */
  51435. pixelWidth: number;
  51436. /**
  51437. * Gets image height in pixel
  51438. */
  51439. pixelHeight: number;
  51440. /**
  51441. * Gets image depth in pixels
  51442. */
  51443. pixelDepth: number;
  51444. /**
  51445. * Gets the number of array elements
  51446. */
  51447. numberOfArrayElements: number;
  51448. /**
  51449. * Gets the number of faces
  51450. */
  51451. numberOfFaces: number;
  51452. /**
  51453. * Gets the number of mipmap levels
  51454. */
  51455. numberOfMipmapLevels: number;
  51456. /**
  51457. * Gets the bytes of key value data
  51458. */
  51459. bytesOfKeyValueData: number;
  51460. /**
  51461. * Gets the load type
  51462. */
  51463. loadType: number;
  51464. /**
  51465. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51466. */
  51467. isInvalid: boolean;
  51468. /**
  51469. * Creates a new KhronosTextureContainer
  51470. * @param arrayBuffer contents of the KTX container file
  51471. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51472. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51473. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51474. */
  51475. constructor(
  51476. /** contents of the KTX container file */
  51477. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51478. /**
  51479. * Uploads KTX content to a Babylon Texture.
  51480. * It is assumed that the texture has already been created & is currently bound
  51481. * @hidden
  51482. */
  51483. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51484. private _upload2DCompressedLevels;
  51485. }
  51486. }
  51487. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  51488. import { Nullable } from "babylonjs/types";
  51489. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51490. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51491. /**
  51492. * Implementation of the KTX Texture Loader.
  51493. * @hidden
  51494. */
  51495. export class _KTXTextureLoader implements IInternalTextureLoader {
  51496. /**
  51497. * Defines wether the loader supports cascade loading the different faces.
  51498. */
  51499. readonly supportCascades: boolean;
  51500. /**
  51501. * This returns if the loader support the current file information.
  51502. * @param extension defines the file extension of the file being loaded
  51503. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51504. * @param fallback defines the fallback internal texture if any
  51505. * @param isBase64 defines whether the texture is encoded as a base64
  51506. * @param isBuffer defines whether the texture data are stored as a buffer
  51507. * @returns true if the loader can load the specified file
  51508. */
  51509. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51510. /**
  51511. * Transform the url before loading if required.
  51512. * @param rootUrl the url of the texture
  51513. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51514. * @returns the transformed texture
  51515. */
  51516. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51517. /**
  51518. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51519. * @param rootUrl the url of the texture
  51520. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51521. * @returns the fallback texture
  51522. */
  51523. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51524. /**
  51525. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51526. * @param data contains the texture data
  51527. * @param texture defines the BabylonJS internal texture
  51528. * @param createPolynomials will be true if polynomials have been requested
  51529. * @param onLoad defines the callback to trigger once the texture is ready
  51530. * @param onError defines the callback to trigger in case of error
  51531. */
  51532. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51533. /**
  51534. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51535. * @param data contains the texture data
  51536. * @param texture defines the BabylonJS internal texture
  51537. * @param callback defines the method to call once ready to upload
  51538. */
  51539. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51540. }
  51541. }
  51542. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  51543. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  51544. import { Scene } from "babylonjs/scene";
  51545. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  51546. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  51547. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  51548. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  51549. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  51550. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  51551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51552. /**
  51553. * Options for the default xr helper
  51554. */
  51555. export class WebXRDefaultExperienceOptions {
  51556. /**
  51557. * Floor meshes that should be used for teleporting
  51558. */
  51559. floorMeshes: Array<AbstractMesh>;
  51560. /**
  51561. * Enable or disable default UI to enter XR
  51562. */
  51563. disableDefaultUI: boolean;
  51564. }
  51565. /**
  51566. * Default experience which provides a similar setup to the previous webVRExperience
  51567. */
  51568. export class WebXRDefaultExperience {
  51569. /**
  51570. * Base experience
  51571. */
  51572. baseExperience: WebXRExperienceHelper;
  51573. /**
  51574. * Input experience extension
  51575. */
  51576. input: WebXRInput;
  51577. /**
  51578. * Loads the controller models
  51579. */
  51580. controllerModelLoader: WebXRControllerModelLoader;
  51581. /**
  51582. * Enables laser pointer and selection
  51583. */
  51584. pointerSelection: WebXRControllerPointerSelection;
  51585. /**
  51586. * Enables teleportation
  51587. */
  51588. teleportation: WebXRControllerTeleportation;
  51589. /**
  51590. * Enables ui for enetering/exiting xr
  51591. */
  51592. enterExitUI: WebXREnterExitUI;
  51593. /**
  51594. * Default target xr should render to
  51595. */
  51596. renderTarget: WebXRRenderTarget;
  51597. /**
  51598. * Creates the default xr experience
  51599. * @param scene scene
  51600. * @param options options for basic configuration
  51601. * @returns resulting WebXRDefaultExperience
  51602. */
  51603. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51604. private constructor();
  51605. /**
  51606. * DIsposes of the experience helper
  51607. */
  51608. dispose(): void;
  51609. }
  51610. }
  51611. declare module "babylonjs/Helpers/sceneHelpers" {
  51612. import { Nullable } from "babylonjs/types";
  51613. import { Mesh } from "babylonjs/Meshes/mesh";
  51614. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51615. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51616. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51617. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51618. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51619. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51620. import "babylonjs/Meshes/Builders/boxBuilder";
  51621. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51622. /** @hidden */
  51623. export var _forceSceneHelpersToBundle: boolean;
  51624. module "babylonjs/scene" {
  51625. interface Scene {
  51626. /**
  51627. * Creates a default light for the scene.
  51628. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51629. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51630. */
  51631. createDefaultLight(replace?: boolean): void;
  51632. /**
  51633. * Creates a default camera for the scene.
  51634. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51635. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51636. * @param replace has default false, when true replaces the active camera in the scene
  51637. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51638. */
  51639. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51640. /**
  51641. * Creates a default camera and a default light.
  51642. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51643. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51644. * @param replace has the default false, when true replaces the active camera/light in the scene
  51645. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51646. */
  51647. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51648. /**
  51649. * Creates a new sky box
  51650. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51651. * @param environmentTexture defines the texture to use as environment texture
  51652. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51653. * @param scale defines the overall scale of the skybox
  51654. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51655. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51656. * @returns a new mesh holding the sky box
  51657. */
  51658. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51659. /**
  51660. * Creates a new environment
  51661. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51662. * @param options defines the options you can use to configure the environment
  51663. * @returns the new EnvironmentHelper
  51664. */
  51665. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51666. /**
  51667. * Creates a new VREXperienceHelper
  51668. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51669. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51670. * @returns a new VREXperienceHelper
  51671. */
  51672. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51673. /**
  51674. * Creates a new WebXRDefaultExperience
  51675. * @see http://doc.babylonjs.com/how_to/webxr
  51676. * @param options experience options
  51677. * @returns a promise for a new WebXRDefaultExperience
  51678. */
  51679. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51680. }
  51681. }
  51682. }
  51683. declare module "babylonjs/Helpers/videoDome" {
  51684. import { Scene } from "babylonjs/scene";
  51685. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51686. import { Mesh } from "babylonjs/Meshes/mesh";
  51687. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51688. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51689. import "babylonjs/Meshes/Builders/sphereBuilder";
  51690. /**
  51691. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51692. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51693. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51694. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51695. */
  51696. export class VideoDome extends TransformNode {
  51697. /**
  51698. * Define the video source as a Monoscopic panoramic 360 video.
  51699. */
  51700. static readonly MODE_MONOSCOPIC: number;
  51701. /**
  51702. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51703. */
  51704. static readonly MODE_TOPBOTTOM: number;
  51705. /**
  51706. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51707. */
  51708. static readonly MODE_SIDEBYSIDE: number;
  51709. private _halfDome;
  51710. private _useDirectMapping;
  51711. /**
  51712. * The video texture being displayed on the sphere
  51713. */
  51714. protected _videoTexture: VideoTexture;
  51715. /**
  51716. * Gets the video texture being displayed on the sphere
  51717. */
  51718. readonly videoTexture: VideoTexture;
  51719. /**
  51720. * The skybox material
  51721. */
  51722. protected _material: BackgroundMaterial;
  51723. /**
  51724. * The surface used for the skybox
  51725. */
  51726. protected _mesh: Mesh;
  51727. /**
  51728. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51729. */
  51730. private _halfDomeMask;
  51731. /**
  51732. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51733. * Also see the options.resolution property.
  51734. */
  51735. fovMultiplier: number;
  51736. private _videoMode;
  51737. /**
  51738. * Gets or set the current video mode for the video. It can be:
  51739. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51740. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51741. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51742. */
  51743. videoMode: number;
  51744. /**
  51745. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51746. *
  51747. */
  51748. /**
  51749. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51750. */
  51751. halfDome: boolean;
  51752. /**
  51753. * Oberserver used in Stereoscopic VR Mode.
  51754. */
  51755. private _onBeforeCameraRenderObserver;
  51756. /**
  51757. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51758. * @param name Element's name, child elements will append suffixes for their own names.
  51759. * @param urlsOrVideo defines the url(s) or the video element to use
  51760. * @param options An object containing optional or exposed sub element properties
  51761. */
  51762. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51763. resolution?: number;
  51764. clickToPlay?: boolean;
  51765. autoPlay?: boolean;
  51766. loop?: boolean;
  51767. size?: number;
  51768. poster?: string;
  51769. faceForward?: boolean;
  51770. useDirectMapping?: boolean;
  51771. halfDomeMode?: boolean;
  51772. }, scene: Scene);
  51773. private _changeVideoMode;
  51774. /**
  51775. * Releases resources associated with this node.
  51776. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51777. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51778. */
  51779. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51780. }
  51781. }
  51782. declare module "babylonjs/Helpers/index" {
  51783. export * from "babylonjs/Helpers/environmentHelper";
  51784. export * from "babylonjs/Helpers/photoDome";
  51785. export * from "babylonjs/Helpers/sceneHelpers";
  51786. export * from "babylonjs/Helpers/videoDome";
  51787. }
  51788. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51789. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51790. import { IDisposable } from "babylonjs/scene";
  51791. import { Engine } from "babylonjs/Engines/engine";
  51792. /**
  51793. * This class can be used to get instrumentation data from a Babylon engine
  51794. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51795. */
  51796. export class EngineInstrumentation implements IDisposable {
  51797. /**
  51798. * Define the instrumented engine.
  51799. */
  51800. engine: Engine;
  51801. private _captureGPUFrameTime;
  51802. private _gpuFrameTimeToken;
  51803. private _gpuFrameTime;
  51804. private _captureShaderCompilationTime;
  51805. private _shaderCompilationTime;
  51806. private _onBeginFrameObserver;
  51807. private _onEndFrameObserver;
  51808. private _onBeforeShaderCompilationObserver;
  51809. private _onAfterShaderCompilationObserver;
  51810. /**
  51811. * Gets the perf counter used for GPU frame time
  51812. */
  51813. readonly gpuFrameTimeCounter: PerfCounter;
  51814. /**
  51815. * Gets the GPU frame time capture status
  51816. */
  51817. /**
  51818. * Enable or disable the GPU frame time capture
  51819. */
  51820. captureGPUFrameTime: boolean;
  51821. /**
  51822. * Gets the perf counter used for shader compilation time
  51823. */
  51824. readonly shaderCompilationTimeCounter: PerfCounter;
  51825. /**
  51826. * Gets the shader compilation time capture status
  51827. */
  51828. /**
  51829. * Enable or disable the shader compilation time capture
  51830. */
  51831. captureShaderCompilationTime: boolean;
  51832. /**
  51833. * Instantiates a new engine instrumentation.
  51834. * This class can be used to get instrumentation data from a Babylon engine
  51835. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51836. * @param engine Defines the engine to instrument
  51837. */
  51838. constructor(
  51839. /**
  51840. * Define the instrumented engine.
  51841. */
  51842. engine: Engine);
  51843. /**
  51844. * Dispose and release associated resources.
  51845. */
  51846. dispose(): void;
  51847. }
  51848. }
  51849. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51850. import { Scene, IDisposable } from "babylonjs/scene";
  51851. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51852. /**
  51853. * This class can be used to get instrumentation data from a Babylon engine
  51854. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51855. */
  51856. export class SceneInstrumentation implements IDisposable {
  51857. /**
  51858. * Defines the scene to instrument
  51859. */
  51860. scene: Scene;
  51861. private _captureActiveMeshesEvaluationTime;
  51862. private _activeMeshesEvaluationTime;
  51863. private _captureRenderTargetsRenderTime;
  51864. private _renderTargetsRenderTime;
  51865. private _captureFrameTime;
  51866. private _frameTime;
  51867. private _captureRenderTime;
  51868. private _renderTime;
  51869. private _captureInterFrameTime;
  51870. private _interFrameTime;
  51871. private _captureParticlesRenderTime;
  51872. private _particlesRenderTime;
  51873. private _captureSpritesRenderTime;
  51874. private _spritesRenderTime;
  51875. private _capturePhysicsTime;
  51876. private _physicsTime;
  51877. private _captureAnimationsTime;
  51878. private _animationsTime;
  51879. private _captureCameraRenderTime;
  51880. private _cameraRenderTime;
  51881. private _onBeforeActiveMeshesEvaluationObserver;
  51882. private _onAfterActiveMeshesEvaluationObserver;
  51883. private _onBeforeRenderTargetsRenderObserver;
  51884. private _onAfterRenderTargetsRenderObserver;
  51885. private _onAfterRenderObserver;
  51886. private _onBeforeDrawPhaseObserver;
  51887. private _onAfterDrawPhaseObserver;
  51888. private _onBeforeAnimationsObserver;
  51889. private _onBeforeParticlesRenderingObserver;
  51890. private _onAfterParticlesRenderingObserver;
  51891. private _onBeforeSpritesRenderingObserver;
  51892. private _onAfterSpritesRenderingObserver;
  51893. private _onBeforePhysicsObserver;
  51894. private _onAfterPhysicsObserver;
  51895. private _onAfterAnimationsObserver;
  51896. private _onBeforeCameraRenderObserver;
  51897. private _onAfterCameraRenderObserver;
  51898. /**
  51899. * Gets the perf counter used for active meshes evaluation time
  51900. */
  51901. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51902. /**
  51903. * Gets the active meshes evaluation time capture status
  51904. */
  51905. /**
  51906. * Enable or disable the active meshes evaluation time capture
  51907. */
  51908. captureActiveMeshesEvaluationTime: boolean;
  51909. /**
  51910. * Gets the perf counter used for render targets render time
  51911. */
  51912. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51913. /**
  51914. * Gets the render targets render time capture status
  51915. */
  51916. /**
  51917. * Enable or disable the render targets render time capture
  51918. */
  51919. captureRenderTargetsRenderTime: boolean;
  51920. /**
  51921. * Gets the perf counter used for particles render time
  51922. */
  51923. readonly particlesRenderTimeCounter: PerfCounter;
  51924. /**
  51925. * Gets the particles render time capture status
  51926. */
  51927. /**
  51928. * Enable or disable the particles render time capture
  51929. */
  51930. captureParticlesRenderTime: boolean;
  51931. /**
  51932. * Gets the perf counter used for sprites render time
  51933. */
  51934. readonly spritesRenderTimeCounter: PerfCounter;
  51935. /**
  51936. * Gets the sprites render time capture status
  51937. */
  51938. /**
  51939. * Enable or disable the sprites render time capture
  51940. */
  51941. captureSpritesRenderTime: boolean;
  51942. /**
  51943. * Gets the perf counter used for physics time
  51944. */
  51945. readonly physicsTimeCounter: PerfCounter;
  51946. /**
  51947. * Gets the physics time capture status
  51948. */
  51949. /**
  51950. * Enable or disable the physics time capture
  51951. */
  51952. capturePhysicsTime: boolean;
  51953. /**
  51954. * Gets the perf counter used for animations time
  51955. */
  51956. readonly animationsTimeCounter: PerfCounter;
  51957. /**
  51958. * Gets the animations time capture status
  51959. */
  51960. /**
  51961. * Enable or disable the animations time capture
  51962. */
  51963. captureAnimationsTime: boolean;
  51964. /**
  51965. * Gets the perf counter used for frame time capture
  51966. */
  51967. readonly frameTimeCounter: PerfCounter;
  51968. /**
  51969. * Gets the frame time capture status
  51970. */
  51971. /**
  51972. * Enable or disable the frame time capture
  51973. */
  51974. captureFrameTime: boolean;
  51975. /**
  51976. * Gets the perf counter used for inter-frames time capture
  51977. */
  51978. readonly interFrameTimeCounter: PerfCounter;
  51979. /**
  51980. * Gets the inter-frames time capture status
  51981. */
  51982. /**
  51983. * Enable or disable the inter-frames time capture
  51984. */
  51985. captureInterFrameTime: boolean;
  51986. /**
  51987. * Gets the perf counter used for render time capture
  51988. */
  51989. readonly renderTimeCounter: PerfCounter;
  51990. /**
  51991. * Gets the render time capture status
  51992. */
  51993. /**
  51994. * Enable or disable the render time capture
  51995. */
  51996. captureRenderTime: boolean;
  51997. /**
  51998. * Gets the perf counter used for camera render time capture
  51999. */
  52000. readonly cameraRenderTimeCounter: PerfCounter;
  52001. /**
  52002. * Gets the camera render time capture status
  52003. */
  52004. /**
  52005. * Enable or disable the camera render time capture
  52006. */
  52007. captureCameraRenderTime: boolean;
  52008. /**
  52009. * Gets the perf counter used for draw calls
  52010. */
  52011. readonly drawCallsCounter: PerfCounter;
  52012. /**
  52013. * Instantiates a new scene instrumentation.
  52014. * This class can be used to get instrumentation data from a Babylon engine
  52015. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52016. * @param scene Defines the scene to instrument
  52017. */
  52018. constructor(
  52019. /**
  52020. * Defines the scene to instrument
  52021. */
  52022. scene: Scene);
  52023. /**
  52024. * Dispose and release associated resources.
  52025. */
  52026. dispose(): void;
  52027. }
  52028. }
  52029. declare module "babylonjs/Instrumentation/index" {
  52030. export * from "babylonjs/Instrumentation/engineInstrumentation";
  52031. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  52032. export * from "babylonjs/Instrumentation/timeToken";
  52033. }
  52034. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  52035. /** @hidden */
  52036. export var glowMapGenerationPixelShader: {
  52037. name: string;
  52038. shader: string;
  52039. };
  52040. }
  52041. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  52042. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52043. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52044. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52045. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52046. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52047. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52048. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52049. /** @hidden */
  52050. export var glowMapGenerationVertexShader: {
  52051. name: string;
  52052. shader: string;
  52053. };
  52054. }
  52055. declare module "babylonjs/Layers/effectLayer" {
  52056. import { Observable } from "babylonjs/Misc/observable";
  52057. import { Nullable } from "babylonjs/types";
  52058. import { Camera } from "babylonjs/Cameras/camera";
  52059. import { Scene } from "babylonjs/scene";
  52060. import { ISize } from "babylonjs/Maths/math.size";
  52061. import { Color4 } from "babylonjs/Maths/math.color";
  52062. import { Engine } from "babylonjs/Engines/engine";
  52063. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52065. import { Mesh } from "babylonjs/Meshes/mesh";
  52066. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52067. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52068. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52069. import { Effect } from "babylonjs/Materials/effect";
  52070. import { Material } from "babylonjs/Materials/material";
  52071. import "babylonjs/Shaders/glowMapGeneration.fragment";
  52072. import "babylonjs/Shaders/glowMapGeneration.vertex";
  52073. /**
  52074. * Effect layer options. This helps customizing the behaviour
  52075. * of the effect layer.
  52076. */
  52077. export interface IEffectLayerOptions {
  52078. /**
  52079. * Multiplication factor apply to the canvas size to compute the render target size
  52080. * used to generated the objects (the smaller the faster).
  52081. */
  52082. mainTextureRatio: number;
  52083. /**
  52084. * Enforces a fixed size texture to ensure effect stability across devices.
  52085. */
  52086. mainTextureFixedSize?: number;
  52087. /**
  52088. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52089. */
  52090. alphaBlendingMode: number;
  52091. /**
  52092. * The camera attached to the layer.
  52093. */
  52094. camera: Nullable<Camera>;
  52095. /**
  52096. * The rendering group to draw the layer in.
  52097. */
  52098. renderingGroupId: number;
  52099. }
  52100. /**
  52101. * The effect layer Helps adding post process effect blended with the main pass.
  52102. *
  52103. * This can be for instance use to generate glow or higlight effects on the scene.
  52104. *
  52105. * The effect layer class can not be used directly and is intented to inherited from to be
  52106. * customized per effects.
  52107. */
  52108. export abstract class EffectLayer {
  52109. private _vertexBuffers;
  52110. private _indexBuffer;
  52111. private _cachedDefines;
  52112. private _effectLayerMapGenerationEffect;
  52113. private _effectLayerOptions;
  52114. private _mergeEffect;
  52115. protected _scene: Scene;
  52116. protected _engine: Engine;
  52117. protected _maxSize: number;
  52118. protected _mainTextureDesiredSize: ISize;
  52119. protected _mainTexture: RenderTargetTexture;
  52120. protected _shouldRender: boolean;
  52121. protected _postProcesses: PostProcess[];
  52122. protected _textures: BaseTexture[];
  52123. protected _emissiveTextureAndColor: {
  52124. texture: Nullable<BaseTexture>;
  52125. color: Color4;
  52126. };
  52127. /**
  52128. * The name of the layer
  52129. */
  52130. name: string;
  52131. /**
  52132. * The clear color of the texture used to generate the glow map.
  52133. */
  52134. neutralColor: Color4;
  52135. /**
  52136. * Specifies wether the highlight layer is enabled or not.
  52137. */
  52138. isEnabled: boolean;
  52139. /**
  52140. * Gets the camera attached to the layer.
  52141. */
  52142. readonly camera: Nullable<Camera>;
  52143. /**
  52144. * Gets the rendering group id the layer should render in.
  52145. */
  52146. renderingGroupId: number;
  52147. /**
  52148. * An event triggered when the effect layer has been disposed.
  52149. */
  52150. onDisposeObservable: Observable<EffectLayer>;
  52151. /**
  52152. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52153. */
  52154. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52155. /**
  52156. * An event triggered when the generated texture is being merged in the scene.
  52157. */
  52158. onBeforeComposeObservable: Observable<EffectLayer>;
  52159. /**
  52160. * An event triggered when the mesh is rendered into the effect render target.
  52161. */
  52162. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52163. /**
  52164. * An event triggered after the mesh has been rendered into the effect render target.
  52165. */
  52166. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52167. /**
  52168. * An event triggered when the generated texture has been merged in the scene.
  52169. */
  52170. onAfterComposeObservable: Observable<EffectLayer>;
  52171. /**
  52172. * An event triggered when the efffect layer changes its size.
  52173. */
  52174. onSizeChangedObservable: Observable<EffectLayer>;
  52175. /** @hidden */
  52176. static _SceneComponentInitialization: (scene: Scene) => void;
  52177. /**
  52178. * Instantiates a new effect Layer and references it in the scene.
  52179. * @param name The name of the layer
  52180. * @param scene The scene to use the layer in
  52181. */
  52182. constructor(
  52183. /** The Friendly of the effect in the scene */
  52184. name: string, scene: Scene);
  52185. /**
  52186. * Get the effect name of the layer.
  52187. * @return The effect name
  52188. */
  52189. abstract getEffectName(): string;
  52190. /**
  52191. * Checks for the readiness of the element composing the layer.
  52192. * @param subMesh the mesh to check for
  52193. * @param useInstances specify wether or not to use instances to render the mesh
  52194. * @return true if ready otherwise, false
  52195. */
  52196. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52197. /**
  52198. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52199. * @returns true if the effect requires stencil during the main canvas render pass.
  52200. */
  52201. abstract needStencil(): boolean;
  52202. /**
  52203. * Create the merge effect. This is the shader use to blit the information back
  52204. * to the main canvas at the end of the scene rendering.
  52205. * @returns The effect containing the shader used to merge the effect on the main canvas
  52206. */
  52207. protected abstract _createMergeEffect(): Effect;
  52208. /**
  52209. * Creates the render target textures and post processes used in the effect layer.
  52210. */
  52211. protected abstract _createTextureAndPostProcesses(): void;
  52212. /**
  52213. * Implementation specific of rendering the generating effect on the main canvas.
  52214. * @param effect The effect used to render through
  52215. */
  52216. protected abstract _internalRender(effect: Effect): void;
  52217. /**
  52218. * Sets the required values for both the emissive texture and and the main color.
  52219. */
  52220. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52221. /**
  52222. * Free any resources and references associated to a mesh.
  52223. * Internal use
  52224. * @param mesh The mesh to free.
  52225. */
  52226. abstract _disposeMesh(mesh: Mesh): void;
  52227. /**
  52228. * Serializes this layer (Glow or Highlight for example)
  52229. * @returns a serialized layer object
  52230. */
  52231. abstract serialize?(): any;
  52232. /**
  52233. * Initializes the effect layer with the required options.
  52234. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52235. */
  52236. protected _init(options: Partial<IEffectLayerOptions>): void;
  52237. /**
  52238. * Generates the index buffer of the full screen quad blending to the main canvas.
  52239. */
  52240. private _generateIndexBuffer;
  52241. /**
  52242. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52243. */
  52244. private _generateVertexBuffer;
  52245. /**
  52246. * Sets the main texture desired size which is the closest power of two
  52247. * of the engine canvas size.
  52248. */
  52249. private _setMainTextureSize;
  52250. /**
  52251. * Creates the main texture for the effect layer.
  52252. */
  52253. protected _createMainTexture(): void;
  52254. /**
  52255. * Adds specific effects defines.
  52256. * @param defines The defines to add specifics to.
  52257. */
  52258. protected _addCustomEffectDefines(defines: string[]): void;
  52259. /**
  52260. * Checks for the readiness of the element composing the layer.
  52261. * @param subMesh the mesh to check for
  52262. * @param useInstances specify wether or not to use instances to render the mesh
  52263. * @param emissiveTexture the associated emissive texture used to generate the glow
  52264. * @return true if ready otherwise, false
  52265. */
  52266. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52267. /**
  52268. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52269. */
  52270. render(): void;
  52271. /**
  52272. * Determine if a given mesh will be used in the current effect.
  52273. * @param mesh mesh to test
  52274. * @returns true if the mesh will be used
  52275. */
  52276. hasMesh(mesh: AbstractMesh): boolean;
  52277. /**
  52278. * Returns true if the layer contains information to display, otherwise false.
  52279. * @returns true if the glow layer should be rendered
  52280. */
  52281. shouldRender(): boolean;
  52282. /**
  52283. * Returns true if the mesh should render, otherwise false.
  52284. * @param mesh The mesh to render
  52285. * @returns true if it should render otherwise false
  52286. */
  52287. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52288. /**
  52289. * Returns true if the mesh can be rendered, otherwise false.
  52290. * @param mesh The mesh to render
  52291. * @param material The material used on the mesh
  52292. * @returns true if it can be rendered otherwise false
  52293. */
  52294. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52295. /**
  52296. * Returns true if the mesh should render, otherwise false.
  52297. * @param mesh The mesh to render
  52298. * @returns true if it should render otherwise false
  52299. */
  52300. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52301. /**
  52302. * Renders the submesh passed in parameter to the generation map.
  52303. */
  52304. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52305. /**
  52306. * Defines wether the current material of the mesh should be use to render the effect.
  52307. * @param mesh defines the current mesh to render
  52308. */
  52309. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52310. /**
  52311. * Rebuild the required buffers.
  52312. * @hidden Internal use only.
  52313. */
  52314. _rebuild(): void;
  52315. /**
  52316. * Dispose only the render target textures and post process.
  52317. */
  52318. private _disposeTextureAndPostProcesses;
  52319. /**
  52320. * Dispose the highlight layer and free resources.
  52321. */
  52322. dispose(): void;
  52323. /**
  52324. * Gets the class name of the effect layer
  52325. * @returns the string with the class name of the effect layer
  52326. */
  52327. getClassName(): string;
  52328. /**
  52329. * Creates an effect layer from parsed effect layer data
  52330. * @param parsedEffectLayer defines effect layer data
  52331. * @param scene defines the current scene
  52332. * @param rootUrl defines the root URL containing the effect layer information
  52333. * @returns a parsed effect Layer
  52334. */
  52335. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52336. }
  52337. }
  52338. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  52339. import { Scene } from "babylonjs/scene";
  52340. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52341. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52342. import { AbstractScene } from "babylonjs/abstractScene";
  52343. module "babylonjs/abstractScene" {
  52344. interface AbstractScene {
  52345. /**
  52346. * The list of effect layers (highlights/glow) added to the scene
  52347. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52348. * @see http://doc.babylonjs.com/how_to/glow_layer
  52349. */
  52350. effectLayers: Array<EffectLayer>;
  52351. /**
  52352. * Removes the given effect layer from this scene.
  52353. * @param toRemove defines the effect layer to remove
  52354. * @returns the index of the removed effect layer
  52355. */
  52356. removeEffectLayer(toRemove: EffectLayer): number;
  52357. /**
  52358. * Adds the given effect layer to this scene
  52359. * @param newEffectLayer defines the effect layer to add
  52360. */
  52361. addEffectLayer(newEffectLayer: EffectLayer): void;
  52362. }
  52363. }
  52364. /**
  52365. * Defines the layer scene component responsible to manage any effect layers
  52366. * in a given scene.
  52367. */
  52368. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52369. /**
  52370. * The component name helpfull to identify the component in the list of scene components.
  52371. */
  52372. readonly name: string;
  52373. /**
  52374. * The scene the component belongs to.
  52375. */
  52376. scene: Scene;
  52377. private _engine;
  52378. private _renderEffects;
  52379. private _needStencil;
  52380. private _previousStencilState;
  52381. /**
  52382. * Creates a new instance of the component for the given scene
  52383. * @param scene Defines the scene to register the component in
  52384. */
  52385. constructor(scene: Scene);
  52386. /**
  52387. * Registers the component in a given scene
  52388. */
  52389. register(): void;
  52390. /**
  52391. * Rebuilds the elements related to this component in case of
  52392. * context lost for instance.
  52393. */
  52394. rebuild(): void;
  52395. /**
  52396. * Serializes the component data to the specified json object
  52397. * @param serializationObject The object to serialize to
  52398. */
  52399. serialize(serializationObject: any): void;
  52400. /**
  52401. * Adds all the elements from the container to the scene
  52402. * @param container the container holding the elements
  52403. */
  52404. addFromContainer(container: AbstractScene): void;
  52405. /**
  52406. * Removes all the elements in the container from the scene
  52407. * @param container contains the elements to remove
  52408. * @param dispose if the removed element should be disposed (default: false)
  52409. */
  52410. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52411. /**
  52412. * Disposes the component and the associated ressources.
  52413. */
  52414. dispose(): void;
  52415. private _isReadyForMesh;
  52416. private _renderMainTexture;
  52417. private _setStencil;
  52418. private _setStencilBack;
  52419. private _draw;
  52420. private _drawCamera;
  52421. private _drawRenderingGroup;
  52422. }
  52423. }
  52424. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52425. /** @hidden */
  52426. export var glowMapMergePixelShader: {
  52427. name: string;
  52428. shader: string;
  52429. };
  52430. }
  52431. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52432. /** @hidden */
  52433. export var glowMapMergeVertexShader: {
  52434. name: string;
  52435. shader: string;
  52436. };
  52437. }
  52438. declare module "babylonjs/Layers/glowLayer" {
  52439. import { Nullable } from "babylonjs/types";
  52440. import { Camera } from "babylonjs/Cameras/camera";
  52441. import { Scene } from "babylonjs/scene";
  52442. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52444. import { Mesh } from "babylonjs/Meshes/mesh";
  52445. import { Texture } from "babylonjs/Materials/Textures/texture";
  52446. import { Effect } from "babylonjs/Materials/effect";
  52447. import { Material } from "babylonjs/Materials/material";
  52448. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52449. import { Color4 } from "babylonjs/Maths/math.color";
  52450. import "babylonjs/Shaders/glowMapMerge.fragment";
  52451. import "babylonjs/Shaders/glowMapMerge.vertex";
  52452. import "babylonjs/Layers/effectLayerSceneComponent";
  52453. module "babylonjs/abstractScene" {
  52454. interface AbstractScene {
  52455. /**
  52456. * Return a the first highlight layer of the scene with a given name.
  52457. * @param name The name of the highlight layer to look for.
  52458. * @return The highlight layer if found otherwise null.
  52459. */
  52460. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52461. }
  52462. }
  52463. /**
  52464. * Glow layer options. This helps customizing the behaviour
  52465. * of the glow layer.
  52466. */
  52467. export interface IGlowLayerOptions {
  52468. /**
  52469. * Multiplication factor apply to the canvas size to compute the render target size
  52470. * used to generated the glowing objects (the smaller the faster).
  52471. */
  52472. mainTextureRatio: number;
  52473. /**
  52474. * Enforces a fixed size texture to ensure resize independant blur.
  52475. */
  52476. mainTextureFixedSize?: number;
  52477. /**
  52478. * How big is the kernel of the blur texture.
  52479. */
  52480. blurKernelSize: number;
  52481. /**
  52482. * The camera attached to the layer.
  52483. */
  52484. camera: Nullable<Camera>;
  52485. /**
  52486. * Enable MSAA by chosing the number of samples.
  52487. */
  52488. mainTextureSamples?: number;
  52489. /**
  52490. * The rendering group to draw the layer in.
  52491. */
  52492. renderingGroupId: number;
  52493. }
  52494. /**
  52495. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52496. *
  52497. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  52498. *
  52499. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52500. */
  52501. export class GlowLayer extends EffectLayer {
  52502. /**
  52503. * Effect Name of the layer.
  52504. */
  52505. static readonly EffectName: string;
  52506. /**
  52507. * The default blur kernel size used for the glow.
  52508. */
  52509. static DefaultBlurKernelSize: number;
  52510. /**
  52511. * The default texture size ratio used for the glow.
  52512. */
  52513. static DefaultTextureRatio: number;
  52514. /**
  52515. * Sets the kernel size of the blur.
  52516. */
  52517. /**
  52518. * Gets the kernel size of the blur.
  52519. */
  52520. blurKernelSize: number;
  52521. /**
  52522. * Sets the glow intensity.
  52523. */
  52524. /**
  52525. * Gets the glow intensity.
  52526. */
  52527. intensity: number;
  52528. private _options;
  52529. private _intensity;
  52530. private _horizontalBlurPostprocess1;
  52531. private _verticalBlurPostprocess1;
  52532. private _horizontalBlurPostprocess2;
  52533. private _verticalBlurPostprocess2;
  52534. private _blurTexture1;
  52535. private _blurTexture2;
  52536. private _postProcesses1;
  52537. private _postProcesses2;
  52538. private _includedOnlyMeshes;
  52539. private _excludedMeshes;
  52540. private _meshesUsingTheirOwnMaterials;
  52541. /**
  52542. * Callback used to let the user override the color selection on a per mesh basis
  52543. */
  52544. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52545. /**
  52546. * Callback used to let the user override the texture selection on a per mesh basis
  52547. */
  52548. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52549. /**
  52550. * Instantiates a new glow Layer and references it to the scene.
  52551. * @param name The name of the layer
  52552. * @param scene The scene to use the layer in
  52553. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52554. */
  52555. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52556. /**
  52557. * Get the effect name of the layer.
  52558. * @return The effect name
  52559. */
  52560. getEffectName(): string;
  52561. /**
  52562. * Create the merge effect. This is the shader use to blit the information back
  52563. * to the main canvas at the end of the scene rendering.
  52564. */
  52565. protected _createMergeEffect(): Effect;
  52566. /**
  52567. * Creates the render target textures and post processes used in the glow layer.
  52568. */
  52569. protected _createTextureAndPostProcesses(): void;
  52570. /**
  52571. * Checks for the readiness of the element composing the layer.
  52572. * @param subMesh the mesh to check for
  52573. * @param useInstances specify wether or not to use instances to render the mesh
  52574. * @param emissiveTexture the associated emissive texture used to generate the glow
  52575. * @return true if ready otherwise, false
  52576. */
  52577. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52578. /**
  52579. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52580. */
  52581. needStencil(): boolean;
  52582. /**
  52583. * Returns true if the mesh can be rendered, otherwise false.
  52584. * @param mesh The mesh to render
  52585. * @param material The material used on the mesh
  52586. * @returns true if it can be rendered otherwise false
  52587. */
  52588. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52589. /**
  52590. * Implementation specific of rendering the generating effect on the main canvas.
  52591. * @param effect The effect used to render through
  52592. */
  52593. protected _internalRender(effect: Effect): void;
  52594. /**
  52595. * Sets the required values for both the emissive texture and and the main color.
  52596. */
  52597. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52598. /**
  52599. * Returns true if the mesh should render, otherwise false.
  52600. * @param mesh The mesh to render
  52601. * @returns true if it should render otherwise false
  52602. */
  52603. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52604. /**
  52605. * Adds specific effects defines.
  52606. * @param defines The defines to add specifics to.
  52607. */
  52608. protected _addCustomEffectDefines(defines: string[]): void;
  52609. /**
  52610. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52611. * @param mesh The mesh to exclude from the glow layer
  52612. */
  52613. addExcludedMesh(mesh: Mesh): void;
  52614. /**
  52615. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52616. * @param mesh The mesh to remove
  52617. */
  52618. removeExcludedMesh(mesh: Mesh): void;
  52619. /**
  52620. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52621. * @param mesh The mesh to include in the glow layer
  52622. */
  52623. addIncludedOnlyMesh(mesh: Mesh): void;
  52624. /**
  52625. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52626. * @param mesh The mesh to remove
  52627. */
  52628. removeIncludedOnlyMesh(mesh: Mesh): void;
  52629. /**
  52630. * Determine if a given mesh will be used in the glow layer
  52631. * @param mesh The mesh to test
  52632. * @returns true if the mesh will be highlighted by the current glow layer
  52633. */
  52634. hasMesh(mesh: AbstractMesh): boolean;
  52635. /**
  52636. * Defines wether the current material of the mesh should be use to render the effect.
  52637. * @param mesh defines the current mesh to render
  52638. */
  52639. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52640. /**
  52641. * Add a mesh to be rendered through its own material and not with emissive only.
  52642. * @param mesh The mesh for which we need to use its material
  52643. */
  52644. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  52645. /**
  52646. * Remove a mesh from being rendered through its own material and not with emissive only.
  52647. * @param mesh The mesh for which we need to not use its material
  52648. */
  52649. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  52650. /**
  52651. * Free any resources and references associated to a mesh.
  52652. * Internal use
  52653. * @param mesh The mesh to free.
  52654. * @hidden
  52655. */
  52656. _disposeMesh(mesh: Mesh): void;
  52657. /**
  52658. * Gets the class name of the effect layer
  52659. * @returns the string with the class name of the effect layer
  52660. */
  52661. getClassName(): string;
  52662. /**
  52663. * Serializes this glow layer
  52664. * @returns a serialized glow layer object
  52665. */
  52666. serialize(): any;
  52667. /**
  52668. * Creates a Glow Layer from parsed glow layer data
  52669. * @param parsedGlowLayer defines glow layer data
  52670. * @param scene defines the current scene
  52671. * @param rootUrl defines the root URL containing the glow layer information
  52672. * @returns a parsed Glow Layer
  52673. */
  52674. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52675. }
  52676. }
  52677. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52678. /** @hidden */
  52679. export var glowBlurPostProcessPixelShader: {
  52680. name: string;
  52681. shader: string;
  52682. };
  52683. }
  52684. declare module "babylonjs/Layers/highlightLayer" {
  52685. import { Observable } from "babylonjs/Misc/observable";
  52686. import { Nullable } from "babylonjs/types";
  52687. import { Camera } from "babylonjs/Cameras/camera";
  52688. import { Scene } from "babylonjs/scene";
  52689. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52690. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52691. import { Mesh } from "babylonjs/Meshes/mesh";
  52692. import { Effect } from "babylonjs/Materials/effect";
  52693. import { Material } from "babylonjs/Materials/material";
  52694. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52695. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52696. import "babylonjs/Shaders/glowMapMerge.fragment";
  52697. import "babylonjs/Shaders/glowMapMerge.vertex";
  52698. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52699. module "babylonjs/abstractScene" {
  52700. interface AbstractScene {
  52701. /**
  52702. * Return a the first highlight layer of the scene with a given name.
  52703. * @param name The name of the highlight layer to look for.
  52704. * @return The highlight layer if found otherwise null.
  52705. */
  52706. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52707. }
  52708. }
  52709. /**
  52710. * Highlight layer options. This helps customizing the behaviour
  52711. * of the highlight layer.
  52712. */
  52713. export interface IHighlightLayerOptions {
  52714. /**
  52715. * Multiplication factor apply to the canvas size to compute the render target size
  52716. * used to generated the glowing objects (the smaller the faster).
  52717. */
  52718. mainTextureRatio: number;
  52719. /**
  52720. * Enforces a fixed size texture to ensure resize independant blur.
  52721. */
  52722. mainTextureFixedSize?: number;
  52723. /**
  52724. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52725. * of the picture to blur (the smaller the faster).
  52726. */
  52727. blurTextureSizeRatio: number;
  52728. /**
  52729. * How big in texel of the blur texture is the vertical blur.
  52730. */
  52731. blurVerticalSize: number;
  52732. /**
  52733. * How big in texel of the blur texture is the horizontal blur.
  52734. */
  52735. blurHorizontalSize: number;
  52736. /**
  52737. * Alpha blending mode used to apply the blur. Default is combine.
  52738. */
  52739. alphaBlendingMode: number;
  52740. /**
  52741. * The camera attached to the layer.
  52742. */
  52743. camera: Nullable<Camera>;
  52744. /**
  52745. * Should we display highlight as a solid stroke?
  52746. */
  52747. isStroke?: boolean;
  52748. /**
  52749. * The rendering group to draw the layer in.
  52750. */
  52751. renderingGroupId: number;
  52752. }
  52753. /**
  52754. * The highlight layer Helps adding a glow effect around a mesh.
  52755. *
  52756. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52757. * glowy meshes to your scene.
  52758. *
  52759. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52760. */
  52761. export class HighlightLayer extends EffectLayer {
  52762. name: string;
  52763. /**
  52764. * Effect Name of the highlight layer.
  52765. */
  52766. static readonly EffectName: string;
  52767. /**
  52768. * The neutral color used during the preparation of the glow effect.
  52769. * This is black by default as the blend operation is a blend operation.
  52770. */
  52771. static NeutralColor: Color4;
  52772. /**
  52773. * Stencil value used for glowing meshes.
  52774. */
  52775. static GlowingMeshStencilReference: number;
  52776. /**
  52777. * Stencil value used for the other meshes in the scene.
  52778. */
  52779. static NormalMeshStencilReference: number;
  52780. /**
  52781. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52782. */
  52783. innerGlow: boolean;
  52784. /**
  52785. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52786. */
  52787. outerGlow: boolean;
  52788. /**
  52789. * Specifies the horizontal size of the blur.
  52790. */
  52791. /**
  52792. * Gets the horizontal size of the blur.
  52793. */
  52794. blurHorizontalSize: number;
  52795. /**
  52796. * Specifies the vertical size of the blur.
  52797. */
  52798. /**
  52799. * Gets the vertical size of the blur.
  52800. */
  52801. blurVerticalSize: number;
  52802. /**
  52803. * An event triggered when the highlight layer is being blurred.
  52804. */
  52805. onBeforeBlurObservable: Observable<HighlightLayer>;
  52806. /**
  52807. * An event triggered when the highlight layer has been blurred.
  52808. */
  52809. onAfterBlurObservable: Observable<HighlightLayer>;
  52810. private _instanceGlowingMeshStencilReference;
  52811. private _options;
  52812. private _downSamplePostprocess;
  52813. private _horizontalBlurPostprocess;
  52814. private _verticalBlurPostprocess;
  52815. private _blurTexture;
  52816. private _meshes;
  52817. private _excludedMeshes;
  52818. /**
  52819. * Instantiates a new highlight Layer and references it to the scene..
  52820. * @param name The name of the layer
  52821. * @param scene The scene to use the layer in
  52822. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52823. */
  52824. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52825. /**
  52826. * Get the effect name of the layer.
  52827. * @return The effect name
  52828. */
  52829. getEffectName(): string;
  52830. /**
  52831. * Create the merge effect. This is the shader use to blit the information back
  52832. * to the main canvas at the end of the scene rendering.
  52833. */
  52834. protected _createMergeEffect(): Effect;
  52835. /**
  52836. * Creates the render target textures and post processes used in the highlight layer.
  52837. */
  52838. protected _createTextureAndPostProcesses(): void;
  52839. /**
  52840. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52841. */
  52842. needStencil(): boolean;
  52843. /**
  52844. * Checks for the readiness of the element composing the layer.
  52845. * @param subMesh the mesh to check for
  52846. * @param useInstances specify wether or not to use instances to render the mesh
  52847. * @param emissiveTexture the associated emissive texture used to generate the glow
  52848. * @return true if ready otherwise, false
  52849. */
  52850. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52851. /**
  52852. * Implementation specific of rendering the generating effect on the main canvas.
  52853. * @param effect The effect used to render through
  52854. */
  52855. protected _internalRender(effect: Effect): void;
  52856. /**
  52857. * Returns true if the layer contains information to display, otherwise false.
  52858. */
  52859. shouldRender(): boolean;
  52860. /**
  52861. * Returns true if the mesh should render, otherwise false.
  52862. * @param mesh The mesh to render
  52863. * @returns true if it should render otherwise false
  52864. */
  52865. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52866. /**
  52867. * Sets the required values for both the emissive texture and and the main color.
  52868. */
  52869. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52870. /**
  52871. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52872. * @param mesh The mesh to exclude from the highlight layer
  52873. */
  52874. addExcludedMesh(mesh: Mesh): void;
  52875. /**
  52876. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52877. * @param mesh The mesh to highlight
  52878. */
  52879. removeExcludedMesh(mesh: Mesh): void;
  52880. /**
  52881. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52882. * @param mesh mesh to test
  52883. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52884. */
  52885. hasMesh(mesh: AbstractMesh): boolean;
  52886. /**
  52887. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52888. * @param mesh The mesh to highlight
  52889. * @param color The color of the highlight
  52890. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52891. */
  52892. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52893. /**
  52894. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52895. * @param mesh The mesh to highlight
  52896. */
  52897. removeMesh(mesh: Mesh): void;
  52898. /**
  52899. * Force the stencil to the normal expected value for none glowing parts
  52900. */
  52901. private _defaultStencilReference;
  52902. /**
  52903. * Free any resources and references associated to a mesh.
  52904. * Internal use
  52905. * @param mesh The mesh to free.
  52906. * @hidden
  52907. */
  52908. _disposeMesh(mesh: Mesh): void;
  52909. /**
  52910. * Dispose the highlight layer and free resources.
  52911. */
  52912. dispose(): void;
  52913. /**
  52914. * Gets the class name of the effect layer
  52915. * @returns the string with the class name of the effect layer
  52916. */
  52917. getClassName(): string;
  52918. /**
  52919. * Serializes this Highlight layer
  52920. * @returns a serialized Highlight layer object
  52921. */
  52922. serialize(): any;
  52923. /**
  52924. * Creates a Highlight layer from parsed Highlight layer data
  52925. * @param parsedHightlightLayer defines the Highlight layer data
  52926. * @param scene defines the current scene
  52927. * @param rootUrl defines the root URL containing the Highlight layer information
  52928. * @returns a parsed Highlight layer
  52929. */
  52930. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52931. }
  52932. }
  52933. declare module "babylonjs/Layers/layerSceneComponent" {
  52934. import { Scene } from "babylonjs/scene";
  52935. import { ISceneComponent } from "babylonjs/sceneComponent";
  52936. import { Layer } from "babylonjs/Layers/layer";
  52937. import { AbstractScene } from "babylonjs/abstractScene";
  52938. module "babylonjs/abstractScene" {
  52939. interface AbstractScene {
  52940. /**
  52941. * The list of layers (background and foreground) of the scene
  52942. */
  52943. layers: Array<Layer>;
  52944. }
  52945. }
  52946. /**
  52947. * Defines the layer scene component responsible to manage any layers
  52948. * in a given scene.
  52949. */
  52950. export class LayerSceneComponent implements ISceneComponent {
  52951. /**
  52952. * The component name helpfull to identify the component in the list of scene components.
  52953. */
  52954. readonly name: string;
  52955. /**
  52956. * The scene the component belongs to.
  52957. */
  52958. scene: Scene;
  52959. private _engine;
  52960. /**
  52961. * Creates a new instance of the component for the given scene
  52962. * @param scene Defines the scene to register the component in
  52963. */
  52964. constructor(scene: Scene);
  52965. /**
  52966. * Registers the component in a given scene
  52967. */
  52968. register(): void;
  52969. /**
  52970. * Rebuilds the elements related to this component in case of
  52971. * context lost for instance.
  52972. */
  52973. rebuild(): void;
  52974. /**
  52975. * Disposes the component and the associated ressources.
  52976. */
  52977. dispose(): void;
  52978. private _draw;
  52979. private _drawCameraPredicate;
  52980. private _drawCameraBackground;
  52981. private _drawCameraForeground;
  52982. private _drawRenderTargetPredicate;
  52983. private _drawRenderTargetBackground;
  52984. private _drawRenderTargetForeground;
  52985. /**
  52986. * Adds all the elements from the container to the scene
  52987. * @param container the container holding the elements
  52988. */
  52989. addFromContainer(container: AbstractScene): void;
  52990. /**
  52991. * Removes all the elements in the container from the scene
  52992. * @param container contains the elements to remove
  52993. * @param dispose if the removed element should be disposed (default: false)
  52994. */
  52995. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52996. }
  52997. }
  52998. declare module "babylonjs/Shaders/layer.fragment" {
  52999. /** @hidden */
  53000. export var layerPixelShader: {
  53001. name: string;
  53002. shader: string;
  53003. };
  53004. }
  53005. declare module "babylonjs/Shaders/layer.vertex" {
  53006. /** @hidden */
  53007. export var layerVertexShader: {
  53008. name: string;
  53009. shader: string;
  53010. };
  53011. }
  53012. declare module "babylonjs/Layers/layer" {
  53013. import { Observable } from "babylonjs/Misc/observable";
  53014. import { Nullable } from "babylonjs/types";
  53015. import { Scene } from "babylonjs/scene";
  53016. import { Vector2 } from "babylonjs/Maths/math.vector";
  53017. import { Color4 } from "babylonjs/Maths/math.color";
  53018. import { Texture } from "babylonjs/Materials/Textures/texture";
  53019. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53020. import "babylonjs/Shaders/layer.fragment";
  53021. import "babylonjs/Shaders/layer.vertex";
  53022. /**
  53023. * This represents a full screen 2d layer.
  53024. * This can be useful to display a picture in the background of your scene for instance.
  53025. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53026. */
  53027. export class Layer {
  53028. /**
  53029. * Define the name of the layer.
  53030. */
  53031. name: string;
  53032. /**
  53033. * Define the texture the layer should display.
  53034. */
  53035. texture: Nullable<Texture>;
  53036. /**
  53037. * Is the layer in background or foreground.
  53038. */
  53039. isBackground: boolean;
  53040. /**
  53041. * Define the color of the layer (instead of texture).
  53042. */
  53043. color: Color4;
  53044. /**
  53045. * Define the scale of the layer in order to zoom in out of the texture.
  53046. */
  53047. scale: Vector2;
  53048. /**
  53049. * Define an offset for the layer in order to shift the texture.
  53050. */
  53051. offset: Vector2;
  53052. /**
  53053. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53054. */
  53055. alphaBlendingMode: number;
  53056. /**
  53057. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53058. * Alpha test will not mix with the background color in case of transparency.
  53059. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53060. */
  53061. alphaTest: boolean;
  53062. /**
  53063. * Define a mask to restrict the layer to only some of the scene cameras.
  53064. */
  53065. layerMask: number;
  53066. /**
  53067. * Define the list of render target the layer is visible into.
  53068. */
  53069. renderTargetTextures: RenderTargetTexture[];
  53070. /**
  53071. * Define if the layer is only used in renderTarget or if it also
  53072. * renders in the main frame buffer of the canvas.
  53073. */
  53074. renderOnlyInRenderTargetTextures: boolean;
  53075. private _scene;
  53076. private _vertexBuffers;
  53077. private _indexBuffer;
  53078. private _effect;
  53079. private _alphaTestEffect;
  53080. /**
  53081. * An event triggered when the layer is disposed.
  53082. */
  53083. onDisposeObservable: Observable<Layer>;
  53084. private _onDisposeObserver;
  53085. /**
  53086. * Back compatibility with callback before the onDisposeObservable existed.
  53087. * The set callback will be triggered when the layer has been disposed.
  53088. */
  53089. onDispose: () => void;
  53090. /**
  53091. * An event triggered before rendering the scene
  53092. */
  53093. onBeforeRenderObservable: Observable<Layer>;
  53094. private _onBeforeRenderObserver;
  53095. /**
  53096. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53097. * The set callback will be triggered just before rendering the layer.
  53098. */
  53099. onBeforeRender: () => void;
  53100. /**
  53101. * An event triggered after rendering the scene
  53102. */
  53103. onAfterRenderObservable: Observable<Layer>;
  53104. private _onAfterRenderObserver;
  53105. /**
  53106. * Back compatibility with callback before the onAfterRenderObservable existed.
  53107. * The set callback will be triggered just after rendering the layer.
  53108. */
  53109. onAfterRender: () => void;
  53110. /**
  53111. * Instantiates a new layer.
  53112. * This represents a full screen 2d layer.
  53113. * This can be useful to display a picture in the background of your scene for instance.
  53114. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53115. * @param name Define the name of the layer in the scene
  53116. * @param imgUrl Define the url of the texture to display in the layer
  53117. * @param scene Define the scene the layer belongs to
  53118. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53119. * @param color Defines a color for the layer
  53120. */
  53121. constructor(
  53122. /**
  53123. * Define the name of the layer.
  53124. */
  53125. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53126. private _createIndexBuffer;
  53127. /** @hidden */
  53128. _rebuild(): void;
  53129. /**
  53130. * Renders the layer in the scene.
  53131. */
  53132. render(): void;
  53133. /**
  53134. * Disposes and releases the associated ressources.
  53135. */
  53136. dispose(): void;
  53137. }
  53138. }
  53139. declare module "babylonjs/Layers/index" {
  53140. export * from "babylonjs/Layers/effectLayer";
  53141. export * from "babylonjs/Layers/effectLayerSceneComponent";
  53142. export * from "babylonjs/Layers/glowLayer";
  53143. export * from "babylonjs/Layers/highlightLayer";
  53144. export * from "babylonjs/Layers/layer";
  53145. export * from "babylonjs/Layers/layerSceneComponent";
  53146. }
  53147. declare module "babylonjs/Shaders/lensFlare.fragment" {
  53148. /** @hidden */
  53149. export var lensFlarePixelShader: {
  53150. name: string;
  53151. shader: string;
  53152. };
  53153. }
  53154. declare module "babylonjs/Shaders/lensFlare.vertex" {
  53155. /** @hidden */
  53156. export var lensFlareVertexShader: {
  53157. name: string;
  53158. shader: string;
  53159. };
  53160. }
  53161. declare module "babylonjs/LensFlares/lensFlareSystem" {
  53162. import { Scene } from "babylonjs/scene";
  53163. import { Vector3 } from "babylonjs/Maths/math.vector";
  53164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53165. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  53166. import "babylonjs/Shaders/lensFlare.fragment";
  53167. import "babylonjs/Shaders/lensFlare.vertex";
  53168. import { Viewport } from "babylonjs/Maths/math.viewport";
  53169. /**
  53170. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53171. * It is usually composed of several `lensFlare`.
  53172. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53173. */
  53174. export class LensFlareSystem {
  53175. /**
  53176. * Define the name of the lens flare system
  53177. */
  53178. name: string;
  53179. /**
  53180. * List of lens flares used in this system.
  53181. */
  53182. lensFlares: LensFlare[];
  53183. /**
  53184. * Define a limit from the border the lens flare can be visible.
  53185. */
  53186. borderLimit: number;
  53187. /**
  53188. * Define a viewport border we do not want to see the lens flare in.
  53189. */
  53190. viewportBorder: number;
  53191. /**
  53192. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53193. */
  53194. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53195. /**
  53196. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53197. */
  53198. layerMask: number;
  53199. /**
  53200. * Define the id of the lens flare system in the scene.
  53201. * (equal to name by default)
  53202. */
  53203. id: string;
  53204. private _scene;
  53205. private _emitter;
  53206. private _vertexBuffers;
  53207. private _indexBuffer;
  53208. private _effect;
  53209. private _positionX;
  53210. private _positionY;
  53211. private _isEnabled;
  53212. /** @hidden */
  53213. static _SceneComponentInitialization: (scene: Scene) => void;
  53214. /**
  53215. * Instantiates a lens flare system.
  53216. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53217. * It is usually composed of several `lensFlare`.
  53218. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53219. * @param name Define the name of the lens flare system in the scene
  53220. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53221. * @param scene Define the scene the lens flare system belongs to
  53222. */
  53223. constructor(
  53224. /**
  53225. * Define the name of the lens flare system
  53226. */
  53227. name: string, emitter: any, scene: Scene);
  53228. /**
  53229. * Define if the lens flare system is enabled.
  53230. */
  53231. isEnabled: boolean;
  53232. /**
  53233. * Get the scene the effects belongs to.
  53234. * @returns the scene holding the lens flare system
  53235. */
  53236. getScene(): Scene;
  53237. /**
  53238. * Get the emitter of the lens flare system.
  53239. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53240. * @returns the emitter of the lens flare system
  53241. */
  53242. getEmitter(): any;
  53243. /**
  53244. * Set the emitter of the lens flare system.
  53245. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53246. * @param newEmitter Define the new emitter of the system
  53247. */
  53248. setEmitter(newEmitter: any): void;
  53249. /**
  53250. * Get the lens flare system emitter position.
  53251. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53252. * @returns the position
  53253. */
  53254. getEmitterPosition(): Vector3;
  53255. /**
  53256. * @hidden
  53257. */
  53258. computeEffectivePosition(globalViewport: Viewport): boolean;
  53259. /** @hidden */
  53260. _isVisible(): boolean;
  53261. /**
  53262. * @hidden
  53263. */
  53264. render(): boolean;
  53265. /**
  53266. * Dispose and release the lens flare with its associated resources.
  53267. */
  53268. dispose(): void;
  53269. /**
  53270. * Parse a lens flare system from a JSON repressentation
  53271. * @param parsedLensFlareSystem Define the JSON to parse
  53272. * @param scene Define the scene the parsed system should be instantiated in
  53273. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53274. * @returns the parsed system
  53275. */
  53276. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53277. /**
  53278. * Serialize the current Lens Flare System into a JSON representation.
  53279. * @returns the serialized JSON
  53280. */
  53281. serialize(): any;
  53282. }
  53283. }
  53284. declare module "babylonjs/LensFlares/lensFlare" {
  53285. import { Nullable } from "babylonjs/types";
  53286. import { Color3 } from "babylonjs/Maths/math.color";
  53287. import { Texture } from "babylonjs/Materials/Textures/texture";
  53288. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53289. /**
  53290. * This represents one of the lens effect in a `lensFlareSystem`.
  53291. * It controls one of the indiviual texture used in the effect.
  53292. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53293. */
  53294. export class LensFlare {
  53295. /**
  53296. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53297. */
  53298. size: number;
  53299. /**
  53300. * 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.
  53301. */
  53302. position: number;
  53303. /**
  53304. * Define the lens color.
  53305. */
  53306. color: Color3;
  53307. /**
  53308. * Define the lens texture.
  53309. */
  53310. texture: Nullable<Texture>;
  53311. /**
  53312. * Define the alpha mode to render this particular lens.
  53313. */
  53314. alphaMode: number;
  53315. private _system;
  53316. /**
  53317. * Creates a new Lens Flare.
  53318. * This represents one of the lens effect in a `lensFlareSystem`.
  53319. * It controls one of the indiviual texture used in the effect.
  53320. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53321. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53322. * @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.
  53323. * @param color Define the lens color
  53324. * @param imgUrl Define the lens texture url
  53325. * @param system Define the `lensFlareSystem` this flare is part of
  53326. * @returns The newly created Lens Flare
  53327. */
  53328. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53329. /**
  53330. * Instantiates a new Lens Flare.
  53331. * This represents one of the lens effect in a `lensFlareSystem`.
  53332. * It controls one of the indiviual texture used in the effect.
  53333. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53334. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53335. * @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.
  53336. * @param color Define the lens color
  53337. * @param imgUrl Define the lens texture url
  53338. * @param system Define the `lensFlareSystem` this flare is part of
  53339. */
  53340. constructor(
  53341. /**
  53342. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53343. */
  53344. size: number,
  53345. /**
  53346. * 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.
  53347. */
  53348. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53349. /**
  53350. * Dispose and release the lens flare with its associated resources.
  53351. */
  53352. dispose(): void;
  53353. }
  53354. }
  53355. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  53356. import { Nullable } from "babylonjs/types";
  53357. import { Scene } from "babylonjs/scene";
  53358. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53359. import { AbstractScene } from "babylonjs/abstractScene";
  53360. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53361. module "babylonjs/abstractScene" {
  53362. interface AbstractScene {
  53363. /**
  53364. * The list of lens flare system added to the scene
  53365. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53366. */
  53367. lensFlareSystems: Array<LensFlareSystem>;
  53368. /**
  53369. * Removes the given lens flare system from this scene.
  53370. * @param toRemove The lens flare system to remove
  53371. * @returns The index of the removed lens flare system
  53372. */
  53373. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53374. /**
  53375. * Adds the given lens flare system to this scene
  53376. * @param newLensFlareSystem The lens flare system to add
  53377. */
  53378. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53379. /**
  53380. * Gets a lens flare system using its name
  53381. * @param name defines the name to look for
  53382. * @returns the lens flare system or null if not found
  53383. */
  53384. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53385. /**
  53386. * Gets a lens flare system using its id
  53387. * @param id defines the id to look for
  53388. * @returns the lens flare system or null if not found
  53389. */
  53390. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53391. }
  53392. }
  53393. /**
  53394. * Defines the lens flare scene component responsible to manage any lens flares
  53395. * in a given scene.
  53396. */
  53397. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53398. /**
  53399. * The component name helpfull to identify the component in the list of scene components.
  53400. */
  53401. readonly name: string;
  53402. /**
  53403. * The scene the component belongs to.
  53404. */
  53405. scene: Scene;
  53406. /**
  53407. * Creates a new instance of the component for the given scene
  53408. * @param scene Defines the scene to register the component in
  53409. */
  53410. constructor(scene: Scene);
  53411. /**
  53412. * Registers the component in a given scene
  53413. */
  53414. register(): void;
  53415. /**
  53416. * Rebuilds the elements related to this component in case of
  53417. * context lost for instance.
  53418. */
  53419. rebuild(): void;
  53420. /**
  53421. * Adds all the elements from the container to the scene
  53422. * @param container the container holding the elements
  53423. */
  53424. addFromContainer(container: AbstractScene): void;
  53425. /**
  53426. * Removes all the elements in the container from the scene
  53427. * @param container contains the elements to remove
  53428. * @param dispose if the removed element should be disposed (default: false)
  53429. */
  53430. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53431. /**
  53432. * Serializes the component data to the specified json object
  53433. * @param serializationObject The object to serialize to
  53434. */
  53435. serialize(serializationObject: any): void;
  53436. /**
  53437. * Disposes the component and the associated ressources.
  53438. */
  53439. dispose(): void;
  53440. private _draw;
  53441. }
  53442. }
  53443. declare module "babylonjs/LensFlares/index" {
  53444. export * from "babylonjs/LensFlares/lensFlare";
  53445. export * from "babylonjs/LensFlares/lensFlareSystem";
  53446. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  53447. }
  53448. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  53449. import { Scene } from "babylonjs/scene";
  53450. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53451. import { AbstractScene } from "babylonjs/abstractScene";
  53452. /**
  53453. * Defines the shadow generator component responsible to manage any shadow generators
  53454. * in a given scene.
  53455. */
  53456. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53457. /**
  53458. * The component name helpfull to identify the component in the list of scene components.
  53459. */
  53460. readonly name: string;
  53461. /**
  53462. * The scene the component belongs to.
  53463. */
  53464. scene: Scene;
  53465. /**
  53466. * Creates a new instance of the component for the given scene
  53467. * @param scene Defines the scene to register the component in
  53468. */
  53469. constructor(scene: Scene);
  53470. /**
  53471. * Registers the component in a given scene
  53472. */
  53473. register(): void;
  53474. /**
  53475. * Rebuilds the elements related to this component in case of
  53476. * context lost for instance.
  53477. */
  53478. rebuild(): void;
  53479. /**
  53480. * Serializes the component data to the specified json object
  53481. * @param serializationObject The object to serialize to
  53482. */
  53483. serialize(serializationObject: any): void;
  53484. /**
  53485. * Adds all the elements from the container to the scene
  53486. * @param container the container holding the elements
  53487. */
  53488. addFromContainer(container: AbstractScene): void;
  53489. /**
  53490. * Removes all the elements in the container from the scene
  53491. * @param container contains the elements to remove
  53492. * @param dispose if the removed element should be disposed (default: false)
  53493. */
  53494. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53495. /**
  53496. * Rebuilds the elements related to this component in case of
  53497. * context lost for instance.
  53498. */
  53499. dispose(): void;
  53500. private _gatherRenderTargets;
  53501. }
  53502. }
  53503. declare module "babylonjs/Lights/Shadows/index" {
  53504. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  53505. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  53506. }
  53507. declare module "babylonjs/Lights/pointLight" {
  53508. import { Scene } from "babylonjs/scene";
  53509. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53511. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  53512. import { Effect } from "babylonjs/Materials/effect";
  53513. /**
  53514. * A point light is a light defined by an unique point in world space.
  53515. * The light is emitted in every direction from this point.
  53516. * A good example of a point light is a standard light bulb.
  53517. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53518. */
  53519. export class PointLight extends ShadowLight {
  53520. private _shadowAngle;
  53521. /**
  53522. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53523. * This specifies what angle the shadow will use to be created.
  53524. *
  53525. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53526. */
  53527. /**
  53528. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53529. * This specifies what angle the shadow will use to be created.
  53530. *
  53531. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53532. */
  53533. shadowAngle: number;
  53534. /**
  53535. * Gets the direction if it has been set.
  53536. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53537. */
  53538. /**
  53539. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53540. */
  53541. direction: Vector3;
  53542. /**
  53543. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53544. * A PointLight emits the light in every direction.
  53545. * It can cast shadows.
  53546. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53547. * ```javascript
  53548. * var pointLight = new PointLight("pl", camera.position, scene);
  53549. * ```
  53550. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53551. * @param name The light friendly name
  53552. * @param position The position of the point light in the scene
  53553. * @param scene The scene the lights belongs to
  53554. */
  53555. constructor(name: string, position: Vector3, scene: Scene);
  53556. /**
  53557. * Returns the string "PointLight"
  53558. * @returns the class name
  53559. */
  53560. getClassName(): string;
  53561. /**
  53562. * Returns the integer 0.
  53563. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53564. */
  53565. getTypeID(): number;
  53566. /**
  53567. * Specifies wether or not the shadowmap should be a cube texture.
  53568. * @returns true if the shadowmap needs to be a cube texture.
  53569. */
  53570. needCube(): boolean;
  53571. /**
  53572. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53573. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53574. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53575. */
  53576. getShadowDirection(faceIndex?: number): Vector3;
  53577. /**
  53578. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53579. * - fov = PI / 2
  53580. * - aspect ratio : 1.0
  53581. * - z-near and far equal to the active camera minZ and maxZ.
  53582. * Returns the PointLight.
  53583. */
  53584. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53585. protected _buildUniformLayout(): void;
  53586. /**
  53587. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53588. * @param effect The effect to update
  53589. * @param lightIndex The index of the light in the effect to update
  53590. * @returns The point light
  53591. */
  53592. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53593. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53594. /**
  53595. * Prepares the list of defines specific to the light type.
  53596. * @param defines the list of defines
  53597. * @param lightIndex defines the index of the light for the effect
  53598. */
  53599. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53600. }
  53601. }
  53602. declare module "babylonjs/Lights/index" {
  53603. export * from "babylonjs/Lights/light";
  53604. export * from "babylonjs/Lights/shadowLight";
  53605. export * from "babylonjs/Lights/Shadows/index";
  53606. export * from "babylonjs/Lights/directionalLight";
  53607. export * from "babylonjs/Lights/hemisphericLight";
  53608. export * from "babylonjs/Lights/pointLight";
  53609. export * from "babylonjs/Lights/spotLight";
  53610. }
  53611. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53612. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53613. /**
  53614. * Header information of HDR texture files.
  53615. */
  53616. export interface HDRInfo {
  53617. /**
  53618. * The height of the texture in pixels.
  53619. */
  53620. height: number;
  53621. /**
  53622. * The width of the texture in pixels.
  53623. */
  53624. width: number;
  53625. /**
  53626. * The index of the beginning of the data in the binary file.
  53627. */
  53628. dataPosition: number;
  53629. }
  53630. /**
  53631. * This groups tools to convert HDR texture to native colors array.
  53632. */
  53633. export class HDRTools {
  53634. private static Ldexp;
  53635. private static Rgbe2float;
  53636. private static readStringLine;
  53637. /**
  53638. * Reads header information from an RGBE texture stored in a native array.
  53639. * More information on this format are available here:
  53640. * https://en.wikipedia.org/wiki/RGBE_image_format
  53641. *
  53642. * @param uint8array The binary file stored in native array.
  53643. * @return The header information.
  53644. */
  53645. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53646. /**
  53647. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53648. * This RGBE texture needs to store the information as a panorama.
  53649. *
  53650. * More information on this format are available here:
  53651. * https://en.wikipedia.org/wiki/RGBE_image_format
  53652. *
  53653. * @param buffer The binary file stored in an array buffer.
  53654. * @param size The expected size of the extracted cubemap.
  53655. * @return The Cube Map information.
  53656. */
  53657. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53658. /**
  53659. * Returns the pixels data extracted from an RGBE texture.
  53660. * This pixels will be stored left to right up to down in the R G B order in one array.
  53661. *
  53662. * More information on this format are available here:
  53663. * https://en.wikipedia.org/wiki/RGBE_image_format
  53664. *
  53665. * @param uint8array The binary file stored in an array buffer.
  53666. * @param hdrInfo The header information of the file.
  53667. * @return The pixels data in RGB right to left up to down order.
  53668. */
  53669. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53670. private static RGBE_ReadPixels_RLE;
  53671. }
  53672. }
  53673. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53674. import { Nullable } from "babylonjs/types";
  53675. import { Scene } from "babylonjs/scene";
  53676. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53677. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53678. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53679. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53680. /**
  53681. * This represents a texture coming from an HDR input.
  53682. *
  53683. * The only supported format is currently panorama picture stored in RGBE format.
  53684. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53685. */
  53686. export class HDRCubeTexture extends BaseTexture {
  53687. private static _facesMapping;
  53688. private _generateHarmonics;
  53689. private _noMipmap;
  53690. private _textureMatrix;
  53691. private _size;
  53692. private _onLoad;
  53693. private _onError;
  53694. /**
  53695. * The texture URL.
  53696. */
  53697. url: string;
  53698. /**
  53699. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53700. */
  53701. coordinatesMode: number;
  53702. protected _isBlocking: boolean;
  53703. /**
  53704. * Sets wether or not the texture is blocking during loading.
  53705. */
  53706. /**
  53707. * Gets wether or not the texture is blocking during loading.
  53708. */
  53709. isBlocking: boolean;
  53710. protected _rotationY: number;
  53711. /**
  53712. * Sets texture matrix rotation angle around Y axis in radians.
  53713. */
  53714. /**
  53715. * Gets texture matrix rotation angle around Y axis radians.
  53716. */
  53717. rotationY: number;
  53718. /**
  53719. * Gets or sets the center of the bounding box associated with the cube texture
  53720. * It must define where the camera used to render the texture was set
  53721. */
  53722. boundingBoxPosition: Vector3;
  53723. private _boundingBoxSize;
  53724. /**
  53725. * Gets or sets the size of the bounding box associated with the cube texture
  53726. * When defined, the cubemap will switch to local mode
  53727. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53728. * @example https://www.babylonjs-playground.com/#RNASML
  53729. */
  53730. boundingBoxSize: Vector3;
  53731. /**
  53732. * Instantiates an HDRTexture from the following parameters.
  53733. *
  53734. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53735. * @param scene The scene the texture will be used in
  53736. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53737. * @param noMipmap Forces to not generate the mipmap if true
  53738. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53739. * @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)
  53740. * @param reserved Reserved flag for internal use.
  53741. */
  53742. 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>);
  53743. /**
  53744. * Get the current class name of the texture useful for serialization or dynamic coding.
  53745. * @returns "HDRCubeTexture"
  53746. */
  53747. getClassName(): string;
  53748. /**
  53749. * Occurs when the file is raw .hdr file.
  53750. */
  53751. private loadTexture;
  53752. clone(): HDRCubeTexture;
  53753. delayLoad(): void;
  53754. /**
  53755. * Get the texture reflection matrix used to rotate/transform the reflection.
  53756. * @returns the reflection matrix
  53757. */
  53758. getReflectionTextureMatrix(): Matrix;
  53759. /**
  53760. * Set the texture reflection matrix used to rotate/transform the reflection.
  53761. * @param value Define the reflection matrix to set
  53762. */
  53763. setReflectionTextureMatrix(value: Matrix): void;
  53764. /**
  53765. * Parses a JSON representation of an HDR Texture in order to create the texture
  53766. * @param parsedTexture Define the JSON representation
  53767. * @param scene Define the scene the texture should be created in
  53768. * @param rootUrl Define the root url in case we need to load relative dependencies
  53769. * @returns the newly created texture after parsing
  53770. */
  53771. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53772. serialize(): any;
  53773. }
  53774. }
  53775. declare module "babylonjs/Physics/physicsEngine" {
  53776. import { Nullable } from "babylonjs/types";
  53777. import { Vector3 } from "babylonjs/Maths/math.vector";
  53778. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53779. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53780. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53781. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53782. /**
  53783. * Class used to control physics engine
  53784. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53785. */
  53786. export class PhysicsEngine implements IPhysicsEngine {
  53787. private _physicsPlugin;
  53788. /**
  53789. * Global value used to control the smallest number supported by the simulation
  53790. */
  53791. static Epsilon: number;
  53792. private _impostors;
  53793. private _joints;
  53794. /**
  53795. * Gets the gravity vector used by the simulation
  53796. */
  53797. gravity: Vector3;
  53798. /**
  53799. * Factory used to create the default physics plugin.
  53800. * @returns The default physics plugin
  53801. */
  53802. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53803. /**
  53804. * Creates a new Physics Engine
  53805. * @param gravity defines the gravity vector used by the simulation
  53806. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53807. */
  53808. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53809. /**
  53810. * Sets the gravity vector used by the simulation
  53811. * @param gravity defines the gravity vector to use
  53812. */
  53813. setGravity(gravity: Vector3): void;
  53814. /**
  53815. * Set the time step of the physics engine.
  53816. * Default is 1/60.
  53817. * To slow it down, enter 1/600 for example.
  53818. * To speed it up, 1/30
  53819. * @param newTimeStep defines the new timestep to apply to this world.
  53820. */
  53821. setTimeStep(newTimeStep?: number): void;
  53822. /**
  53823. * Get the time step of the physics engine.
  53824. * @returns the current time step
  53825. */
  53826. getTimeStep(): number;
  53827. /**
  53828. * Release all resources
  53829. */
  53830. dispose(): void;
  53831. /**
  53832. * Gets the name of the current physics plugin
  53833. * @returns the name of the plugin
  53834. */
  53835. getPhysicsPluginName(): string;
  53836. /**
  53837. * Adding a new impostor for the impostor tracking.
  53838. * This will be done by the impostor itself.
  53839. * @param impostor the impostor to add
  53840. */
  53841. addImpostor(impostor: PhysicsImpostor): void;
  53842. /**
  53843. * Remove an impostor from the engine.
  53844. * This impostor and its mesh will not longer be updated by the physics engine.
  53845. * @param impostor the impostor to remove
  53846. */
  53847. removeImpostor(impostor: PhysicsImpostor): void;
  53848. /**
  53849. * Add a joint to the physics engine
  53850. * @param mainImpostor defines the main impostor to which the joint is added.
  53851. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53852. * @param joint defines the joint that will connect both impostors.
  53853. */
  53854. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53855. /**
  53856. * Removes a joint from the simulation
  53857. * @param mainImpostor defines the impostor used with the joint
  53858. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53859. * @param joint defines the joint to remove
  53860. */
  53861. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53862. /**
  53863. * Called by the scene. No need to call it.
  53864. * @param delta defines the timespam between frames
  53865. */
  53866. _step(delta: number): void;
  53867. /**
  53868. * Gets the current plugin used to run the simulation
  53869. * @returns current plugin
  53870. */
  53871. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53872. /**
  53873. * Gets the list of physic impostors
  53874. * @returns an array of PhysicsImpostor
  53875. */
  53876. getImpostors(): Array<PhysicsImpostor>;
  53877. /**
  53878. * Gets the impostor for a physics enabled object
  53879. * @param object defines the object impersonated by the impostor
  53880. * @returns the PhysicsImpostor or null if not found
  53881. */
  53882. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53883. /**
  53884. * Gets the impostor for a physics body object
  53885. * @param body defines physics body used by the impostor
  53886. * @returns the PhysicsImpostor or null if not found
  53887. */
  53888. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53889. /**
  53890. * Does a raycast in the physics world
  53891. * @param from when should the ray start?
  53892. * @param to when should the ray end?
  53893. * @returns PhysicsRaycastResult
  53894. */
  53895. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53896. }
  53897. }
  53898. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53899. import { Nullable } from "babylonjs/types";
  53900. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53902. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53903. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53904. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53905. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53906. /** @hidden */
  53907. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53908. private _useDeltaForWorldStep;
  53909. world: any;
  53910. name: string;
  53911. private _physicsMaterials;
  53912. private _fixedTimeStep;
  53913. private _cannonRaycastResult;
  53914. private _raycastResult;
  53915. private _physicsBodysToRemoveAfterStep;
  53916. BJSCANNON: any;
  53917. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53918. setGravity(gravity: Vector3): void;
  53919. setTimeStep(timeStep: number): void;
  53920. getTimeStep(): number;
  53921. executeStep(delta: number): void;
  53922. private _removeMarkedPhysicsBodiesFromWorld;
  53923. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53924. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53925. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53926. private _processChildMeshes;
  53927. removePhysicsBody(impostor: PhysicsImpostor): void;
  53928. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53929. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53930. private _addMaterial;
  53931. private _checkWithEpsilon;
  53932. private _createShape;
  53933. private _createHeightmap;
  53934. private _minus90X;
  53935. private _plus90X;
  53936. private _tmpPosition;
  53937. private _tmpDeltaPosition;
  53938. private _tmpUnityRotation;
  53939. private _updatePhysicsBodyTransformation;
  53940. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53941. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53942. isSupported(): boolean;
  53943. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53944. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53945. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53946. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53947. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53948. getBodyMass(impostor: PhysicsImpostor): number;
  53949. getBodyFriction(impostor: PhysicsImpostor): number;
  53950. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53951. getBodyRestitution(impostor: PhysicsImpostor): number;
  53952. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53953. sleepBody(impostor: PhysicsImpostor): void;
  53954. wakeUpBody(impostor: PhysicsImpostor): void;
  53955. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53956. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53957. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53958. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53959. getRadius(impostor: PhysicsImpostor): number;
  53960. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53961. dispose(): void;
  53962. private _extendNamespace;
  53963. /**
  53964. * Does a raycast in the physics world
  53965. * @param from when should the ray start?
  53966. * @param to when should the ray end?
  53967. * @returns PhysicsRaycastResult
  53968. */
  53969. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53970. }
  53971. }
  53972. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53973. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53974. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53975. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53977. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53978. import { Nullable } from "babylonjs/types";
  53979. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53980. /** @hidden */
  53981. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53982. world: any;
  53983. name: string;
  53984. BJSOIMO: any;
  53985. private _raycastResult;
  53986. constructor(iterations?: number, oimoInjection?: any);
  53987. setGravity(gravity: Vector3): void;
  53988. setTimeStep(timeStep: number): void;
  53989. getTimeStep(): number;
  53990. private _tmpImpostorsArray;
  53991. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53992. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53993. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53994. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53995. private _tmpPositionVector;
  53996. removePhysicsBody(impostor: PhysicsImpostor): void;
  53997. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53998. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53999. isSupported(): boolean;
  54000. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54001. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54002. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54003. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54004. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54005. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54006. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54007. getBodyMass(impostor: PhysicsImpostor): number;
  54008. getBodyFriction(impostor: PhysicsImpostor): number;
  54009. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54010. getBodyRestitution(impostor: PhysicsImpostor): number;
  54011. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54012. sleepBody(impostor: PhysicsImpostor): void;
  54013. wakeUpBody(impostor: PhysicsImpostor): void;
  54014. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54015. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54016. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54017. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54018. getRadius(impostor: PhysicsImpostor): number;
  54019. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54020. dispose(): void;
  54021. /**
  54022. * Does a raycast in the physics world
  54023. * @param from when should the ray start?
  54024. * @param to when should the ray end?
  54025. * @returns PhysicsRaycastResult
  54026. */
  54027. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54028. }
  54029. }
  54030. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  54031. import { Nullable } from "babylonjs/types";
  54032. import { Scene } from "babylonjs/scene";
  54033. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  54034. import { Color4 } from "babylonjs/Maths/math.color";
  54035. import { Mesh } from "babylonjs/Meshes/mesh";
  54036. /**
  54037. * Class containing static functions to help procedurally build meshes
  54038. */
  54039. export class RibbonBuilder {
  54040. /**
  54041. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54042. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54043. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54044. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54045. * * 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
  54046. * * 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
  54047. * * 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
  54048. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54049. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54050. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54051. * * 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
  54052. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54053. * * 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
  54054. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54056. * @param name defines the name of the mesh
  54057. * @param options defines the options used to create the mesh
  54058. * @param scene defines the hosting scene
  54059. * @returns the ribbon mesh
  54060. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54061. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54062. */
  54063. static CreateRibbon(name: string, options: {
  54064. pathArray: Vector3[][];
  54065. closeArray?: boolean;
  54066. closePath?: boolean;
  54067. offset?: number;
  54068. updatable?: boolean;
  54069. sideOrientation?: number;
  54070. frontUVs?: Vector4;
  54071. backUVs?: Vector4;
  54072. instance?: Mesh;
  54073. invertUV?: boolean;
  54074. uvs?: Vector2[];
  54075. colors?: Color4[];
  54076. }, scene?: Nullable<Scene>): Mesh;
  54077. }
  54078. }
  54079. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  54080. import { Nullable } from "babylonjs/types";
  54081. import { Scene } from "babylonjs/scene";
  54082. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  54083. import { Mesh } from "babylonjs/Meshes/mesh";
  54084. /**
  54085. * Class containing static functions to help procedurally build meshes
  54086. */
  54087. export class ShapeBuilder {
  54088. /**
  54089. * 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.
  54090. * * 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.
  54091. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54092. * * 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.
  54093. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54094. * * 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
  54095. * * 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
  54096. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54098. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54099. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54101. * @param name defines the name of the mesh
  54102. * @param options defines the options used to create the mesh
  54103. * @param scene defines the hosting scene
  54104. * @returns the extruded shape mesh
  54105. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54106. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54107. */
  54108. static ExtrudeShape(name: string, options: {
  54109. shape: Vector3[];
  54110. path: Vector3[];
  54111. scale?: number;
  54112. rotation?: number;
  54113. cap?: number;
  54114. updatable?: boolean;
  54115. sideOrientation?: number;
  54116. frontUVs?: Vector4;
  54117. backUVs?: Vector4;
  54118. instance?: Mesh;
  54119. invertUV?: boolean;
  54120. }, scene?: Nullable<Scene>): Mesh;
  54121. /**
  54122. * Creates an custom extruded shape mesh.
  54123. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54124. * * 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.
  54125. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54126. * * 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
  54127. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54128. * * 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
  54129. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54130. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54131. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54132. * * 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
  54133. * * 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
  54134. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54135. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54136. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54137. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54139. * @param name defines the name of the mesh
  54140. * @param options defines the options used to create the mesh
  54141. * @param scene defines the hosting scene
  54142. * @returns the custom extruded shape mesh
  54143. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54144. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54145. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54146. */
  54147. static ExtrudeShapeCustom(name: string, options: {
  54148. shape: Vector3[];
  54149. path: Vector3[];
  54150. scaleFunction?: any;
  54151. rotationFunction?: any;
  54152. ribbonCloseArray?: boolean;
  54153. ribbonClosePath?: boolean;
  54154. cap?: number;
  54155. updatable?: boolean;
  54156. sideOrientation?: number;
  54157. frontUVs?: Vector4;
  54158. backUVs?: Vector4;
  54159. instance?: Mesh;
  54160. invertUV?: boolean;
  54161. }, scene?: Nullable<Scene>): Mesh;
  54162. private static _ExtrudeShapeGeneric;
  54163. }
  54164. }
  54165. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  54166. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  54167. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54168. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54169. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54170. import { Nullable } from "babylonjs/types";
  54171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54172. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54173. /**
  54174. * AmmoJS Physics plugin
  54175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  54176. * @see https://github.com/kripken/ammo.js/
  54177. */
  54178. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  54179. private _useDeltaForWorldStep;
  54180. /**
  54181. * Reference to the Ammo library
  54182. */
  54183. bjsAMMO: any;
  54184. /**
  54185. * Created ammoJS world which physics bodies are added to
  54186. */
  54187. world: any;
  54188. /**
  54189. * Name of the plugin
  54190. */
  54191. name: string;
  54192. private _timeStep;
  54193. private _fixedTimeStep;
  54194. private _maxSteps;
  54195. private _tmpQuaternion;
  54196. private _tmpAmmoTransform;
  54197. private _tmpAmmoQuaternion;
  54198. private _tmpAmmoConcreteContactResultCallback;
  54199. private _collisionConfiguration;
  54200. private _dispatcher;
  54201. private _overlappingPairCache;
  54202. private _solver;
  54203. private _softBodySolver;
  54204. private _tmpAmmoVectorA;
  54205. private _tmpAmmoVectorB;
  54206. private _tmpAmmoVectorC;
  54207. private _tmpAmmoVectorD;
  54208. private _tmpContactCallbackResult;
  54209. private _tmpAmmoVectorRCA;
  54210. private _tmpAmmoVectorRCB;
  54211. private _raycastResult;
  54212. private static readonly DISABLE_COLLISION_FLAG;
  54213. private static readonly KINEMATIC_FLAG;
  54214. private static readonly DISABLE_DEACTIVATION_FLAG;
  54215. /**
  54216. * Initializes the ammoJS plugin
  54217. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54218. * @param ammoInjection can be used to inject your own ammo reference
  54219. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54220. */
  54221. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54222. /**
  54223. * Sets the gravity of the physics world (m/(s^2))
  54224. * @param gravity Gravity to set
  54225. */
  54226. setGravity(gravity: Vector3): void;
  54227. /**
  54228. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54229. * @param timeStep timestep to use in seconds
  54230. */
  54231. setTimeStep(timeStep: number): void;
  54232. /**
  54233. * 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)
  54234. * @param fixedTimeStep fixedTimeStep to use in seconds
  54235. */
  54236. setFixedTimeStep(fixedTimeStep: number): void;
  54237. /**
  54238. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54239. * @param maxSteps the maximum number of steps by the physics engine per frame
  54240. */
  54241. setMaxSteps(maxSteps: number): void;
  54242. /**
  54243. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54244. * @returns the current timestep in seconds
  54245. */
  54246. getTimeStep(): number;
  54247. private _isImpostorInContact;
  54248. private _isImpostorPairInContact;
  54249. private _stepSimulation;
  54250. /**
  54251. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54252. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54253. * After the step the babylon meshes are set to the position of the physics imposters
  54254. * @param delta amount of time to step forward
  54255. * @param impostors array of imposters to update before/after the step
  54256. */
  54257. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54258. /**
  54259. * Update babylon mesh to match physics world object
  54260. * @param impostor imposter to match
  54261. */
  54262. private _afterSoftStep;
  54263. /**
  54264. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54265. * @param impostor imposter to match
  54266. */
  54267. private _ropeStep;
  54268. /**
  54269. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54270. * @param impostor imposter to match
  54271. */
  54272. private _softbodyOrClothStep;
  54273. private _tmpVector;
  54274. private _tmpMatrix;
  54275. /**
  54276. * Applies an impulse on the imposter
  54277. * @param impostor imposter to apply impulse to
  54278. * @param force amount of force to be applied to the imposter
  54279. * @param contactPoint the location to apply the impulse on the imposter
  54280. */
  54281. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54282. /**
  54283. * Applies a force on the imposter
  54284. * @param impostor imposter to apply force
  54285. * @param force amount of force to be applied to the imposter
  54286. * @param contactPoint the location to apply the force on the imposter
  54287. */
  54288. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54289. /**
  54290. * Creates a physics body using the plugin
  54291. * @param impostor the imposter to create the physics body on
  54292. */
  54293. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54294. /**
  54295. * Removes the physics body from the imposter and disposes of the body's memory
  54296. * @param impostor imposter to remove the physics body from
  54297. */
  54298. removePhysicsBody(impostor: PhysicsImpostor): void;
  54299. /**
  54300. * Generates a joint
  54301. * @param impostorJoint the imposter joint to create the joint with
  54302. */
  54303. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54304. /**
  54305. * Removes a joint
  54306. * @param impostorJoint the imposter joint to remove the joint from
  54307. */
  54308. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54309. private _addMeshVerts;
  54310. /**
  54311. * Initialise the soft body vertices to match its object's (mesh) vertices
  54312. * Softbody vertices (nodes) are in world space and to match this
  54313. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  54314. * @param impostor to create the softbody for
  54315. */
  54316. private _softVertexData;
  54317. /**
  54318. * Create an impostor's soft body
  54319. * @param impostor to create the softbody for
  54320. */
  54321. private _createSoftbody;
  54322. /**
  54323. * Create cloth for an impostor
  54324. * @param impostor to create the softbody for
  54325. */
  54326. private _createCloth;
  54327. /**
  54328. * Create rope for an impostor
  54329. * @param impostor to create the softbody for
  54330. */
  54331. private _createRope;
  54332. private _addHullVerts;
  54333. private _createShape;
  54334. /**
  54335. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  54336. * @param impostor imposter containing the physics body and babylon object
  54337. */
  54338. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54339. /**
  54340. * Sets the babylon object's position/rotation from the physics body's position/rotation
  54341. * @param impostor imposter containing the physics body and babylon object
  54342. * @param newPosition new position
  54343. * @param newRotation new rotation
  54344. */
  54345. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54346. /**
  54347. * If this plugin is supported
  54348. * @returns true if its supported
  54349. */
  54350. isSupported(): boolean;
  54351. /**
  54352. * Sets the linear velocity of the physics body
  54353. * @param impostor imposter to set the velocity on
  54354. * @param velocity velocity to set
  54355. */
  54356. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54357. /**
  54358. * Sets the angular velocity of the physics body
  54359. * @param impostor imposter to set the velocity on
  54360. * @param velocity velocity to set
  54361. */
  54362. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54363. /**
  54364. * gets the linear velocity
  54365. * @param impostor imposter to get linear velocity from
  54366. * @returns linear velocity
  54367. */
  54368. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54369. /**
  54370. * gets the angular velocity
  54371. * @param impostor imposter to get angular velocity from
  54372. * @returns angular velocity
  54373. */
  54374. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54375. /**
  54376. * Sets the mass of physics body
  54377. * @param impostor imposter to set the mass on
  54378. * @param mass mass to set
  54379. */
  54380. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54381. /**
  54382. * Gets the mass of the physics body
  54383. * @param impostor imposter to get the mass from
  54384. * @returns mass
  54385. */
  54386. getBodyMass(impostor: PhysicsImpostor): number;
  54387. /**
  54388. * Gets friction of the impostor
  54389. * @param impostor impostor to get friction from
  54390. * @returns friction value
  54391. */
  54392. getBodyFriction(impostor: PhysicsImpostor): number;
  54393. /**
  54394. * Sets friction of the impostor
  54395. * @param impostor impostor to set friction on
  54396. * @param friction friction value
  54397. */
  54398. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54399. /**
  54400. * Gets restitution of the impostor
  54401. * @param impostor impostor to get restitution from
  54402. * @returns restitution value
  54403. */
  54404. getBodyRestitution(impostor: PhysicsImpostor): number;
  54405. /**
  54406. * Sets resitution of the impostor
  54407. * @param impostor impostor to set resitution on
  54408. * @param restitution resitution value
  54409. */
  54410. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54411. /**
  54412. * Gets pressure inside the impostor
  54413. * @param impostor impostor to get pressure from
  54414. * @returns pressure value
  54415. */
  54416. getBodyPressure(impostor: PhysicsImpostor): number;
  54417. /**
  54418. * Sets pressure inside a soft body impostor
  54419. * Cloth and rope must remain 0 pressure
  54420. * @param impostor impostor to set pressure on
  54421. * @param pressure pressure value
  54422. */
  54423. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  54424. /**
  54425. * Gets stiffness of the impostor
  54426. * @param impostor impostor to get stiffness from
  54427. * @returns pressure value
  54428. */
  54429. getBodyStiffness(impostor: PhysicsImpostor): number;
  54430. /**
  54431. * Sets stiffness of the impostor
  54432. * @param impostor impostor to set stiffness on
  54433. * @param stiffness stiffness value from 0 to 1
  54434. */
  54435. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  54436. /**
  54437. * Gets velocityIterations of the impostor
  54438. * @param impostor impostor to get velocity iterations from
  54439. * @returns velocityIterations value
  54440. */
  54441. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  54442. /**
  54443. * Sets velocityIterations of the impostor
  54444. * @param impostor impostor to set velocity iterations on
  54445. * @param velocityIterations velocityIterations value
  54446. */
  54447. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  54448. /**
  54449. * Gets positionIterations of the impostor
  54450. * @param impostor impostor to get position iterations from
  54451. * @returns positionIterations value
  54452. */
  54453. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  54454. /**
  54455. * Sets positionIterations of the impostor
  54456. * @param impostor impostor to set position on
  54457. * @param positionIterations positionIterations value
  54458. */
  54459. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  54460. /**
  54461. * Append an anchor to a cloth object
  54462. * @param impostor is the cloth impostor to add anchor to
  54463. * @param otherImpostor is the rigid impostor to anchor to
  54464. * @param width ratio across width from 0 to 1
  54465. * @param height ratio up height from 0 to 1
  54466. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54467. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54468. */
  54469. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54470. /**
  54471. * Append an hook to a rope object
  54472. * @param impostor is the rope impostor to add hook to
  54473. * @param otherImpostor is the rigid impostor to hook to
  54474. * @param length ratio along the rope from 0 to 1
  54475. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  54476. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54477. */
  54478. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54479. /**
  54480. * Sleeps the physics body and stops it from being active
  54481. * @param impostor impostor to sleep
  54482. */
  54483. sleepBody(impostor: PhysicsImpostor): void;
  54484. /**
  54485. * Activates the physics body
  54486. * @param impostor impostor to activate
  54487. */
  54488. wakeUpBody(impostor: PhysicsImpostor): void;
  54489. /**
  54490. * Updates the distance parameters of the joint
  54491. * @param joint joint to update
  54492. * @param maxDistance maximum distance of the joint
  54493. * @param minDistance minimum distance of the joint
  54494. */
  54495. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54496. /**
  54497. * Sets a motor on the joint
  54498. * @param joint joint to set motor on
  54499. * @param speed speed of the motor
  54500. * @param maxForce maximum force of the motor
  54501. * @param motorIndex index of the motor
  54502. */
  54503. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54504. /**
  54505. * Sets the motors limit
  54506. * @param joint joint to set limit on
  54507. * @param upperLimit upper limit
  54508. * @param lowerLimit lower limit
  54509. */
  54510. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54511. /**
  54512. * Syncs the position and rotation of a mesh with the impostor
  54513. * @param mesh mesh to sync
  54514. * @param impostor impostor to update the mesh with
  54515. */
  54516. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54517. /**
  54518. * Gets the radius of the impostor
  54519. * @param impostor impostor to get radius from
  54520. * @returns the radius
  54521. */
  54522. getRadius(impostor: PhysicsImpostor): number;
  54523. /**
  54524. * Gets the box size of the impostor
  54525. * @param impostor impostor to get box size from
  54526. * @param result the resulting box size
  54527. */
  54528. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54529. /**
  54530. * Disposes of the impostor
  54531. */
  54532. dispose(): void;
  54533. /**
  54534. * Does a raycast in the physics world
  54535. * @param from when should the ray start?
  54536. * @param to when should the ray end?
  54537. * @returns PhysicsRaycastResult
  54538. */
  54539. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54540. }
  54541. }
  54542. declare module "babylonjs/Probes/reflectionProbe" {
  54543. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54544. import { Vector3 } from "babylonjs/Maths/math.vector";
  54545. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54546. import { Nullable } from "babylonjs/types";
  54547. import { Scene } from "babylonjs/scene";
  54548. module "babylonjs/abstractScene" {
  54549. interface AbstractScene {
  54550. /**
  54551. * The list of reflection probes added to the scene
  54552. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54553. */
  54554. reflectionProbes: Array<ReflectionProbe>;
  54555. /**
  54556. * Removes the given reflection probe from this scene.
  54557. * @param toRemove The reflection probe to remove
  54558. * @returns The index of the removed reflection probe
  54559. */
  54560. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54561. /**
  54562. * Adds the given reflection probe to this scene.
  54563. * @param newReflectionProbe The reflection probe to add
  54564. */
  54565. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54566. }
  54567. }
  54568. /**
  54569. * Class used to generate realtime reflection / refraction cube textures
  54570. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54571. */
  54572. export class ReflectionProbe {
  54573. /** defines the name of the probe */
  54574. name: string;
  54575. private _scene;
  54576. private _renderTargetTexture;
  54577. private _projectionMatrix;
  54578. private _viewMatrix;
  54579. private _target;
  54580. private _add;
  54581. private _attachedMesh;
  54582. private _invertYAxis;
  54583. /** Gets or sets probe position (center of the cube map) */
  54584. position: Vector3;
  54585. /**
  54586. * Creates a new reflection probe
  54587. * @param name defines the name of the probe
  54588. * @param size defines the texture resolution (for each face)
  54589. * @param scene defines the hosting scene
  54590. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54591. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54592. */
  54593. constructor(
  54594. /** defines the name of the probe */
  54595. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54596. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54597. samples: number;
  54598. /** Gets or sets the refresh rate to use (on every frame by default) */
  54599. refreshRate: number;
  54600. /**
  54601. * Gets the hosting scene
  54602. * @returns a Scene
  54603. */
  54604. getScene(): Scene;
  54605. /** Gets the internal CubeTexture used to render to */
  54606. readonly cubeTexture: RenderTargetTexture;
  54607. /** Gets the list of meshes to render */
  54608. readonly renderList: Nullable<AbstractMesh[]>;
  54609. /**
  54610. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54611. * @param mesh defines the mesh to attach to
  54612. */
  54613. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54614. /**
  54615. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54616. * @param renderingGroupId The rendering group id corresponding to its index
  54617. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54618. */
  54619. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54620. /**
  54621. * Clean all associated resources
  54622. */
  54623. dispose(): void;
  54624. /**
  54625. * Converts the reflection probe information to a readable string for debug purpose.
  54626. * @param fullDetails Supports for multiple levels of logging within scene loading
  54627. * @returns the human readable reflection probe info
  54628. */
  54629. toString(fullDetails?: boolean): string;
  54630. /**
  54631. * Get the class name of the relfection probe.
  54632. * @returns "ReflectionProbe"
  54633. */
  54634. getClassName(): string;
  54635. /**
  54636. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54637. * @returns The JSON representation of the texture
  54638. */
  54639. serialize(): any;
  54640. /**
  54641. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54642. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54643. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54644. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54645. * @returns The parsed reflection probe if successful
  54646. */
  54647. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54648. }
  54649. }
  54650. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54651. /** @hidden */
  54652. export var _BabylonLoaderRegistered: boolean;
  54653. /**
  54654. * Helps setting up some configuration for the babylon file loader.
  54655. */
  54656. export class BabylonFileLoaderConfiguration {
  54657. /**
  54658. * The loader does not allow injecting custom physix engine into the plugins.
  54659. * Unfortunately in ES6, we need to manually inject them into the plugin.
  54660. * So you could set this variable to your engine import to make it work.
  54661. */
  54662. static LoaderInjectedPhysicsEngine: any;
  54663. }
  54664. }
  54665. declare module "babylonjs/Loading/Plugins/index" {
  54666. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54667. }
  54668. declare module "babylonjs/Loading/index" {
  54669. export * from "babylonjs/Loading/loadingScreen";
  54670. export * from "babylonjs/Loading/Plugins/index";
  54671. export * from "babylonjs/Loading/sceneLoader";
  54672. export * from "babylonjs/Loading/sceneLoaderFlags";
  54673. }
  54674. declare module "babylonjs/Materials/Background/index" {
  54675. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54676. }
  54677. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54678. import { Scene } from "babylonjs/scene";
  54679. import { Color3 } from "babylonjs/Maths/math.color";
  54680. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54681. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54682. /**
  54683. * The Physically based simple base material of BJS.
  54684. *
  54685. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54686. * It is used as the base class for both the specGloss and metalRough conventions.
  54687. */
  54688. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54689. /**
  54690. * Number of Simultaneous lights allowed on the material.
  54691. */
  54692. maxSimultaneousLights: number;
  54693. /**
  54694. * If sets to true, disables all the lights affecting the material.
  54695. */
  54696. disableLighting: boolean;
  54697. /**
  54698. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54699. */
  54700. environmentTexture: BaseTexture;
  54701. /**
  54702. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54703. */
  54704. invertNormalMapX: boolean;
  54705. /**
  54706. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54707. */
  54708. invertNormalMapY: boolean;
  54709. /**
  54710. * Normal map used in the model.
  54711. */
  54712. normalTexture: BaseTexture;
  54713. /**
  54714. * Emissivie color used to self-illuminate the model.
  54715. */
  54716. emissiveColor: Color3;
  54717. /**
  54718. * Emissivie texture used to self-illuminate the model.
  54719. */
  54720. emissiveTexture: BaseTexture;
  54721. /**
  54722. * Occlusion Channel Strenght.
  54723. */
  54724. occlusionStrength: number;
  54725. /**
  54726. * Occlusion Texture of the material (adding extra occlusion effects).
  54727. */
  54728. occlusionTexture: BaseTexture;
  54729. /**
  54730. * Defines the alpha limits in alpha test mode.
  54731. */
  54732. alphaCutOff: number;
  54733. /**
  54734. * Gets the current double sided mode.
  54735. */
  54736. /**
  54737. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54738. */
  54739. doubleSided: boolean;
  54740. /**
  54741. * Stores the pre-calculated light information of a mesh in a texture.
  54742. */
  54743. lightmapTexture: BaseTexture;
  54744. /**
  54745. * If true, the light map contains occlusion information instead of lighting info.
  54746. */
  54747. useLightmapAsShadowmap: boolean;
  54748. /**
  54749. * Instantiates a new PBRMaterial instance.
  54750. *
  54751. * @param name The material name
  54752. * @param scene The scene the material will be use in.
  54753. */
  54754. constructor(name: string, scene: Scene);
  54755. getClassName(): string;
  54756. }
  54757. }
  54758. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54759. import { Scene } from "babylonjs/scene";
  54760. import { Color3 } from "babylonjs/Maths/math.color";
  54761. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54762. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54763. /**
  54764. * The PBR material of BJS following the metal roughness convention.
  54765. *
  54766. * This fits to the PBR convention in the GLTF definition:
  54767. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54768. */
  54769. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54770. /**
  54771. * The base color has two different interpretations depending on the value of metalness.
  54772. * When the material is a metal, the base color is the specific measured reflectance value
  54773. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54774. * of the material.
  54775. */
  54776. baseColor: Color3;
  54777. /**
  54778. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54779. * well as opacity information in the alpha channel.
  54780. */
  54781. baseTexture: BaseTexture;
  54782. /**
  54783. * Specifies the metallic scalar value of the material.
  54784. * Can also be used to scale the metalness values of the metallic texture.
  54785. */
  54786. metallic: number;
  54787. /**
  54788. * Specifies the roughness scalar value of the material.
  54789. * Can also be used to scale the roughness values of the metallic texture.
  54790. */
  54791. roughness: number;
  54792. /**
  54793. * Texture containing both the metallic value in the B channel and the
  54794. * roughness value in the G channel to keep better precision.
  54795. */
  54796. metallicRoughnessTexture: BaseTexture;
  54797. /**
  54798. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54799. *
  54800. * @param name The material name
  54801. * @param scene The scene the material will be use in.
  54802. */
  54803. constructor(name: string, scene: Scene);
  54804. /**
  54805. * Return the currrent class name of the material.
  54806. */
  54807. getClassName(): string;
  54808. /**
  54809. * Makes a duplicate of the current material.
  54810. * @param name - name to use for the new material.
  54811. */
  54812. clone(name: string): PBRMetallicRoughnessMaterial;
  54813. /**
  54814. * Serialize the material to a parsable JSON object.
  54815. */
  54816. serialize(): any;
  54817. /**
  54818. * Parses a JSON object correponding to the serialize function.
  54819. */
  54820. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54821. }
  54822. }
  54823. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54824. import { Scene } from "babylonjs/scene";
  54825. import { Color3 } from "babylonjs/Maths/math.color";
  54826. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54827. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54828. /**
  54829. * The PBR material of BJS following the specular glossiness convention.
  54830. *
  54831. * This fits to the PBR convention in the GLTF definition:
  54832. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54833. */
  54834. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54835. /**
  54836. * Specifies the diffuse color of the material.
  54837. */
  54838. diffuseColor: Color3;
  54839. /**
  54840. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54841. * channel.
  54842. */
  54843. diffuseTexture: BaseTexture;
  54844. /**
  54845. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54846. */
  54847. specularColor: Color3;
  54848. /**
  54849. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54850. */
  54851. glossiness: number;
  54852. /**
  54853. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54854. */
  54855. specularGlossinessTexture: BaseTexture;
  54856. /**
  54857. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54858. *
  54859. * @param name The material name
  54860. * @param scene The scene the material will be use in.
  54861. */
  54862. constructor(name: string, scene: Scene);
  54863. /**
  54864. * Return the currrent class name of the material.
  54865. */
  54866. getClassName(): string;
  54867. /**
  54868. * Makes a duplicate of the current material.
  54869. * @param name - name to use for the new material.
  54870. */
  54871. clone(name: string): PBRSpecularGlossinessMaterial;
  54872. /**
  54873. * Serialize the material to a parsable JSON object.
  54874. */
  54875. serialize(): any;
  54876. /**
  54877. * Parses a JSON object correponding to the serialize function.
  54878. */
  54879. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54880. }
  54881. }
  54882. declare module "babylonjs/Materials/PBR/index" {
  54883. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54884. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54885. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54886. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54887. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54888. }
  54889. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54890. import { Nullable } from "babylonjs/types";
  54891. import { Scene } from "babylonjs/scene";
  54892. import { Matrix } from "babylonjs/Maths/math.vector";
  54893. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54894. /**
  54895. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54896. * It can help converting any input color in a desired output one. This can then be used to create effects
  54897. * from sepia, black and white to sixties or futuristic rendering...
  54898. *
  54899. * The only supported format is currently 3dl.
  54900. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54901. */
  54902. export class ColorGradingTexture extends BaseTexture {
  54903. /**
  54904. * The current texture matrix. (will always be identity in color grading texture)
  54905. */
  54906. private _textureMatrix;
  54907. /**
  54908. * The texture URL.
  54909. */
  54910. url: string;
  54911. /**
  54912. * Empty line regex stored for GC.
  54913. */
  54914. private static _noneEmptyLineRegex;
  54915. private _engine;
  54916. /**
  54917. * Instantiates a ColorGradingTexture from the following parameters.
  54918. *
  54919. * @param url The location of the color gradind data (currently only supporting 3dl)
  54920. * @param scene The scene the texture will be used in
  54921. */
  54922. constructor(url: string, scene: Scene);
  54923. /**
  54924. * Returns the texture matrix used in most of the material.
  54925. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54926. */
  54927. getTextureMatrix(): Matrix;
  54928. /**
  54929. * Occurs when the file being loaded is a .3dl LUT file.
  54930. */
  54931. private load3dlTexture;
  54932. /**
  54933. * Starts the loading process of the texture.
  54934. */
  54935. private loadTexture;
  54936. /**
  54937. * Clones the color gradind texture.
  54938. */
  54939. clone(): ColorGradingTexture;
  54940. /**
  54941. * Called during delayed load for textures.
  54942. */
  54943. delayLoad(): void;
  54944. /**
  54945. * Parses a color grading texture serialized by Babylon.
  54946. * @param parsedTexture The texture information being parsedTexture
  54947. * @param scene The scene to load the texture in
  54948. * @param rootUrl The root url of the data assets to load
  54949. * @return A color gradind texture
  54950. */
  54951. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54952. /**
  54953. * Serializes the LUT texture to json format.
  54954. */
  54955. serialize(): any;
  54956. }
  54957. }
  54958. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54959. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54960. import { Scene } from "babylonjs/scene";
  54961. import { Nullable } from "babylonjs/types";
  54962. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54963. /**
  54964. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54965. */
  54966. export class EquiRectangularCubeTexture extends BaseTexture {
  54967. /** The six faces of the cube. */
  54968. private static _FacesMapping;
  54969. private _noMipmap;
  54970. private _onLoad;
  54971. private _onError;
  54972. /** The size of the cubemap. */
  54973. private _size;
  54974. /** The buffer of the image. */
  54975. private _buffer;
  54976. /** The width of the input image. */
  54977. private _width;
  54978. /** The height of the input image. */
  54979. private _height;
  54980. /** The URL to the image. */
  54981. url: string;
  54982. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54983. coordinatesMode: number;
  54984. /**
  54985. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54986. * @param url The location of the image
  54987. * @param scene The scene the texture will be used in
  54988. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54989. * @param noMipmap Forces to not generate the mipmap if true
  54990. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54991. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54992. * @param onLoad — defines a callback called when texture is loaded
  54993. * @param onError — defines a callback called if there is an error
  54994. */
  54995. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54996. /**
  54997. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54998. */
  54999. private loadImage;
  55000. /**
  55001. * Convert the image buffer into a cubemap and create a CubeTexture.
  55002. */
  55003. private loadTexture;
  55004. /**
  55005. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55006. * @param buffer The ArrayBuffer that should be converted.
  55007. * @returns The buffer as Float32Array.
  55008. */
  55009. private getFloat32ArrayFromArrayBuffer;
  55010. /**
  55011. * Get the current class name of the texture useful for serialization or dynamic coding.
  55012. * @returns "EquiRectangularCubeTexture"
  55013. */
  55014. getClassName(): string;
  55015. /**
  55016. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55017. * @returns A clone of the current EquiRectangularCubeTexture.
  55018. */
  55019. clone(): EquiRectangularCubeTexture;
  55020. }
  55021. }
  55022. declare module "babylonjs/Misc/tga" {
  55023. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55024. /**
  55025. * Based on jsTGALoader - Javascript loader for TGA file
  55026. * By Vincent Thibault
  55027. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55028. */
  55029. export class TGATools {
  55030. private static _TYPE_INDEXED;
  55031. private static _TYPE_RGB;
  55032. private static _TYPE_GREY;
  55033. private static _TYPE_RLE_INDEXED;
  55034. private static _TYPE_RLE_RGB;
  55035. private static _TYPE_RLE_GREY;
  55036. private static _ORIGIN_MASK;
  55037. private static _ORIGIN_SHIFT;
  55038. private static _ORIGIN_BL;
  55039. private static _ORIGIN_BR;
  55040. private static _ORIGIN_UL;
  55041. private static _ORIGIN_UR;
  55042. /**
  55043. * Gets the header of a TGA file
  55044. * @param data defines the TGA data
  55045. * @returns the header
  55046. */
  55047. static GetTGAHeader(data: Uint8Array): any;
  55048. /**
  55049. * Uploads TGA content to a Babylon Texture
  55050. * @hidden
  55051. */
  55052. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55053. /** @hidden */
  55054. 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;
  55055. /** @hidden */
  55056. 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;
  55057. /** @hidden */
  55058. 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;
  55059. /** @hidden */
  55060. 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;
  55061. /** @hidden */
  55062. 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;
  55063. /** @hidden */
  55064. 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;
  55065. }
  55066. }
  55067. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  55068. import { Nullable } from "babylonjs/types";
  55069. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55070. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55071. /**
  55072. * Implementation of the TGA Texture Loader.
  55073. * @hidden
  55074. */
  55075. export class _TGATextureLoader implements IInternalTextureLoader {
  55076. /**
  55077. * Defines wether the loader supports cascade loading the different faces.
  55078. */
  55079. readonly supportCascades: boolean;
  55080. /**
  55081. * This returns if the loader support the current file information.
  55082. * @param extension defines the file extension of the file being loaded
  55083. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55084. * @param fallback defines the fallback internal texture if any
  55085. * @param isBase64 defines whether the texture is encoded as a base64
  55086. * @param isBuffer defines whether the texture data are stored as a buffer
  55087. * @returns true if the loader can load the specified file
  55088. */
  55089. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55090. /**
  55091. * Transform the url before loading if required.
  55092. * @param rootUrl the url of the texture
  55093. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55094. * @returns the transformed texture
  55095. */
  55096. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55097. /**
  55098. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55099. * @param rootUrl the url of the texture
  55100. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55101. * @returns the fallback texture
  55102. */
  55103. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55104. /**
  55105. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55106. * @param data contains the texture data
  55107. * @param texture defines the BabylonJS internal texture
  55108. * @param createPolynomials will be true if polynomials have been requested
  55109. * @param onLoad defines the callback to trigger once the texture is ready
  55110. * @param onError defines the callback to trigger in case of error
  55111. */
  55112. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55113. /**
  55114. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55115. * @param data contains the texture data
  55116. * @param texture defines the BabylonJS internal texture
  55117. * @param callback defines the method to call once ready to upload
  55118. */
  55119. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55120. }
  55121. }
  55122. declare module "babylonjs/Misc/basis" {
  55123. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55124. /**
  55125. * Info about the .basis files
  55126. */
  55127. class BasisFileInfo {
  55128. /**
  55129. * If the file has alpha
  55130. */
  55131. hasAlpha: boolean;
  55132. /**
  55133. * Info about each image of the basis file
  55134. */
  55135. images: Array<{
  55136. levels: Array<{
  55137. width: number;
  55138. height: number;
  55139. transcodedPixels: ArrayBufferView;
  55140. }>;
  55141. }>;
  55142. }
  55143. /**
  55144. * Result of transcoding a basis file
  55145. */
  55146. class TranscodeResult {
  55147. /**
  55148. * Info about the .basis file
  55149. */
  55150. fileInfo: BasisFileInfo;
  55151. /**
  55152. * Format to use when loading the file
  55153. */
  55154. format: number;
  55155. }
  55156. /**
  55157. * Configuration options for the Basis transcoder
  55158. */
  55159. export class BasisTranscodeConfiguration {
  55160. /**
  55161. * Supported compression formats used to determine the supported output format of the transcoder
  55162. */
  55163. supportedCompressionFormats?: {
  55164. /**
  55165. * etc1 compression format
  55166. */
  55167. etc1?: boolean;
  55168. /**
  55169. * s3tc compression format
  55170. */
  55171. s3tc?: boolean;
  55172. /**
  55173. * pvrtc compression format
  55174. */
  55175. pvrtc?: boolean;
  55176. /**
  55177. * etc2 compression format
  55178. */
  55179. etc2?: boolean;
  55180. };
  55181. /**
  55182. * If mipmap levels should be loaded for transcoded images (Default: true)
  55183. */
  55184. loadMipmapLevels?: boolean;
  55185. /**
  55186. * Index of a single image to load (Default: all images)
  55187. */
  55188. loadSingleImage?: number;
  55189. }
  55190. /**
  55191. * Used to load .Basis files
  55192. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  55193. */
  55194. export class BasisTools {
  55195. private static _IgnoreSupportedFormats;
  55196. /**
  55197. * URL to use when loading the basis transcoder
  55198. */
  55199. static JSModuleURL: string;
  55200. /**
  55201. * URL to use when loading the wasm module for the transcoder
  55202. */
  55203. static WasmModuleURL: string;
  55204. /**
  55205. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55206. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55207. * @returns internal format corresponding to the Basis format
  55208. */
  55209. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55210. private static _WorkerPromise;
  55211. private static _Worker;
  55212. private static _actionId;
  55213. private static _CreateWorkerAsync;
  55214. /**
  55215. * Transcodes a loaded image file to compressed pixel data
  55216. * @param imageData image data to transcode
  55217. * @param config configuration options for the transcoding
  55218. * @returns a promise resulting in the transcoded image
  55219. */
  55220. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55221. /**
  55222. * Loads a texture from the transcode result
  55223. * @param texture texture load to
  55224. * @param transcodeResult the result of transcoding the basis file to load from
  55225. */
  55226. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55227. }
  55228. }
  55229. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  55230. import { Nullable } from "babylonjs/types";
  55231. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55232. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55233. /**
  55234. * Loader for .basis file format
  55235. */
  55236. export class _BasisTextureLoader implements IInternalTextureLoader {
  55237. /**
  55238. * Defines whether the loader supports cascade loading the different faces.
  55239. */
  55240. readonly supportCascades: boolean;
  55241. /**
  55242. * This returns if the loader support the current file information.
  55243. * @param extension defines the file extension of the file being loaded
  55244. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55245. * @param fallback defines the fallback internal texture if any
  55246. * @param isBase64 defines whether the texture is encoded as a base64
  55247. * @param isBuffer defines whether the texture data are stored as a buffer
  55248. * @returns true if the loader can load the specified file
  55249. */
  55250. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55251. /**
  55252. * Transform the url before loading if required.
  55253. * @param rootUrl the url of the texture
  55254. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55255. * @returns the transformed texture
  55256. */
  55257. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55258. /**
  55259. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55260. * @param rootUrl the url of the texture
  55261. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55262. * @returns the fallback texture
  55263. */
  55264. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55265. /**
  55266. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55267. * @param data contains the texture data
  55268. * @param texture defines the BabylonJS internal texture
  55269. * @param createPolynomials will be true if polynomials have been requested
  55270. * @param onLoad defines the callback to trigger once the texture is ready
  55271. * @param onError defines the callback to trigger in case of error
  55272. */
  55273. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55274. /**
  55275. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55276. * @param data contains the texture data
  55277. * @param texture defines the BabylonJS internal texture
  55278. * @param callback defines the method to call once ready to upload
  55279. */
  55280. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55281. }
  55282. }
  55283. declare module "babylonjs/Materials/Textures/Loaders/index" {
  55284. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55285. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55286. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55287. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  55288. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  55289. }
  55290. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  55291. import { Scene } from "babylonjs/scene";
  55292. import { Texture } from "babylonjs/Materials/Textures/texture";
  55293. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55294. /**
  55295. * 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.
  55296. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55297. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55298. */
  55299. export class CustomProceduralTexture extends ProceduralTexture {
  55300. private _animate;
  55301. private _time;
  55302. private _config;
  55303. private _texturePath;
  55304. /**
  55305. * Instantiates a new Custom Procedural Texture.
  55306. * 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.
  55307. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55308. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55309. * @param name Define the name of the texture
  55310. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55311. * @param size Define the size of the texture to create
  55312. * @param scene Define the scene the texture belongs to
  55313. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55314. * @param generateMipMaps Define if the texture should creates mip maps or not
  55315. */
  55316. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55317. private _loadJson;
  55318. /**
  55319. * Is the texture ready to be used ? (rendered at least once)
  55320. * @returns true if ready, otherwise, false.
  55321. */
  55322. isReady(): boolean;
  55323. /**
  55324. * Render the texture to its associated render target.
  55325. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55326. */
  55327. render(useCameraPostProcess?: boolean): void;
  55328. /**
  55329. * Update the list of dependant textures samplers in the shader.
  55330. */
  55331. updateTextures(): void;
  55332. /**
  55333. * Update the uniform values of the procedural texture in the shader.
  55334. */
  55335. updateShaderUniforms(): void;
  55336. /**
  55337. * Define if the texture animates or not.
  55338. */
  55339. animate: boolean;
  55340. }
  55341. }
  55342. declare module "babylonjs/Shaders/noise.fragment" {
  55343. /** @hidden */
  55344. export var noisePixelShader: {
  55345. name: string;
  55346. shader: string;
  55347. };
  55348. }
  55349. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  55350. import { Nullable } from "babylonjs/types";
  55351. import { Scene } from "babylonjs/scene";
  55352. import { Texture } from "babylonjs/Materials/Textures/texture";
  55353. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55354. import "babylonjs/Shaders/noise.fragment";
  55355. /**
  55356. * Class used to generate noise procedural textures
  55357. */
  55358. export class NoiseProceduralTexture extends ProceduralTexture {
  55359. private _time;
  55360. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55361. brightness: number;
  55362. /** Defines the number of octaves to process */
  55363. octaves: number;
  55364. /** Defines the level of persistence (0.8 by default) */
  55365. persistence: number;
  55366. /** Gets or sets animation speed factor (default is 1) */
  55367. animationSpeedFactor: number;
  55368. /**
  55369. * Creates a new NoiseProceduralTexture
  55370. * @param name defines the name fo the texture
  55371. * @param size defines the size of the texture (default is 256)
  55372. * @param scene defines the hosting scene
  55373. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55374. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55375. */
  55376. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55377. private _updateShaderUniforms;
  55378. protected _getDefines(): string;
  55379. /** Generate the current state of the procedural texture */
  55380. render(useCameraPostProcess?: boolean): void;
  55381. /**
  55382. * Serializes this noise procedural texture
  55383. * @returns a serialized noise procedural texture object
  55384. */
  55385. serialize(): any;
  55386. /**
  55387. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55388. * @param parsedTexture defines parsed texture data
  55389. * @param scene defines the current scene
  55390. * @param rootUrl defines the root URL containing noise procedural texture information
  55391. * @returns a parsed NoiseProceduralTexture
  55392. */
  55393. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  55394. }
  55395. }
  55396. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  55397. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  55398. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  55399. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55400. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  55401. }
  55402. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  55403. import { Nullable } from "babylonjs/types";
  55404. import { Scene } from "babylonjs/scene";
  55405. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55406. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55407. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55408. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55409. /**
  55410. * Raw cube texture where the raw buffers are passed in
  55411. */
  55412. export class RawCubeTexture extends CubeTexture {
  55413. /**
  55414. * Creates a cube texture where the raw buffers are passed in.
  55415. * @param scene defines the scene the texture is attached to
  55416. * @param data defines the array of data to use to create each face
  55417. * @param size defines the size of the textures
  55418. * @param format defines the format of the data
  55419. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  55420. * @param generateMipMaps defines if the engine should generate the mip levels
  55421. * @param invertY defines if data must be stored with Y axis inverted
  55422. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  55423. * @param compression defines the compression used (null by default)
  55424. */
  55425. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  55426. /**
  55427. * Updates the raw cube texture.
  55428. * @param data defines the data to store
  55429. * @param format defines the data format
  55430. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55431. * @param invertY defines if data must be stored with Y axis inverted
  55432. * @param compression defines the compression used (null by default)
  55433. * @param level defines which level of the texture to update
  55434. */
  55435. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  55436. /**
  55437. * Updates a raw cube texture with RGBD encoded data.
  55438. * @param data defines the array of data [mipmap][face] to use to create each face
  55439. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  55440. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55441. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55442. * @returns a promsie that resolves when the operation is complete
  55443. */
  55444. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  55445. /**
  55446. * Clones the raw cube texture.
  55447. * @return a new cube texture
  55448. */
  55449. clone(): CubeTexture;
  55450. /** @hidden */
  55451. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55452. }
  55453. }
  55454. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  55455. import { Scene } from "babylonjs/scene";
  55456. import { Texture } from "babylonjs/Materials/Textures/texture";
  55457. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55458. /**
  55459. * Class used to store 3D textures containing user data
  55460. */
  55461. export class RawTexture3D extends Texture {
  55462. /** Gets or sets the texture format to use */
  55463. format: number;
  55464. private _engine;
  55465. /**
  55466. * Create a new RawTexture3D
  55467. * @param data defines the data of the texture
  55468. * @param width defines the width of the texture
  55469. * @param height defines the height of the texture
  55470. * @param depth defines the depth of the texture
  55471. * @param format defines the texture format to use
  55472. * @param scene defines the hosting scene
  55473. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55474. * @param invertY defines if texture must be stored with Y axis inverted
  55475. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55476. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55477. */
  55478. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55479. /** Gets or sets the texture format to use */
  55480. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55481. /**
  55482. * Update the texture with new data
  55483. * @param data defines the data to store in the texture
  55484. */
  55485. update(data: ArrayBufferView): void;
  55486. }
  55487. }
  55488. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  55489. import { Scene } from "babylonjs/scene";
  55490. import { Texture } from "babylonjs/Materials/Textures/texture";
  55491. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55492. /**
  55493. * Class used to store 2D array textures containing user data
  55494. */
  55495. export class RawTexture2DArray extends Texture {
  55496. /** Gets or sets the texture format to use */
  55497. format: number;
  55498. private _engine;
  55499. /**
  55500. * Create a new RawTexture2DArray
  55501. * @param data defines the data of the texture
  55502. * @param width defines the width of the texture
  55503. * @param height defines the height of the texture
  55504. * @param depth defines the number of layers of the texture
  55505. * @param format defines the texture format to use
  55506. * @param scene defines the hosting scene
  55507. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55508. * @param invertY defines if texture must be stored with Y axis inverted
  55509. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55510. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55511. */
  55512. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55513. /** Gets or sets the texture format to use */
  55514. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55515. /**
  55516. * Update the texture with new data
  55517. * @param data defines the data to store in the texture
  55518. */
  55519. update(data: ArrayBufferView): void;
  55520. }
  55521. }
  55522. declare module "babylonjs/Materials/Textures/refractionTexture" {
  55523. import { Scene } from "babylonjs/scene";
  55524. import { Plane } from "babylonjs/Maths/math.plane";
  55525. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55526. /**
  55527. * Creates a refraction texture used by refraction channel of the standard material.
  55528. * It is like a mirror but to see through a material.
  55529. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55530. */
  55531. export class RefractionTexture extends RenderTargetTexture {
  55532. /**
  55533. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  55534. * 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.
  55535. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55536. */
  55537. refractionPlane: Plane;
  55538. /**
  55539. * Define how deep under the surface we should see.
  55540. */
  55541. depth: number;
  55542. /**
  55543. * Creates a refraction texture used by refraction channel of the standard material.
  55544. * It is like a mirror but to see through a material.
  55545. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55546. * @param name Define the texture name
  55547. * @param size Define the size of the underlying texture
  55548. * @param scene Define the scene the refraction belongs to
  55549. * @param generateMipMaps Define if we need to generate mips level for the refraction
  55550. */
  55551. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  55552. /**
  55553. * Clone the refraction texture.
  55554. * @returns the cloned texture
  55555. */
  55556. clone(): RefractionTexture;
  55557. /**
  55558. * Serialize the texture to a JSON representation you could use in Parse later on
  55559. * @returns the serialized JSON representation
  55560. */
  55561. serialize(): any;
  55562. }
  55563. }
  55564. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  55565. import { Nullable } from "babylonjs/types";
  55566. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55567. import { Matrix } from "babylonjs/Maths/math.vector";
  55568. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55569. import "babylonjs/Engines/Extensions/engine.videoTexture";
  55570. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55571. import { Scene } from "babylonjs/scene";
  55572. /**
  55573. * Defines the options related to the creation of an HtmlElementTexture
  55574. */
  55575. export interface IHtmlElementTextureOptions {
  55576. /**
  55577. * Defines wether mip maps should be created or not.
  55578. */
  55579. generateMipMaps?: boolean;
  55580. /**
  55581. * Defines the sampling mode of the texture.
  55582. */
  55583. samplingMode?: number;
  55584. /**
  55585. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  55586. */
  55587. engine: Nullable<ThinEngine>;
  55588. /**
  55589. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  55590. */
  55591. scene: Nullable<Scene>;
  55592. }
  55593. /**
  55594. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  55595. * To be as efficient as possible depending on your constraints nothing aside the first upload
  55596. * is automatically managed.
  55597. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  55598. * in your application.
  55599. *
  55600. * As the update is not automatic, you need to call them manually.
  55601. */
  55602. export class HtmlElementTexture extends BaseTexture {
  55603. /**
  55604. * The texture URL.
  55605. */
  55606. element: HTMLVideoElement | HTMLCanvasElement;
  55607. private static readonly DefaultOptions;
  55608. private _textureMatrix;
  55609. private _engine;
  55610. private _isVideo;
  55611. private _generateMipMaps;
  55612. private _samplingMode;
  55613. /**
  55614. * Instantiates a HtmlElementTexture from the following parameters.
  55615. *
  55616. * @param name Defines the name of the texture
  55617. * @param element Defines the video or canvas the texture is filled with
  55618. * @param options Defines the other none mandatory texture creation options
  55619. */
  55620. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55621. private _createInternalTexture;
  55622. /**
  55623. * Returns the texture matrix used in most of the material.
  55624. */
  55625. getTextureMatrix(): Matrix;
  55626. /**
  55627. * Updates the content of the texture.
  55628. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55629. */
  55630. update(invertY?: Nullable<boolean>): void;
  55631. }
  55632. }
  55633. declare module "babylonjs/Materials/Textures/index" {
  55634. export * from "babylonjs/Materials/Textures/baseTexture";
  55635. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  55636. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  55637. export * from "babylonjs/Materials/Textures/cubeTexture";
  55638. export * from "babylonjs/Materials/Textures/dynamicTexture";
  55639. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  55640. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  55641. export * from "babylonjs/Materials/Textures/internalTexture";
  55642. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  55643. export * from "babylonjs/Materials/Textures/Loaders/index";
  55644. export * from "babylonjs/Materials/Textures/mirrorTexture";
  55645. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  55646. export * from "babylonjs/Materials/Textures/Procedurals/index";
  55647. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  55648. export * from "babylonjs/Materials/Textures/rawTexture";
  55649. export * from "babylonjs/Materials/Textures/rawTexture3D";
  55650. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  55651. export * from "babylonjs/Materials/Textures/refractionTexture";
  55652. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  55653. export * from "babylonjs/Materials/Textures/texture";
  55654. export * from "babylonjs/Materials/Textures/videoTexture";
  55655. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55656. }
  55657. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55658. /**
  55659. * Enum used to define the target of a block
  55660. */
  55661. export enum NodeMaterialBlockTargets {
  55662. /** Vertex shader */
  55663. Vertex = 1,
  55664. /** Fragment shader */
  55665. Fragment = 2,
  55666. /** Neutral */
  55667. Neutral = 4,
  55668. /** Vertex and Fragment */
  55669. VertexAndFragment = 3
  55670. }
  55671. }
  55672. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55673. /**
  55674. * Defines the kind of connection point for node based material
  55675. */
  55676. export enum NodeMaterialBlockConnectionPointTypes {
  55677. /** Float */
  55678. Float = 1,
  55679. /** Int */
  55680. Int = 2,
  55681. /** Vector2 */
  55682. Vector2 = 4,
  55683. /** Vector3 */
  55684. Vector3 = 8,
  55685. /** Vector4 */
  55686. Vector4 = 16,
  55687. /** Color3 */
  55688. Color3 = 32,
  55689. /** Color4 */
  55690. Color4 = 64,
  55691. /** Matrix */
  55692. Matrix = 128,
  55693. /** Detect type based on connection */
  55694. AutoDetect = 1024,
  55695. /** Output type that will be defined by input type */
  55696. BasedOnInput = 2048
  55697. }
  55698. }
  55699. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55700. /**
  55701. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55702. */
  55703. export enum NodeMaterialBlockConnectionPointMode {
  55704. /** Value is an uniform */
  55705. Uniform = 0,
  55706. /** Value is a mesh attribute */
  55707. Attribute = 1,
  55708. /** Value is a varying between vertex and fragment shaders */
  55709. Varying = 2,
  55710. /** Mode is undefined */
  55711. Undefined = 3
  55712. }
  55713. }
  55714. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55715. /**
  55716. * Enum used to define system values e.g. values automatically provided by the system
  55717. */
  55718. export enum NodeMaterialSystemValues {
  55719. /** World */
  55720. World = 1,
  55721. /** View */
  55722. View = 2,
  55723. /** Projection */
  55724. Projection = 3,
  55725. /** ViewProjection */
  55726. ViewProjection = 4,
  55727. /** WorldView */
  55728. WorldView = 5,
  55729. /** WorldViewProjection */
  55730. WorldViewProjection = 6,
  55731. /** CameraPosition */
  55732. CameraPosition = 7,
  55733. /** Fog Color */
  55734. FogColor = 8,
  55735. /** Delta time */
  55736. DeltaTime = 9
  55737. }
  55738. }
  55739. declare module "babylonjs/Materials/Node/Enums/index" {
  55740. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55741. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55742. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55743. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55744. }
  55745. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55746. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55747. /**
  55748. * Root class for all node material optimizers
  55749. */
  55750. export class NodeMaterialOptimizer {
  55751. /**
  55752. * Function used to optimize a NodeMaterial graph
  55753. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55754. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55755. */
  55756. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55757. }
  55758. }
  55759. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55760. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55761. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55762. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55763. import { Scene } from "babylonjs/scene";
  55764. /**
  55765. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55766. */
  55767. export class TransformBlock extends NodeMaterialBlock {
  55768. /**
  55769. * Defines the value to use to complement W value to transform it to a Vector4
  55770. */
  55771. complementW: number;
  55772. /**
  55773. * Defines the value to use to complement z value to transform it to a Vector4
  55774. */
  55775. complementZ: number;
  55776. /**
  55777. * Creates a new TransformBlock
  55778. * @param name defines the block name
  55779. */
  55780. constructor(name: string);
  55781. /**
  55782. * Gets the current class name
  55783. * @returns the class name
  55784. */
  55785. getClassName(): string;
  55786. /**
  55787. * Gets the vector input
  55788. */
  55789. readonly vector: NodeMaterialConnectionPoint;
  55790. /**
  55791. * Gets the output component
  55792. */
  55793. readonly output: NodeMaterialConnectionPoint;
  55794. /**
  55795. * Gets the matrix transform input
  55796. */
  55797. readonly transform: NodeMaterialConnectionPoint;
  55798. protected _buildBlock(state: NodeMaterialBuildState): this;
  55799. serialize(): any;
  55800. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55801. protected _dumpPropertiesCode(): string;
  55802. }
  55803. }
  55804. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55805. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55806. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55807. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55808. /**
  55809. * Block used to output the vertex position
  55810. */
  55811. export class VertexOutputBlock extends NodeMaterialBlock {
  55812. /**
  55813. * Creates a new VertexOutputBlock
  55814. * @param name defines the block name
  55815. */
  55816. constructor(name: string);
  55817. /**
  55818. * Gets the current class name
  55819. * @returns the class name
  55820. */
  55821. getClassName(): string;
  55822. /**
  55823. * Gets the vector input component
  55824. */
  55825. readonly vector: NodeMaterialConnectionPoint;
  55826. protected _buildBlock(state: NodeMaterialBuildState): this;
  55827. }
  55828. }
  55829. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55830. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55831. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55832. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55833. /**
  55834. * Block used to output the final color
  55835. */
  55836. export class FragmentOutputBlock extends NodeMaterialBlock {
  55837. /**
  55838. * Create a new FragmentOutputBlock
  55839. * @param name defines the block name
  55840. */
  55841. constructor(name: string);
  55842. /**
  55843. * Gets the current class name
  55844. * @returns the class name
  55845. */
  55846. getClassName(): string;
  55847. /**
  55848. * Gets the rgba input component
  55849. */
  55850. readonly rgba: NodeMaterialConnectionPoint;
  55851. /**
  55852. * Gets the rgb input component
  55853. */
  55854. readonly rgb: NodeMaterialConnectionPoint;
  55855. /**
  55856. * Gets the a input component
  55857. */
  55858. readonly a: NodeMaterialConnectionPoint;
  55859. protected _buildBlock(state: NodeMaterialBuildState): this;
  55860. }
  55861. }
  55862. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55863. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55864. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55865. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55866. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55868. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55869. import { Effect } from "babylonjs/Materials/effect";
  55870. import { Mesh } from "babylonjs/Meshes/mesh";
  55871. import { Nullable } from "babylonjs/types";
  55872. import { Scene } from "babylonjs/scene";
  55873. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55874. /**
  55875. * Block used to read a reflection texture from a sampler
  55876. */
  55877. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55878. private _define3DName;
  55879. private _defineCubicName;
  55880. private _defineExplicitName;
  55881. private _defineProjectionName;
  55882. private _defineLocalCubicName;
  55883. private _defineSphericalName;
  55884. private _definePlanarName;
  55885. private _defineEquirectangularName;
  55886. private _defineMirroredEquirectangularFixedName;
  55887. private _defineEquirectangularFixedName;
  55888. private _defineSkyboxName;
  55889. private _cubeSamplerName;
  55890. private _2DSamplerName;
  55891. private _positionUVWName;
  55892. private _directionWName;
  55893. private _reflectionCoordsName;
  55894. private _reflection2DCoordsName;
  55895. private _reflectionColorName;
  55896. private _reflectionMatrixName;
  55897. /**
  55898. * Gets or sets the texture associated with the node
  55899. */
  55900. texture: Nullable<BaseTexture>;
  55901. /**
  55902. * Create a new TextureBlock
  55903. * @param name defines the block name
  55904. */
  55905. constructor(name: string);
  55906. /**
  55907. * Gets the current class name
  55908. * @returns the class name
  55909. */
  55910. getClassName(): string;
  55911. /**
  55912. * Gets the world position input component
  55913. */
  55914. readonly position: NodeMaterialConnectionPoint;
  55915. /**
  55916. * Gets the world position input component
  55917. */
  55918. readonly worldPosition: NodeMaterialConnectionPoint;
  55919. /**
  55920. * Gets the world normal input component
  55921. */
  55922. readonly worldNormal: NodeMaterialConnectionPoint;
  55923. /**
  55924. * Gets the world input component
  55925. */
  55926. readonly world: NodeMaterialConnectionPoint;
  55927. /**
  55928. * Gets the camera (or eye) position component
  55929. */
  55930. readonly cameraPosition: NodeMaterialConnectionPoint;
  55931. /**
  55932. * Gets the view input component
  55933. */
  55934. readonly view: NodeMaterialConnectionPoint;
  55935. /**
  55936. * Gets the rgb output component
  55937. */
  55938. readonly rgb: NodeMaterialConnectionPoint;
  55939. /**
  55940. * Gets the r output component
  55941. */
  55942. readonly r: NodeMaterialConnectionPoint;
  55943. /**
  55944. * Gets the g output component
  55945. */
  55946. readonly g: NodeMaterialConnectionPoint;
  55947. /**
  55948. * Gets the b output component
  55949. */
  55950. readonly b: NodeMaterialConnectionPoint;
  55951. autoConfigure(material: NodeMaterial): void;
  55952. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55953. isReady(): boolean;
  55954. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55955. private _injectVertexCode;
  55956. private _writeOutput;
  55957. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55958. protected _dumpPropertiesCode(): string;
  55959. serialize(): any;
  55960. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55961. }
  55962. }
  55963. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55964. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55965. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55966. import { Scene } from "babylonjs/scene";
  55967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55968. import { Matrix } from "babylonjs/Maths/math.vector";
  55969. import { Mesh } from "babylonjs/Meshes/mesh";
  55970. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55971. import { Observable } from "babylonjs/Misc/observable";
  55972. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55973. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55974. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55975. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55976. import { Nullable } from "babylonjs/types";
  55977. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55978. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55979. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55980. /**
  55981. * Interface used to configure the node material editor
  55982. */
  55983. export interface INodeMaterialEditorOptions {
  55984. /** Define the URl to load node editor script */
  55985. editorURL?: string;
  55986. }
  55987. /** @hidden */
  55988. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55989. /** BONES */
  55990. NUM_BONE_INFLUENCERS: number;
  55991. BonesPerMesh: number;
  55992. BONETEXTURE: boolean;
  55993. /** MORPH TARGETS */
  55994. MORPHTARGETS: boolean;
  55995. MORPHTARGETS_NORMAL: boolean;
  55996. MORPHTARGETS_TANGENT: boolean;
  55997. MORPHTARGETS_UV: boolean;
  55998. NUM_MORPH_INFLUENCERS: number;
  55999. /** IMAGE PROCESSING */
  56000. IMAGEPROCESSING: boolean;
  56001. VIGNETTE: boolean;
  56002. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56003. VIGNETTEBLENDMODEOPAQUE: boolean;
  56004. TONEMAPPING: boolean;
  56005. TONEMAPPING_ACES: boolean;
  56006. CONTRAST: boolean;
  56007. EXPOSURE: boolean;
  56008. COLORCURVES: boolean;
  56009. COLORGRADING: boolean;
  56010. COLORGRADING3D: boolean;
  56011. SAMPLER3DGREENDEPTH: boolean;
  56012. SAMPLER3DBGRMAP: boolean;
  56013. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56014. /** MISC. */
  56015. BUMPDIRECTUV: number;
  56016. constructor();
  56017. setValue(name: string, value: boolean): void;
  56018. }
  56019. /**
  56020. * Class used to configure NodeMaterial
  56021. */
  56022. export interface INodeMaterialOptions {
  56023. /**
  56024. * Defines if blocks should emit comments
  56025. */
  56026. emitComments: boolean;
  56027. }
  56028. /**
  56029. * Class used to create a node based material built by assembling shader blocks
  56030. */
  56031. export class NodeMaterial extends PushMaterial {
  56032. private static _BuildIdGenerator;
  56033. private _options;
  56034. private _vertexCompilationState;
  56035. private _fragmentCompilationState;
  56036. private _sharedData;
  56037. private _buildId;
  56038. private _buildWasSuccessful;
  56039. private _cachedWorldViewMatrix;
  56040. private _cachedWorldViewProjectionMatrix;
  56041. private _optimizers;
  56042. private _animationFrame;
  56043. /** Define the URl to load node editor script */
  56044. static EditorURL: string;
  56045. private BJSNODEMATERIALEDITOR;
  56046. /** Get the inspector from bundle or global */
  56047. private _getGlobalNodeMaterialEditor;
  56048. /**
  56049. * 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)
  56050. */
  56051. ignoreAlpha: boolean;
  56052. /**
  56053. * Defines the maximum number of lights that can be used in the material
  56054. */
  56055. maxSimultaneousLights: number;
  56056. /**
  56057. * Observable raised when the material is built
  56058. */
  56059. onBuildObservable: Observable<NodeMaterial>;
  56060. /**
  56061. * Gets or sets the root nodes of the material vertex shader
  56062. */
  56063. _vertexOutputNodes: NodeMaterialBlock[];
  56064. /**
  56065. * Gets or sets the root nodes of the material fragment (pixel) shader
  56066. */
  56067. _fragmentOutputNodes: NodeMaterialBlock[];
  56068. /** Gets or sets options to control the node material overall behavior */
  56069. options: INodeMaterialOptions;
  56070. /**
  56071. * Default configuration related to image processing available in the standard Material.
  56072. */
  56073. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56074. /**
  56075. * Gets the image processing configuration used either in this material.
  56076. */
  56077. /**
  56078. * Sets the Default image processing configuration used either in the this material.
  56079. *
  56080. * If sets to null, the scene one is in use.
  56081. */
  56082. imageProcessingConfiguration: ImageProcessingConfiguration;
  56083. /**
  56084. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  56085. */
  56086. attachedBlocks: NodeMaterialBlock[];
  56087. /**
  56088. * Create a new node based material
  56089. * @param name defines the material name
  56090. * @param scene defines the hosting scene
  56091. * @param options defines creation option
  56092. */
  56093. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  56094. /**
  56095. * Gets the current class name of the material e.g. "NodeMaterial"
  56096. * @returns the class name
  56097. */
  56098. getClassName(): string;
  56099. /**
  56100. * Keep track of the image processing observer to allow dispose and replace.
  56101. */
  56102. private _imageProcessingObserver;
  56103. /**
  56104. * Attaches a new image processing configuration to the Standard Material.
  56105. * @param configuration
  56106. */
  56107. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56108. /**
  56109. * Get a block by its name
  56110. * @param name defines the name of the block to retrieve
  56111. * @returns the required block or null if not found
  56112. */
  56113. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  56114. /**
  56115. * Get a block by its name
  56116. * @param predicate defines the predicate used to find the good candidate
  56117. * @returns the required block or null if not found
  56118. */
  56119. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  56120. /**
  56121. * Get an input block by its name
  56122. * @param predicate defines the predicate used to find the good candidate
  56123. * @returns the required input block or null if not found
  56124. */
  56125. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  56126. /**
  56127. * Gets the list of input blocks attached to this material
  56128. * @returns an array of InputBlocks
  56129. */
  56130. getInputBlocks(): InputBlock[];
  56131. /**
  56132. * Adds a new optimizer to the list of optimizers
  56133. * @param optimizer defines the optimizers to add
  56134. * @returns the current material
  56135. */
  56136. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56137. /**
  56138. * Remove an optimizer from the list of optimizers
  56139. * @param optimizer defines the optimizers to remove
  56140. * @returns the current material
  56141. */
  56142. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56143. /**
  56144. * Add a new block to the list of output nodes
  56145. * @param node defines the node to add
  56146. * @returns the current material
  56147. */
  56148. addOutputNode(node: NodeMaterialBlock): this;
  56149. /**
  56150. * Remove a block from the list of root nodes
  56151. * @param node defines the node to remove
  56152. * @returns the current material
  56153. */
  56154. removeOutputNode(node: NodeMaterialBlock): this;
  56155. private _addVertexOutputNode;
  56156. private _removeVertexOutputNode;
  56157. private _addFragmentOutputNode;
  56158. private _removeFragmentOutputNode;
  56159. /**
  56160. * Specifies if the material will require alpha blending
  56161. * @returns a boolean specifying if alpha blending is needed
  56162. */
  56163. needAlphaBlending(): boolean;
  56164. /**
  56165. * Specifies if this material should be rendered in alpha test mode
  56166. * @returns a boolean specifying if an alpha test is needed.
  56167. */
  56168. needAlphaTesting(): boolean;
  56169. private _initializeBlock;
  56170. private _resetDualBlocks;
  56171. /**
  56172. * Build the material and generates the inner effect
  56173. * @param verbose defines if the build should log activity
  56174. */
  56175. build(verbose?: boolean): void;
  56176. /**
  56177. * Runs an otpimization phase to try to improve the shader code
  56178. */
  56179. optimize(): void;
  56180. private _prepareDefinesForAttributes;
  56181. /**
  56182. * Get if the submesh is ready to be used and all its information available.
  56183. * Child classes can use it to update shaders
  56184. * @param mesh defines the mesh to check
  56185. * @param subMesh defines which submesh to check
  56186. * @param useInstances specifies that instances should be used
  56187. * @returns a boolean indicating that the submesh is ready or not
  56188. */
  56189. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56190. /**
  56191. * Get a string representing the shaders built by the current node graph
  56192. */
  56193. readonly compiledShaders: string;
  56194. /**
  56195. * Binds the world matrix to the material
  56196. * @param world defines the world transformation matrix
  56197. */
  56198. bindOnlyWorldMatrix(world: Matrix): void;
  56199. /**
  56200. * Binds the submesh to this material by preparing the effect and shader to draw
  56201. * @param world defines the world transformation matrix
  56202. * @param mesh defines the mesh containing the submesh
  56203. * @param subMesh defines the submesh to bind the material to
  56204. */
  56205. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56206. /**
  56207. * Gets the active textures from the material
  56208. * @returns an array of textures
  56209. */
  56210. getActiveTextures(): BaseTexture[];
  56211. /**
  56212. * Gets the list of texture blocks
  56213. * @returns an array of texture blocks
  56214. */
  56215. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56216. /**
  56217. * Specifies if the material uses a texture
  56218. * @param texture defines the texture to check against the material
  56219. * @returns a boolean specifying if the material uses the texture
  56220. */
  56221. hasTexture(texture: BaseTexture): boolean;
  56222. /**
  56223. * Disposes the material
  56224. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56225. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56226. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56227. */
  56228. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56229. /** Creates the node editor window. */
  56230. private _createNodeEditor;
  56231. /**
  56232. * Launch the node material editor
  56233. * @param config Define the configuration of the editor
  56234. * @return a promise fulfilled when the node editor is visible
  56235. */
  56236. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56237. /**
  56238. * Clear the current material
  56239. */
  56240. clear(): void;
  56241. /**
  56242. * Clear the current material and set it to a default state
  56243. */
  56244. setToDefault(): void;
  56245. /**
  56246. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56247. * @param url defines the url to load from
  56248. * @returns a promise that will fullfil when the material is fully loaded
  56249. */
  56250. loadAsync(url: string): Promise<void>;
  56251. private _gatherBlocks;
  56252. /**
  56253. * Generate a string containing the code declaration required to create an equivalent of this material
  56254. * @returns a string
  56255. */
  56256. generateCode(): string;
  56257. /**
  56258. * Serializes this material in a JSON representation
  56259. * @returns the serialized material object
  56260. */
  56261. serialize(): any;
  56262. private _restoreConnections;
  56263. /**
  56264. * Clear the current graph and load a new one from a serialization object
  56265. * @param source defines the JSON representation of the material
  56266. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56267. */
  56268. loadFromSerialization(source: any, rootUrl?: string): void;
  56269. /**
  56270. * Creates a node material from parsed material data
  56271. * @param source defines the JSON representation of the material
  56272. * @param scene defines the hosting scene
  56273. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56274. * @returns a new node material
  56275. */
  56276. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56277. /**
  56278. * Creates a new node material set to default basic configuration
  56279. * @param name defines the name of the material
  56280. * @param scene defines the hosting scene
  56281. * @returns a new NodeMaterial
  56282. */
  56283. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  56284. }
  56285. }
  56286. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  56287. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56288. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56289. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56290. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56292. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56293. import { Effect } from "babylonjs/Materials/effect";
  56294. import { Mesh } from "babylonjs/Meshes/mesh";
  56295. import { Nullable } from "babylonjs/types";
  56296. import { Texture } from "babylonjs/Materials/Textures/texture";
  56297. import { Scene } from "babylonjs/scene";
  56298. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56299. /**
  56300. * Block used to read a texture from a sampler
  56301. */
  56302. export class TextureBlock extends NodeMaterialBlock {
  56303. private _defineName;
  56304. private _linearDefineName;
  56305. private _samplerName;
  56306. private _transformedUVName;
  56307. private _textureTransformName;
  56308. private _textureInfoName;
  56309. private _mainUVName;
  56310. private _mainUVDefineName;
  56311. /**
  56312. * Gets or sets the texture associated with the node
  56313. */
  56314. texture: Nullable<Texture>;
  56315. /**
  56316. * Create a new TextureBlock
  56317. * @param name defines the block name
  56318. */
  56319. constructor(name: string);
  56320. /**
  56321. * Gets the current class name
  56322. * @returns the class name
  56323. */
  56324. getClassName(): string;
  56325. /**
  56326. * Gets the uv input component
  56327. */
  56328. readonly uv: NodeMaterialConnectionPoint;
  56329. /**
  56330. * Gets the rgba output component
  56331. */
  56332. readonly rgba: NodeMaterialConnectionPoint;
  56333. /**
  56334. * Gets the rgb output component
  56335. */
  56336. readonly rgb: NodeMaterialConnectionPoint;
  56337. /**
  56338. * Gets the r output component
  56339. */
  56340. readonly r: NodeMaterialConnectionPoint;
  56341. /**
  56342. * Gets the g output component
  56343. */
  56344. readonly g: NodeMaterialConnectionPoint;
  56345. /**
  56346. * Gets the b output component
  56347. */
  56348. readonly b: NodeMaterialConnectionPoint;
  56349. /**
  56350. * Gets the a output component
  56351. */
  56352. readonly a: NodeMaterialConnectionPoint;
  56353. readonly target: NodeMaterialBlockTargets;
  56354. autoConfigure(material: NodeMaterial): void;
  56355. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56356. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56357. isReady(): boolean;
  56358. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56359. private readonly _isMixed;
  56360. private _injectVertexCode;
  56361. private _writeOutput;
  56362. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56363. protected _dumpPropertiesCode(): string;
  56364. serialize(): any;
  56365. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56366. }
  56367. }
  56368. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  56369. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56370. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56371. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56372. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56373. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56374. import { Scene } from "babylonjs/scene";
  56375. /**
  56376. * Class used to store shared data between 2 NodeMaterialBuildState
  56377. */
  56378. export class NodeMaterialBuildStateSharedData {
  56379. /**
  56380. * Gets the list of emitted varyings
  56381. */
  56382. temps: string[];
  56383. /**
  56384. * Gets the list of emitted varyings
  56385. */
  56386. varyings: string[];
  56387. /**
  56388. * Gets the varying declaration string
  56389. */
  56390. varyingDeclaration: string;
  56391. /**
  56392. * Input blocks
  56393. */
  56394. inputBlocks: InputBlock[];
  56395. /**
  56396. * Input blocks
  56397. */
  56398. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  56399. /**
  56400. * Bindable blocks (Blocks that need to set data to the effect)
  56401. */
  56402. bindableBlocks: NodeMaterialBlock[];
  56403. /**
  56404. * List of blocks that can provide a compilation fallback
  56405. */
  56406. blocksWithFallbacks: NodeMaterialBlock[];
  56407. /**
  56408. * List of blocks that can provide a define update
  56409. */
  56410. blocksWithDefines: NodeMaterialBlock[];
  56411. /**
  56412. * List of blocks that can provide a repeatable content
  56413. */
  56414. repeatableContentBlocks: NodeMaterialBlock[];
  56415. /**
  56416. * List of blocks that can provide a dynamic list of uniforms
  56417. */
  56418. dynamicUniformBlocks: NodeMaterialBlock[];
  56419. /**
  56420. * List of blocks that can block the isReady function for the material
  56421. */
  56422. blockingBlocks: NodeMaterialBlock[];
  56423. /**
  56424. * Gets the list of animated inputs
  56425. */
  56426. animatedInputs: InputBlock[];
  56427. /**
  56428. * Build Id used to avoid multiple recompilations
  56429. */
  56430. buildId: number;
  56431. /** List of emitted variables */
  56432. variableNames: {
  56433. [key: string]: number;
  56434. };
  56435. /** List of emitted defines */
  56436. defineNames: {
  56437. [key: string]: number;
  56438. };
  56439. /** Should emit comments? */
  56440. emitComments: boolean;
  56441. /** Emit build activity */
  56442. verbose: boolean;
  56443. /** Gets or sets the hosting scene */
  56444. scene: Scene;
  56445. /**
  56446. * Gets the compilation hints emitted at compilation time
  56447. */
  56448. hints: {
  56449. needWorldViewMatrix: boolean;
  56450. needWorldViewProjectionMatrix: boolean;
  56451. needAlphaBlending: boolean;
  56452. needAlphaTesting: boolean;
  56453. };
  56454. /**
  56455. * List of compilation checks
  56456. */
  56457. checks: {
  56458. emitVertex: boolean;
  56459. emitFragment: boolean;
  56460. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  56461. };
  56462. /** Creates a new shared data */
  56463. constructor();
  56464. /**
  56465. * Emits console errors and exceptions if there is a failing check
  56466. */
  56467. emitErrors(): void;
  56468. }
  56469. }
  56470. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  56471. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56472. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56473. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  56474. /**
  56475. * Class used to store node based material build state
  56476. */
  56477. export class NodeMaterialBuildState {
  56478. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  56479. supportUniformBuffers: boolean;
  56480. /**
  56481. * Gets the list of emitted attributes
  56482. */
  56483. attributes: string[];
  56484. /**
  56485. * Gets the list of emitted uniforms
  56486. */
  56487. uniforms: string[];
  56488. /**
  56489. * Gets the list of emitted constants
  56490. */
  56491. constants: string[];
  56492. /**
  56493. * Gets the list of emitted samplers
  56494. */
  56495. samplers: string[];
  56496. /**
  56497. * Gets the list of emitted functions
  56498. */
  56499. functions: {
  56500. [key: string]: string;
  56501. };
  56502. /**
  56503. * Gets the list of emitted extensions
  56504. */
  56505. extensions: {
  56506. [key: string]: string;
  56507. };
  56508. /**
  56509. * Gets the target of the compilation state
  56510. */
  56511. target: NodeMaterialBlockTargets;
  56512. /**
  56513. * Gets the list of emitted counters
  56514. */
  56515. counters: {
  56516. [key: string]: number;
  56517. };
  56518. /**
  56519. * Shared data between multiple NodeMaterialBuildState instances
  56520. */
  56521. sharedData: NodeMaterialBuildStateSharedData;
  56522. /** @hidden */
  56523. _vertexState: NodeMaterialBuildState;
  56524. /** @hidden */
  56525. _attributeDeclaration: string;
  56526. /** @hidden */
  56527. _uniformDeclaration: string;
  56528. /** @hidden */
  56529. _constantDeclaration: string;
  56530. /** @hidden */
  56531. _samplerDeclaration: string;
  56532. /** @hidden */
  56533. _varyingTransfer: string;
  56534. private _repeatableContentAnchorIndex;
  56535. /** @hidden */
  56536. _builtCompilationString: string;
  56537. /**
  56538. * Gets the emitted compilation strings
  56539. */
  56540. compilationString: string;
  56541. /**
  56542. * Finalize the compilation strings
  56543. * @param state defines the current compilation state
  56544. */
  56545. finalize(state: NodeMaterialBuildState): void;
  56546. /** @hidden */
  56547. readonly _repeatableContentAnchor: string;
  56548. /** @hidden */
  56549. _getFreeVariableName(prefix: string): string;
  56550. /** @hidden */
  56551. _getFreeDefineName(prefix: string): string;
  56552. /** @hidden */
  56553. _excludeVariableName(name: string): void;
  56554. /** @hidden */
  56555. _emit2DSampler(name: string): void;
  56556. /** @hidden */
  56557. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  56558. /** @hidden */
  56559. _emitExtension(name: string, extension: string): void;
  56560. /** @hidden */
  56561. _emitFunction(name: string, code: string, comments: string): void;
  56562. /** @hidden */
  56563. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  56564. replaceStrings?: {
  56565. search: RegExp;
  56566. replace: string;
  56567. }[];
  56568. repeatKey?: string;
  56569. }): string;
  56570. /** @hidden */
  56571. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  56572. repeatKey?: string;
  56573. removeAttributes?: boolean;
  56574. removeUniforms?: boolean;
  56575. removeVaryings?: boolean;
  56576. removeIfDef?: boolean;
  56577. replaceStrings?: {
  56578. search: RegExp;
  56579. replace: string;
  56580. }[];
  56581. }, storeKey?: string): void;
  56582. /** @hidden */
  56583. _registerTempVariable(name: string): boolean;
  56584. /** @hidden */
  56585. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  56586. /** @hidden */
  56587. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  56588. /** @hidden */
  56589. _emitFloat(value: number): string;
  56590. }
  56591. }
  56592. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  56593. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56594. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56595. import { Nullable } from "babylonjs/types";
  56596. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56597. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56598. import { Effect } from "babylonjs/Materials/effect";
  56599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56600. import { Mesh } from "babylonjs/Meshes/mesh";
  56601. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56602. import { Scene } from "babylonjs/scene";
  56603. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56604. /**
  56605. * Defines a block that can be used inside a node based material
  56606. */
  56607. export class NodeMaterialBlock {
  56608. private _buildId;
  56609. private _buildTarget;
  56610. private _target;
  56611. private _isFinalMerger;
  56612. private _isInput;
  56613. protected _isUnique: boolean;
  56614. /** @hidden */
  56615. _codeVariableName: string;
  56616. /** @hidden */
  56617. _inputs: NodeMaterialConnectionPoint[];
  56618. /** @hidden */
  56619. _outputs: NodeMaterialConnectionPoint[];
  56620. /** @hidden */
  56621. _preparationId: number;
  56622. /**
  56623. * Gets or sets the name of the block
  56624. */
  56625. name: string;
  56626. /**
  56627. * Gets or sets the unique id of the node
  56628. */
  56629. uniqueId: number;
  56630. /**
  56631. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  56632. */
  56633. readonly isUnique: boolean;
  56634. /**
  56635. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  56636. */
  56637. readonly isFinalMerger: boolean;
  56638. /**
  56639. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  56640. */
  56641. readonly isInput: boolean;
  56642. /**
  56643. * Gets or sets the build Id
  56644. */
  56645. buildId: number;
  56646. /**
  56647. * Gets or sets the target of the block
  56648. */
  56649. target: NodeMaterialBlockTargets;
  56650. /**
  56651. * Gets the list of input points
  56652. */
  56653. readonly inputs: NodeMaterialConnectionPoint[];
  56654. /** Gets the list of output points */
  56655. readonly outputs: NodeMaterialConnectionPoint[];
  56656. /**
  56657. * Find an input by its name
  56658. * @param name defines the name of the input to look for
  56659. * @returns the input or null if not found
  56660. */
  56661. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56662. /**
  56663. * Find an output by its name
  56664. * @param name defines the name of the outputto look for
  56665. * @returns the output or null if not found
  56666. */
  56667. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56668. /**
  56669. * Creates a new NodeMaterialBlock
  56670. * @param name defines the block name
  56671. * @param target defines the target of that block (Vertex by default)
  56672. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56673. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56674. */
  56675. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56676. /**
  56677. * Initialize the block and prepare the context for build
  56678. * @param state defines the state that will be used for the build
  56679. */
  56680. initialize(state: NodeMaterialBuildState): void;
  56681. /**
  56682. * Bind data to effect. Will only be called for blocks with isBindable === true
  56683. * @param effect defines the effect to bind data to
  56684. * @param nodeMaterial defines the hosting NodeMaterial
  56685. * @param mesh defines the mesh that will be rendered
  56686. */
  56687. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56688. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56689. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56690. protected _writeFloat(value: number): string;
  56691. /**
  56692. * Gets the current class name e.g. "NodeMaterialBlock"
  56693. * @returns the class name
  56694. */
  56695. getClassName(): string;
  56696. /**
  56697. * Register a new input. Must be called inside a block constructor
  56698. * @param name defines the connection point name
  56699. * @param type defines the connection point type
  56700. * @param isOptional defines a boolean indicating that this input can be omitted
  56701. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56702. * @returns the current block
  56703. */
  56704. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56705. /**
  56706. * Register a new output. Must be called inside a block constructor
  56707. * @param name defines the connection point name
  56708. * @param type defines the connection point type
  56709. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56710. * @returns the current block
  56711. */
  56712. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56713. /**
  56714. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56715. * @param forOutput defines an optional connection point to check compatibility with
  56716. * @returns the first available input or null
  56717. */
  56718. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56719. /**
  56720. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56721. * @param forBlock defines an optional block to check compatibility with
  56722. * @returns the first available input or null
  56723. */
  56724. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56725. /**
  56726. * Gets the sibling of the given output
  56727. * @param current defines the current output
  56728. * @returns the next output in the list or null
  56729. */
  56730. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56731. /**
  56732. * Connect current block with another block
  56733. * @param other defines the block to connect with
  56734. * @param options define the various options to help pick the right connections
  56735. * @returns the current block
  56736. */
  56737. connectTo(other: NodeMaterialBlock, options?: {
  56738. input?: string;
  56739. output?: string;
  56740. outputSwizzle?: string;
  56741. }): this | undefined;
  56742. protected _buildBlock(state: NodeMaterialBuildState): void;
  56743. /**
  56744. * Add uniforms, samplers and uniform buffers at compilation time
  56745. * @param state defines the state to update
  56746. * @param nodeMaterial defines the node material requesting the update
  56747. * @param defines defines the material defines to update
  56748. * @param uniformBuffers defines the list of uniform buffer names
  56749. */
  56750. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56751. /**
  56752. * Add potential fallbacks if shader compilation fails
  56753. * @param mesh defines the mesh to be rendered
  56754. * @param fallbacks defines the current prioritized list of fallbacks
  56755. */
  56756. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56757. /**
  56758. * Initialize defines for shader compilation
  56759. * @param mesh defines the mesh to be rendered
  56760. * @param nodeMaterial defines the node material requesting the update
  56761. * @param defines defines the material defines to update
  56762. * @param useInstances specifies that instances should be used
  56763. */
  56764. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56765. /**
  56766. * Update defines for shader compilation
  56767. * @param mesh defines the mesh to be rendered
  56768. * @param nodeMaterial defines the node material requesting the update
  56769. * @param defines defines the material defines to update
  56770. * @param useInstances specifies that instances should be used
  56771. */
  56772. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56773. /**
  56774. * Lets the block try to connect some inputs automatically
  56775. * @param material defines the hosting NodeMaterial
  56776. */
  56777. autoConfigure(material: NodeMaterial): void;
  56778. /**
  56779. * Function called when a block is declared as repeatable content generator
  56780. * @param vertexShaderState defines the current compilation state for the vertex shader
  56781. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56782. * @param mesh defines the mesh to be rendered
  56783. * @param defines defines the material defines to update
  56784. */
  56785. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56786. /**
  56787. * Checks if the block is ready
  56788. * @param mesh defines the mesh to be rendered
  56789. * @param nodeMaterial defines the node material requesting the update
  56790. * @param defines defines the material defines to update
  56791. * @param useInstances specifies that instances should be used
  56792. * @returns true if the block is ready
  56793. */
  56794. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56795. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56796. private _processBuild;
  56797. /**
  56798. * Compile the current node and generate the shader code
  56799. * @param state defines the current compilation state (uniforms, samplers, current string)
  56800. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56801. * @returns true if already built
  56802. */
  56803. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56804. protected _inputRename(name: string): string;
  56805. protected _outputRename(name: string): string;
  56806. protected _dumpPropertiesCode(): string;
  56807. /** @hidden */
  56808. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56809. /** @hidden */
  56810. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  56811. /**
  56812. * Clone the current block to a new identical block
  56813. * @param scene defines the hosting scene
  56814. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56815. * @returns a copy of the current block
  56816. */
  56817. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56818. /**
  56819. * Serializes this block in a JSON representation
  56820. * @returns the serialized block object
  56821. */
  56822. serialize(): any;
  56823. /** @hidden */
  56824. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56825. /**
  56826. * Release resources
  56827. */
  56828. dispose(): void;
  56829. }
  56830. }
  56831. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56832. /**
  56833. * Enum defining the type of animations supported by InputBlock
  56834. */
  56835. export enum AnimatedInputBlockTypes {
  56836. /** No animation */
  56837. None = 0,
  56838. /** Time based animation. Will only work for floats */
  56839. Time = 1
  56840. }
  56841. }
  56842. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56843. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56844. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56845. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56846. import { Nullable } from "babylonjs/types";
  56847. import { Effect } from "babylonjs/Materials/effect";
  56848. import { Matrix } from "babylonjs/Maths/math.vector";
  56849. import { Scene } from "babylonjs/scene";
  56850. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56851. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56852. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56853. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56854. /**
  56855. * Block used to expose an input value
  56856. */
  56857. export class InputBlock extends NodeMaterialBlock {
  56858. private _mode;
  56859. private _associatedVariableName;
  56860. private _storedValue;
  56861. private _valueCallback;
  56862. private _type;
  56863. private _animationType;
  56864. /** Gets or set a value used to limit the range of float values */
  56865. min: number;
  56866. /** Gets or set a value used to limit the range of float values */
  56867. max: number;
  56868. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56869. matrixMode: number;
  56870. /** @hidden */
  56871. _systemValue: Nullable<NodeMaterialSystemValues>;
  56872. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56873. visibleInInspector: boolean;
  56874. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56875. isConstant: boolean;
  56876. /**
  56877. * Gets or sets the connection point type (default is float)
  56878. */
  56879. readonly type: NodeMaterialBlockConnectionPointTypes;
  56880. /**
  56881. * Creates a new InputBlock
  56882. * @param name defines the block name
  56883. * @param target defines the target of that block (Vertex by default)
  56884. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56885. */
  56886. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56887. /**
  56888. * Gets the output component
  56889. */
  56890. readonly output: NodeMaterialConnectionPoint;
  56891. /**
  56892. * Set the source of this connection point to a vertex attribute
  56893. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56894. * @returns the current connection point
  56895. */
  56896. setAsAttribute(attributeName?: string): InputBlock;
  56897. /**
  56898. * Set the source of this connection point to a system value
  56899. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56900. * @returns the current connection point
  56901. */
  56902. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56903. /**
  56904. * Gets or sets the value of that point.
  56905. * Please note that this value will be ignored if valueCallback is defined
  56906. */
  56907. value: any;
  56908. /**
  56909. * Gets or sets a callback used to get the value of that point.
  56910. * Please note that setting this value will force the connection point to ignore the value property
  56911. */
  56912. valueCallback: () => any;
  56913. /**
  56914. * Gets or sets the associated variable name in the shader
  56915. */
  56916. associatedVariableName: string;
  56917. /** Gets or sets the type of animation applied to the input */
  56918. animationType: AnimatedInputBlockTypes;
  56919. /**
  56920. * Gets a boolean indicating that this connection point not defined yet
  56921. */
  56922. readonly isUndefined: boolean;
  56923. /**
  56924. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56925. * In this case the connection point name must be the name of the uniform to use.
  56926. * Can only be set on inputs
  56927. */
  56928. isUniform: boolean;
  56929. /**
  56930. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56931. * In this case the connection point name must be the name of the attribute to use
  56932. * Can only be set on inputs
  56933. */
  56934. isAttribute: boolean;
  56935. /**
  56936. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56937. * Can only be set on exit points
  56938. */
  56939. isVarying: boolean;
  56940. /**
  56941. * Gets a boolean indicating that the current connection point is a system value
  56942. */
  56943. readonly isSystemValue: boolean;
  56944. /**
  56945. * Gets or sets the current well known value or null if not defined as a system value
  56946. */
  56947. systemValue: Nullable<NodeMaterialSystemValues>;
  56948. /**
  56949. * Gets the current class name
  56950. * @returns the class name
  56951. */
  56952. getClassName(): string;
  56953. /**
  56954. * Animate the input if animationType !== None
  56955. * @param scene defines the rendering scene
  56956. */
  56957. animate(scene: Scene): void;
  56958. private _emitDefine;
  56959. initialize(state: NodeMaterialBuildState): void;
  56960. /**
  56961. * Set the input block to its default value (based on its type)
  56962. */
  56963. setDefaultValue(): void;
  56964. private _emitConstant;
  56965. private _emit;
  56966. /** @hidden */
  56967. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56968. /** @hidden */
  56969. _transmit(effect: Effect, scene: Scene): void;
  56970. protected _buildBlock(state: NodeMaterialBuildState): void;
  56971. protected _dumpPropertiesCode(): string;
  56972. serialize(): any;
  56973. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56974. }
  56975. }
  56976. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56977. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56978. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56979. import { Nullable } from "babylonjs/types";
  56980. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56981. import { Observable } from "babylonjs/Misc/observable";
  56982. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56983. /**
  56984. * Enum used to define the compatibility state between two connection points
  56985. */
  56986. export enum NodeMaterialConnectionPointCompatibilityStates {
  56987. /** Points are compatibles */
  56988. Compatible = 0,
  56989. /** Points are incompatible because of their types */
  56990. TypeIncompatible = 1,
  56991. /** Points are incompatible because of their targets (vertex vs fragment) */
  56992. TargetIncompatible = 2
  56993. }
  56994. /**
  56995. * Defines a connection point for a block
  56996. */
  56997. export class NodeMaterialConnectionPoint {
  56998. /** @hidden */
  56999. _ownerBlock: NodeMaterialBlock;
  57000. /** @hidden */
  57001. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57002. private _endpoints;
  57003. private _associatedVariableName;
  57004. /** @hidden */
  57005. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57006. /** @hidden */
  57007. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57008. private _type;
  57009. /** @hidden */
  57010. _enforceAssociatedVariableName: boolean;
  57011. /**
  57012. * Gets or sets the additional types supported by this connection point
  57013. */
  57014. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57015. /**
  57016. * Gets or sets the additional types excluded by this connection point
  57017. */
  57018. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57019. /**
  57020. * Observable triggered when this point is connected
  57021. */
  57022. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  57023. /**
  57024. * Gets or sets the associated variable name in the shader
  57025. */
  57026. associatedVariableName: string;
  57027. /**
  57028. * Gets or sets the connection point type (default is float)
  57029. */
  57030. type: NodeMaterialBlockConnectionPointTypes;
  57031. /**
  57032. * Gets or sets the connection point name
  57033. */
  57034. name: string;
  57035. /**
  57036. * Gets or sets a boolean indicating that this connection point can be omitted
  57037. */
  57038. isOptional: boolean;
  57039. /**
  57040. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  57041. */
  57042. define: string;
  57043. /** @hidden */
  57044. _prioritizeVertex: boolean;
  57045. private _target;
  57046. /** Gets or sets the target of that connection point */
  57047. target: NodeMaterialBlockTargets;
  57048. /**
  57049. * Gets a boolean indicating that the current point is connected
  57050. */
  57051. readonly isConnected: boolean;
  57052. /**
  57053. * Gets a boolean indicating that the current point is connected to an input block
  57054. */
  57055. readonly isConnectedToInputBlock: boolean;
  57056. /**
  57057. * Gets a the connected input block (if any)
  57058. */
  57059. readonly connectInputBlock: Nullable<InputBlock>;
  57060. /** Get the other side of the connection (if any) */
  57061. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57062. /** Get the block that owns this connection point */
  57063. readonly ownerBlock: NodeMaterialBlock;
  57064. /** Get the block connected on the other side of this connection (if any) */
  57065. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  57066. /** Get the block connected on the endpoints of this connection (if any) */
  57067. readonly connectedBlocks: Array<NodeMaterialBlock>;
  57068. /** Gets the list of connected endpoints */
  57069. readonly endpoints: NodeMaterialConnectionPoint[];
  57070. /** Gets a boolean indicating if that output point is connected to at least one input */
  57071. readonly hasEndpoints: boolean;
  57072. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  57073. readonly isConnectedInVertexShader: boolean;
  57074. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  57075. readonly isConnectedInFragmentShader: boolean;
  57076. /**
  57077. * Creates a new connection point
  57078. * @param name defines the connection point name
  57079. * @param ownerBlock defines the block hosting this connection point
  57080. */
  57081. constructor(name: string, ownerBlock: NodeMaterialBlock);
  57082. /**
  57083. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  57084. * @returns the class name
  57085. */
  57086. getClassName(): string;
  57087. /**
  57088. * Gets a boolean indicating if the current point can be connected to another point
  57089. * @param connectionPoint defines the other connection point
  57090. * @returns a boolean
  57091. */
  57092. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  57093. /**
  57094. * Gets a number indicating if the current point can be connected to another point
  57095. * @param connectionPoint defines the other connection point
  57096. * @returns a number defining the compatibility state
  57097. */
  57098. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57099. /**
  57100. * Connect this point to another connection point
  57101. * @param connectionPoint defines the other connection point
  57102. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  57103. * @returns the current connection point
  57104. */
  57105. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  57106. /**
  57107. * Disconnect this point from one of his endpoint
  57108. * @param endpoint defines the other connection point
  57109. * @returns the current connection point
  57110. */
  57111. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  57112. /**
  57113. * Serializes this point in a JSON representation
  57114. * @returns the serialized point object
  57115. */
  57116. serialize(): any;
  57117. /**
  57118. * Release resources
  57119. */
  57120. dispose(): void;
  57121. }
  57122. }
  57123. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  57124. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57125. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57127. import { Mesh } from "babylonjs/Meshes/mesh";
  57128. import { Effect } from "babylonjs/Materials/effect";
  57129. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57130. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57131. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57132. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57133. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57134. /**
  57135. * Block used to add support for vertex skinning (bones)
  57136. */
  57137. export class BonesBlock extends NodeMaterialBlock {
  57138. /**
  57139. * Creates a new BonesBlock
  57140. * @param name defines the block name
  57141. */
  57142. constructor(name: string);
  57143. /**
  57144. * Initialize the block and prepare the context for build
  57145. * @param state defines the state that will be used for the build
  57146. */
  57147. initialize(state: NodeMaterialBuildState): void;
  57148. /**
  57149. * Gets the current class name
  57150. * @returns the class name
  57151. */
  57152. getClassName(): string;
  57153. /**
  57154. * Gets the matrix indices input component
  57155. */
  57156. readonly matricesIndices: NodeMaterialConnectionPoint;
  57157. /**
  57158. * Gets the matrix weights input component
  57159. */
  57160. readonly matricesWeights: NodeMaterialConnectionPoint;
  57161. /**
  57162. * Gets the extra matrix indices input component
  57163. */
  57164. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  57165. /**
  57166. * Gets the extra matrix weights input component
  57167. */
  57168. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  57169. /**
  57170. * Gets the world input component
  57171. */
  57172. readonly world: NodeMaterialConnectionPoint;
  57173. /**
  57174. * Gets the output component
  57175. */
  57176. readonly output: NodeMaterialConnectionPoint;
  57177. autoConfigure(material: NodeMaterial): void;
  57178. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57179. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57180. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57181. protected _buildBlock(state: NodeMaterialBuildState): this;
  57182. }
  57183. }
  57184. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  57185. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57186. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57187. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57189. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57190. /**
  57191. * Block used to add support for instances
  57192. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57193. */
  57194. export class InstancesBlock extends NodeMaterialBlock {
  57195. /**
  57196. * Creates a new InstancesBlock
  57197. * @param name defines the block name
  57198. */
  57199. constructor(name: string);
  57200. /**
  57201. * Gets the current class name
  57202. * @returns the class name
  57203. */
  57204. getClassName(): string;
  57205. /**
  57206. * Gets the first world row input component
  57207. */
  57208. readonly world0: NodeMaterialConnectionPoint;
  57209. /**
  57210. * Gets the second world row input component
  57211. */
  57212. readonly world1: NodeMaterialConnectionPoint;
  57213. /**
  57214. * Gets the third world row input component
  57215. */
  57216. readonly world2: NodeMaterialConnectionPoint;
  57217. /**
  57218. * Gets the forth world row input component
  57219. */
  57220. readonly world3: NodeMaterialConnectionPoint;
  57221. /**
  57222. * Gets the world input component
  57223. */
  57224. readonly world: NodeMaterialConnectionPoint;
  57225. /**
  57226. * Gets the output component
  57227. */
  57228. readonly output: NodeMaterialConnectionPoint;
  57229. autoConfigure(material: NodeMaterial): void;
  57230. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57231. protected _buildBlock(state: NodeMaterialBuildState): this;
  57232. }
  57233. }
  57234. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  57235. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57236. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57237. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57239. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57240. import { Effect } from "babylonjs/Materials/effect";
  57241. import { Mesh } from "babylonjs/Meshes/mesh";
  57242. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57243. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57244. /**
  57245. * Block used to add morph targets support to vertex shader
  57246. */
  57247. export class MorphTargetsBlock extends NodeMaterialBlock {
  57248. private _repeatableContentAnchor;
  57249. private _repeatebleContentGenerated;
  57250. /**
  57251. * Create a new MorphTargetsBlock
  57252. * @param name defines the block name
  57253. */
  57254. constructor(name: string);
  57255. /**
  57256. * Gets the current class name
  57257. * @returns the class name
  57258. */
  57259. getClassName(): string;
  57260. /**
  57261. * Gets the position input component
  57262. */
  57263. readonly position: NodeMaterialConnectionPoint;
  57264. /**
  57265. * Gets the normal input component
  57266. */
  57267. readonly normal: NodeMaterialConnectionPoint;
  57268. /**
  57269. * Gets the tangent input component
  57270. */
  57271. readonly tangent: NodeMaterialConnectionPoint;
  57272. /**
  57273. * Gets the tangent input component
  57274. */
  57275. readonly uv: NodeMaterialConnectionPoint;
  57276. /**
  57277. * Gets the position output component
  57278. */
  57279. readonly positionOutput: NodeMaterialConnectionPoint;
  57280. /**
  57281. * Gets the normal output component
  57282. */
  57283. readonly normalOutput: NodeMaterialConnectionPoint;
  57284. /**
  57285. * Gets the tangent output component
  57286. */
  57287. readonly tangentOutput: NodeMaterialConnectionPoint;
  57288. /**
  57289. * Gets the tangent output component
  57290. */
  57291. readonly uvOutput: NodeMaterialConnectionPoint;
  57292. initialize(state: NodeMaterialBuildState): void;
  57293. autoConfigure(material: NodeMaterial): void;
  57294. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57295. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57296. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57297. protected _buildBlock(state: NodeMaterialBuildState): this;
  57298. }
  57299. }
  57300. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  57301. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57302. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57303. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57304. import { Nullable } from "babylonjs/types";
  57305. import { Scene } from "babylonjs/scene";
  57306. import { Effect } from "babylonjs/Materials/effect";
  57307. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57308. import { Mesh } from "babylonjs/Meshes/mesh";
  57309. import { Light } from "babylonjs/Lights/light";
  57310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57311. /**
  57312. * Block used to get data information from a light
  57313. */
  57314. export class LightInformationBlock extends NodeMaterialBlock {
  57315. private _lightDataUniformName;
  57316. private _lightColorUniformName;
  57317. private _lightTypeDefineName;
  57318. /**
  57319. * Gets or sets the light associated with this block
  57320. */
  57321. light: Nullable<Light>;
  57322. /**
  57323. * Creates a new LightInformationBlock
  57324. * @param name defines the block name
  57325. */
  57326. constructor(name: string);
  57327. /**
  57328. * Gets the current class name
  57329. * @returns the class name
  57330. */
  57331. getClassName(): string;
  57332. /**
  57333. * Gets the world position input component
  57334. */
  57335. readonly worldPosition: NodeMaterialConnectionPoint;
  57336. /**
  57337. * Gets the direction output component
  57338. */
  57339. readonly direction: NodeMaterialConnectionPoint;
  57340. /**
  57341. * Gets the direction output component
  57342. */
  57343. readonly color: NodeMaterialConnectionPoint;
  57344. /**
  57345. * Gets the direction output component
  57346. */
  57347. readonly intensity: NodeMaterialConnectionPoint;
  57348. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57349. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57350. protected _buildBlock(state: NodeMaterialBuildState): this;
  57351. serialize(): any;
  57352. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57353. }
  57354. }
  57355. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  57356. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  57357. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  57358. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  57359. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  57360. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  57361. }
  57362. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  57363. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57364. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57365. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57366. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57367. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57368. import { Effect } from "babylonjs/Materials/effect";
  57369. import { Mesh } from "babylonjs/Meshes/mesh";
  57370. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57371. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57372. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57373. /**
  57374. * Block used to add image processing support to fragment shader
  57375. */
  57376. export class ImageProcessingBlock extends NodeMaterialBlock {
  57377. /**
  57378. * Create a new ImageProcessingBlock
  57379. * @param name defines the block name
  57380. */
  57381. constructor(name: string);
  57382. /**
  57383. * Gets the current class name
  57384. * @returns the class name
  57385. */
  57386. getClassName(): string;
  57387. /**
  57388. * Gets the color input component
  57389. */
  57390. readonly color: NodeMaterialConnectionPoint;
  57391. /**
  57392. * Gets the output component
  57393. */
  57394. readonly output: NodeMaterialConnectionPoint;
  57395. /**
  57396. * Initialize the block and prepare the context for build
  57397. * @param state defines the state that will be used for the build
  57398. */
  57399. initialize(state: NodeMaterialBuildState): void;
  57400. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  57401. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57402. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57403. protected _buildBlock(state: NodeMaterialBuildState): this;
  57404. }
  57405. }
  57406. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  57407. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57408. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57409. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57410. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57412. import { Effect } from "babylonjs/Materials/effect";
  57413. import { Mesh } from "babylonjs/Meshes/mesh";
  57414. import { Scene } from "babylonjs/scene";
  57415. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57416. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57417. /**
  57418. * Block used to pertub normals based on a normal map
  57419. */
  57420. export class PerturbNormalBlock extends NodeMaterialBlock {
  57421. private _tangentSpaceParameterName;
  57422. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57423. invertX: boolean;
  57424. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  57425. invertY: boolean;
  57426. /**
  57427. * Create a new PerturbNormalBlock
  57428. * @param name defines the block name
  57429. */
  57430. constructor(name: string);
  57431. /**
  57432. * Gets the current class name
  57433. * @returns the class name
  57434. */
  57435. getClassName(): string;
  57436. /**
  57437. * Gets the world position input component
  57438. */
  57439. readonly worldPosition: NodeMaterialConnectionPoint;
  57440. /**
  57441. * Gets the world normal input component
  57442. */
  57443. readonly worldNormal: NodeMaterialConnectionPoint;
  57444. /**
  57445. * Gets the uv input component
  57446. */
  57447. readonly uv: NodeMaterialConnectionPoint;
  57448. /**
  57449. * Gets the normal map color input component
  57450. */
  57451. readonly normalMapColor: NodeMaterialConnectionPoint;
  57452. /**
  57453. * Gets the strength input component
  57454. */
  57455. readonly strength: NodeMaterialConnectionPoint;
  57456. /**
  57457. * Gets the output component
  57458. */
  57459. readonly output: NodeMaterialConnectionPoint;
  57460. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57461. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57462. autoConfigure(material: NodeMaterial): void;
  57463. protected _buildBlock(state: NodeMaterialBuildState): this;
  57464. protected _dumpPropertiesCode(): string;
  57465. serialize(): any;
  57466. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57467. }
  57468. }
  57469. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  57470. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57471. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57472. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57473. /**
  57474. * Block used to discard a pixel if a value is smaller than a cutoff
  57475. */
  57476. export class DiscardBlock extends NodeMaterialBlock {
  57477. /**
  57478. * Create a new DiscardBlock
  57479. * @param name defines the block name
  57480. */
  57481. constructor(name: string);
  57482. /**
  57483. * Gets the current class name
  57484. * @returns the class name
  57485. */
  57486. getClassName(): string;
  57487. /**
  57488. * Gets the color input component
  57489. */
  57490. readonly value: NodeMaterialConnectionPoint;
  57491. /**
  57492. * Gets the cutoff input component
  57493. */
  57494. readonly cutoff: NodeMaterialConnectionPoint;
  57495. protected _buildBlock(state: NodeMaterialBuildState): this;
  57496. }
  57497. }
  57498. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  57499. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57500. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57501. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57502. /**
  57503. * Block used to test if the fragment shader is front facing
  57504. */
  57505. export class FrontFacingBlock extends NodeMaterialBlock {
  57506. /**
  57507. * Creates a new FrontFacingBlock
  57508. * @param name defines the block name
  57509. */
  57510. constructor(name: string);
  57511. /**
  57512. * Gets the current class name
  57513. * @returns the class name
  57514. */
  57515. getClassName(): string;
  57516. /**
  57517. * Gets the output component
  57518. */
  57519. readonly output: NodeMaterialConnectionPoint;
  57520. protected _buildBlock(state: NodeMaterialBuildState): this;
  57521. }
  57522. }
  57523. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  57524. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  57525. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  57526. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  57527. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  57528. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  57529. }
  57530. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  57531. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57532. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57533. import { Mesh } from "babylonjs/Meshes/mesh";
  57534. import { Effect } from "babylonjs/Materials/effect";
  57535. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57537. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57538. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57539. /**
  57540. * Block used to add support for scene fog
  57541. */
  57542. export class FogBlock extends NodeMaterialBlock {
  57543. private _fogDistanceName;
  57544. private _fogParameters;
  57545. /**
  57546. * Create a new FogBlock
  57547. * @param name defines the block name
  57548. */
  57549. constructor(name: string);
  57550. /**
  57551. * Gets the current class name
  57552. * @returns the class name
  57553. */
  57554. getClassName(): string;
  57555. /**
  57556. * Gets the world position input component
  57557. */
  57558. readonly worldPosition: NodeMaterialConnectionPoint;
  57559. /**
  57560. * Gets the view input component
  57561. */
  57562. readonly view: NodeMaterialConnectionPoint;
  57563. /**
  57564. * Gets the color input component
  57565. */
  57566. readonly input: NodeMaterialConnectionPoint;
  57567. /**
  57568. * Gets the fog color input component
  57569. */
  57570. readonly fogColor: NodeMaterialConnectionPoint;
  57571. /**
  57572. * Gets the output component
  57573. */
  57574. readonly output: NodeMaterialConnectionPoint;
  57575. autoConfigure(material: NodeMaterial): void;
  57576. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57577. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57578. protected _buildBlock(state: NodeMaterialBuildState): this;
  57579. }
  57580. }
  57581. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  57582. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57583. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57584. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57586. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57587. import { Effect } from "babylonjs/Materials/effect";
  57588. import { Mesh } from "babylonjs/Meshes/mesh";
  57589. import { Light } from "babylonjs/Lights/light";
  57590. import { Nullable } from "babylonjs/types";
  57591. import { Scene } from "babylonjs/scene";
  57592. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57593. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57594. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57595. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57596. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  57597. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57598. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57599. /**
  57600. * Block used to add light in the fragment shader
  57601. */
  57602. export class LightBlock extends NodeMaterialBlock {
  57603. private _lightId;
  57604. /**
  57605. * Gets or sets the light associated with this block
  57606. */
  57607. light: Nullable<Light>;
  57608. /**
  57609. * Create a new LightBlock
  57610. * @param name defines the block name
  57611. */
  57612. constructor(name: string);
  57613. /**
  57614. * Gets the current class name
  57615. * @returns the class name
  57616. */
  57617. getClassName(): string;
  57618. /**
  57619. * Gets the world position input component
  57620. */
  57621. readonly worldPosition: NodeMaterialConnectionPoint;
  57622. /**
  57623. * Gets the world normal input component
  57624. */
  57625. readonly worldNormal: NodeMaterialConnectionPoint;
  57626. /**
  57627. * Gets the camera (or eye) position component
  57628. */
  57629. readonly cameraPosition: NodeMaterialConnectionPoint;
  57630. /**
  57631. * Gets the glossiness component
  57632. */
  57633. readonly glossiness: NodeMaterialConnectionPoint;
  57634. /**
  57635. * Gets the glossinness power component
  57636. */
  57637. readonly glossPower: NodeMaterialConnectionPoint;
  57638. /**
  57639. * Gets the diffuse color component
  57640. */
  57641. readonly diffuseColor: NodeMaterialConnectionPoint;
  57642. /**
  57643. * Gets the specular color component
  57644. */
  57645. readonly specularColor: NodeMaterialConnectionPoint;
  57646. /**
  57647. * Gets the diffuse output component
  57648. */
  57649. readonly diffuseOutput: NodeMaterialConnectionPoint;
  57650. /**
  57651. * Gets the specular output component
  57652. */
  57653. readonly specularOutput: NodeMaterialConnectionPoint;
  57654. autoConfigure(material: NodeMaterial): void;
  57655. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57656. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57657. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57658. private _injectVertexCode;
  57659. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57660. serialize(): any;
  57661. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57662. }
  57663. }
  57664. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  57665. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  57666. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  57667. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57668. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57669. }
  57670. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  57671. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57672. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57673. }
  57674. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  57675. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57676. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57677. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57678. /**
  57679. * Block used to multiply 2 values
  57680. */
  57681. export class MultiplyBlock extends NodeMaterialBlock {
  57682. /**
  57683. * Creates a new MultiplyBlock
  57684. * @param name defines the block name
  57685. */
  57686. constructor(name: string);
  57687. /**
  57688. * Gets the current class name
  57689. * @returns the class name
  57690. */
  57691. getClassName(): string;
  57692. /**
  57693. * Gets the left operand input component
  57694. */
  57695. readonly left: NodeMaterialConnectionPoint;
  57696. /**
  57697. * Gets the right operand input component
  57698. */
  57699. readonly right: NodeMaterialConnectionPoint;
  57700. /**
  57701. * Gets the output component
  57702. */
  57703. readonly output: NodeMaterialConnectionPoint;
  57704. protected _buildBlock(state: NodeMaterialBuildState): this;
  57705. }
  57706. }
  57707. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  57708. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57709. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57710. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57711. /**
  57712. * Block used to add 2 vectors
  57713. */
  57714. export class AddBlock extends NodeMaterialBlock {
  57715. /**
  57716. * Creates a new AddBlock
  57717. * @param name defines the block name
  57718. */
  57719. constructor(name: string);
  57720. /**
  57721. * Gets the current class name
  57722. * @returns the class name
  57723. */
  57724. getClassName(): string;
  57725. /**
  57726. * Gets the left operand input component
  57727. */
  57728. readonly left: NodeMaterialConnectionPoint;
  57729. /**
  57730. * Gets the right operand input component
  57731. */
  57732. readonly right: NodeMaterialConnectionPoint;
  57733. /**
  57734. * Gets the output component
  57735. */
  57736. readonly output: NodeMaterialConnectionPoint;
  57737. protected _buildBlock(state: NodeMaterialBuildState): this;
  57738. }
  57739. }
  57740. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57741. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57742. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57743. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57744. /**
  57745. * Block used to scale a vector by a float
  57746. */
  57747. export class ScaleBlock extends NodeMaterialBlock {
  57748. /**
  57749. * Creates a new ScaleBlock
  57750. * @param name defines the block name
  57751. */
  57752. constructor(name: string);
  57753. /**
  57754. * Gets the current class name
  57755. * @returns the class name
  57756. */
  57757. getClassName(): string;
  57758. /**
  57759. * Gets the input component
  57760. */
  57761. readonly input: NodeMaterialConnectionPoint;
  57762. /**
  57763. * Gets the factor input component
  57764. */
  57765. readonly factor: NodeMaterialConnectionPoint;
  57766. /**
  57767. * Gets the output component
  57768. */
  57769. readonly output: NodeMaterialConnectionPoint;
  57770. protected _buildBlock(state: NodeMaterialBuildState): this;
  57771. }
  57772. }
  57773. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57774. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57775. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57776. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57777. import { Scene } from "babylonjs/scene";
  57778. /**
  57779. * Block used to clamp a float
  57780. */
  57781. export class ClampBlock extends NodeMaterialBlock {
  57782. /** Gets or sets the minimum range */
  57783. minimum: number;
  57784. /** Gets or sets the maximum range */
  57785. maximum: number;
  57786. /**
  57787. * Creates a new ClampBlock
  57788. * @param name defines the block name
  57789. */
  57790. constructor(name: string);
  57791. /**
  57792. * Gets the current class name
  57793. * @returns the class name
  57794. */
  57795. getClassName(): string;
  57796. /**
  57797. * Gets the value input component
  57798. */
  57799. readonly value: NodeMaterialConnectionPoint;
  57800. /**
  57801. * Gets the output component
  57802. */
  57803. readonly output: NodeMaterialConnectionPoint;
  57804. protected _buildBlock(state: NodeMaterialBuildState): this;
  57805. protected _dumpPropertiesCode(): string;
  57806. serialize(): any;
  57807. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57808. }
  57809. }
  57810. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57811. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57812. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57813. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57814. /**
  57815. * Block used to apply a cross product between 2 vectors
  57816. */
  57817. export class CrossBlock extends NodeMaterialBlock {
  57818. /**
  57819. * Creates a new CrossBlock
  57820. * @param name defines the block name
  57821. */
  57822. constructor(name: string);
  57823. /**
  57824. * Gets the current class name
  57825. * @returns the class name
  57826. */
  57827. getClassName(): string;
  57828. /**
  57829. * Gets the left operand input component
  57830. */
  57831. readonly left: NodeMaterialConnectionPoint;
  57832. /**
  57833. * Gets the right operand input component
  57834. */
  57835. readonly right: NodeMaterialConnectionPoint;
  57836. /**
  57837. * Gets the output component
  57838. */
  57839. readonly output: NodeMaterialConnectionPoint;
  57840. protected _buildBlock(state: NodeMaterialBuildState): this;
  57841. }
  57842. }
  57843. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57844. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57845. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57846. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57847. /**
  57848. * Block used to apply a dot product between 2 vectors
  57849. */
  57850. export class DotBlock extends NodeMaterialBlock {
  57851. /**
  57852. * Creates a new DotBlock
  57853. * @param name defines the block name
  57854. */
  57855. constructor(name: string);
  57856. /**
  57857. * Gets the current class name
  57858. * @returns the class name
  57859. */
  57860. getClassName(): string;
  57861. /**
  57862. * Gets the left operand input component
  57863. */
  57864. readonly left: NodeMaterialConnectionPoint;
  57865. /**
  57866. * Gets the right operand input component
  57867. */
  57868. readonly right: NodeMaterialConnectionPoint;
  57869. /**
  57870. * Gets the output component
  57871. */
  57872. readonly output: NodeMaterialConnectionPoint;
  57873. protected _buildBlock(state: NodeMaterialBuildState): this;
  57874. }
  57875. }
  57876. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57877. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57878. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57879. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57880. import { Vector2 } from "babylonjs/Maths/math.vector";
  57881. import { Scene } from "babylonjs/scene";
  57882. /**
  57883. * Block used to remap a float from a range to a new one
  57884. */
  57885. export class RemapBlock extends NodeMaterialBlock {
  57886. /**
  57887. * Gets or sets the source range
  57888. */
  57889. sourceRange: Vector2;
  57890. /**
  57891. * Gets or sets the target range
  57892. */
  57893. targetRange: Vector2;
  57894. /**
  57895. * Creates a new RemapBlock
  57896. * @param name defines the block name
  57897. */
  57898. constructor(name: string);
  57899. /**
  57900. * Gets the current class name
  57901. * @returns the class name
  57902. */
  57903. getClassName(): string;
  57904. /**
  57905. * Gets the input component
  57906. */
  57907. readonly input: NodeMaterialConnectionPoint;
  57908. /**
  57909. * Gets the source min input component
  57910. */
  57911. readonly sourceMin: NodeMaterialConnectionPoint;
  57912. /**
  57913. * Gets the source max input component
  57914. */
  57915. readonly sourceMax: NodeMaterialConnectionPoint;
  57916. /**
  57917. * Gets the target min input component
  57918. */
  57919. readonly targetMin: NodeMaterialConnectionPoint;
  57920. /**
  57921. * Gets the target max input component
  57922. */
  57923. readonly targetMax: NodeMaterialConnectionPoint;
  57924. /**
  57925. * Gets the output component
  57926. */
  57927. readonly output: NodeMaterialConnectionPoint;
  57928. protected _buildBlock(state: NodeMaterialBuildState): this;
  57929. protected _dumpPropertiesCode(): string;
  57930. serialize(): any;
  57931. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57932. }
  57933. }
  57934. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57935. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57936. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57937. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57938. /**
  57939. * Block used to normalize a vector
  57940. */
  57941. export class NormalizeBlock extends NodeMaterialBlock {
  57942. /**
  57943. * Creates a new NormalizeBlock
  57944. * @param name defines the block name
  57945. */
  57946. constructor(name: string);
  57947. /**
  57948. * Gets the current class name
  57949. * @returns the class name
  57950. */
  57951. getClassName(): string;
  57952. /**
  57953. * Gets the input component
  57954. */
  57955. readonly input: NodeMaterialConnectionPoint;
  57956. /**
  57957. * Gets the output component
  57958. */
  57959. readonly output: NodeMaterialConnectionPoint;
  57960. protected _buildBlock(state: NodeMaterialBuildState): this;
  57961. }
  57962. }
  57963. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57964. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57965. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57966. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57967. import { Scene } from "babylonjs/scene";
  57968. /**
  57969. * Operations supported by the Trigonometry block
  57970. */
  57971. export enum TrigonometryBlockOperations {
  57972. /** Cos */
  57973. Cos = 0,
  57974. /** Sin */
  57975. Sin = 1,
  57976. /** Abs */
  57977. Abs = 2,
  57978. /** Exp */
  57979. Exp = 3,
  57980. /** Exp2 */
  57981. Exp2 = 4,
  57982. /** Round */
  57983. Round = 5,
  57984. /** Floor */
  57985. Floor = 6,
  57986. /** Ceiling */
  57987. Ceiling = 7,
  57988. /** Square root */
  57989. Sqrt = 8,
  57990. /** Log */
  57991. Log = 9,
  57992. /** Tangent */
  57993. Tan = 10,
  57994. /** Arc tangent */
  57995. ArcTan = 11,
  57996. /** Arc cosinus */
  57997. ArcCos = 12,
  57998. /** Arc sinus */
  57999. ArcSin = 13,
  58000. /** Fraction */
  58001. Fract = 14,
  58002. /** Sign */
  58003. Sign = 15,
  58004. /** To radians (from degrees) */
  58005. Radians = 16,
  58006. /** To degrees (from radians) */
  58007. Degrees = 17
  58008. }
  58009. /**
  58010. * Block used to apply trigonometry operation to floats
  58011. */
  58012. export class TrigonometryBlock extends NodeMaterialBlock {
  58013. /**
  58014. * Gets or sets the operation applied by the block
  58015. */
  58016. operation: TrigonometryBlockOperations;
  58017. /**
  58018. * Creates a new TrigonometryBlock
  58019. * @param name defines the block name
  58020. */
  58021. constructor(name: string);
  58022. /**
  58023. * Gets the current class name
  58024. * @returns the class name
  58025. */
  58026. getClassName(): string;
  58027. /**
  58028. * Gets the input component
  58029. */
  58030. readonly input: NodeMaterialConnectionPoint;
  58031. /**
  58032. * Gets the output component
  58033. */
  58034. readonly output: NodeMaterialConnectionPoint;
  58035. protected _buildBlock(state: NodeMaterialBuildState): this;
  58036. serialize(): any;
  58037. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58038. }
  58039. }
  58040. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  58041. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58042. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58043. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58044. /**
  58045. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58046. */
  58047. export class ColorMergerBlock extends NodeMaterialBlock {
  58048. /**
  58049. * Create a new ColorMergerBlock
  58050. * @param name defines the block name
  58051. */
  58052. constructor(name: string);
  58053. /**
  58054. * Gets the current class name
  58055. * @returns the class name
  58056. */
  58057. getClassName(): string;
  58058. /**
  58059. * Gets the r component (input)
  58060. */
  58061. readonly r: NodeMaterialConnectionPoint;
  58062. /**
  58063. * Gets the g component (input)
  58064. */
  58065. readonly g: NodeMaterialConnectionPoint;
  58066. /**
  58067. * Gets the b component (input)
  58068. */
  58069. readonly b: NodeMaterialConnectionPoint;
  58070. /**
  58071. * Gets the a component (input)
  58072. */
  58073. readonly a: NodeMaterialConnectionPoint;
  58074. /**
  58075. * Gets the rgba component (output)
  58076. */
  58077. readonly rgba: NodeMaterialConnectionPoint;
  58078. /**
  58079. * Gets the rgb component (output)
  58080. */
  58081. readonly rgb: NodeMaterialConnectionPoint;
  58082. protected _buildBlock(state: NodeMaterialBuildState): this;
  58083. }
  58084. }
  58085. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  58086. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58087. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58088. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58089. /**
  58090. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58091. */
  58092. export class VectorMergerBlock extends NodeMaterialBlock {
  58093. /**
  58094. * Create a new VectorMergerBlock
  58095. * @param name defines the block name
  58096. */
  58097. constructor(name: string);
  58098. /**
  58099. * Gets the current class name
  58100. * @returns the class name
  58101. */
  58102. getClassName(): string;
  58103. /**
  58104. * Gets the x component (input)
  58105. */
  58106. readonly x: NodeMaterialConnectionPoint;
  58107. /**
  58108. * Gets the y component (input)
  58109. */
  58110. readonly y: NodeMaterialConnectionPoint;
  58111. /**
  58112. * Gets the z component (input)
  58113. */
  58114. readonly z: NodeMaterialConnectionPoint;
  58115. /**
  58116. * Gets the w component (input)
  58117. */
  58118. readonly w: NodeMaterialConnectionPoint;
  58119. /**
  58120. * Gets the xyzw component (output)
  58121. */
  58122. readonly xyzw: NodeMaterialConnectionPoint;
  58123. /**
  58124. * Gets the xyz component (output)
  58125. */
  58126. readonly xyz: NodeMaterialConnectionPoint;
  58127. /**
  58128. * Gets the xy component (output)
  58129. */
  58130. readonly xy: NodeMaterialConnectionPoint;
  58131. protected _buildBlock(state: NodeMaterialBuildState): this;
  58132. }
  58133. }
  58134. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  58135. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58136. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58137. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58138. /**
  58139. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  58140. */
  58141. export class ColorSplitterBlock extends NodeMaterialBlock {
  58142. /**
  58143. * Create a new ColorSplitterBlock
  58144. * @param name defines the block name
  58145. */
  58146. constructor(name: string);
  58147. /**
  58148. * Gets the current class name
  58149. * @returns the class name
  58150. */
  58151. getClassName(): string;
  58152. /**
  58153. * Gets the rgba component (input)
  58154. */
  58155. readonly rgba: NodeMaterialConnectionPoint;
  58156. /**
  58157. * Gets the rgb component (input)
  58158. */
  58159. readonly rgbIn: NodeMaterialConnectionPoint;
  58160. /**
  58161. * Gets the rgb component (output)
  58162. */
  58163. readonly rgbOut: NodeMaterialConnectionPoint;
  58164. /**
  58165. * Gets the r component (output)
  58166. */
  58167. readonly r: NodeMaterialConnectionPoint;
  58168. /**
  58169. * Gets the g component (output)
  58170. */
  58171. readonly g: NodeMaterialConnectionPoint;
  58172. /**
  58173. * Gets the b component (output)
  58174. */
  58175. readonly b: NodeMaterialConnectionPoint;
  58176. /**
  58177. * Gets the a component (output)
  58178. */
  58179. readonly a: NodeMaterialConnectionPoint;
  58180. protected _inputRename(name: string): string;
  58181. protected _outputRename(name: string): string;
  58182. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58183. }
  58184. }
  58185. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  58186. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58187. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58188. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58189. /**
  58190. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58191. */
  58192. export class VectorSplitterBlock extends NodeMaterialBlock {
  58193. /**
  58194. * Create a new VectorSplitterBlock
  58195. * @param name defines the block name
  58196. */
  58197. constructor(name: string);
  58198. /**
  58199. * Gets the current class name
  58200. * @returns the class name
  58201. */
  58202. getClassName(): string;
  58203. /**
  58204. * Gets the xyzw component (input)
  58205. */
  58206. readonly xyzw: NodeMaterialConnectionPoint;
  58207. /**
  58208. * Gets the xyz component (input)
  58209. */
  58210. readonly xyzIn: NodeMaterialConnectionPoint;
  58211. /**
  58212. * Gets the xy component (input)
  58213. */
  58214. readonly xyIn: NodeMaterialConnectionPoint;
  58215. /**
  58216. * Gets the xyz component (output)
  58217. */
  58218. readonly xyzOut: NodeMaterialConnectionPoint;
  58219. /**
  58220. * Gets the xy component (output)
  58221. */
  58222. readonly xyOut: NodeMaterialConnectionPoint;
  58223. /**
  58224. * Gets the x component (output)
  58225. */
  58226. readonly x: NodeMaterialConnectionPoint;
  58227. /**
  58228. * Gets the y component (output)
  58229. */
  58230. readonly y: NodeMaterialConnectionPoint;
  58231. /**
  58232. * Gets the z component (output)
  58233. */
  58234. readonly z: NodeMaterialConnectionPoint;
  58235. /**
  58236. * Gets the w component (output)
  58237. */
  58238. readonly w: NodeMaterialConnectionPoint;
  58239. protected _inputRename(name: string): string;
  58240. protected _outputRename(name: string): string;
  58241. protected _buildBlock(state: NodeMaterialBuildState): this;
  58242. }
  58243. }
  58244. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  58245. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58246. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58247. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58248. /**
  58249. * Block used to lerp between 2 values
  58250. */
  58251. export class LerpBlock extends NodeMaterialBlock {
  58252. /**
  58253. * Creates a new LerpBlock
  58254. * @param name defines the block name
  58255. */
  58256. constructor(name: string);
  58257. /**
  58258. * Gets the current class name
  58259. * @returns the class name
  58260. */
  58261. getClassName(): string;
  58262. /**
  58263. * Gets the left operand input component
  58264. */
  58265. readonly left: NodeMaterialConnectionPoint;
  58266. /**
  58267. * Gets the right operand input component
  58268. */
  58269. readonly right: NodeMaterialConnectionPoint;
  58270. /**
  58271. * Gets the gradient operand input component
  58272. */
  58273. readonly gradient: NodeMaterialConnectionPoint;
  58274. /**
  58275. * Gets the output component
  58276. */
  58277. readonly output: NodeMaterialConnectionPoint;
  58278. protected _buildBlock(state: NodeMaterialBuildState): this;
  58279. }
  58280. }
  58281. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  58282. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58283. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58284. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58285. /**
  58286. * Block used to divide 2 vectors
  58287. */
  58288. export class DivideBlock extends NodeMaterialBlock {
  58289. /**
  58290. * Creates a new DivideBlock
  58291. * @param name defines the block name
  58292. */
  58293. constructor(name: string);
  58294. /**
  58295. * Gets the current class name
  58296. * @returns the class name
  58297. */
  58298. getClassName(): string;
  58299. /**
  58300. * Gets the left operand input component
  58301. */
  58302. readonly left: NodeMaterialConnectionPoint;
  58303. /**
  58304. * Gets the right operand input component
  58305. */
  58306. readonly right: NodeMaterialConnectionPoint;
  58307. /**
  58308. * Gets the output component
  58309. */
  58310. readonly output: NodeMaterialConnectionPoint;
  58311. protected _buildBlock(state: NodeMaterialBuildState): this;
  58312. }
  58313. }
  58314. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  58315. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58316. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58317. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58318. /**
  58319. * Block used to subtract 2 vectors
  58320. */
  58321. export class SubtractBlock extends NodeMaterialBlock {
  58322. /**
  58323. * Creates a new SubtractBlock
  58324. * @param name defines the block name
  58325. */
  58326. constructor(name: string);
  58327. /**
  58328. * Gets the current class name
  58329. * @returns the class name
  58330. */
  58331. getClassName(): string;
  58332. /**
  58333. * Gets the left operand input component
  58334. */
  58335. readonly left: NodeMaterialConnectionPoint;
  58336. /**
  58337. * Gets the right operand input component
  58338. */
  58339. readonly right: NodeMaterialConnectionPoint;
  58340. /**
  58341. * Gets the output component
  58342. */
  58343. readonly output: NodeMaterialConnectionPoint;
  58344. protected _buildBlock(state: NodeMaterialBuildState): this;
  58345. }
  58346. }
  58347. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  58348. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58349. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58350. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58351. /**
  58352. * Block used to step a value
  58353. */
  58354. export class StepBlock extends NodeMaterialBlock {
  58355. /**
  58356. * Creates a new StepBlock
  58357. * @param name defines the block name
  58358. */
  58359. constructor(name: string);
  58360. /**
  58361. * Gets the current class name
  58362. * @returns the class name
  58363. */
  58364. getClassName(): string;
  58365. /**
  58366. * Gets the value operand input component
  58367. */
  58368. readonly value: NodeMaterialConnectionPoint;
  58369. /**
  58370. * Gets the edge operand input component
  58371. */
  58372. readonly edge: NodeMaterialConnectionPoint;
  58373. /**
  58374. * Gets the output component
  58375. */
  58376. readonly output: NodeMaterialConnectionPoint;
  58377. protected _buildBlock(state: NodeMaterialBuildState): this;
  58378. }
  58379. }
  58380. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  58381. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58382. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58383. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58384. /**
  58385. * Block used to get the opposite (1 - x) of a value
  58386. */
  58387. export class OneMinusBlock extends NodeMaterialBlock {
  58388. /**
  58389. * Creates a new OneMinusBlock
  58390. * @param name defines the block name
  58391. */
  58392. constructor(name: string);
  58393. /**
  58394. * Gets the current class name
  58395. * @returns the class name
  58396. */
  58397. getClassName(): string;
  58398. /**
  58399. * Gets the input component
  58400. */
  58401. readonly input: NodeMaterialConnectionPoint;
  58402. /**
  58403. * Gets the output component
  58404. */
  58405. readonly output: NodeMaterialConnectionPoint;
  58406. protected _buildBlock(state: NodeMaterialBuildState): this;
  58407. }
  58408. }
  58409. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  58410. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58411. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58412. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58413. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58414. /**
  58415. * Block used to get the view direction
  58416. */
  58417. export class ViewDirectionBlock extends NodeMaterialBlock {
  58418. /**
  58419. * Creates a new ViewDirectionBlock
  58420. * @param name defines the block name
  58421. */
  58422. constructor(name: string);
  58423. /**
  58424. * Gets the current class name
  58425. * @returns the class name
  58426. */
  58427. getClassName(): string;
  58428. /**
  58429. * Gets the world position component
  58430. */
  58431. readonly worldPosition: NodeMaterialConnectionPoint;
  58432. /**
  58433. * Gets the camera position component
  58434. */
  58435. readonly cameraPosition: NodeMaterialConnectionPoint;
  58436. /**
  58437. * Gets the output component
  58438. */
  58439. readonly output: NodeMaterialConnectionPoint;
  58440. autoConfigure(material: NodeMaterial): void;
  58441. protected _buildBlock(state: NodeMaterialBuildState): this;
  58442. }
  58443. }
  58444. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  58445. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58446. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58447. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58448. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58449. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  58450. /**
  58451. * Block used to compute fresnel value
  58452. */
  58453. export class FresnelBlock extends NodeMaterialBlock {
  58454. /**
  58455. * Create a new FresnelBlock
  58456. * @param name defines the block name
  58457. */
  58458. constructor(name: string);
  58459. /**
  58460. * Gets the current class name
  58461. * @returns the class name
  58462. */
  58463. getClassName(): string;
  58464. /**
  58465. * Gets the world normal input component
  58466. */
  58467. readonly worldNormal: NodeMaterialConnectionPoint;
  58468. /**
  58469. * Gets the view direction input component
  58470. */
  58471. readonly viewDirection: NodeMaterialConnectionPoint;
  58472. /**
  58473. * Gets the bias input component
  58474. */
  58475. readonly bias: NodeMaterialConnectionPoint;
  58476. /**
  58477. * Gets the camera (or eye) position component
  58478. */
  58479. readonly power: NodeMaterialConnectionPoint;
  58480. /**
  58481. * Gets the fresnel output component
  58482. */
  58483. readonly fresnel: NodeMaterialConnectionPoint;
  58484. autoConfigure(material: NodeMaterial): void;
  58485. protected _buildBlock(state: NodeMaterialBuildState): this;
  58486. }
  58487. }
  58488. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  58489. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58490. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58491. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58492. /**
  58493. * Block used to get the max of 2 values
  58494. */
  58495. export class MaxBlock extends NodeMaterialBlock {
  58496. /**
  58497. * Creates a new MaxBlock
  58498. * @param name defines the block name
  58499. */
  58500. constructor(name: string);
  58501. /**
  58502. * Gets the current class name
  58503. * @returns the class name
  58504. */
  58505. getClassName(): string;
  58506. /**
  58507. * Gets the left operand input component
  58508. */
  58509. readonly left: NodeMaterialConnectionPoint;
  58510. /**
  58511. * Gets the right operand input component
  58512. */
  58513. readonly right: NodeMaterialConnectionPoint;
  58514. /**
  58515. * Gets the output component
  58516. */
  58517. readonly output: NodeMaterialConnectionPoint;
  58518. protected _buildBlock(state: NodeMaterialBuildState): this;
  58519. }
  58520. }
  58521. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  58522. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58523. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58524. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58525. /**
  58526. * Block used to get the min of 2 values
  58527. */
  58528. export class MinBlock extends NodeMaterialBlock {
  58529. /**
  58530. * Creates a new MinBlock
  58531. * @param name defines the block name
  58532. */
  58533. constructor(name: string);
  58534. /**
  58535. * Gets the current class name
  58536. * @returns the class name
  58537. */
  58538. getClassName(): string;
  58539. /**
  58540. * Gets the left operand input component
  58541. */
  58542. readonly left: NodeMaterialConnectionPoint;
  58543. /**
  58544. * Gets the right operand input component
  58545. */
  58546. readonly right: NodeMaterialConnectionPoint;
  58547. /**
  58548. * Gets the output component
  58549. */
  58550. readonly output: NodeMaterialConnectionPoint;
  58551. protected _buildBlock(state: NodeMaterialBuildState): this;
  58552. }
  58553. }
  58554. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  58555. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58556. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58557. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58558. /**
  58559. * Block used to get the distance between 2 values
  58560. */
  58561. export class DistanceBlock extends NodeMaterialBlock {
  58562. /**
  58563. * Creates a new DistanceBlock
  58564. * @param name defines the block name
  58565. */
  58566. constructor(name: string);
  58567. /**
  58568. * Gets the current class name
  58569. * @returns the class name
  58570. */
  58571. getClassName(): string;
  58572. /**
  58573. * Gets the left operand input component
  58574. */
  58575. readonly left: NodeMaterialConnectionPoint;
  58576. /**
  58577. * Gets the right operand input component
  58578. */
  58579. readonly right: NodeMaterialConnectionPoint;
  58580. /**
  58581. * Gets the output component
  58582. */
  58583. readonly output: NodeMaterialConnectionPoint;
  58584. protected _buildBlock(state: NodeMaterialBuildState): this;
  58585. }
  58586. }
  58587. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  58588. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58589. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58590. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58591. /**
  58592. * Block used to get the length of a vector
  58593. */
  58594. export class LengthBlock extends NodeMaterialBlock {
  58595. /**
  58596. * Creates a new LengthBlock
  58597. * @param name defines the block name
  58598. */
  58599. constructor(name: string);
  58600. /**
  58601. * Gets the current class name
  58602. * @returns the class name
  58603. */
  58604. getClassName(): string;
  58605. /**
  58606. * Gets the value input component
  58607. */
  58608. readonly value: NodeMaterialConnectionPoint;
  58609. /**
  58610. * Gets the output component
  58611. */
  58612. readonly output: NodeMaterialConnectionPoint;
  58613. protected _buildBlock(state: NodeMaterialBuildState): this;
  58614. }
  58615. }
  58616. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  58617. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58618. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58619. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58620. /**
  58621. * Block used to get negative version of a value (i.e. x * -1)
  58622. */
  58623. export class NegateBlock extends NodeMaterialBlock {
  58624. /**
  58625. * Creates a new NegateBlock
  58626. * @param name defines the block name
  58627. */
  58628. constructor(name: string);
  58629. /**
  58630. * Gets the current class name
  58631. * @returns the class name
  58632. */
  58633. getClassName(): string;
  58634. /**
  58635. * Gets the value input component
  58636. */
  58637. readonly value: NodeMaterialConnectionPoint;
  58638. /**
  58639. * Gets the output component
  58640. */
  58641. readonly output: NodeMaterialConnectionPoint;
  58642. protected _buildBlock(state: NodeMaterialBuildState): this;
  58643. }
  58644. }
  58645. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  58646. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58647. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58648. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58649. /**
  58650. * Block used to get the value of the first parameter raised to the power of the second
  58651. */
  58652. export class PowBlock extends NodeMaterialBlock {
  58653. /**
  58654. * Creates a new PowBlock
  58655. * @param name defines the block name
  58656. */
  58657. constructor(name: string);
  58658. /**
  58659. * Gets the current class name
  58660. * @returns the class name
  58661. */
  58662. getClassName(): string;
  58663. /**
  58664. * Gets the value operand input component
  58665. */
  58666. readonly value: NodeMaterialConnectionPoint;
  58667. /**
  58668. * Gets the power operand input component
  58669. */
  58670. readonly power: NodeMaterialConnectionPoint;
  58671. /**
  58672. * Gets the output component
  58673. */
  58674. readonly output: NodeMaterialConnectionPoint;
  58675. protected _buildBlock(state: NodeMaterialBuildState): this;
  58676. }
  58677. }
  58678. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  58679. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58680. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58682. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58683. /**
  58684. * Block used to get a random number
  58685. */
  58686. export class RandomNumberBlock extends NodeMaterialBlock {
  58687. /**
  58688. * Creates a new RandomNumberBlock
  58689. * @param name defines the block name
  58690. */
  58691. constructor(name: string);
  58692. /**
  58693. * Gets the current class name
  58694. * @returns the class name
  58695. */
  58696. getClassName(): string;
  58697. /**
  58698. * Gets the seed input component
  58699. */
  58700. readonly seed: NodeMaterialConnectionPoint;
  58701. /**
  58702. * Gets the output component
  58703. */
  58704. readonly output: NodeMaterialConnectionPoint;
  58705. protected _buildBlock(state: NodeMaterialBuildState): this;
  58706. }
  58707. }
  58708. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  58709. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58710. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58711. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58712. /**
  58713. * Block used to compute arc tangent of 2 values
  58714. */
  58715. export class ArcTan2Block extends NodeMaterialBlock {
  58716. /**
  58717. * Creates a new ArcTan2Block
  58718. * @param name defines the block name
  58719. */
  58720. constructor(name: string);
  58721. /**
  58722. * Gets the current class name
  58723. * @returns the class name
  58724. */
  58725. getClassName(): string;
  58726. /**
  58727. * Gets the x operand input component
  58728. */
  58729. readonly x: NodeMaterialConnectionPoint;
  58730. /**
  58731. * Gets the y operand input component
  58732. */
  58733. readonly y: NodeMaterialConnectionPoint;
  58734. /**
  58735. * Gets the output component
  58736. */
  58737. readonly output: NodeMaterialConnectionPoint;
  58738. protected _buildBlock(state: NodeMaterialBuildState): this;
  58739. }
  58740. }
  58741. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58742. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58743. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58744. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58745. /**
  58746. * Block used to smooth step a value
  58747. */
  58748. export class SmoothStepBlock extends NodeMaterialBlock {
  58749. /**
  58750. * Creates a new SmoothStepBlock
  58751. * @param name defines the block name
  58752. */
  58753. constructor(name: string);
  58754. /**
  58755. * Gets the current class name
  58756. * @returns the class name
  58757. */
  58758. getClassName(): string;
  58759. /**
  58760. * Gets the value operand input component
  58761. */
  58762. readonly value: NodeMaterialConnectionPoint;
  58763. /**
  58764. * Gets the first edge operand input component
  58765. */
  58766. readonly edge0: NodeMaterialConnectionPoint;
  58767. /**
  58768. * Gets the second edge operand input component
  58769. */
  58770. readonly edge1: NodeMaterialConnectionPoint;
  58771. /**
  58772. * Gets the output component
  58773. */
  58774. readonly output: NodeMaterialConnectionPoint;
  58775. protected _buildBlock(state: NodeMaterialBuildState): this;
  58776. }
  58777. }
  58778. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58779. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58780. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58781. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58782. /**
  58783. * Block used to get the reciprocal (1 / x) of a value
  58784. */
  58785. export class ReciprocalBlock extends NodeMaterialBlock {
  58786. /**
  58787. * Creates a new ReciprocalBlock
  58788. * @param name defines the block name
  58789. */
  58790. constructor(name: string);
  58791. /**
  58792. * Gets the current class name
  58793. * @returns the class name
  58794. */
  58795. getClassName(): string;
  58796. /**
  58797. * Gets the input component
  58798. */
  58799. readonly input: NodeMaterialConnectionPoint;
  58800. /**
  58801. * Gets the output component
  58802. */
  58803. readonly output: NodeMaterialConnectionPoint;
  58804. protected _buildBlock(state: NodeMaterialBuildState): this;
  58805. }
  58806. }
  58807. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58808. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58809. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58810. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58811. /**
  58812. * Block used to replace a color by another one
  58813. */
  58814. export class ReplaceColorBlock extends NodeMaterialBlock {
  58815. /**
  58816. * Creates a new ReplaceColorBlock
  58817. * @param name defines the block name
  58818. */
  58819. constructor(name: string);
  58820. /**
  58821. * Gets the current class name
  58822. * @returns the class name
  58823. */
  58824. getClassName(): string;
  58825. /**
  58826. * Gets the value input component
  58827. */
  58828. readonly value: NodeMaterialConnectionPoint;
  58829. /**
  58830. * Gets the reference input component
  58831. */
  58832. readonly reference: NodeMaterialConnectionPoint;
  58833. /**
  58834. * Gets the distance input component
  58835. */
  58836. readonly distance: NodeMaterialConnectionPoint;
  58837. /**
  58838. * Gets the replacement input component
  58839. */
  58840. readonly replacement: NodeMaterialConnectionPoint;
  58841. /**
  58842. * Gets the output component
  58843. */
  58844. readonly output: NodeMaterialConnectionPoint;
  58845. protected _buildBlock(state: NodeMaterialBuildState): this;
  58846. }
  58847. }
  58848. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58849. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58850. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58851. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58852. /**
  58853. * Block used to posterize a value
  58854. * @see https://en.wikipedia.org/wiki/Posterization
  58855. */
  58856. export class PosterizeBlock extends NodeMaterialBlock {
  58857. /**
  58858. * Creates a new PosterizeBlock
  58859. * @param name defines the block name
  58860. */
  58861. constructor(name: string);
  58862. /**
  58863. * Gets the current class name
  58864. * @returns the class name
  58865. */
  58866. getClassName(): string;
  58867. /**
  58868. * Gets the value input component
  58869. */
  58870. readonly value: NodeMaterialConnectionPoint;
  58871. /**
  58872. * Gets the steps input component
  58873. */
  58874. readonly steps: NodeMaterialConnectionPoint;
  58875. /**
  58876. * Gets the output component
  58877. */
  58878. readonly output: NodeMaterialConnectionPoint;
  58879. protected _buildBlock(state: NodeMaterialBuildState): this;
  58880. }
  58881. }
  58882. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58883. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58884. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58885. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58886. import { Scene } from "babylonjs/scene";
  58887. /**
  58888. * Operations supported by the Wave block
  58889. */
  58890. export enum WaveBlockKind {
  58891. /** SawTooth */
  58892. SawTooth = 0,
  58893. /** Square */
  58894. Square = 1,
  58895. /** Triangle */
  58896. Triangle = 2
  58897. }
  58898. /**
  58899. * Block used to apply wave operation to floats
  58900. */
  58901. export class WaveBlock extends NodeMaterialBlock {
  58902. /**
  58903. * Gets or sets the kibnd of wave to be applied by the block
  58904. */
  58905. kind: WaveBlockKind;
  58906. /**
  58907. * Creates a new WaveBlock
  58908. * @param name defines the block name
  58909. */
  58910. constructor(name: string);
  58911. /**
  58912. * Gets the current class name
  58913. * @returns the class name
  58914. */
  58915. getClassName(): string;
  58916. /**
  58917. * Gets the input component
  58918. */
  58919. readonly input: NodeMaterialConnectionPoint;
  58920. /**
  58921. * Gets the output component
  58922. */
  58923. readonly output: NodeMaterialConnectionPoint;
  58924. protected _buildBlock(state: NodeMaterialBuildState): this;
  58925. serialize(): any;
  58926. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58927. }
  58928. }
  58929. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58930. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58931. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58932. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58933. import { Color3 } from "babylonjs/Maths/math.color";
  58934. import { Scene } from "babylonjs/scene";
  58935. /**
  58936. * Class used to store a color step for the GradientBlock
  58937. */
  58938. export class GradientBlockColorStep {
  58939. /**
  58940. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58941. */
  58942. step: number;
  58943. /**
  58944. * Gets or sets the color associated with this step
  58945. */
  58946. color: Color3;
  58947. /**
  58948. * Creates a new GradientBlockColorStep
  58949. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58950. * @param color defines the color associated with this step
  58951. */
  58952. constructor(
  58953. /**
  58954. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58955. */
  58956. step: number,
  58957. /**
  58958. * Gets or sets the color associated with this step
  58959. */
  58960. color: Color3);
  58961. }
  58962. /**
  58963. * Block used to return a color from a gradient based on an input value between 0 and 1
  58964. */
  58965. export class GradientBlock extends NodeMaterialBlock {
  58966. /**
  58967. * Gets or sets the list of color steps
  58968. */
  58969. colorSteps: GradientBlockColorStep[];
  58970. /**
  58971. * Creates a new GradientBlock
  58972. * @param name defines the block name
  58973. */
  58974. constructor(name: string);
  58975. /**
  58976. * Gets the current class name
  58977. * @returns the class name
  58978. */
  58979. getClassName(): string;
  58980. /**
  58981. * Gets the gradient input component
  58982. */
  58983. readonly gradient: NodeMaterialConnectionPoint;
  58984. /**
  58985. * Gets the output component
  58986. */
  58987. readonly output: NodeMaterialConnectionPoint;
  58988. private _writeColorConstant;
  58989. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58990. serialize(): any;
  58991. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58992. protected _dumpPropertiesCode(): string;
  58993. }
  58994. }
  58995. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58996. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58997. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58998. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58999. /**
  59000. * Block used to normalize lerp between 2 values
  59001. */
  59002. export class NLerpBlock extends NodeMaterialBlock {
  59003. /**
  59004. * Creates a new NLerpBlock
  59005. * @param name defines the block name
  59006. */
  59007. constructor(name: string);
  59008. /**
  59009. * Gets the current class name
  59010. * @returns the class name
  59011. */
  59012. getClassName(): string;
  59013. /**
  59014. * Gets the left operand input component
  59015. */
  59016. readonly left: NodeMaterialConnectionPoint;
  59017. /**
  59018. * Gets the right operand input component
  59019. */
  59020. readonly right: NodeMaterialConnectionPoint;
  59021. /**
  59022. * Gets the gradient operand input component
  59023. */
  59024. readonly gradient: NodeMaterialConnectionPoint;
  59025. /**
  59026. * Gets the output component
  59027. */
  59028. readonly output: NodeMaterialConnectionPoint;
  59029. protected _buildBlock(state: NodeMaterialBuildState): this;
  59030. }
  59031. }
  59032. declare module "babylonjs/Materials/Node/Blocks/index" {
  59033. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  59034. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  59035. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  59036. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  59037. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  59038. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  59039. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  59040. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  59041. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  59042. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  59043. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  59044. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  59045. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  59046. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  59047. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  59048. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  59049. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  59050. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  59051. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  59052. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  59053. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  59054. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  59055. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  59056. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  59057. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  59058. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  59059. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  59060. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  59061. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  59062. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  59063. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  59064. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  59065. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  59066. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  59067. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  59068. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  59069. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  59070. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  59071. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  59072. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  59073. }
  59074. declare module "babylonjs/Materials/Node/Optimizers/index" {
  59075. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59076. }
  59077. declare module "babylonjs/Materials/Node/index" {
  59078. export * from "babylonjs/Materials/Node/Enums/index";
  59079. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59080. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  59081. export * from "babylonjs/Materials/Node/nodeMaterial";
  59082. export * from "babylonjs/Materials/Node/Blocks/index";
  59083. export * from "babylonjs/Materials/Node/Optimizers/index";
  59084. }
  59085. declare module "babylonjs/Materials/effectRenderer" {
  59086. import { Nullable } from "babylonjs/types";
  59087. import { Texture } from "babylonjs/Materials/Textures/texture";
  59088. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59089. import { Viewport } from "babylonjs/Maths/math.viewport";
  59090. import { Observable } from "babylonjs/Misc/observable";
  59091. import { Effect } from "babylonjs/Materials/effect";
  59092. import "babylonjs/Engines/Extensions/engine.renderTarget";
  59093. import "babylonjs/Shaders/postprocess.vertex";
  59094. /**
  59095. * Effect Render Options
  59096. */
  59097. export interface IEffectRendererOptions {
  59098. /**
  59099. * Defines the vertices positions.
  59100. */
  59101. positions?: number[];
  59102. /**
  59103. * Defines the indices.
  59104. */
  59105. indices?: number[];
  59106. }
  59107. /**
  59108. * Helper class to render one or more effects
  59109. */
  59110. export class EffectRenderer {
  59111. private engine;
  59112. private static _DefaultOptions;
  59113. private _vertexBuffers;
  59114. private _indexBuffer;
  59115. private _ringBufferIndex;
  59116. private _ringScreenBuffer;
  59117. private _fullscreenViewport;
  59118. private _getNextFrameBuffer;
  59119. /**
  59120. * Creates an effect renderer
  59121. * @param engine the engine to use for rendering
  59122. * @param options defines the options of the effect renderer
  59123. */
  59124. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59125. /**
  59126. * Sets the current viewport in normalized coordinates 0-1
  59127. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59128. */
  59129. setViewport(viewport?: Viewport): void;
  59130. /**
  59131. * Binds the embedded attributes buffer to the effect.
  59132. * @param effect Defines the effect to bind the attributes for
  59133. */
  59134. bindBuffers(effect: Effect): void;
  59135. /**
  59136. * Sets the current effect wrapper to use during draw.
  59137. * The effect needs to be ready before calling this api.
  59138. * This also sets the default full screen position attribute.
  59139. * @param effectWrapper Defines the effect to draw with
  59140. */
  59141. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59142. /**
  59143. * Draws a full screen quad.
  59144. */
  59145. draw(): void;
  59146. /**
  59147. * renders one or more effects to a specified texture
  59148. * @param effectWrappers list of effects to renderer
  59149. * @param outputTexture texture to draw to, if null it will render to the screen
  59150. */
  59151. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  59152. /**
  59153. * Disposes of the effect renderer
  59154. */
  59155. dispose(): void;
  59156. }
  59157. /**
  59158. * Options to create an EffectWrapper
  59159. */
  59160. interface EffectWrapperCreationOptions {
  59161. /**
  59162. * Engine to use to create the effect
  59163. */
  59164. engine: ThinEngine;
  59165. /**
  59166. * Fragment shader for the effect
  59167. */
  59168. fragmentShader: string;
  59169. /**
  59170. * Vertex shader for the effect
  59171. */
  59172. vertexShader?: string;
  59173. /**
  59174. * Attributes to use in the shader
  59175. */
  59176. attributeNames?: Array<string>;
  59177. /**
  59178. * Uniforms to use in the shader
  59179. */
  59180. uniformNames?: Array<string>;
  59181. /**
  59182. * Texture sampler names to use in the shader
  59183. */
  59184. samplerNames?: Array<string>;
  59185. /**
  59186. * The friendly name of the effect displayed in Spector.
  59187. */
  59188. name?: string;
  59189. }
  59190. /**
  59191. * Wraps an effect to be used for rendering
  59192. */
  59193. export class EffectWrapper {
  59194. /**
  59195. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59196. */
  59197. onApplyObservable: Observable<{}>;
  59198. /**
  59199. * The underlying effect
  59200. */
  59201. effect: Effect;
  59202. /**
  59203. * Creates an effect to be renderer
  59204. * @param creationOptions options to create the effect
  59205. */
  59206. constructor(creationOptions: EffectWrapperCreationOptions);
  59207. /**
  59208. * Disposes of the effect wrapper
  59209. */
  59210. dispose(): void;
  59211. }
  59212. }
  59213. declare module "babylonjs/Materials/index" {
  59214. export * from "babylonjs/Materials/Background/index";
  59215. export * from "babylonjs/Materials/colorCurves";
  59216. export * from "babylonjs/Materials/iEffectFallbacks";
  59217. export * from "babylonjs/Materials/effectFallbacks";
  59218. export * from "babylonjs/Materials/effect";
  59219. export * from "babylonjs/Materials/fresnelParameters";
  59220. export * from "babylonjs/Materials/imageProcessingConfiguration";
  59221. export * from "babylonjs/Materials/material";
  59222. export * from "babylonjs/Materials/materialDefines";
  59223. export * from "babylonjs/Materials/materialHelper";
  59224. export * from "babylonjs/Materials/multiMaterial";
  59225. export * from "babylonjs/Materials/PBR/index";
  59226. export * from "babylonjs/Materials/pushMaterial";
  59227. export * from "babylonjs/Materials/shaderMaterial";
  59228. export * from "babylonjs/Materials/standardMaterial";
  59229. export * from "babylonjs/Materials/Textures/index";
  59230. export * from "babylonjs/Materials/uniformBuffer";
  59231. export * from "babylonjs/Materials/materialFlags";
  59232. export * from "babylonjs/Materials/Node/index";
  59233. export * from "babylonjs/Materials/effectRenderer";
  59234. }
  59235. declare module "babylonjs/Maths/index" {
  59236. export * from "babylonjs/Maths/math.scalar";
  59237. export * from "babylonjs/Maths/math";
  59238. export * from "babylonjs/Maths/sphericalPolynomial";
  59239. }
  59240. declare module "babylonjs/Misc/workerPool" {
  59241. import { IDisposable } from "babylonjs/scene";
  59242. /**
  59243. * Helper class to push actions to a pool of workers.
  59244. */
  59245. export class WorkerPool implements IDisposable {
  59246. private _workerInfos;
  59247. private _pendingActions;
  59248. /**
  59249. * Constructor
  59250. * @param workers Array of workers to use for actions
  59251. */
  59252. constructor(workers: Array<Worker>);
  59253. /**
  59254. * Terminates all workers and clears any pending actions.
  59255. */
  59256. dispose(): void;
  59257. /**
  59258. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59259. * pended until a worker has completed its action.
  59260. * @param action The action to perform. Call onComplete when the action is complete.
  59261. */
  59262. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59263. private _execute;
  59264. }
  59265. }
  59266. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  59267. import { IDisposable } from "babylonjs/scene";
  59268. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59269. /**
  59270. * Configuration for Draco compression
  59271. */
  59272. export interface IDracoCompressionConfiguration {
  59273. /**
  59274. * Configuration for the decoder.
  59275. */
  59276. decoder: {
  59277. /**
  59278. * The url to the WebAssembly module.
  59279. */
  59280. wasmUrl?: string;
  59281. /**
  59282. * The url to the WebAssembly binary.
  59283. */
  59284. wasmBinaryUrl?: string;
  59285. /**
  59286. * The url to the fallback JavaScript module.
  59287. */
  59288. fallbackUrl?: string;
  59289. };
  59290. }
  59291. /**
  59292. * Draco compression (https://google.github.io/draco/)
  59293. *
  59294. * This class wraps the Draco module.
  59295. *
  59296. * **Encoder**
  59297. *
  59298. * The encoder is not currently implemented.
  59299. *
  59300. * **Decoder**
  59301. *
  59302. * 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.
  59303. *
  59304. * To update the configuration, use the following code:
  59305. * ```javascript
  59306. * DracoCompression.Configuration = {
  59307. * decoder: {
  59308. * wasmUrl: "<url to the WebAssembly library>",
  59309. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  59310. * fallbackUrl: "<url to the fallback JavaScript library>",
  59311. * }
  59312. * };
  59313. * ```
  59314. *
  59315. * 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.
  59316. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  59317. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  59318. *
  59319. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  59320. * ```javascript
  59321. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  59322. * ```
  59323. *
  59324. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  59325. */
  59326. export class DracoCompression implements IDisposable {
  59327. private _workerPoolPromise?;
  59328. private _decoderModulePromise?;
  59329. /**
  59330. * The configuration. Defaults to the following urls:
  59331. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  59332. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  59333. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  59334. */
  59335. static Configuration: IDracoCompressionConfiguration;
  59336. /**
  59337. * Returns true if the decoder configuration is available.
  59338. */
  59339. static readonly DecoderAvailable: boolean;
  59340. /**
  59341. * Default number of workers to create when creating the draco compression object.
  59342. */
  59343. static DefaultNumWorkers: number;
  59344. private static GetDefaultNumWorkers;
  59345. private static _Default;
  59346. /**
  59347. * Default instance for the draco compression object.
  59348. */
  59349. static readonly Default: DracoCompression;
  59350. /**
  59351. * Constructor
  59352. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59353. */
  59354. constructor(numWorkers?: number);
  59355. /**
  59356. * Stop all async operations and release resources.
  59357. */
  59358. dispose(): void;
  59359. /**
  59360. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  59361. * @returns a promise that resolves when ready
  59362. */
  59363. whenReadyAsync(): Promise<void>;
  59364. /**
  59365. * Decode Draco compressed mesh data to vertex data.
  59366. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  59367. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  59368. * @returns A promise that resolves with the decoded vertex data
  59369. */
  59370. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  59371. [kind: string]: number;
  59372. }): Promise<VertexData>;
  59373. }
  59374. }
  59375. declare module "babylonjs/Meshes/Compression/index" {
  59376. export * from "babylonjs/Meshes/Compression/dracoCompression";
  59377. }
  59378. declare module "babylonjs/Meshes/csg" {
  59379. import { Nullable } from "babylonjs/types";
  59380. import { Scene } from "babylonjs/scene";
  59381. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59382. import { Mesh } from "babylonjs/Meshes/mesh";
  59383. import { Material } from "babylonjs/Materials/material";
  59384. /**
  59385. * Class for building Constructive Solid Geometry
  59386. */
  59387. export class CSG {
  59388. private polygons;
  59389. /**
  59390. * The world matrix
  59391. */
  59392. matrix: Matrix;
  59393. /**
  59394. * Stores the position
  59395. */
  59396. position: Vector3;
  59397. /**
  59398. * Stores the rotation
  59399. */
  59400. rotation: Vector3;
  59401. /**
  59402. * Stores the rotation quaternion
  59403. */
  59404. rotationQuaternion: Nullable<Quaternion>;
  59405. /**
  59406. * Stores the scaling vector
  59407. */
  59408. scaling: Vector3;
  59409. /**
  59410. * Convert the Mesh to CSG
  59411. * @param mesh The Mesh to convert to CSG
  59412. * @returns A new CSG from the Mesh
  59413. */
  59414. static FromMesh(mesh: Mesh): CSG;
  59415. /**
  59416. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  59417. * @param polygons Polygons used to construct a CSG solid
  59418. */
  59419. private static FromPolygons;
  59420. /**
  59421. * Clones, or makes a deep copy, of the CSG
  59422. * @returns A new CSG
  59423. */
  59424. clone(): CSG;
  59425. /**
  59426. * Unions this CSG with another CSG
  59427. * @param csg The CSG to union against this CSG
  59428. * @returns The unioned CSG
  59429. */
  59430. union(csg: CSG): CSG;
  59431. /**
  59432. * Unions this CSG with another CSG in place
  59433. * @param csg The CSG to union against this CSG
  59434. */
  59435. unionInPlace(csg: CSG): void;
  59436. /**
  59437. * Subtracts this CSG with another CSG
  59438. * @param csg The CSG to subtract against this CSG
  59439. * @returns A new CSG
  59440. */
  59441. subtract(csg: CSG): CSG;
  59442. /**
  59443. * Subtracts this CSG with another CSG in place
  59444. * @param csg The CSG to subtact against this CSG
  59445. */
  59446. subtractInPlace(csg: CSG): void;
  59447. /**
  59448. * Intersect this CSG with another CSG
  59449. * @param csg The CSG to intersect against this CSG
  59450. * @returns A new CSG
  59451. */
  59452. intersect(csg: CSG): CSG;
  59453. /**
  59454. * Intersects this CSG with another CSG in place
  59455. * @param csg The CSG to intersect against this CSG
  59456. */
  59457. intersectInPlace(csg: CSG): void;
  59458. /**
  59459. * Return a new CSG solid with solid and empty space switched. This solid is
  59460. * not modified.
  59461. * @returns A new CSG solid with solid and empty space switched
  59462. */
  59463. inverse(): CSG;
  59464. /**
  59465. * Inverses the CSG in place
  59466. */
  59467. inverseInPlace(): void;
  59468. /**
  59469. * This is used to keep meshes transformations so they can be restored
  59470. * when we build back a Babylon Mesh
  59471. * NB : All CSG operations are performed in world coordinates
  59472. * @param csg The CSG to copy the transform attributes from
  59473. * @returns This CSG
  59474. */
  59475. copyTransformAttributes(csg: CSG): CSG;
  59476. /**
  59477. * Build Raw mesh from CSG
  59478. * Coordinates here are in world space
  59479. * @param name The name of the mesh geometry
  59480. * @param scene The Scene
  59481. * @param keepSubMeshes Specifies if the submeshes should be kept
  59482. * @returns A new Mesh
  59483. */
  59484. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59485. /**
  59486. * Build Mesh from CSG taking material and transforms into account
  59487. * @param name The name of the Mesh
  59488. * @param material The material of the Mesh
  59489. * @param scene The Scene
  59490. * @param keepSubMeshes Specifies if submeshes should be kept
  59491. * @returns The new Mesh
  59492. */
  59493. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59494. }
  59495. }
  59496. declare module "babylonjs/Meshes/trailMesh" {
  59497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59498. import { Mesh } from "babylonjs/Meshes/mesh";
  59499. import { Scene } from "babylonjs/scene";
  59500. /**
  59501. * Class used to create a trail following a mesh
  59502. */
  59503. export class TrailMesh extends Mesh {
  59504. private _generator;
  59505. private _autoStart;
  59506. private _running;
  59507. private _diameter;
  59508. private _length;
  59509. private _sectionPolygonPointsCount;
  59510. private _sectionVectors;
  59511. private _sectionNormalVectors;
  59512. private _beforeRenderObserver;
  59513. /**
  59514. * @constructor
  59515. * @param name The value used by scene.getMeshByName() to do a lookup.
  59516. * @param generator The mesh to generate a trail.
  59517. * @param scene The scene to add this mesh to.
  59518. * @param diameter Diameter of trailing mesh. Default is 1.
  59519. * @param length Length of trailing mesh. Default is 60.
  59520. * @param autoStart Automatically start trailing mesh. Default true.
  59521. */
  59522. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  59523. /**
  59524. * "TrailMesh"
  59525. * @returns "TrailMesh"
  59526. */
  59527. getClassName(): string;
  59528. private _createMesh;
  59529. /**
  59530. * Start trailing mesh.
  59531. */
  59532. start(): void;
  59533. /**
  59534. * Stop trailing mesh.
  59535. */
  59536. stop(): void;
  59537. /**
  59538. * Update trailing mesh geometry.
  59539. */
  59540. update(): void;
  59541. /**
  59542. * Returns a new TrailMesh object.
  59543. * @param name is a string, the name given to the new mesh
  59544. * @param newGenerator use new generator object for cloned trail mesh
  59545. * @returns a new mesh
  59546. */
  59547. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  59548. /**
  59549. * Serializes this trail mesh
  59550. * @param serializationObject object to write serialization to
  59551. */
  59552. serialize(serializationObject: any): void;
  59553. /**
  59554. * Parses a serialized trail mesh
  59555. * @param parsedMesh the serialized mesh
  59556. * @param scene the scene to create the trail mesh in
  59557. * @returns the created trail mesh
  59558. */
  59559. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  59560. }
  59561. }
  59562. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  59563. import { Nullable } from "babylonjs/types";
  59564. import { Scene } from "babylonjs/scene";
  59565. import { Vector4 } from "babylonjs/Maths/math.vector";
  59566. import { Color4 } from "babylonjs/Maths/math.color";
  59567. import { Mesh } from "babylonjs/Meshes/mesh";
  59568. /**
  59569. * Class containing static functions to help procedurally build meshes
  59570. */
  59571. export class TiledBoxBuilder {
  59572. /**
  59573. * Creates a box mesh
  59574. * 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)
  59575. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59577. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59579. * @param name defines the name of the mesh
  59580. * @param options defines the options used to create the mesh
  59581. * @param scene defines the hosting scene
  59582. * @returns the box mesh
  59583. */
  59584. static CreateTiledBox(name: string, options: {
  59585. pattern?: number;
  59586. width?: number;
  59587. height?: number;
  59588. depth?: number;
  59589. tileSize?: number;
  59590. tileWidth?: number;
  59591. tileHeight?: number;
  59592. alignHorizontal?: number;
  59593. alignVertical?: number;
  59594. faceUV?: Vector4[];
  59595. faceColors?: Color4[];
  59596. sideOrientation?: number;
  59597. updatable?: boolean;
  59598. }, scene?: Nullable<Scene>): Mesh;
  59599. }
  59600. }
  59601. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  59602. import { Vector4 } from "babylonjs/Maths/math.vector";
  59603. import { Mesh } from "babylonjs/Meshes/mesh";
  59604. /**
  59605. * Class containing static functions to help procedurally build meshes
  59606. */
  59607. export class TorusKnotBuilder {
  59608. /**
  59609. * Creates a torus knot mesh
  59610. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59611. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59612. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59613. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59615. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59617. * @param name defines the name of the mesh
  59618. * @param options defines the options used to create the mesh
  59619. * @param scene defines the hosting scene
  59620. * @returns the torus knot mesh
  59621. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59622. */
  59623. static CreateTorusKnot(name: string, options: {
  59624. radius?: number;
  59625. tube?: number;
  59626. radialSegments?: number;
  59627. tubularSegments?: number;
  59628. p?: number;
  59629. q?: number;
  59630. updatable?: boolean;
  59631. sideOrientation?: number;
  59632. frontUVs?: Vector4;
  59633. backUVs?: Vector4;
  59634. }, scene: any): Mesh;
  59635. }
  59636. }
  59637. declare module "babylonjs/Meshes/polygonMesh" {
  59638. import { Scene } from "babylonjs/scene";
  59639. import { Vector2 } from "babylonjs/Maths/math.vector";
  59640. import { Mesh } from "babylonjs/Meshes/mesh";
  59641. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59642. import { Path2 } from "babylonjs/Maths/math.path";
  59643. /**
  59644. * Polygon
  59645. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  59646. */
  59647. export class Polygon {
  59648. /**
  59649. * Creates a rectangle
  59650. * @param xmin bottom X coord
  59651. * @param ymin bottom Y coord
  59652. * @param xmax top X coord
  59653. * @param ymax top Y coord
  59654. * @returns points that make the resulting rectation
  59655. */
  59656. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  59657. /**
  59658. * Creates a circle
  59659. * @param radius radius of circle
  59660. * @param cx scale in x
  59661. * @param cy scale in y
  59662. * @param numberOfSides number of sides that make up the circle
  59663. * @returns points that make the resulting circle
  59664. */
  59665. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  59666. /**
  59667. * Creates a polygon from input string
  59668. * @param input Input polygon data
  59669. * @returns the parsed points
  59670. */
  59671. static Parse(input: string): Vector2[];
  59672. /**
  59673. * Starts building a polygon from x and y coordinates
  59674. * @param x x coordinate
  59675. * @param y y coordinate
  59676. * @returns the started path2
  59677. */
  59678. static StartingAt(x: number, y: number): Path2;
  59679. }
  59680. /**
  59681. * Builds a polygon
  59682. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  59683. */
  59684. export class PolygonMeshBuilder {
  59685. private _points;
  59686. private _outlinepoints;
  59687. private _holes;
  59688. private _name;
  59689. private _scene;
  59690. private _epoints;
  59691. private _eholes;
  59692. private _addToepoint;
  59693. /**
  59694. * Babylon reference to the earcut plugin.
  59695. */
  59696. bjsEarcut: any;
  59697. /**
  59698. * Creates a PolygonMeshBuilder
  59699. * @param name name of the builder
  59700. * @param contours Path of the polygon
  59701. * @param scene scene to add to when creating the mesh
  59702. * @param earcutInjection can be used to inject your own earcut reference
  59703. */
  59704. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  59705. /**
  59706. * Adds a whole within the polygon
  59707. * @param hole Array of points defining the hole
  59708. * @returns this
  59709. */
  59710. addHole(hole: Vector2[]): PolygonMeshBuilder;
  59711. /**
  59712. * Creates the polygon
  59713. * @param updatable If the mesh should be updatable
  59714. * @param depth The depth of the mesh created
  59715. * @returns the created mesh
  59716. */
  59717. build(updatable?: boolean, depth?: number): Mesh;
  59718. /**
  59719. * Creates the polygon
  59720. * @param depth The depth of the mesh created
  59721. * @returns the created VertexData
  59722. */
  59723. buildVertexData(depth?: number): VertexData;
  59724. /**
  59725. * Adds a side to the polygon
  59726. * @param positions points that make the polygon
  59727. * @param normals normals of the polygon
  59728. * @param uvs uvs of the polygon
  59729. * @param indices indices of the polygon
  59730. * @param bounds bounds of the polygon
  59731. * @param points points of the polygon
  59732. * @param depth depth of the polygon
  59733. * @param flip flip of the polygon
  59734. */
  59735. private addSide;
  59736. }
  59737. }
  59738. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59739. import { Scene } from "babylonjs/scene";
  59740. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59741. import { Color4 } from "babylonjs/Maths/math.color";
  59742. import { Mesh } from "babylonjs/Meshes/mesh";
  59743. import { Nullable } from "babylonjs/types";
  59744. /**
  59745. * Class containing static functions to help procedurally build meshes
  59746. */
  59747. export class PolygonBuilder {
  59748. /**
  59749. * Creates a polygon mesh
  59750. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59751. * * 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
  59752. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59754. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59755. * * Remember you can only change the shape positions, not their number when updating a polygon
  59756. * @param name defines the name of the mesh
  59757. * @param options defines the options used to create the mesh
  59758. * @param scene defines the hosting scene
  59759. * @param earcutInjection can be used to inject your own earcut reference
  59760. * @returns the polygon mesh
  59761. */
  59762. static CreatePolygon(name: string, options: {
  59763. shape: Vector3[];
  59764. holes?: Vector3[][];
  59765. depth?: number;
  59766. faceUV?: Vector4[];
  59767. faceColors?: Color4[];
  59768. updatable?: boolean;
  59769. sideOrientation?: number;
  59770. frontUVs?: Vector4;
  59771. backUVs?: Vector4;
  59772. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59773. /**
  59774. * Creates an extruded polygon mesh, with depth in the Y direction.
  59775. * * 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)
  59776. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59777. * @param name defines the name of the mesh
  59778. * @param options defines the options used to create the mesh
  59779. * @param scene defines the hosting scene
  59780. * @param earcutInjection can be used to inject your own earcut reference
  59781. * @returns the polygon mesh
  59782. */
  59783. static ExtrudePolygon(name: string, options: {
  59784. shape: Vector3[];
  59785. holes?: Vector3[][];
  59786. depth?: number;
  59787. faceUV?: Vector4[];
  59788. faceColors?: Color4[];
  59789. updatable?: boolean;
  59790. sideOrientation?: number;
  59791. frontUVs?: Vector4;
  59792. backUVs?: Vector4;
  59793. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59794. }
  59795. }
  59796. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59797. import { Scene } from "babylonjs/scene";
  59798. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59799. import { Mesh } from "babylonjs/Meshes/mesh";
  59800. import { Nullable } from "babylonjs/types";
  59801. /**
  59802. * Class containing static functions to help procedurally build meshes
  59803. */
  59804. export class LatheBuilder {
  59805. /**
  59806. * Creates lathe mesh.
  59807. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59808. * * 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
  59809. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59810. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59811. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59812. * * 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
  59813. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59814. * * 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
  59815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59816. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59817. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59819. * @param name defines the name of the mesh
  59820. * @param options defines the options used to create the mesh
  59821. * @param scene defines the hosting scene
  59822. * @returns the lathe mesh
  59823. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59824. */
  59825. static CreateLathe(name: string, options: {
  59826. shape: Vector3[];
  59827. radius?: number;
  59828. tessellation?: number;
  59829. clip?: number;
  59830. arc?: number;
  59831. closed?: boolean;
  59832. updatable?: boolean;
  59833. sideOrientation?: number;
  59834. frontUVs?: Vector4;
  59835. backUVs?: Vector4;
  59836. cap?: number;
  59837. invertUV?: boolean;
  59838. }, scene?: Nullable<Scene>): Mesh;
  59839. }
  59840. }
  59841. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59842. import { Nullable } from "babylonjs/types";
  59843. import { Scene } from "babylonjs/scene";
  59844. import { Vector4 } from "babylonjs/Maths/math.vector";
  59845. import { Mesh } from "babylonjs/Meshes/mesh";
  59846. /**
  59847. * Class containing static functions to help procedurally build meshes
  59848. */
  59849. export class TiledPlaneBuilder {
  59850. /**
  59851. * Creates a tiled plane mesh
  59852. * * The parameter `pattern` will, depending on value, do nothing or
  59853. * * * flip (reflect about central vertical) alternate tiles across and up
  59854. * * * flip every tile on alternate rows
  59855. * * * rotate (180 degs) alternate tiles across and up
  59856. * * * rotate every tile on alternate rows
  59857. * * * flip and rotate alternate tiles across and up
  59858. * * * flip and rotate every tile on alternate rows
  59859. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59860. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59862. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59863. * * 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)
  59864. * * 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)
  59865. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59866. * @param name defines the name of the mesh
  59867. * @param options defines the options used to create the mesh
  59868. * @param scene defines the hosting scene
  59869. * @returns the box mesh
  59870. */
  59871. static CreateTiledPlane(name: string, options: {
  59872. pattern?: number;
  59873. tileSize?: number;
  59874. tileWidth?: number;
  59875. tileHeight?: number;
  59876. size?: number;
  59877. width?: number;
  59878. height?: number;
  59879. alignHorizontal?: number;
  59880. alignVertical?: number;
  59881. sideOrientation?: number;
  59882. frontUVs?: Vector4;
  59883. backUVs?: Vector4;
  59884. updatable?: boolean;
  59885. }, scene?: Nullable<Scene>): Mesh;
  59886. }
  59887. }
  59888. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59889. import { Nullable } from "babylonjs/types";
  59890. import { Scene } from "babylonjs/scene";
  59891. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59892. import { Mesh } from "babylonjs/Meshes/mesh";
  59893. /**
  59894. * Class containing static functions to help procedurally build meshes
  59895. */
  59896. export class TubeBuilder {
  59897. /**
  59898. * Creates a tube mesh.
  59899. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59900. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59901. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59902. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59903. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59904. * * 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)
  59905. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59906. * * 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
  59907. * * 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
  59908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59909. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59910. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59912. * @param name defines the name of the mesh
  59913. * @param options defines the options used to create the mesh
  59914. * @param scene defines the hosting scene
  59915. * @returns the tube mesh
  59916. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59917. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59918. */
  59919. static CreateTube(name: string, options: {
  59920. path: Vector3[];
  59921. radius?: number;
  59922. tessellation?: number;
  59923. radiusFunction?: {
  59924. (i: number, distance: number): number;
  59925. };
  59926. cap?: number;
  59927. arc?: number;
  59928. updatable?: boolean;
  59929. sideOrientation?: number;
  59930. frontUVs?: Vector4;
  59931. backUVs?: Vector4;
  59932. instance?: Mesh;
  59933. invertUV?: boolean;
  59934. }, scene?: Nullable<Scene>): Mesh;
  59935. }
  59936. }
  59937. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59938. import { Scene } from "babylonjs/scene";
  59939. import { Vector4 } from "babylonjs/Maths/math.vector";
  59940. import { Mesh } from "babylonjs/Meshes/mesh";
  59941. import { Nullable } from "babylonjs/types";
  59942. /**
  59943. * Class containing static functions to help procedurally build meshes
  59944. */
  59945. export class IcoSphereBuilder {
  59946. /**
  59947. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59948. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59949. * * 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`)
  59950. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59951. * * 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
  59952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59955. * @param name defines the name of the mesh
  59956. * @param options defines the options used to create the mesh
  59957. * @param scene defines the hosting scene
  59958. * @returns the icosahedron mesh
  59959. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59960. */
  59961. static CreateIcoSphere(name: string, options: {
  59962. radius?: number;
  59963. radiusX?: number;
  59964. radiusY?: number;
  59965. radiusZ?: number;
  59966. flat?: boolean;
  59967. subdivisions?: number;
  59968. sideOrientation?: number;
  59969. frontUVs?: Vector4;
  59970. backUVs?: Vector4;
  59971. updatable?: boolean;
  59972. }, scene?: Nullable<Scene>): Mesh;
  59973. }
  59974. }
  59975. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59976. import { Vector3 } from "babylonjs/Maths/math.vector";
  59977. import { Mesh } from "babylonjs/Meshes/mesh";
  59978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59979. /**
  59980. * Class containing static functions to help procedurally build meshes
  59981. */
  59982. export class DecalBuilder {
  59983. /**
  59984. * Creates a decal mesh.
  59985. * 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
  59986. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59987. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59988. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59989. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59990. * @param name defines the name of the mesh
  59991. * @param sourceMesh defines the mesh where the decal must be applied
  59992. * @param options defines the options used to create the mesh
  59993. * @param scene defines the hosting scene
  59994. * @returns the decal mesh
  59995. * @see https://doc.babylonjs.com/how_to/decals
  59996. */
  59997. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59998. position?: Vector3;
  59999. normal?: Vector3;
  60000. size?: Vector3;
  60001. angle?: number;
  60002. }): Mesh;
  60003. }
  60004. }
  60005. declare module "babylonjs/Meshes/meshBuilder" {
  60006. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  60007. import { Nullable } from "babylonjs/types";
  60008. import { Scene } from "babylonjs/scene";
  60009. import { Mesh } from "babylonjs/Meshes/mesh";
  60010. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  60011. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  60012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60013. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60014. import { Plane } from "babylonjs/Maths/math.plane";
  60015. /**
  60016. * Class containing static functions to help procedurally build meshes
  60017. */
  60018. export class MeshBuilder {
  60019. /**
  60020. * Creates a box mesh
  60021. * * The parameter `size` sets the size (float) of each box side (default 1)
  60022. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60023. * * 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)
  60024. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60026. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60028. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60029. * @param name defines the name of the mesh
  60030. * @param options defines the options used to create the mesh
  60031. * @param scene defines the hosting scene
  60032. * @returns the box mesh
  60033. */
  60034. static CreateBox(name: string, options: {
  60035. size?: number;
  60036. width?: number;
  60037. height?: number;
  60038. depth?: number;
  60039. faceUV?: Vector4[];
  60040. faceColors?: Color4[];
  60041. sideOrientation?: number;
  60042. frontUVs?: Vector4;
  60043. backUVs?: Vector4;
  60044. updatable?: boolean;
  60045. }, scene?: Nullable<Scene>): Mesh;
  60046. /**
  60047. * Creates a tiled box mesh
  60048. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60050. * @param name defines the name of the mesh
  60051. * @param options defines the options used to create the mesh
  60052. * @param scene defines the hosting scene
  60053. * @returns the tiled box mesh
  60054. */
  60055. static CreateTiledBox(name: string, options: {
  60056. pattern?: number;
  60057. size?: number;
  60058. width?: number;
  60059. height?: number;
  60060. depth: number;
  60061. tileSize?: number;
  60062. tileWidth?: number;
  60063. tileHeight?: number;
  60064. faceUV?: Vector4[];
  60065. faceColors?: Color4[];
  60066. alignHorizontal?: number;
  60067. alignVertical?: number;
  60068. sideOrientation?: number;
  60069. updatable?: boolean;
  60070. }, scene?: Nullable<Scene>): Mesh;
  60071. /**
  60072. * Creates a sphere mesh
  60073. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60074. * * 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`)
  60075. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60076. * * 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
  60077. * * 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)
  60078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60081. * @param name defines the name of the mesh
  60082. * @param options defines the options used to create the mesh
  60083. * @param scene defines the hosting scene
  60084. * @returns the sphere mesh
  60085. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  60086. */
  60087. static CreateSphere(name: string, options: {
  60088. segments?: number;
  60089. diameter?: number;
  60090. diameterX?: number;
  60091. diameterY?: number;
  60092. diameterZ?: number;
  60093. arc?: number;
  60094. slice?: number;
  60095. sideOrientation?: number;
  60096. frontUVs?: Vector4;
  60097. backUVs?: Vector4;
  60098. updatable?: boolean;
  60099. }, scene?: Nullable<Scene>): Mesh;
  60100. /**
  60101. * Creates a plane polygonal mesh. By default, this is a disc
  60102. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  60103. * * 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
  60104. * * 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
  60105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60106. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60108. * @param name defines the name of the mesh
  60109. * @param options defines the options used to create the mesh
  60110. * @param scene defines the hosting scene
  60111. * @returns the plane polygonal mesh
  60112. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  60113. */
  60114. static CreateDisc(name: string, options: {
  60115. radius?: number;
  60116. tessellation?: number;
  60117. arc?: number;
  60118. updatable?: boolean;
  60119. sideOrientation?: number;
  60120. frontUVs?: Vector4;
  60121. backUVs?: Vector4;
  60122. }, scene?: Nullable<Scene>): Mesh;
  60123. /**
  60124. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60125. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60126. * * 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`)
  60127. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60128. * * 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
  60129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60130. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60132. * @param name defines the name of the mesh
  60133. * @param options defines the options used to create the mesh
  60134. * @param scene defines the hosting scene
  60135. * @returns the icosahedron mesh
  60136. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60137. */
  60138. static CreateIcoSphere(name: string, options: {
  60139. radius?: number;
  60140. radiusX?: number;
  60141. radiusY?: number;
  60142. radiusZ?: number;
  60143. flat?: boolean;
  60144. subdivisions?: number;
  60145. sideOrientation?: number;
  60146. frontUVs?: Vector4;
  60147. backUVs?: Vector4;
  60148. updatable?: boolean;
  60149. }, scene?: Nullable<Scene>): Mesh;
  60150. /**
  60151. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60152. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60153. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60154. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60155. * * 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
  60156. * * 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
  60157. * * 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
  60158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60159. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60160. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60161. * * 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
  60162. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60163. * * 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
  60164. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60166. * @param name defines the name of the mesh
  60167. * @param options defines the options used to create the mesh
  60168. * @param scene defines the hosting scene
  60169. * @returns the ribbon mesh
  60170. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60171. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60172. */
  60173. static CreateRibbon(name: string, options: {
  60174. pathArray: Vector3[][];
  60175. closeArray?: boolean;
  60176. closePath?: boolean;
  60177. offset?: number;
  60178. updatable?: boolean;
  60179. sideOrientation?: number;
  60180. frontUVs?: Vector4;
  60181. backUVs?: Vector4;
  60182. instance?: Mesh;
  60183. invertUV?: boolean;
  60184. uvs?: Vector2[];
  60185. colors?: Color4[];
  60186. }, scene?: Nullable<Scene>): Mesh;
  60187. /**
  60188. * Creates a cylinder or a cone mesh
  60189. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  60190. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  60191. * * 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.
  60192. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  60193. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  60194. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  60195. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  60196. * * 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).
  60197. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  60198. * * 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).
  60199. * * 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
  60200. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  60201. * * 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
  60202. * * 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.
  60203. * * If `enclose` is false, a ring surface is one element.
  60204. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  60205. * * 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
  60206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60207. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60209. * @param name defines the name of the mesh
  60210. * @param options defines the options used to create the mesh
  60211. * @param scene defines the hosting scene
  60212. * @returns the cylinder mesh
  60213. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  60214. */
  60215. static CreateCylinder(name: string, options: {
  60216. height?: number;
  60217. diameterTop?: number;
  60218. diameterBottom?: number;
  60219. diameter?: number;
  60220. tessellation?: number;
  60221. subdivisions?: number;
  60222. arc?: number;
  60223. faceColors?: Color4[];
  60224. faceUV?: Vector4[];
  60225. updatable?: boolean;
  60226. hasRings?: boolean;
  60227. enclose?: boolean;
  60228. cap?: number;
  60229. sideOrientation?: number;
  60230. frontUVs?: Vector4;
  60231. backUVs?: Vector4;
  60232. }, scene?: Nullable<Scene>): Mesh;
  60233. /**
  60234. * Creates a torus mesh
  60235. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  60236. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  60237. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  60238. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60239. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60241. * @param name defines the name of the mesh
  60242. * @param options defines the options used to create the mesh
  60243. * @param scene defines the hosting scene
  60244. * @returns the torus mesh
  60245. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  60246. */
  60247. static CreateTorus(name: string, options: {
  60248. diameter?: number;
  60249. thickness?: number;
  60250. tessellation?: number;
  60251. updatable?: boolean;
  60252. sideOrientation?: number;
  60253. frontUVs?: Vector4;
  60254. backUVs?: Vector4;
  60255. }, scene?: Nullable<Scene>): Mesh;
  60256. /**
  60257. * Creates a torus knot mesh
  60258. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60259. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60260. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60261. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60265. * @param name defines the name of the mesh
  60266. * @param options defines the options used to create the mesh
  60267. * @param scene defines the hosting scene
  60268. * @returns the torus knot mesh
  60269. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60270. */
  60271. static CreateTorusKnot(name: string, options: {
  60272. radius?: number;
  60273. tube?: number;
  60274. radialSegments?: number;
  60275. tubularSegments?: number;
  60276. p?: number;
  60277. q?: number;
  60278. updatable?: boolean;
  60279. sideOrientation?: number;
  60280. frontUVs?: Vector4;
  60281. backUVs?: Vector4;
  60282. }, scene?: Nullable<Scene>): Mesh;
  60283. /**
  60284. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  60285. * * 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
  60286. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  60287. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  60288. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  60289. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  60290. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  60291. * * 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
  60292. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  60293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60294. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  60295. * @param name defines the name of the new line system
  60296. * @param options defines the options used to create the line system
  60297. * @param scene defines the hosting scene
  60298. * @returns a new line system mesh
  60299. */
  60300. static CreateLineSystem(name: string, options: {
  60301. lines: Vector3[][];
  60302. updatable?: boolean;
  60303. instance?: Nullable<LinesMesh>;
  60304. colors?: Nullable<Color4[][]>;
  60305. useVertexAlpha?: boolean;
  60306. }, scene: Nullable<Scene>): LinesMesh;
  60307. /**
  60308. * Creates a line mesh
  60309. * 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
  60310. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60311. * * The parameter `points` is an array successive Vector3
  60312. * * 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
  60313. * * The optional parameter `colors` is an array of successive Color4, one per line point
  60314. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  60315. * * When updating an instance, remember that only point positions can change, not the number of points
  60316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60317. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  60318. * @param name defines the name of the new line system
  60319. * @param options defines the options used to create the line system
  60320. * @param scene defines the hosting scene
  60321. * @returns a new line mesh
  60322. */
  60323. static CreateLines(name: string, options: {
  60324. points: Vector3[];
  60325. updatable?: boolean;
  60326. instance?: Nullable<LinesMesh>;
  60327. colors?: Color4[];
  60328. useVertexAlpha?: boolean;
  60329. }, scene?: Nullable<Scene>): LinesMesh;
  60330. /**
  60331. * Creates a dashed line mesh
  60332. * * 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
  60333. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60334. * * The parameter `points` is an array successive Vector3
  60335. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  60336. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  60337. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  60338. * * 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
  60339. * * When updating an instance, remember that only point positions can change, not the number of points
  60340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60341. * @param name defines the name of the mesh
  60342. * @param options defines the options used to create the mesh
  60343. * @param scene defines the hosting scene
  60344. * @returns the dashed line mesh
  60345. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  60346. */
  60347. static CreateDashedLines(name: string, options: {
  60348. points: Vector3[];
  60349. dashSize?: number;
  60350. gapSize?: number;
  60351. dashNb?: number;
  60352. updatable?: boolean;
  60353. instance?: LinesMesh;
  60354. }, scene?: Nullable<Scene>): LinesMesh;
  60355. /**
  60356. * 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.
  60357. * * 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.
  60358. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60359. * * 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.
  60360. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60361. * * 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
  60362. * * 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
  60363. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60364. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60365. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60366. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60368. * @param name defines the name of the mesh
  60369. * @param options defines the options used to create the mesh
  60370. * @param scene defines the hosting scene
  60371. * @returns the extruded shape mesh
  60372. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60373. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60374. */
  60375. static ExtrudeShape(name: string, options: {
  60376. shape: Vector3[];
  60377. path: Vector3[];
  60378. scale?: number;
  60379. rotation?: number;
  60380. cap?: number;
  60381. updatable?: boolean;
  60382. sideOrientation?: number;
  60383. frontUVs?: Vector4;
  60384. backUVs?: Vector4;
  60385. instance?: Mesh;
  60386. invertUV?: boolean;
  60387. }, scene?: Nullable<Scene>): Mesh;
  60388. /**
  60389. * Creates an custom extruded shape mesh.
  60390. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60391. * * 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.
  60392. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60393. * * 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
  60394. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60395. * * 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
  60396. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60397. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60398. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60399. * * 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
  60400. * * 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
  60401. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60403. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60404. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60406. * @param name defines the name of the mesh
  60407. * @param options defines the options used to create the mesh
  60408. * @param scene defines the hosting scene
  60409. * @returns the custom extruded shape mesh
  60410. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60411. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60412. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60413. */
  60414. static ExtrudeShapeCustom(name: string, options: {
  60415. shape: Vector3[];
  60416. path: Vector3[];
  60417. scaleFunction?: any;
  60418. rotationFunction?: any;
  60419. ribbonCloseArray?: boolean;
  60420. ribbonClosePath?: boolean;
  60421. cap?: number;
  60422. updatable?: boolean;
  60423. sideOrientation?: number;
  60424. frontUVs?: Vector4;
  60425. backUVs?: Vector4;
  60426. instance?: Mesh;
  60427. invertUV?: boolean;
  60428. }, scene?: Nullable<Scene>): Mesh;
  60429. /**
  60430. * Creates lathe mesh.
  60431. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60432. * * 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
  60433. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60434. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60435. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60436. * * 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
  60437. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60438. * * 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
  60439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60440. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60441. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60443. * @param name defines the name of the mesh
  60444. * @param options defines the options used to create the mesh
  60445. * @param scene defines the hosting scene
  60446. * @returns the lathe mesh
  60447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60448. */
  60449. static CreateLathe(name: string, options: {
  60450. shape: Vector3[];
  60451. radius?: number;
  60452. tessellation?: number;
  60453. clip?: number;
  60454. arc?: number;
  60455. closed?: boolean;
  60456. updatable?: boolean;
  60457. sideOrientation?: number;
  60458. frontUVs?: Vector4;
  60459. backUVs?: Vector4;
  60460. cap?: number;
  60461. invertUV?: boolean;
  60462. }, scene?: Nullable<Scene>): Mesh;
  60463. /**
  60464. * Creates a tiled plane mesh
  60465. * * You can set a limited pattern arrangement with the tiles
  60466. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60467. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60469. * @param name defines the name of the mesh
  60470. * @param options defines the options used to create the mesh
  60471. * @param scene defines the hosting scene
  60472. * @returns the plane mesh
  60473. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60474. */
  60475. static CreateTiledPlane(name: string, options: {
  60476. pattern?: number;
  60477. tileSize?: number;
  60478. tileWidth?: number;
  60479. tileHeight?: number;
  60480. size?: number;
  60481. width?: number;
  60482. height?: number;
  60483. alignHorizontal?: number;
  60484. alignVertical?: number;
  60485. sideOrientation?: number;
  60486. frontUVs?: Vector4;
  60487. backUVs?: Vector4;
  60488. updatable?: boolean;
  60489. }, scene?: Nullable<Scene>): Mesh;
  60490. /**
  60491. * Creates a plane mesh
  60492. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  60493. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  60494. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  60495. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60496. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60498. * @param name defines the name of the mesh
  60499. * @param options defines the options used to create the mesh
  60500. * @param scene defines the hosting scene
  60501. * @returns the plane mesh
  60502. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60503. */
  60504. static CreatePlane(name: string, options: {
  60505. size?: number;
  60506. width?: number;
  60507. height?: number;
  60508. sideOrientation?: number;
  60509. frontUVs?: Vector4;
  60510. backUVs?: Vector4;
  60511. updatable?: boolean;
  60512. sourcePlane?: Plane;
  60513. }, scene?: Nullable<Scene>): Mesh;
  60514. /**
  60515. * Creates a ground mesh
  60516. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  60517. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  60518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60519. * @param name defines the name of the mesh
  60520. * @param options defines the options used to create the mesh
  60521. * @param scene defines the hosting scene
  60522. * @returns the ground mesh
  60523. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  60524. */
  60525. static CreateGround(name: string, options: {
  60526. width?: number;
  60527. height?: number;
  60528. subdivisions?: number;
  60529. subdivisionsX?: number;
  60530. subdivisionsY?: number;
  60531. updatable?: boolean;
  60532. }, scene?: Nullable<Scene>): Mesh;
  60533. /**
  60534. * Creates a tiled ground mesh
  60535. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  60536. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  60537. * * 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
  60538. * * 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
  60539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60540. * @param name defines the name of the mesh
  60541. * @param options defines the options used to create the mesh
  60542. * @param scene defines the hosting scene
  60543. * @returns the tiled ground mesh
  60544. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  60545. */
  60546. static CreateTiledGround(name: string, options: {
  60547. xmin: number;
  60548. zmin: number;
  60549. xmax: number;
  60550. zmax: number;
  60551. subdivisions?: {
  60552. w: number;
  60553. h: number;
  60554. };
  60555. precision?: {
  60556. w: number;
  60557. h: number;
  60558. };
  60559. updatable?: boolean;
  60560. }, scene?: Nullable<Scene>): Mesh;
  60561. /**
  60562. * Creates a ground mesh from a height map
  60563. * * The parameter `url` sets the URL of the height map image resource.
  60564. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  60565. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  60566. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  60567. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  60568. * * 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.
  60569. * * 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).
  60570. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  60571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60572. * @param name defines the name of the mesh
  60573. * @param url defines the url to the height map
  60574. * @param options defines the options used to create the mesh
  60575. * @param scene defines the hosting scene
  60576. * @returns the ground mesh
  60577. * @see https://doc.babylonjs.com/babylon101/height_map
  60578. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  60579. */
  60580. static CreateGroundFromHeightMap(name: string, url: string, options: {
  60581. width?: number;
  60582. height?: number;
  60583. subdivisions?: number;
  60584. minHeight?: number;
  60585. maxHeight?: number;
  60586. colorFilter?: Color3;
  60587. alphaFilter?: number;
  60588. updatable?: boolean;
  60589. onReady?: (mesh: GroundMesh) => void;
  60590. }, scene?: Nullable<Scene>): GroundMesh;
  60591. /**
  60592. * Creates a polygon mesh
  60593. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60594. * * 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
  60595. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60597. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60598. * * Remember you can only change the shape positions, not their number when updating a polygon
  60599. * @param name defines the name of the mesh
  60600. * @param options defines the options used to create the mesh
  60601. * @param scene defines the hosting scene
  60602. * @param earcutInjection can be used to inject your own earcut reference
  60603. * @returns the polygon mesh
  60604. */
  60605. static CreatePolygon(name: string, options: {
  60606. shape: Vector3[];
  60607. holes?: Vector3[][];
  60608. depth?: number;
  60609. faceUV?: Vector4[];
  60610. faceColors?: Color4[];
  60611. updatable?: boolean;
  60612. sideOrientation?: number;
  60613. frontUVs?: Vector4;
  60614. backUVs?: Vector4;
  60615. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60616. /**
  60617. * Creates an extruded polygon mesh, with depth in the Y direction.
  60618. * * 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)
  60619. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60620. * @param name defines the name of the mesh
  60621. * @param options defines the options used to create the mesh
  60622. * @param scene defines the hosting scene
  60623. * @param earcutInjection can be used to inject your own earcut reference
  60624. * @returns the polygon mesh
  60625. */
  60626. static ExtrudePolygon(name: string, options: {
  60627. shape: Vector3[];
  60628. holes?: Vector3[][];
  60629. depth?: number;
  60630. faceUV?: Vector4[];
  60631. faceColors?: Color4[];
  60632. updatable?: boolean;
  60633. sideOrientation?: number;
  60634. frontUVs?: Vector4;
  60635. backUVs?: Vector4;
  60636. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60637. /**
  60638. * Creates a tube mesh.
  60639. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60640. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60641. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60642. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60643. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60644. * * 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)
  60645. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60646. * * 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
  60647. * * 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
  60648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60649. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60650. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60652. * @param name defines the name of the mesh
  60653. * @param options defines the options used to create the mesh
  60654. * @param scene defines the hosting scene
  60655. * @returns the tube mesh
  60656. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60657. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60658. */
  60659. static CreateTube(name: string, options: {
  60660. path: Vector3[];
  60661. radius?: number;
  60662. tessellation?: number;
  60663. radiusFunction?: {
  60664. (i: number, distance: number): number;
  60665. };
  60666. cap?: number;
  60667. arc?: number;
  60668. updatable?: boolean;
  60669. sideOrientation?: number;
  60670. frontUVs?: Vector4;
  60671. backUVs?: Vector4;
  60672. instance?: Mesh;
  60673. invertUV?: boolean;
  60674. }, scene?: Nullable<Scene>): Mesh;
  60675. /**
  60676. * Creates a polyhedron mesh
  60677. * * 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
  60678. * * The parameter `size` (positive float, default 1) sets the polygon size
  60679. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  60680. * * 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`
  60681. * * 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
  60682. * * 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)`)
  60683. * * 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
  60684. * * 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
  60685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60686. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60688. * @param name defines the name of the mesh
  60689. * @param options defines the options used to create the mesh
  60690. * @param scene defines the hosting scene
  60691. * @returns the polyhedron mesh
  60692. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  60693. */
  60694. static CreatePolyhedron(name: string, options: {
  60695. type?: number;
  60696. size?: number;
  60697. sizeX?: number;
  60698. sizeY?: number;
  60699. sizeZ?: number;
  60700. custom?: any;
  60701. faceUV?: Vector4[];
  60702. faceColors?: Color4[];
  60703. flat?: boolean;
  60704. updatable?: boolean;
  60705. sideOrientation?: number;
  60706. frontUVs?: Vector4;
  60707. backUVs?: Vector4;
  60708. }, scene?: Nullable<Scene>): Mesh;
  60709. /**
  60710. * Creates a decal mesh.
  60711. * 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
  60712. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60713. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60714. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60715. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60716. * @param name defines the name of the mesh
  60717. * @param sourceMesh defines the mesh where the decal must be applied
  60718. * @param options defines the options used to create the mesh
  60719. * @param scene defines the hosting scene
  60720. * @returns the decal mesh
  60721. * @see https://doc.babylonjs.com/how_to/decals
  60722. */
  60723. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60724. position?: Vector3;
  60725. normal?: Vector3;
  60726. size?: Vector3;
  60727. angle?: number;
  60728. }): Mesh;
  60729. }
  60730. }
  60731. declare module "babylonjs/Meshes/meshSimplification" {
  60732. import { Mesh } from "babylonjs/Meshes/mesh";
  60733. /**
  60734. * A simplifier interface for future simplification implementations
  60735. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60736. */
  60737. export interface ISimplifier {
  60738. /**
  60739. * Simplification of a given mesh according to the given settings.
  60740. * Since this requires computation, it is assumed that the function runs async.
  60741. * @param settings The settings of the simplification, including quality and distance
  60742. * @param successCallback A callback that will be called after the mesh was simplified.
  60743. * @param errorCallback in case of an error, this callback will be called. optional.
  60744. */
  60745. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60746. }
  60747. /**
  60748. * Expected simplification settings.
  60749. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60750. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60751. */
  60752. export interface ISimplificationSettings {
  60753. /**
  60754. * Gets or sets the expected quality
  60755. */
  60756. quality: number;
  60757. /**
  60758. * Gets or sets the distance when this optimized version should be used
  60759. */
  60760. distance: number;
  60761. /**
  60762. * Gets an already optimized mesh
  60763. */
  60764. optimizeMesh?: boolean;
  60765. }
  60766. /**
  60767. * Class used to specify simplification options
  60768. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60769. */
  60770. export class SimplificationSettings implements ISimplificationSettings {
  60771. /** expected quality */
  60772. quality: number;
  60773. /** distance when this optimized version should be used */
  60774. distance: number;
  60775. /** already optimized mesh */
  60776. optimizeMesh?: boolean | undefined;
  60777. /**
  60778. * Creates a SimplificationSettings
  60779. * @param quality expected quality
  60780. * @param distance distance when this optimized version should be used
  60781. * @param optimizeMesh already optimized mesh
  60782. */
  60783. constructor(
  60784. /** expected quality */
  60785. quality: number,
  60786. /** distance when this optimized version should be used */
  60787. distance: number,
  60788. /** already optimized mesh */
  60789. optimizeMesh?: boolean | undefined);
  60790. }
  60791. /**
  60792. * Interface used to define a simplification task
  60793. */
  60794. export interface ISimplificationTask {
  60795. /**
  60796. * Array of settings
  60797. */
  60798. settings: Array<ISimplificationSettings>;
  60799. /**
  60800. * Simplification type
  60801. */
  60802. simplificationType: SimplificationType;
  60803. /**
  60804. * Mesh to simplify
  60805. */
  60806. mesh: Mesh;
  60807. /**
  60808. * Callback called on success
  60809. */
  60810. successCallback?: () => void;
  60811. /**
  60812. * Defines if parallel processing can be used
  60813. */
  60814. parallelProcessing: boolean;
  60815. }
  60816. /**
  60817. * Queue used to order the simplification tasks
  60818. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60819. */
  60820. export class SimplificationQueue {
  60821. private _simplificationArray;
  60822. /**
  60823. * Gets a boolean indicating that the process is still running
  60824. */
  60825. running: boolean;
  60826. /**
  60827. * Creates a new queue
  60828. */
  60829. constructor();
  60830. /**
  60831. * Adds a new simplification task
  60832. * @param task defines a task to add
  60833. */
  60834. addTask(task: ISimplificationTask): void;
  60835. /**
  60836. * Execute next task
  60837. */
  60838. executeNext(): void;
  60839. /**
  60840. * Execute a simplification task
  60841. * @param task defines the task to run
  60842. */
  60843. runSimplification(task: ISimplificationTask): void;
  60844. private getSimplifier;
  60845. }
  60846. /**
  60847. * The implemented types of simplification
  60848. * At the moment only Quadratic Error Decimation is implemented
  60849. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60850. */
  60851. export enum SimplificationType {
  60852. /** Quadratic error decimation */
  60853. QUADRATIC = 0
  60854. }
  60855. }
  60856. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60857. import { Scene } from "babylonjs/scene";
  60858. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60859. import { ISceneComponent } from "babylonjs/sceneComponent";
  60860. module "babylonjs/scene" {
  60861. interface Scene {
  60862. /** @hidden (Backing field) */
  60863. _simplificationQueue: SimplificationQueue;
  60864. /**
  60865. * Gets or sets the simplification queue attached to the scene
  60866. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60867. */
  60868. simplificationQueue: SimplificationQueue;
  60869. }
  60870. }
  60871. module "babylonjs/Meshes/mesh" {
  60872. interface Mesh {
  60873. /**
  60874. * Simplify the mesh according to the given array of settings.
  60875. * Function will return immediately and will simplify async
  60876. * @param settings a collection of simplification settings
  60877. * @param parallelProcessing should all levels calculate parallel or one after the other
  60878. * @param simplificationType the type of simplification to run
  60879. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60880. * @returns the current mesh
  60881. */
  60882. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60883. }
  60884. }
  60885. /**
  60886. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60887. * created in a scene
  60888. */
  60889. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60890. /**
  60891. * The component name helpfull to identify the component in the list of scene components.
  60892. */
  60893. readonly name: string;
  60894. /**
  60895. * The scene the component belongs to.
  60896. */
  60897. scene: Scene;
  60898. /**
  60899. * Creates a new instance of the component for the given scene
  60900. * @param scene Defines the scene to register the component in
  60901. */
  60902. constructor(scene: Scene);
  60903. /**
  60904. * Registers the component in a given scene
  60905. */
  60906. register(): void;
  60907. /**
  60908. * Rebuilds the elements related to this component in case of
  60909. * context lost for instance.
  60910. */
  60911. rebuild(): void;
  60912. /**
  60913. * Disposes the component and the associated ressources
  60914. */
  60915. dispose(): void;
  60916. private _beforeCameraUpdate;
  60917. }
  60918. }
  60919. declare module "babylonjs/Meshes/Builders/index" {
  60920. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60921. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60922. export * from "babylonjs/Meshes/Builders/discBuilder";
  60923. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60924. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60925. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60926. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60927. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60928. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60929. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60930. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60931. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60932. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60933. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60934. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60935. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60936. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60937. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60938. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60939. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60940. }
  60941. declare module "babylonjs/Meshes/index" {
  60942. export * from "babylonjs/Meshes/abstractMesh";
  60943. export * from "babylonjs/Meshes/buffer";
  60944. export * from "babylonjs/Meshes/Compression/index";
  60945. export * from "babylonjs/Meshes/csg";
  60946. export * from "babylonjs/Meshes/geometry";
  60947. export * from "babylonjs/Meshes/groundMesh";
  60948. export * from "babylonjs/Meshes/trailMesh";
  60949. export * from "babylonjs/Meshes/instancedMesh";
  60950. export * from "babylonjs/Meshes/linesMesh";
  60951. export * from "babylonjs/Meshes/mesh";
  60952. export * from "babylonjs/Meshes/mesh.vertexData";
  60953. export * from "babylonjs/Meshes/meshBuilder";
  60954. export * from "babylonjs/Meshes/meshSimplification";
  60955. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60956. export * from "babylonjs/Meshes/polygonMesh";
  60957. export * from "babylonjs/Meshes/subMesh";
  60958. export * from "babylonjs/Meshes/meshLODLevel";
  60959. export * from "babylonjs/Meshes/transformNode";
  60960. export * from "babylonjs/Meshes/Builders/index";
  60961. export * from "babylonjs/Meshes/dataBuffer";
  60962. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60963. }
  60964. declare module "babylonjs/Morph/index" {
  60965. export * from "babylonjs/Morph/morphTarget";
  60966. export * from "babylonjs/Morph/morphTargetManager";
  60967. }
  60968. declare module "babylonjs/Navigation/INavigationEngine" {
  60969. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60970. import { Vector3 } from "babylonjs/Maths/math";
  60971. import { Mesh } from "babylonjs/Meshes/mesh";
  60972. import { Scene } from "babylonjs/scene";
  60973. /**
  60974. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60975. */
  60976. export interface INavigationEnginePlugin {
  60977. /**
  60978. * plugin name
  60979. */
  60980. name: string;
  60981. /**
  60982. * Creates a navigation mesh
  60983. * @param meshes array of all the geometry used to compute the navigatio mesh
  60984. * @param parameters bunch of parameters used to filter geometry
  60985. */
  60986. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60987. /**
  60988. * Create a navigation mesh debug mesh
  60989. * @param scene is where the mesh will be added
  60990. * @returns debug display mesh
  60991. */
  60992. createDebugNavMesh(scene: Scene): Mesh;
  60993. /**
  60994. * Get a navigation mesh constrained position, closest to the parameter position
  60995. * @param position world position
  60996. * @returns the closest point to position constrained by the navigation mesh
  60997. */
  60998. getClosestPoint(position: Vector3): Vector3;
  60999. /**
  61000. * Get a navigation mesh constrained position, within a particular radius
  61001. * @param position world position
  61002. * @param maxRadius the maximum distance to the constrained world position
  61003. * @returns the closest point to position constrained by the navigation mesh
  61004. */
  61005. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61006. /**
  61007. * Compute the final position from a segment made of destination-position
  61008. * @param position world position
  61009. * @param destination world position
  61010. * @returns the resulting point along the navmesh
  61011. */
  61012. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61013. /**
  61014. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61015. * @param start world position
  61016. * @param end world position
  61017. * @returns array containing world position composing the path
  61018. */
  61019. computePath(start: Vector3, end: Vector3): Vector3[];
  61020. /**
  61021. * If this plugin is supported
  61022. * @returns true if plugin is supported
  61023. */
  61024. isSupported(): boolean;
  61025. /**
  61026. * Create a new Crowd so you can add agents
  61027. * @param maxAgents the maximum agent count in the crowd
  61028. * @param maxAgentRadius the maximum radius an agent can have
  61029. * @param scene to attach the crowd to
  61030. * @returns the crowd you can add agents to
  61031. */
  61032. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61033. /**
  61034. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61035. * The queries will try to find a solution within those bounds
  61036. * default is (1,1,1)
  61037. * @param extent x,y,z value that define the extent around the queries point of reference
  61038. */
  61039. setDefaultQueryExtent(extent: Vector3): void;
  61040. /**
  61041. * Get the Bounding box extent specified by setDefaultQueryExtent
  61042. * @returns the box extent values
  61043. */
  61044. getDefaultQueryExtent(): Vector3;
  61045. /**
  61046. * Release all resources
  61047. */
  61048. dispose(): void;
  61049. }
  61050. /**
  61051. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61052. */
  61053. export interface ICrowd {
  61054. /**
  61055. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61056. * You can attach anything to that node. The node position is updated in the scene update tick.
  61057. * @param pos world position that will be constrained by the navigation mesh
  61058. * @param parameters agent parameters
  61059. * @param transform hooked to the agent that will be update by the scene
  61060. * @returns agent index
  61061. */
  61062. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61063. /**
  61064. * Returns the agent position in world space
  61065. * @param index agent index returned by addAgent
  61066. * @returns world space position
  61067. */
  61068. getAgentPosition(index: number): Vector3;
  61069. /**
  61070. * Gets the agent velocity in world space
  61071. * @param index agent index returned by addAgent
  61072. * @returns world space velocity
  61073. */
  61074. getAgentVelocity(index: number): Vector3;
  61075. /**
  61076. * remove a particular agent previously created
  61077. * @param index agent index returned by addAgent
  61078. */
  61079. removeAgent(index: number): void;
  61080. /**
  61081. * get the list of all agents attached to this crowd
  61082. * @returns list of agent indices
  61083. */
  61084. getAgents(): number[];
  61085. /**
  61086. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61087. * @param deltaTime in seconds
  61088. */
  61089. update(deltaTime: number): void;
  61090. /**
  61091. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61092. * @param index agent index returned by addAgent
  61093. * @param destination targeted world position
  61094. */
  61095. agentGoto(index: number, destination: Vector3): void;
  61096. /**
  61097. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61098. * The queries will try to find a solution within those bounds
  61099. * default is (1,1,1)
  61100. * @param extent x,y,z value that define the extent around the queries point of reference
  61101. */
  61102. setDefaultQueryExtent(extent: Vector3): void;
  61103. /**
  61104. * Get the Bounding box extent specified by setDefaultQueryExtent
  61105. * @returns the box extent values
  61106. */
  61107. getDefaultQueryExtent(): Vector3;
  61108. /**
  61109. * Release all resources
  61110. */
  61111. dispose(): void;
  61112. }
  61113. /**
  61114. * Configures an agent
  61115. */
  61116. export interface IAgentParameters {
  61117. /**
  61118. * Agent radius. [Limit: >= 0]
  61119. */
  61120. radius: number;
  61121. /**
  61122. * Agent height. [Limit: > 0]
  61123. */
  61124. height: number;
  61125. /**
  61126. * Maximum allowed acceleration. [Limit: >= 0]
  61127. */
  61128. maxAcceleration: number;
  61129. /**
  61130. * Maximum allowed speed. [Limit: >= 0]
  61131. */
  61132. maxSpeed: number;
  61133. /**
  61134. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  61135. */
  61136. collisionQueryRange: number;
  61137. /**
  61138. * The path visibility optimization range. [Limit: > 0]
  61139. */
  61140. pathOptimizationRange: number;
  61141. /**
  61142. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  61143. */
  61144. separationWeight: number;
  61145. }
  61146. /**
  61147. * Configures the navigation mesh creation
  61148. */
  61149. export interface INavMeshParameters {
  61150. /**
  61151. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  61152. */
  61153. cs: number;
  61154. /**
  61155. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  61156. */
  61157. ch: number;
  61158. /**
  61159. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  61160. */
  61161. walkableSlopeAngle: number;
  61162. /**
  61163. * Minimum floor to 'ceiling' height that will still allow the floor area to
  61164. * be considered walkable. [Limit: >= 3] [Units: vx]
  61165. */
  61166. walkableHeight: number;
  61167. /**
  61168. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  61169. */
  61170. walkableClimb: number;
  61171. /**
  61172. * The distance to erode/shrink the walkable area of the heightfield away from
  61173. * obstructions. [Limit: >=0] [Units: vx]
  61174. */
  61175. walkableRadius: number;
  61176. /**
  61177. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  61178. */
  61179. maxEdgeLen: number;
  61180. /**
  61181. * The maximum distance a simplfied contour's border edges should deviate
  61182. * the original raw contour. [Limit: >=0] [Units: vx]
  61183. */
  61184. maxSimplificationError: number;
  61185. /**
  61186. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  61187. */
  61188. minRegionArea: number;
  61189. /**
  61190. * Any regions with a span count smaller than this value will, if possible,
  61191. * be merged with larger regions. [Limit: >=0] [Units: vx]
  61192. */
  61193. mergeRegionArea: number;
  61194. /**
  61195. * The maximum number of vertices allowed for polygons generated during the
  61196. * contour to polygon conversion process. [Limit: >= 3]
  61197. */
  61198. maxVertsPerPoly: number;
  61199. /**
  61200. * Sets the sampling distance to use when generating the detail mesh.
  61201. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  61202. */
  61203. detailSampleDist: number;
  61204. /**
  61205. * The maximum distance the detail mesh surface should deviate from heightfield
  61206. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  61207. */
  61208. detailSampleMaxError: number;
  61209. }
  61210. }
  61211. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  61212. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  61213. import { Mesh } from "babylonjs/Meshes/mesh";
  61214. import { Scene } from "babylonjs/scene";
  61215. import { Vector3 } from "babylonjs/Maths/math";
  61216. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61217. /**
  61218. * RecastJS navigation plugin
  61219. */
  61220. export class RecastJSPlugin implements INavigationEnginePlugin {
  61221. /**
  61222. * Reference to the Recast library
  61223. */
  61224. bjsRECAST: any;
  61225. /**
  61226. * plugin name
  61227. */
  61228. name: string;
  61229. /**
  61230. * the first navmesh created. We might extend this to support multiple navmeshes
  61231. */
  61232. navMesh: any;
  61233. /**
  61234. * Initializes the recastJS plugin
  61235. * @param recastInjection can be used to inject your own recast reference
  61236. */
  61237. constructor(recastInjection?: any);
  61238. /**
  61239. * Creates a navigation mesh
  61240. * @param meshes array of all the geometry used to compute the navigatio mesh
  61241. * @param parameters bunch of parameters used to filter geometry
  61242. */
  61243. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61244. /**
  61245. * Create a navigation mesh debug mesh
  61246. * @param scene is where the mesh will be added
  61247. * @returns debug display mesh
  61248. */
  61249. createDebugNavMesh(scene: Scene): Mesh;
  61250. /**
  61251. * Get a navigation mesh constrained position, closest to the parameter position
  61252. * @param position world position
  61253. * @returns the closest point to position constrained by the navigation mesh
  61254. */
  61255. getClosestPoint(position: Vector3): Vector3;
  61256. /**
  61257. * Get a navigation mesh constrained position, within a particular radius
  61258. * @param position world position
  61259. * @param maxRadius the maximum distance to the constrained world position
  61260. * @returns the closest point to position constrained by the navigation mesh
  61261. */
  61262. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61263. /**
  61264. * Compute the final position from a segment made of destination-position
  61265. * @param position world position
  61266. * @param destination world position
  61267. * @returns the resulting point along the navmesh
  61268. */
  61269. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61270. /**
  61271. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61272. * @param start world position
  61273. * @param end world position
  61274. * @returns array containing world position composing the path
  61275. */
  61276. computePath(start: Vector3, end: Vector3): Vector3[];
  61277. /**
  61278. * Create a new Crowd so you can add agents
  61279. * @param maxAgents the maximum agent count in the crowd
  61280. * @param maxAgentRadius the maximum radius an agent can have
  61281. * @param scene to attach the crowd to
  61282. * @returns the crowd you can add agents to
  61283. */
  61284. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61285. /**
  61286. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61287. * The queries will try to find a solution within those bounds
  61288. * default is (1,1,1)
  61289. * @param extent x,y,z value that define the extent around the queries point of reference
  61290. */
  61291. setDefaultQueryExtent(extent: Vector3): void;
  61292. /**
  61293. * Get the Bounding box extent specified by setDefaultQueryExtent
  61294. * @returns the box extent values
  61295. */
  61296. getDefaultQueryExtent(): Vector3;
  61297. /**
  61298. * Disposes
  61299. */
  61300. dispose(): void;
  61301. /**
  61302. * If this plugin is supported
  61303. * @returns true if plugin is supported
  61304. */
  61305. isSupported(): boolean;
  61306. }
  61307. /**
  61308. * Recast detour crowd implementation
  61309. */
  61310. export class RecastJSCrowd implements ICrowd {
  61311. /**
  61312. * Recast/detour plugin
  61313. */
  61314. bjsRECASTPlugin: RecastJSPlugin;
  61315. /**
  61316. * Link to the detour crowd
  61317. */
  61318. recastCrowd: any;
  61319. /**
  61320. * One transform per agent
  61321. */
  61322. transforms: TransformNode[];
  61323. /**
  61324. * All agents created
  61325. */
  61326. agents: number[];
  61327. /**
  61328. * Link to the scene is kept to unregister the crowd from the scene
  61329. */
  61330. private _scene;
  61331. /**
  61332. * Observer for crowd updates
  61333. */
  61334. private _onBeforeAnimationsObserver;
  61335. /**
  61336. * Constructor
  61337. * @param plugin recastJS plugin
  61338. * @param maxAgents the maximum agent count in the crowd
  61339. * @param maxAgentRadius the maximum radius an agent can have
  61340. * @param scene to attach the crowd to
  61341. * @returns the crowd you can add agents to
  61342. */
  61343. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  61344. /**
  61345. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61346. * You can attach anything to that node. The node position is updated in the scene update tick.
  61347. * @param pos world position that will be constrained by the navigation mesh
  61348. * @param parameters agent parameters
  61349. * @param transform hooked to the agent that will be update by the scene
  61350. * @returns agent index
  61351. */
  61352. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61353. /**
  61354. * Returns the agent position in world space
  61355. * @param index agent index returned by addAgent
  61356. * @returns world space position
  61357. */
  61358. getAgentPosition(index: number): Vector3;
  61359. /**
  61360. * Returns the agent velocity in world space
  61361. * @param index agent index returned by addAgent
  61362. * @returns world space velocity
  61363. */
  61364. getAgentVelocity(index: number): Vector3;
  61365. /**
  61366. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61367. * @param index agent index returned by addAgent
  61368. * @param destination targeted world position
  61369. */
  61370. agentGoto(index: number, destination: Vector3): void;
  61371. /**
  61372. * remove a particular agent previously created
  61373. * @param index agent index returned by addAgent
  61374. */
  61375. removeAgent(index: number): void;
  61376. /**
  61377. * get the list of all agents attached to this crowd
  61378. * @returns list of agent indices
  61379. */
  61380. getAgents(): number[];
  61381. /**
  61382. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61383. * @param deltaTime in seconds
  61384. */
  61385. update(deltaTime: number): void;
  61386. /**
  61387. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61388. * The queries will try to find a solution within those bounds
  61389. * default is (1,1,1)
  61390. * @param extent x,y,z value that define the extent around the queries point of reference
  61391. */
  61392. setDefaultQueryExtent(extent: Vector3): void;
  61393. /**
  61394. * Get the Bounding box extent specified by setDefaultQueryExtent
  61395. * @returns the box extent values
  61396. */
  61397. getDefaultQueryExtent(): Vector3;
  61398. /**
  61399. * Release all resources
  61400. */
  61401. dispose(): void;
  61402. }
  61403. }
  61404. declare module "babylonjs/Navigation/Plugins/index" {
  61405. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  61406. }
  61407. declare module "babylonjs/Navigation/index" {
  61408. export * from "babylonjs/Navigation/INavigationEngine";
  61409. export * from "babylonjs/Navigation/Plugins/index";
  61410. }
  61411. declare module "babylonjs/Offline/database" {
  61412. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  61413. /**
  61414. * Class used to enable access to IndexedDB
  61415. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61416. */
  61417. export class Database implements IOfflineProvider {
  61418. private _callbackManifestChecked;
  61419. private _currentSceneUrl;
  61420. private _db;
  61421. private _enableSceneOffline;
  61422. private _enableTexturesOffline;
  61423. private _manifestVersionFound;
  61424. private _mustUpdateRessources;
  61425. private _hasReachedQuota;
  61426. private _isSupported;
  61427. private _idbFactory;
  61428. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  61429. private static IsUASupportingBlobStorage;
  61430. /**
  61431. * Gets a boolean indicating if Database storate is enabled (off by default)
  61432. */
  61433. static IDBStorageEnabled: boolean;
  61434. /**
  61435. * Gets a boolean indicating if scene must be saved in the database
  61436. */
  61437. readonly enableSceneOffline: boolean;
  61438. /**
  61439. * Gets a boolean indicating if textures must be saved in the database
  61440. */
  61441. readonly enableTexturesOffline: boolean;
  61442. /**
  61443. * Creates a new Database
  61444. * @param urlToScene defines the url to load the scene
  61445. * @param callbackManifestChecked defines the callback to use when manifest is checked
  61446. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  61447. */
  61448. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  61449. private static _ParseURL;
  61450. private static _ReturnFullUrlLocation;
  61451. private _checkManifestFile;
  61452. /**
  61453. * Open the database and make it available
  61454. * @param successCallback defines the callback to call on success
  61455. * @param errorCallback defines the callback to call on error
  61456. */
  61457. open(successCallback: () => void, errorCallback: () => void): void;
  61458. /**
  61459. * Loads an image from the database
  61460. * @param url defines the url to load from
  61461. * @param image defines the target DOM image
  61462. */
  61463. loadImage(url: string, image: HTMLImageElement): void;
  61464. private _loadImageFromDBAsync;
  61465. private _saveImageIntoDBAsync;
  61466. private _checkVersionFromDB;
  61467. private _loadVersionFromDBAsync;
  61468. private _saveVersionIntoDBAsync;
  61469. /**
  61470. * Loads a file from database
  61471. * @param url defines the URL to load from
  61472. * @param sceneLoaded defines a callback to call on success
  61473. * @param progressCallBack defines a callback to call when progress changed
  61474. * @param errorCallback defines a callback to call on error
  61475. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61476. */
  61477. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61478. private _loadFileAsync;
  61479. private _saveFileAsync;
  61480. /**
  61481. * Validates if xhr data is correct
  61482. * @param xhr defines the request to validate
  61483. * @param dataType defines the expected data type
  61484. * @returns true if data is correct
  61485. */
  61486. private static _ValidateXHRData;
  61487. }
  61488. }
  61489. declare module "babylonjs/Offline/index" {
  61490. export * from "babylonjs/Offline/database";
  61491. export * from "babylonjs/Offline/IOfflineProvider";
  61492. }
  61493. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  61494. /** @hidden */
  61495. export var gpuUpdateParticlesPixelShader: {
  61496. name: string;
  61497. shader: string;
  61498. };
  61499. }
  61500. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  61501. /** @hidden */
  61502. export var gpuUpdateParticlesVertexShader: {
  61503. name: string;
  61504. shader: string;
  61505. };
  61506. }
  61507. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  61508. /** @hidden */
  61509. export var clipPlaneFragmentDeclaration2: {
  61510. name: string;
  61511. shader: string;
  61512. };
  61513. }
  61514. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  61515. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  61516. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61517. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61518. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61519. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  61520. /** @hidden */
  61521. export var gpuRenderParticlesPixelShader: {
  61522. name: string;
  61523. shader: string;
  61524. };
  61525. }
  61526. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  61527. /** @hidden */
  61528. export var clipPlaneVertexDeclaration2: {
  61529. name: string;
  61530. shader: string;
  61531. };
  61532. }
  61533. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  61534. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  61535. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  61536. /** @hidden */
  61537. export var gpuRenderParticlesVertexShader: {
  61538. name: string;
  61539. shader: string;
  61540. };
  61541. }
  61542. declare module "babylonjs/Particles/gpuParticleSystem" {
  61543. import { Nullable } from "babylonjs/types";
  61544. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  61545. import { Observable } from "babylonjs/Misc/observable";
  61546. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61547. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61548. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  61549. import { Scene, IDisposable } from "babylonjs/scene";
  61550. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  61551. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61552. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  61553. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  61554. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  61555. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  61556. /**
  61557. * This represents a GPU particle system in Babylon
  61558. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  61559. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  61560. */
  61561. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  61562. /**
  61563. * The layer mask we are rendering the particles through.
  61564. */
  61565. layerMask: number;
  61566. private _capacity;
  61567. private _activeCount;
  61568. private _currentActiveCount;
  61569. private _accumulatedCount;
  61570. private _renderEffect;
  61571. private _updateEffect;
  61572. private _buffer0;
  61573. private _buffer1;
  61574. private _spriteBuffer;
  61575. private _updateVAO;
  61576. private _renderVAO;
  61577. private _targetIndex;
  61578. private _sourceBuffer;
  61579. private _targetBuffer;
  61580. private _engine;
  61581. private _currentRenderId;
  61582. private _started;
  61583. private _stopped;
  61584. private _timeDelta;
  61585. private _randomTexture;
  61586. private _randomTexture2;
  61587. private _attributesStrideSize;
  61588. private _updateEffectOptions;
  61589. private _randomTextureSize;
  61590. private _actualFrame;
  61591. private readonly _rawTextureWidth;
  61592. /**
  61593. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  61594. */
  61595. static readonly IsSupported: boolean;
  61596. /**
  61597. * An event triggered when the system is disposed.
  61598. */
  61599. onDisposeObservable: Observable<GPUParticleSystem>;
  61600. /**
  61601. * Gets the maximum number of particles active at the same time.
  61602. * @returns The max number of active particles.
  61603. */
  61604. getCapacity(): number;
  61605. /**
  61606. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  61607. * to override the particles.
  61608. */
  61609. forceDepthWrite: boolean;
  61610. /**
  61611. * Gets or set the number of active particles
  61612. */
  61613. activeParticleCount: number;
  61614. private _preWarmDone;
  61615. /**
  61616. * Is this system ready to be used/rendered
  61617. * @return true if the system is ready
  61618. */
  61619. isReady(): boolean;
  61620. /**
  61621. * Gets if the system has been started. (Note: this will still be true after stop is called)
  61622. * @returns True if it has been started, otherwise false.
  61623. */
  61624. isStarted(): boolean;
  61625. /**
  61626. * Starts the particle system and begins to emit
  61627. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  61628. */
  61629. start(delay?: number): void;
  61630. /**
  61631. * Stops the particle system.
  61632. */
  61633. stop(): void;
  61634. /**
  61635. * Remove all active particles
  61636. */
  61637. reset(): void;
  61638. /**
  61639. * Returns the string "GPUParticleSystem"
  61640. * @returns a string containing the class name
  61641. */
  61642. getClassName(): string;
  61643. private _colorGradientsTexture;
  61644. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  61645. /**
  61646. * Adds a new color gradient
  61647. * @param gradient defines the gradient to use (between 0 and 1)
  61648. * @param color1 defines the color to affect to the specified gradient
  61649. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  61650. * @returns the current particle system
  61651. */
  61652. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  61653. /**
  61654. * Remove a specific color gradient
  61655. * @param gradient defines the gradient to remove
  61656. * @returns the current particle system
  61657. */
  61658. removeColorGradient(gradient: number): GPUParticleSystem;
  61659. private _angularSpeedGradientsTexture;
  61660. private _sizeGradientsTexture;
  61661. private _velocityGradientsTexture;
  61662. private _limitVelocityGradientsTexture;
  61663. private _dragGradientsTexture;
  61664. private _addFactorGradient;
  61665. /**
  61666. * Adds a new size gradient
  61667. * @param gradient defines the gradient to use (between 0 and 1)
  61668. * @param factor defines the size factor to affect to the specified gradient
  61669. * @returns the current particle system
  61670. */
  61671. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  61672. /**
  61673. * Remove a specific size gradient
  61674. * @param gradient defines the gradient to remove
  61675. * @returns the current particle system
  61676. */
  61677. removeSizeGradient(gradient: number): GPUParticleSystem;
  61678. /**
  61679. * Adds a new angular speed gradient
  61680. * @param gradient defines the gradient to use (between 0 and 1)
  61681. * @param factor defines the angular speed to affect to the specified gradient
  61682. * @returns the current particle system
  61683. */
  61684. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  61685. /**
  61686. * Remove a specific angular speed gradient
  61687. * @param gradient defines the gradient to remove
  61688. * @returns the current particle system
  61689. */
  61690. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  61691. /**
  61692. * Adds a new velocity gradient
  61693. * @param gradient defines the gradient to use (between 0 and 1)
  61694. * @param factor defines the velocity to affect to the specified gradient
  61695. * @returns the current particle system
  61696. */
  61697. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61698. /**
  61699. * Remove a specific velocity gradient
  61700. * @param gradient defines the gradient to remove
  61701. * @returns the current particle system
  61702. */
  61703. removeVelocityGradient(gradient: number): GPUParticleSystem;
  61704. /**
  61705. * Adds a new limit velocity gradient
  61706. * @param gradient defines the gradient to use (between 0 and 1)
  61707. * @param factor defines the limit velocity value to affect to the specified gradient
  61708. * @returns the current particle system
  61709. */
  61710. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61711. /**
  61712. * Remove a specific limit velocity gradient
  61713. * @param gradient defines the gradient to remove
  61714. * @returns the current particle system
  61715. */
  61716. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  61717. /**
  61718. * Adds a new drag gradient
  61719. * @param gradient defines the gradient to use (between 0 and 1)
  61720. * @param factor defines the drag value to affect to the specified gradient
  61721. * @returns the current particle system
  61722. */
  61723. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  61724. /**
  61725. * Remove a specific drag gradient
  61726. * @param gradient defines the gradient to remove
  61727. * @returns the current particle system
  61728. */
  61729. removeDragGradient(gradient: number): GPUParticleSystem;
  61730. /**
  61731. * Not supported by GPUParticleSystem
  61732. * @param gradient defines the gradient to use (between 0 and 1)
  61733. * @param factor defines the emit rate value to affect to the specified gradient
  61734. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61735. * @returns the current particle system
  61736. */
  61737. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61738. /**
  61739. * Not supported by GPUParticleSystem
  61740. * @param gradient defines the gradient to remove
  61741. * @returns the current particle system
  61742. */
  61743. removeEmitRateGradient(gradient: number): IParticleSystem;
  61744. /**
  61745. * Not supported by GPUParticleSystem
  61746. * @param gradient defines the gradient to use (between 0 and 1)
  61747. * @param factor defines the start size value to affect to the specified gradient
  61748. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61749. * @returns the current particle system
  61750. */
  61751. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61752. /**
  61753. * Not supported by GPUParticleSystem
  61754. * @param gradient defines the gradient to remove
  61755. * @returns the current particle system
  61756. */
  61757. removeStartSizeGradient(gradient: number): IParticleSystem;
  61758. /**
  61759. * Not supported by GPUParticleSystem
  61760. * @param gradient defines the gradient to use (between 0 and 1)
  61761. * @param min defines the color remap minimal range
  61762. * @param max defines the color remap maximal range
  61763. * @returns the current particle system
  61764. */
  61765. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61766. /**
  61767. * Not supported by GPUParticleSystem
  61768. * @param gradient defines the gradient to remove
  61769. * @returns the current particle system
  61770. */
  61771. removeColorRemapGradient(): IParticleSystem;
  61772. /**
  61773. * Not supported by GPUParticleSystem
  61774. * @param gradient defines the gradient to use (between 0 and 1)
  61775. * @param min defines the alpha remap minimal range
  61776. * @param max defines the alpha remap maximal range
  61777. * @returns the current particle system
  61778. */
  61779. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61780. /**
  61781. * Not supported by GPUParticleSystem
  61782. * @param gradient defines the gradient to remove
  61783. * @returns the current particle system
  61784. */
  61785. removeAlphaRemapGradient(): IParticleSystem;
  61786. /**
  61787. * Not supported by GPUParticleSystem
  61788. * @param gradient defines the gradient to use (between 0 and 1)
  61789. * @param color defines the color to affect to the specified gradient
  61790. * @returns the current particle system
  61791. */
  61792. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61793. /**
  61794. * Not supported by GPUParticleSystem
  61795. * @param gradient defines the gradient to remove
  61796. * @returns the current particle system
  61797. */
  61798. removeRampGradient(): IParticleSystem;
  61799. /**
  61800. * Not supported by GPUParticleSystem
  61801. * @returns the list of ramp gradients
  61802. */
  61803. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61804. /**
  61805. * Not supported by GPUParticleSystem
  61806. * Gets or sets a boolean indicating that ramp gradients must be used
  61807. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61808. */
  61809. useRampGradients: boolean;
  61810. /**
  61811. * Not supported by GPUParticleSystem
  61812. * @param gradient defines the gradient to use (between 0 and 1)
  61813. * @param factor defines the life time factor to affect to the specified gradient
  61814. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61815. * @returns the current particle system
  61816. */
  61817. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61818. /**
  61819. * Not supported by GPUParticleSystem
  61820. * @param gradient defines the gradient to remove
  61821. * @returns the current particle system
  61822. */
  61823. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61824. /**
  61825. * Instantiates a GPU particle system.
  61826. * 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.
  61827. * @param name The name of the particle system
  61828. * @param options The options used to create the system
  61829. * @param scene The scene the particle system belongs to
  61830. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61831. */
  61832. constructor(name: string, options: Partial<{
  61833. capacity: number;
  61834. randomTextureSize: number;
  61835. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61836. protected _reset(): void;
  61837. private _createUpdateVAO;
  61838. private _createRenderVAO;
  61839. private _initialize;
  61840. /** @hidden */
  61841. _recreateUpdateEffect(): void;
  61842. /** @hidden */
  61843. _recreateRenderEffect(): void;
  61844. /**
  61845. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61846. * @param preWarm defines if we are in the pre-warmimg phase
  61847. */
  61848. animate(preWarm?: boolean): void;
  61849. private _createFactorGradientTexture;
  61850. private _createSizeGradientTexture;
  61851. private _createAngularSpeedGradientTexture;
  61852. private _createVelocityGradientTexture;
  61853. private _createLimitVelocityGradientTexture;
  61854. private _createDragGradientTexture;
  61855. private _createColorGradientTexture;
  61856. /**
  61857. * Renders the particle system in its current state
  61858. * @param preWarm defines if the system should only update the particles but not render them
  61859. * @returns the current number of particles
  61860. */
  61861. render(preWarm?: boolean): number;
  61862. /**
  61863. * Rebuilds the particle system
  61864. */
  61865. rebuild(): void;
  61866. private _releaseBuffers;
  61867. private _releaseVAOs;
  61868. /**
  61869. * Disposes the particle system and free the associated resources
  61870. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61871. */
  61872. dispose(disposeTexture?: boolean): void;
  61873. /**
  61874. * Clones the particle system.
  61875. * @param name The name of the cloned object
  61876. * @param newEmitter The new emitter to use
  61877. * @returns the cloned particle system
  61878. */
  61879. clone(name: string, newEmitter: any): GPUParticleSystem;
  61880. /**
  61881. * Serializes the particle system to a JSON object.
  61882. * @returns the JSON object
  61883. */
  61884. serialize(): any;
  61885. /**
  61886. * Parses a JSON object to create a GPU particle system.
  61887. * @param parsedParticleSystem The JSON object to parse
  61888. * @param scene The scene to create the particle system in
  61889. * @param rootUrl The root url to use to load external dependencies like texture
  61890. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61891. * @returns the parsed GPU particle system
  61892. */
  61893. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61894. }
  61895. }
  61896. declare module "babylonjs/Particles/particleSystemSet" {
  61897. import { Nullable } from "babylonjs/types";
  61898. import { Color3 } from "babylonjs/Maths/math.color";
  61899. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61900. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61901. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61902. import { Scene, IDisposable } from "babylonjs/scene";
  61903. /**
  61904. * Represents a set of particle systems working together to create a specific effect
  61905. */
  61906. export class ParticleSystemSet implements IDisposable {
  61907. /**
  61908. * Gets or sets base Assets URL
  61909. */
  61910. static BaseAssetsUrl: string;
  61911. private _emitterCreationOptions;
  61912. private _emitterNode;
  61913. /**
  61914. * Gets the particle system list
  61915. */
  61916. systems: IParticleSystem[];
  61917. /**
  61918. * Gets the emitter node used with this set
  61919. */
  61920. readonly emitterNode: Nullable<TransformNode>;
  61921. /**
  61922. * Creates a new emitter mesh as a sphere
  61923. * @param options defines the options used to create the sphere
  61924. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61925. * @param scene defines the hosting scene
  61926. */
  61927. setEmitterAsSphere(options: {
  61928. diameter: number;
  61929. segments: number;
  61930. color: Color3;
  61931. }, renderingGroupId: number, scene: Scene): void;
  61932. /**
  61933. * Starts all particle systems of the set
  61934. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61935. */
  61936. start(emitter?: AbstractMesh): void;
  61937. /**
  61938. * Release all associated resources
  61939. */
  61940. dispose(): void;
  61941. /**
  61942. * Serialize the set into a JSON compatible object
  61943. * @returns a JSON compatible representation of the set
  61944. */
  61945. serialize(): any;
  61946. /**
  61947. * Parse a new ParticleSystemSet from a serialized source
  61948. * @param data defines a JSON compatible representation of the set
  61949. * @param scene defines the hosting scene
  61950. * @param gpu defines if we want GPU particles or CPU particles
  61951. * @returns a new ParticleSystemSet
  61952. */
  61953. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61954. }
  61955. }
  61956. declare module "babylonjs/Particles/particleHelper" {
  61957. import { Nullable } from "babylonjs/types";
  61958. import { Scene } from "babylonjs/scene";
  61959. import { Vector3 } from "babylonjs/Maths/math.vector";
  61960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61961. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61962. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61963. /**
  61964. * This class is made for on one-liner static method to help creating particle system set.
  61965. */
  61966. export class ParticleHelper {
  61967. /**
  61968. * Gets or sets base Assets URL
  61969. */
  61970. static BaseAssetsUrl: string;
  61971. /**
  61972. * Create a default particle system that you can tweak
  61973. * @param emitter defines the emitter to use
  61974. * @param capacity defines the system capacity (default is 500 particles)
  61975. * @param scene defines the hosting scene
  61976. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61977. * @returns the new Particle system
  61978. */
  61979. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61980. /**
  61981. * This is the main static method (one-liner) of this helper to create different particle systems
  61982. * @param type This string represents the type to the particle system to create
  61983. * @param scene The scene where the particle system should live
  61984. * @param gpu If the system will use gpu
  61985. * @returns the ParticleSystemSet created
  61986. */
  61987. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61988. /**
  61989. * Static function used to export a particle system to a ParticleSystemSet variable.
  61990. * Please note that the emitter shape is not exported
  61991. * @param systems defines the particle systems to export
  61992. * @returns the created particle system set
  61993. */
  61994. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61995. }
  61996. }
  61997. declare module "babylonjs/Particles/particleSystemComponent" {
  61998. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61999. import { Effect } from "babylonjs/Materials/effect";
  62000. import "babylonjs/Shaders/particles.vertex";
  62001. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  62002. module "babylonjs/Engines/engine" {
  62003. interface Engine {
  62004. /**
  62005. * Create an effect to use with particle systems.
  62006. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62007. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62008. * @param uniformsNames defines a list of attribute names
  62009. * @param samplers defines an array of string used to represent textures
  62010. * @param defines defines the string containing the defines to use to compile the shaders
  62011. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62012. * @param onCompiled defines a function to call when the effect creation is successful
  62013. * @param onError defines a function to call when the effect creation has failed
  62014. * @returns the new Effect
  62015. */
  62016. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62017. }
  62018. }
  62019. module "babylonjs/Meshes/mesh" {
  62020. interface Mesh {
  62021. /**
  62022. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62023. * @returns an array of IParticleSystem
  62024. */
  62025. getEmittedParticleSystems(): IParticleSystem[];
  62026. /**
  62027. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62028. * @returns an array of IParticleSystem
  62029. */
  62030. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62031. }
  62032. }
  62033. /**
  62034. * @hidden
  62035. */
  62036. export var _IDoNeedToBeInTheBuild: number;
  62037. }
  62038. declare module "babylonjs/Particles/pointsCloudSystem" {
  62039. import { Color4 } from "babylonjs/Maths/math";
  62040. import { Mesh } from "babylonjs/Meshes/mesh";
  62041. import { Scene, IDisposable } from "babylonjs/scene";
  62042. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  62043. /** Defines the 4 color options */
  62044. export enum PointColor {
  62045. /** color value */
  62046. Color = 2,
  62047. /** uv value */
  62048. UV = 1,
  62049. /** random value */
  62050. Random = 0,
  62051. /** stated value */
  62052. Stated = 3
  62053. }
  62054. /**
  62055. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62056. * 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.
  62057. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62058. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62059. *
  62060. * Full documentation here : TO BE ENTERED
  62061. */
  62062. export class PointsCloudSystem implements IDisposable {
  62063. /**
  62064. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62065. * Example : var p = SPS.particles[i];
  62066. */
  62067. particles: CloudPoint[];
  62068. /**
  62069. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62070. */
  62071. nbParticles: number;
  62072. /**
  62073. * This a counter for your own usage. It's not set by any SPS functions.
  62074. */
  62075. counter: number;
  62076. /**
  62077. * The PCS name. This name is also given to the underlying mesh.
  62078. */
  62079. name: string;
  62080. /**
  62081. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62082. */
  62083. mesh: Mesh;
  62084. /**
  62085. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62086. * Please read :
  62087. */
  62088. vars: any;
  62089. /**
  62090. * @hidden
  62091. */
  62092. _size: number;
  62093. private _scene;
  62094. private _promises;
  62095. private _positions;
  62096. private _indices;
  62097. private _normals;
  62098. private _colors;
  62099. private _uvs;
  62100. private _indices32;
  62101. private _positions32;
  62102. private _colors32;
  62103. private _uvs32;
  62104. private _updatable;
  62105. private _isVisibilityBoxLocked;
  62106. private _alwaysVisible;
  62107. private _groups;
  62108. private _groupCounter;
  62109. private _computeParticleColor;
  62110. private _computeParticleTexture;
  62111. private _computeParticleRotation;
  62112. private _computeBoundingBox;
  62113. private _isReady;
  62114. /**
  62115. * Creates a PCS (Points Cloud System) object
  62116. * @param name (String) is the PCS name, this will be the underlying mesh name
  62117. * @param pointSize (number) is the size for each point
  62118. * @param scene (Scene) is the scene in which the PCS is added
  62119. * @param options defines the options of the PCS e.g.
  62120. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62121. */
  62122. constructor(name: string, pointSize: number, scene: Scene, options?: {
  62123. updatable?: boolean;
  62124. });
  62125. /**
  62126. * Builds the PCS underlying mesh. Returns a standard Mesh.
  62127. * If no points were added to the PCS, the returned mesh is just a single point.
  62128. * @returns a promise for the created mesh
  62129. */
  62130. buildMeshAsync(): Promise<Mesh>;
  62131. /**
  62132. * @hidden
  62133. */
  62134. private _buildMesh;
  62135. private _addParticle;
  62136. private _randomUnitVector;
  62137. private _getColorIndicesForCoord;
  62138. private _setPointsColorOrUV;
  62139. private _colorFromTexture;
  62140. private _calculateDensity;
  62141. /**
  62142. * Adds points to the PCS in random positions within a unit sphere
  62143. * @param nb (positive integer) the number of particles to be created from this model
  62144. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  62145. * @returns the number of groups in the system
  62146. */
  62147. addPoints(nb: number, pointFunction?: any): number;
  62148. /**
  62149. * Adds points to the PCS from the surface of the model shape
  62150. * @param mesh is any Mesh object that will be used as a surface model for the points
  62151. * @param nb (positive integer) the number of particles to be created from this model
  62152. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62153. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62154. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62155. * @returns the number of groups in the system
  62156. */
  62157. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62158. /**
  62159. * Adds points to the PCS inside the model shape
  62160. * @param mesh is any Mesh object that will be used as a surface model for the points
  62161. * @param nb (positive integer) the number of particles to be created from this model
  62162. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62163. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62164. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62165. * @returns the number of groups in the system
  62166. */
  62167. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62168. /**
  62169. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  62170. * This method calls `updateParticle()` for each particle of the SPS.
  62171. * For an animated SPS, it is usually called within the render loop.
  62172. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  62173. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  62174. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  62175. * @returns the PCS.
  62176. */
  62177. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  62178. /**
  62179. * Disposes the PCS.
  62180. */
  62181. dispose(): void;
  62182. /**
  62183. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  62184. * doc :
  62185. * @returns the PCS.
  62186. */
  62187. refreshVisibleSize(): PointsCloudSystem;
  62188. /**
  62189. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  62190. * @param size the size (float) of the visibility box
  62191. * note : this doesn't lock the PCS mesh bounding box.
  62192. * doc :
  62193. */
  62194. setVisibilityBox(size: number): void;
  62195. /**
  62196. * Gets whether the PCS is always visible or not
  62197. * doc :
  62198. */
  62199. /**
  62200. * Sets the PCS as always visible or not
  62201. * doc :
  62202. */
  62203. isAlwaysVisible: boolean;
  62204. /**
  62205. * Tells to `setParticles()` to compute the particle rotations or not
  62206. * Default value : false. The PCS is faster when it's set to false
  62207. * Note : particle rotations are only applied to parent particles
  62208. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  62209. */
  62210. computeParticleRotation: boolean;
  62211. /**
  62212. * Tells to `setParticles()` to compute the particle colors or not.
  62213. * Default value : true. The PCS is faster when it's set to false.
  62214. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62215. */
  62216. /**
  62217. * Gets if `setParticles()` computes the particle colors or not.
  62218. * Default value : false. The PCS is faster when it's set to false.
  62219. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62220. */
  62221. computeParticleColor: boolean;
  62222. /**
  62223. * Gets if `setParticles()` computes the particle textures or not.
  62224. * Default value : false. The PCS is faster when it's set to false.
  62225. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  62226. */
  62227. computeParticleTexture: boolean;
  62228. /**
  62229. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  62230. */
  62231. /**
  62232. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  62233. */
  62234. computeBoundingBox: boolean;
  62235. /**
  62236. * This function does nothing. It may be overwritten to set all the particle first values.
  62237. * The PCS doesn't call this function, you may have to call it by your own.
  62238. * doc :
  62239. */
  62240. initParticles(): void;
  62241. /**
  62242. * This function does nothing. It may be overwritten to recycle a particle
  62243. * The PCS doesn't call this function, you can to call it
  62244. * doc :
  62245. * @param particle The particle to recycle
  62246. * @returns the recycled particle
  62247. */
  62248. recycleParticle(particle: CloudPoint): CloudPoint;
  62249. /**
  62250. * Updates a particle : this function should be overwritten by the user.
  62251. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  62252. * doc :
  62253. * @example : just set a particle position or velocity and recycle conditions
  62254. * @param particle The particle to update
  62255. * @returns the updated particle
  62256. */
  62257. updateParticle(particle: CloudPoint): CloudPoint;
  62258. /**
  62259. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  62260. * This does nothing and may be overwritten by the user.
  62261. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62262. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62263. * @param update the boolean update value actually passed to setParticles()
  62264. */
  62265. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62266. /**
  62267. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  62268. * This will be passed three parameters.
  62269. * This does nothing and may be overwritten by the user.
  62270. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62271. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62272. * @param update the boolean update value actually passed to setParticles()
  62273. */
  62274. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62275. }
  62276. }
  62277. declare module "babylonjs/Particles/cloudPoint" {
  62278. import { Nullable } from "babylonjs/types";
  62279. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  62280. import { Mesh } from "babylonjs/Meshes/mesh";
  62281. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62282. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  62283. /**
  62284. * Represents one particle of a points cloud system.
  62285. */
  62286. export class CloudPoint {
  62287. /**
  62288. * particle global index
  62289. */
  62290. idx: number;
  62291. /**
  62292. * The color of the particle
  62293. */
  62294. color: Nullable<Color4>;
  62295. /**
  62296. * The world space position of the particle.
  62297. */
  62298. position: Vector3;
  62299. /**
  62300. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  62301. */
  62302. rotation: Vector3;
  62303. /**
  62304. * The world space rotation quaternion of the particle.
  62305. */
  62306. rotationQuaternion: Nullable<Quaternion>;
  62307. /**
  62308. * The uv of the particle.
  62309. */
  62310. uv: Nullable<Vector2>;
  62311. /**
  62312. * The current speed of the particle.
  62313. */
  62314. velocity: Vector3;
  62315. /**
  62316. * The pivot point in the particle local space.
  62317. */
  62318. pivot: Vector3;
  62319. /**
  62320. * Must the particle be translated from its pivot point in its local space ?
  62321. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  62322. * Default : false
  62323. */
  62324. translateFromPivot: boolean;
  62325. /**
  62326. * Index of this particle in the global "positions" array (Internal use)
  62327. * @hidden
  62328. */
  62329. _pos: number;
  62330. /**
  62331. * @hidden Index of this particle in the global "indices" array (Internal use)
  62332. */
  62333. _ind: number;
  62334. /**
  62335. * Group this particle belongs to
  62336. */
  62337. _group: PointsGroup;
  62338. /**
  62339. * Group id of this particle
  62340. */
  62341. groupId: number;
  62342. /**
  62343. * Index of the particle in its group id (Internal use)
  62344. */
  62345. idxInGroup: number;
  62346. /**
  62347. * @hidden Particle BoundingInfo object (Internal use)
  62348. */
  62349. _boundingInfo: BoundingInfo;
  62350. /**
  62351. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  62352. */
  62353. _pcs: PointsCloudSystem;
  62354. /**
  62355. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  62356. */
  62357. _stillInvisible: boolean;
  62358. /**
  62359. * @hidden Last computed particle rotation matrix
  62360. */
  62361. _rotationMatrix: number[];
  62362. /**
  62363. * Parent particle Id, if any.
  62364. * Default null.
  62365. */
  62366. parentId: Nullable<number>;
  62367. /**
  62368. * @hidden Internal global position in the PCS.
  62369. */
  62370. _globalPosition: Vector3;
  62371. /**
  62372. * Creates a Point Cloud object.
  62373. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  62374. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  62375. * @param group (PointsGroup) is the group the particle belongs to
  62376. * @param groupId (integer) is the group identifier in the PCS.
  62377. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  62378. * @param pcs defines the PCS it is associated to
  62379. */
  62380. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  62381. /**
  62382. * get point size
  62383. */
  62384. /**
  62385. * Set point size
  62386. */
  62387. size: Vector3;
  62388. /**
  62389. * Legacy support, changed quaternion to rotationQuaternion
  62390. */
  62391. /**
  62392. * Legacy support, changed quaternion to rotationQuaternion
  62393. */
  62394. quaternion: Nullable<Quaternion>;
  62395. /**
  62396. * Returns a boolean. True if the particle intersects a mesh, else false
  62397. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  62398. * @param target is the object (point or mesh) what the intersection is computed against
  62399. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  62400. * @returns true if it intersects
  62401. */
  62402. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  62403. /**
  62404. * get the rotation matrix of the particle
  62405. * @hidden
  62406. */
  62407. getRotationMatrix(m: Matrix): void;
  62408. }
  62409. /**
  62410. * Represents a group of points in a points cloud system
  62411. * * PCS internal tool, don't use it manually.
  62412. */
  62413. export class PointsGroup {
  62414. /**
  62415. * The group id
  62416. * @hidden
  62417. */
  62418. groupID: number;
  62419. /**
  62420. * image data for group (internal use)
  62421. * @hidden
  62422. */
  62423. _groupImageData: Nullable<ArrayBufferView>;
  62424. /**
  62425. * Image Width (internal use)
  62426. * @hidden
  62427. */
  62428. _groupImgWidth: number;
  62429. /**
  62430. * Image Height (internal use)
  62431. * @hidden
  62432. */
  62433. _groupImgHeight: number;
  62434. /**
  62435. * Custom position function (internal use)
  62436. * @hidden
  62437. */
  62438. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  62439. /**
  62440. * density per facet for surface points
  62441. * @hidden
  62442. */
  62443. _groupDensity: number[];
  62444. /**
  62445. * Only when points are colored by texture carries pointer to texture list array
  62446. * @hidden
  62447. */
  62448. _textureNb: number;
  62449. /**
  62450. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  62451. * PCS internal tool, don't use it manually.
  62452. * @hidden
  62453. */
  62454. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  62455. }
  62456. }
  62457. declare module "babylonjs/Particles/index" {
  62458. export * from "babylonjs/Particles/baseParticleSystem";
  62459. export * from "babylonjs/Particles/EmitterTypes/index";
  62460. export * from "babylonjs/Particles/gpuParticleSystem";
  62461. export * from "babylonjs/Particles/IParticleSystem";
  62462. export * from "babylonjs/Particles/particle";
  62463. export * from "babylonjs/Particles/particleHelper";
  62464. export * from "babylonjs/Particles/particleSystem";
  62465. export * from "babylonjs/Particles/particleSystemComponent";
  62466. export * from "babylonjs/Particles/particleSystemSet";
  62467. export * from "babylonjs/Particles/solidParticle";
  62468. export * from "babylonjs/Particles/solidParticleSystem";
  62469. export * from "babylonjs/Particles/cloudPoint";
  62470. export * from "babylonjs/Particles/pointsCloudSystem";
  62471. export * from "babylonjs/Particles/subEmitter";
  62472. }
  62473. declare module "babylonjs/Physics/physicsEngineComponent" {
  62474. import { Nullable } from "babylonjs/types";
  62475. import { Observable, Observer } from "babylonjs/Misc/observable";
  62476. import { Vector3 } from "babylonjs/Maths/math.vector";
  62477. import { Mesh } from "babylonjs/Meshes/mesh";
  62478. import { ISceneComponent } from "babylonjs/sceneComponent";
  62479. import { Scene } from "babylonjs/scene";
  62480. import { Node } from "babylonjs/node";
  62481. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62482. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62483. module "babylonjs/scene" {
  62484. interface Scene {
  62485. /** @hidden (Backing field) */
  62486. _physicsEngine: Nullable<IPhysicsEngine>;
  62487. /**
  62488. * Gets the current physics engine
  62489. * @returns a IPhysicsEngine or null if none attached
  62490. */
  62491. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  62492. /**
  62493. * Enables physics to the current scene
  62494. * @param gravity defines the scene's gravity for the physics engine
  62495. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  62496. * @return a boolean indicating if the physics engine was initialized
  62497. */
  62498. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  62499. /**
  62500. * Disables and disposes the physics engine associated with the scene
  62501. */
  62502. disablePhysicsEngine(): void;
  62503. /**
  62504. * Gets a boolean indicating if there is an active physics engine
  62505. * @returns a boolean indicating if there is an active physics engine
  62506. */
  62507. isPhysicsEnabled(): boolean;
  62508. /**
  62509. * Deletes a physics compound impostor
  62510. * @param compound defines the compound to delete
  62511. */
  62512. deleteCompoundImpostor(compound: any): void;
  62513. /**
  62514. * An event triggered when physic simulation is about to be run
  62515. */
  62516. onBeforePhysicsObservable: Observable<Scene>;
  62517. /**
  62518. * An event triggered when physic simulation has been done
  62519. */
  62520. onAfterPhysicsObservable: Observable<Scene>;
  62521. }
  62522. }
  62523. module "babylonjs/Meshes/abstractMesh" {
  62524. interface AbstractMesh {
  62525. /** @hidden */
  62526. _physicsImpostor: Nullable<PhysicsImpostor>;
  62527. /**
  62528. * Gets or sets impostor used for physic simulation
  62529. * @see http://doc.babylonjs.com/features/physics_engine
  62530. */
  62531. physicsImpostor: Nullable<PhysicsImpostor>;
  62532. /**
  62533. * Gets the current physics impostor
  62534. * @see http://doc.babylonjs.com/features/physics_engine
  62535. * @returns a physics impostor or null
  62536. */
  62537. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  62538. /** Apply a physic impulse to the mesh
  62539. * @param force defines the force to apply
  62540. * @param contactPoint defines where to apply the force
  62541. * @returns the current mesh
  62542. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  62543. */
  62544. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  62545. /**
  62546. * Creates a physic joint between two meshes
  62547. * @param otherMesh defines the other mesh to use
  62548. * @param pivot1 defines the pivot to use on this mesh
  62549. * @param pivot2 defines the pivot to use on the other mesh
  62550. * @param options defines additional options (can be plugin dependent)
  62551. * @returns the current mesh
  62552. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  62553. */
  62554. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  62555. /** @hidden */
  62556. _disposePhysicsObserver: Nullable<Observer<Node>>;
  62557. }
  62558. }
  62559. /**
  62560. * Defines the physics engine scene component responsible to manage a physics engine
  62561. */
  62562. export class PhysicsEngineSceneComponent implements ISceneComponent {
  62563. /**
  62564. * The component name helpful to identify the component in the list of scene components.
  62565. */
  62566. readonly name: string;
  62567. /**
  62568. * The scene the component belongs to.
  62569. */
  62570. scene: Scene;
  62571. /**
  62572. * Creates a new instance of the component for the given scene
  62573. * @param scene Defines the scene to register the component in
  62574. */
  62575. constructor(scene: Scene);
  62576. /**
  62577. * Registers the component in a given scene
  62578. */
  62579. register(): void;
  62580. /**
  62581. * Rebuilds the elements related to this component in case of
  62582. * context lost for instance.
  62583. */
  62584. rebuild(): void;
  62585. /**
  62586. * Disposes the component and the associated ressources
  62587. */
  62588. dispose(): void;
  62589. }
  62590. }
  62591. declare module "babylonjs/Physics/physicsHelper" {
  62592. import { Nullable } from "babylonjs/types";
  62593. import { Vector3 } from "babylonjs/Maths/math.vector";
  62594. import { Mesh } from "babylonjs/Meshes/mesh";
  62595. import { Scene } from "babylonjs/scene";
  62596. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62597. /**
  62598. * A helper for physics simulations
  62599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62600. */
  62601. export class PhysicsHelper {
  62602. private _scene;
  62603. private _physicsEngine;
  62604. /**
  62605. * Initializes the Physics helper
  62606. * @param scene Babylon.js scene
  62607. */
  62608. constructor(scene: Scene);
  62609. /**
  62610. * Applies a radial explosion impulse
  62611. * @param origin the origin of the explosion
  62612. * @param radiusOrEventOptions the radius or the options of radial explosion
  62613. * @param strength the explosion strength
  62614. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62615. * @returns A physics radial explosion event, or null
  62616. */
  62617. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62618. /**
  62619. * Applies a radial explosion force
  62620. * @param origin the origin of the explosion
  62621. * @param radiusOrEventOptions the radius or the options of radial explosion
  62622. * @param strength the explosion strength
  62623. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62624. * @returns A physics radial explosion event, or null
  62625. */
  62626. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62627. /**
  62628. * Creates a gravitational field
  62629. * @param origin the origin of the explosion
  62630. * @param radiusOrEventOptions the radius or the options of radial explosion
  62631. * @param strength the explosion strength
  62632. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62633. * @returns A physics gravitational field event, or null
  62634. */
  62635. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  62636. /**
  62637. * Creates a physics updraft event
  62638. * @param origin the origin of the updraft
  62639. * @param radiusOrEventOptions the radius or the options of the updraft
  62640. * @param strength the strength of the updraft
  62641. * @param height the height of the updraft
  62642. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  62643. * @returns A physics updraft event, or null
  62644. */
  62645. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  62646. /**
  62647. * Creates a physics vortex event
  62648. * @param origin the of the vortex
  62649. * @param radiusOrEventOptions the radius or the options of the vortex
  62650. * @param strength the strength of the vortex
  62651. * @param height the height of the vortex
  62652. * @returns a Physics vortex event, or null
  62653. * A physics vortex event or null
  62654. */
  62655. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  62656. }
  62657. /**
  62658. * Represents a physics radial explosion event
  62659. */
  62660. class PhysicsRadialExplosionEvent {
  62661. private _scene;
  62662. private _options;
  62663. private _sphere;
  62664. private _dataFetched;
  62665. /**
  62666. * Initializes a radial explosioin event
  62667. * @param _scene BabylonJS scene
  62668. * @param _options The options for the vortex event
  62669. */
  62670. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  62671. /**
  62672. * Returns the data related to the radial explosion event (sphere).
  62673. * @returns The radial explosion event data
  62674. */
  62675. getData(): PhysicsRadialExplosionEventData;
  62676. /**
  62677. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  62678. * @param impostor A physics imposter
  62679. * @param origin the origin of the explosion
  62680. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  62681. */
  62682. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  62683. /**
  62684. * Triggers affecterd impostors callbacks
  62685. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  62686. */
  62687. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  62688. /**
  62689. * Disposes the sphere.
  62690. * @param force Specifies if the sphere should be disposed by force
  62691. */
  62692. dispose(force?: boolean): void;
  62693. /*** Helpers ***/
  62694. private _prepareSphere;
  62695. private _intersectsWithSphere;
  62696. }
  62697. /**
  62698. * Represents a gravitational field event
  62699. */
  62700. class PhysicsGravitationalFieldEvent {
  62701. private _physicsHelper;
  62702. private _scene;
  62703. private _origin;
  62704. private _options;
  62705. private _tickCallback;
  62706. private _sphere;
  62707. private _dataFetched;
  62708. /**
  62709. * Initializes the physics gravitational field event
  62710. * @param _physicsHelper A physics helper
  62711. * @param _scene BabylonJS scene
  62712. * @param _origin The origin position of the gravitational field event
  62713. * @param _options The options for the vortex event
  62714. */
  62715. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  62716. /**
  62717. * Returns the data related to the gravitational field event (sphere).
  62718. * @returns A gravitational field event
  62719. */
  62720. getData(): PhysicsGravitationalFieldEventData;
  62721. /**
  62722. * Enables the gravitational field.
  62723. */
  62724. enable(): void;
  62725. /**
  62726. * Disables the gravitational field.
  62727. */
  62728. disable(): void;
  62729. /**
  62730. * Disposes the sphere.
  62731. * @param force The force to dispose from the gravitational field event
  62732. */
  62733. dispose(force?: boolean): void;
  62734. private _tick;
  62735. }
  62736. /**
  62737. * Represents a physics updraft event
  62738. */
  62739. class PhysicsUpdraftEvent {
  62740. private _scene;
  62741. private _origin;
  62742. private _options;
  62743. private _physicsEngine;
  62744. private _originTop;
  62745. private _originDirection;
  62746. private _tickCallback;
  62747. private _cylinder;
  62748. private _cylinderPosition;
  62749. private _dataFetched;
  62750. /**
  62751. * Initializes the physics updraft event
  62752. * @param _scene BabylonJS scene
  62753. * @param _origin The origin position of the updraft
  62754. * @param _options The options for the updraft event
  62755. */
  62756. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  62757. /**
  62758. * Returns the data related to the updraft event (cylinder).
  62759. * @returns A physics updraft event
  62760. */
  62761. getData(): PhysicsUpdraftEventData;
  62762. /**
  62763. * Enables the updraft.
  62764. */
  62765. enable(): void;
  62766. /**
  62767. * Disables the updraft.
  62768. */
  62769. disable(): void;
  62770. /**
  62771. * Disposes the cylinder.
  62772. * @param force Specifies if the updraft should be disposed by force
  62773. */
  62774. dispose(force?: boolean): void;
  62775. private getImpostorHitData;
  62776. private _tick;
  62777. /*** Helpers ***/
  62778. private _prepareCylinder;
  62779. private _intersectsWithCylinder;
  62780. }
  62781. /**
  62782. * Represents a physics vortex event
  62783. */
  62784. class PhysicsVortexEvent {
  62785. private _scene;
  62786. private _origin;
  62787. private _options;
  62788. private _physicsEngine;
  62789. private _originTop;
  62790. private _tickCallback;
  62791. private _cylinder;
  62792. private _cylinderPosition;
  62793. private _dataFetched;
  62794. /**
  62795. * Initializes the physics vortex event
  62796. * @param _scene The BabylonJS scene
  62797. * @param _origin The origin position of the vortex
  62798. * @param _options The options for the vortex event
  62799. */
  62800. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  62801. /**
  62802. * Returns the data related to the vortex event (cylinder).
  62803. * @returns The physics vortex event data
  62804. */
  62805. getData(): PhysicsVortexEventData;
  62806. /**
  62807. * Enables the vortex.
  62808. */
  62809. enable(): void;
  62810. /**
  62811. * Disables the cortex.
  62812. */
  62813. disable(): void;
  62814. /**
  62815. * Disposes the sphere.
  62816. * @param force
  62817. */
  62818. dispose(force?: boolean): void;
  62819. private getImpostorHitData;
  62820. private _tick;
  62821. /*** Helpers ***/
  62822. private _prepareCylinder;
  62823. private _intersectsWithCylinder;
  62824. }
  62825. /**
  62826. * Options fot the radial explosion event
  62827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62828. */
  62829. export class PhysicsRadialExplosionEventOptions {
  62830. /**
  62831. * The radius of the sphere for the radial explosion.
  62832. */
  62833. radius: number;
  62834. /**
  62835. * The strenth of the explosion.
  62836. */
  62837. strength: number;
  62838. /**
  62839. * The strenght of the force in correspondence to the distance of the affected object
  62840. */
  62841. falloff: PhysicsRadialImpulseFalloff;
  62842. /**
  62843. * Sphere options for the radial explosion.
  62844. */
  62845. sphere: {
  62846. segments: number;
  62847. diameter: number;
  62848. };
  62849. /**
  62850. * Sphere options for the radial explosion.
  62851. */
  62852. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  62853. }
  62854. /**
  62855. * Options fot the updraft event
  62856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62857. */
  62858. export class PhysicsUpdraftEventOptions {
  62859. /**
  62860. * The radius of the cylinder for the vortex
  62861. */
  62862. radius: number;
  62863. /**
  62864. * The strenth of the updraft.
  62865. */
  62866. strength: number;
  62867. /**
  62868. * The height of the cylinder for the updraft.
  62869. */
  62870. height: number;
  62871. /**
  62872. * The mode for the the updraft.
  62873. */
  62874. updraftMode: PhysicsUpdraftMode;
  62875. }
  62876. /**
  62877. * Options fot the vortex event
  62878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62879. */
  62880. export class PhysicsVortexEventOptions {
  62881. /**
  62882. * The radius of the cylinder for the vortex
  62883. */
  62884. radius: number;
  62885. /**
  62886. * The strenth of the vortex.
  62887. */
  62888. strength: number;
  62889. /**
  62890. * The height of the cylinder for the vortex.
  62891. */
  62892. height: number;
  62893. /**
  62894. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  62895. */
  62896. centripetalForceThreshold: number;
  62897. /**
  62898. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  62899. */
  62900. centripetalForceMultiplier: number;
  62901. /**
  62902. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  62903. */
  62904. centrifugalForceMultiplier: number;
  62905. /**
  62906. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  62907. */
  62908. updraftForceMultiplier: number;
  62909. }
  62910. /**
  62911. * The strenght of the force in correspondence to the distance of the affected object
  62912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62913. */
  62914. export enum PhysicsRadialImpulseFalloff {
  62915. /** Defines that impulse is constant in strength across it's whole radius */
  62916. Constant = 0,
  62917. /** Defines that impulse gets weaker if it's further from the origin */
  62918. Linear = 1
  62919. }
  62920. /**
  62921. * The strength of the force in correspondence to the distance of the affected object
  62922. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62923. */
  62924. export enum PhysicsUpdraftMode {
  62925. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  62926. Center = 0,
  62927. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  62928. Perpendicular = 1
  62929. }
  62930. /**
  62931. * Interface for a physics hit data
  62932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62933. */
  62934. export interface PhysicsHitData {
  62935. /**
  62936. * The force applied at the contact point
  62937. */
  62938. force: Vector3;
  62939. /**
  62940. * The contact point
  62941. */
  62942. contactPoint: Vector3;
  62943. /**
  62944. * The distance from the origin to the contact point
  62945. */
  62946. distanceFromOrigin: number;
  62947. }
  62948. /**
  62949. * Interface for radial explosion event data
  62950. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62951. */
  62952. export interface PhysicsRadialExplosionEventData {
  62953. /**
  62954. * A sphere used for the radial explosion event
  62955. */
  62956. sphere: Mesh;
  62957. }
  62958. /**
  62959. * Interface for gravitational field event data
  62960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62961. */
  62962. export interface PhysicsGravitationalFieldEventData {
  62963. /**
  62964. * A sphere mesh used for the gravitational field event
  62965. */
  62966. sphere: Mesh;
  62967. }
  62968. /**
  62969. * Interface for updraft event data
  62970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62971. */
  62972. export interface PhysicsUpdraftEventData {
  62973. /**
  62974. * A cylinder used for the updraft event
  62975. */
  62976. cylinder: Mesh;
  62977. }
  62978. /**
  62979. * Interface for vortex event data
  62980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62981. */
  62982. export interface PhysicsVortexEventData {
  62983. /**
  62984. * A cylinder used for the vortex event
  62985. */
  62986. cylinder: Mesh;
  62987. }
  62988. /**
  62989. * Interface for an affected physics impostor
  62990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62991. */
  62992. export interface PhysicsAffectedImpostorWithData {
  62993. /**
  62994. * The impostor affected by the effect
  62995. */
  62996. impostor: PhysicsImpostor;
  62997. /**
  62998. * The data about the hit/horce from the explosion
  62999. */
  63000. hitData: PhysicsHitData;
  63001. }
  63002. }
  63003. declare module "babylonjs/Physics/Plugins/index" {
  63004. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  63005. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  63006. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  63007. }
  63008. declare module "babylonjs/Physics/index" {
  63009. export * from "babylonjs/Physics/IPhysicsEngine";
  63010. export * from "babylonjs/Physics/physicsEngine";
  63011. export * from "babylonjs/Physics/physicsEngineComponent";
  63012. export * from "babylonjs/Physics/physicsHelper";
  63013. export * from "babylonjs/Physics/physicsImpostor";
  63014. export * from "babylonjs/Physics/physicsJoint";
  63015. export * from "babylonjs/Physics/Plugins/index";
  63016. }
  63017. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  63018. /** @hidden */
  63019. export var blackAndWhitePixelShader: {
  63020. name: string;
  63021. shader: string;
  63022. };
  63023. }
  63024. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  63025. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63026. import { Camera } from "babylonjs/Cameras/camera";
  63027. import { Engine } from "babylonjs/Engines/engine";
  63028. import "babylonjs/Shaders/blackAndWhite.fragment";
  63029. /**
  63030. * Post process used to render in black and white
  63031. */
  63032. export class BlackAndWhitePostProcess extends PostProcess {
  63033. /**
  63034. * Linear about to convert he result to black and white (default: 1)
  63035. */
  63036. degree: number;
  63037. /**
  63038. * Creates a black and white post process
  63039. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63040. * @param name The name of the effect.
  63041. * @param options The required width/height ratio to downsize to before computing the render pass.
  63042. * @param camera The camera to apply the render pass to.
  63043. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63044. * @param engine The engine which the post process will be applied. (default: current engine)
  63045. * @param reusable If the post process can be reused on the same frame. (default: false)
  63046. */
  63047. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63048. }
  63049. }
  63050. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  63051. import { Nullable } from "babylonjs/types";
  63052. import { Camera } from "babylonjs/Cameras/camera";
  63053. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63054. import { Engine } from "babylonjs/Engines/engine";
  63055. /**
  63056. * This represents a set of one or more post processes in Babylon.
  63057. * A post process can be used to apply a shader to a texture after it is rendered.
  63058. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63059. */
  63060. export class PostProcessRenderEffect {
  63061. private _postProcesses;
  63062. private _getPostProcesses;
  63063. private _singleInstance;
  63064. private _cameras;
  63065. private _indicesForCamera;
  63066. /**
  63067. * Name of the effect
  63068. * @hidden
  63069. */
  63070. _name: string;
  63071. /**
  63072. * Instantiates a post process render effect.
  63073. * A post process can be used to apply a shader to a texture after it is rendered.
  63074. * @param engine The engine the effect is tied to
  63075. * @param name The name of the effect
  63076. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63077. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63078. */
  63079. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63080. /**
  63081. * Checks if all the post processes in the effect are supported.
  63082. */
  63083. readonly isSupported: boolean;
  63084. /**
  63085. * Updates the current state of the effect
  63086. * @hidden
  63087. */
  63088. _update(): void;
  63089. /**
  63090. * Attaches the effect on cameras
  63091. * @param cameras The camera to attach to.
  63092. * @hidden
  63093. */
  63094. _attachCameras(cameras: Camera): void;
  63095. /**
  63096. * Attaches the effect on cameras
  63097. * @param cameras The camera to attach to.
  63098. * @hidden
  63099. */
  63100. _attachCameras(cameras: Camera[]): void;
  63101. /**
  63102. * Detaches the effect on cameras
  63103. * @param cameras The camera to detatch from.
  63104. * @hidden
  63105. */
  63106. _detachCameras(cameras: Camera): void;
  63107. /**
  63108. * Detatches the effect on cameras
  63109. * @param cameras The camera to detatch from.
  63110. * @hidden
  63111. */
  63112. _detachCameras(cameras: Camera[]): void;
  63113. /**
  63114. * Enables the effect on given cameras
  63115. * @param cameras The camera to enable.
  63116. * @hidden
  63117. */
  63118. _enable(cameras: Camera): void;
  63119. /**
  63120. * Enables the effect on given cameras
  63121. * @param cameras The camera to enable.
  63122. * @hidden
  63123. */
  63124. _enable(cameras: Nullable<Camera[]>): void;
  63125. /**
  63126. * Disables the effect on the given cameras
  63127. * @param cameras The camera to disable.
  63128. * @hidden
  63129. */
  63130. _disable(cameras: Camera): void;
  63131. /**
  63132. * Disables the effect on the given cameras
  63133. * @param cameras The camera to disable.
  63134. * @hidden
  63135. */
  63136. _disable(cameras: Nullable<Camera[]>): void;
  63137. /**
  63138. * Gets a list of the post processes contained in the effect.
  63139. * @param camera The camera to get the post processes on.
  63140. * @returns The list of the post processes in the effect.
  63141. */
  63142. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63143. }
  63144. }
  63145. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  63146. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63147. /** @hidden */
  63148. export var extractHighlightsPixelShader: {
  63149. name: string;
  63150. shader: string;
  63151. };
  63152. }
  63153. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  63154. import { Nullable } from "babylonjs/types";
  63155. import { Camera } from "babylonjs/Cameras/camera";
  63156. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63157. import { Engine } from "babylonjs/Engines/engine";
  63158. import "babylonjs/Shaders/extractHighlights.fragment";
  63159. /**
  63160. * 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.
  63161. */
  63162. export class ExtractHighlightsPostProcess extends PostProcess {
  63163. /**
  63164. * The luminance threshold, pixels below this value will be set to black.
  63165. */
  63166. threshold: number;
  63167. /** @hidden */
  63168. _exposure: number;
  63169. /**
  63170. * Post process which has the input texture to be used when performing highlight extraction
  63171. * @hidden
  63172. */
  63173. _inputPostProcess: Nullable<PostProcess>;
  63174. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63175. }
  63176. }
  63177. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  63178. /** @hidden */
  63179. export var bloomMergePixelShader: {
  63180. name: string;
  63181. shader: string;
  63182. };
  63183. }
  63184. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  63185. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63186. import { Nullable } from "babylonjs/types";
  63187. import { Engine } from "babylonjs/Engines/engine";
  63188. import { Camera } from "babylonjs/Cameras/camera";
  63189. import "babylonjs/Shaders/bloomMerge.fragment";
  63190. /**
  63191. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63192. */
  63193. export class BloomMergePostProcess extends PostProcess {
  63194. /** Weight of the bloom to be added to the original input. */
  63195. weight: number;
  63196. /**
  63197. * Creates a new instance of @see BloomMergePostProcess
  63198. * @param name The name of the effect.
  63199. * @param originalFromInput Post process which's input will be used for the merge.
  63200. * @param blurred Blurred highlights post process which's output will be used.
  63201. * @param weight Weight of the bloom to be added to the original input.
  63202. * @param options The required width/height ratio to downsize to before computing the render pass.
  63203. * @param camera The camera to apply the render pass to.
  63204. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63205. * @param engine The engine which the post process will be applied. (default: current engine)
  63206. * @param reusable If the post process can be reused on the same frame. (default: false)
  63207. * @param textureType Type of textures used when performing the post process. (default: 0)
  63208. * @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)
  63209. */
  63210. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  63211. /** Weight of the bloom to be added to the original input. */
  63212. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63213. }
  63214. }
  63215. declare module "babylonjs/PostProcesses/bloomEffect" {
  63216. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63217. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63218. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63219. import { Camera } from "babylonjs/Cameras/camera";
  63220. import { Scene } from "babylonjs/scene";
  63221. /**
  63222. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  63223. */
  63224. export class BloomEffect extends PostProcessRenderEffect {
  63225. private bloomScale;
  63226. /**
  63227. * @hidden Internal
  63228. */
  63229. _effects: Array<PostProcess>;
  63230. /**
  63231. * @hidden Internal
  63232. */
  63233. _downscale: ExtractHighlightsPostProcess;
  63234. private _blurX;
  63235. private _blurY;
  63236. private _merge;
  63237. /**
  63238. * The luminance threshold to find bright areas of the image to bloom.
  63239. */
  63240. threshold: number;
  63241. /**
  63242. * The strength of the bloom.
  63243. */
  63244. weight: number;
  63245. /**
  63246. * Specifies the size of the bloom blur kernel, relative to the final output size
  63247. */
  63248. kernel: number;
  63249. /**
  63250. * Creates a new instance of @see BloomEffect
  63251. * @param scene The scene the effect belongs to.
  63252. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  63253. * @param bloomKernel The size of the kernel to be used when applying the blur.
  63254. * @param bloomWeight The the strength of bloom.
  63255. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63256. * @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)
  63257. */
  63258. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  63259. /**
  63260. * Disposes each of the internal effects for a given camera.
  63261. * @param camera The camera to dispose the effect on.
  63262. */
  63263. disposeEffects(camera: Camera): void;
  63264. /**
  63265. * @hidden Internal
  63266. */
  63267. _updateEffects(): void;
  63268. /**
  63269. * Internal
  63270. * @returns if all the contained post processes are ready.
  63271. * @hidden
  63272. */
  63273. _isReady(): boolean;
  63274. }
  63275. }
  63276. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  63277. /** @hidden */
  63278. export var chromaticAberrationPixelShader: {
  63279. name: string;
  63280. shader: string;
  63281. };
  63282. }
  63283. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  63284. import { Vector2 } from "babylonjs/Maths/math.vector";
  63285. import { Nullable } from "babylonjs/types";
  63286. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63287. import { Camera } from "babylonjs/Cameras/camera";
  63288. import { Engine } from "babylonjs/Engines/engine";
  63289. import "babylonjs/Shaders/chromaticAberration.fragment";
  63290. /**
  63291. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  63292. */
  63293. export class ChromaticAberrationPostProcess extends PostProcess {
  63294. /**
  63295. * The amount of seperation of rgb channels (default: 30)
  63296. */
  63297. aberrationAmount: number;
  63298. /**
  63299. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  63300. */
  63301. radialIntensity: number;
  63302. /**
  63303. * 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))
  63304. */
  63305. direction: Vector2;
  63306. /**
  63307. * 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))
  63308. */
  63309. centerPosition: Vector2;
  63310. /**
  63311. * Creates a new instance ChromaticAberrationPostProcess
  63312. * @param name The name of the effect.
  63313. * @param screenWidth The width of the screen to apply the effect on.
  63314. * @param screenHeight The height of the screen to apply the effect on.
  63315. * @param options The required width/height ratio to downsize to before computing the render pass.
  63316. * @param camera The camera to apply the render pass to.
  63317. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63318. * @param engine The engine which the post process will be applied. (default: current engine)
  63319. * @param reusable If the post process can be reused on the same frame. (default: false)
  63320. * @param textureType Type of textures used when performing the post process. (default: 0)
  63321. * @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)
  63322. */
  63323. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63324. }
  63325. }
  63326. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  63327. /** @hidden */
  63328. export var circleOfConfusionPixelShader: {
  63329. name: string;
  63330. shader: string;
  63331. };
  63332. }
  63333. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  63334. import { Nullable } from "babylonjs/types";
  63335. import { Engine } from "babylonjs/Engines/engine";
  63336. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63337. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63338. import { Camera } from "babylonjs/Cameras/camera";
  63339. import "babylonjs/Shaders/circleOfConfusion.fragment";
  63340. /**
  63341. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  63342. */
  63343. export class CircleOfConfusionPostProcess extends PostProcess {
  63344. /**
  63345. * 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.
  63346. */
  63347. lensSize: number;
  63348. /**
  63349. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63350. */
  63351. fStop: number;
  63352. /**
  63353. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63354. */
  63355. focusDistance: number;
  63356. /**
  63357. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  63358. */
  63359. focalLength: number;
  63360. private _depthTexture;
  63361. /**
  63362. * Creates a new instance CircleOfConfusionPostProcess
  63363. * @param name The name of the effect.
  63364. * @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.
  63365. * @param options The required width/height ratio to downsize to before computing the render pass.
  63366. * @param camera The camera to apply the render pass to.
  63367. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63368. * @param engine The engine which the post process will be applied. (default: current engine)
  63369. * @param reusable If the post process can be reused on the same frame. (default: false)
  63370. * @param textureType Type of textures used when performing the post process. (default: 0)
  63371. * @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)
  63372. */
  63373. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63374. /**
  63375. * 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.
  63376. */
  63377. depthTexture: RenderTargetTexture;
  63378. }
  63379. }
  63380. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  63381. /** @hidden */
  63382. export var colorCorrectionPixelShader: {
  63383. name: string;
  63384. shader: string;
  63385. };
  63386. }
  63387. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  63388. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63389. import { Engine } from "babylonjs/Engines/engine";
  63390. import { Camera } from "babylonjs/Cameras/camera";
  63391. import "babylonjs/Shaders/colorCorrection.fragment";
  63392. /**
  63393. *
  63394. * This post-process allows the modification of rendered colors by using
  63395. * a 'look-up table' (LUT). This effect is also called Color Grading.
  63396. *
  63397. * The object needs to be provided an url to a texture containing the color
  63398. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  63399. * Use an image editing software to tweak the LUT to match your needs.
  63400. *
  63401. * For an example of a color LUT, see here:
  63402. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  63403. * For explanations on color grading, see here:
  63404. * @see http://udn.epicgames.com/Three/ColorGrading.html
  63405. *
  63406. */
  63407. export class ColorCorrectionPostProcess extends PostProcess {
  63408. private _colorTableTexture;
  63409. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63410. }
  63411. }
  63412. declare module "babylonjs/Shaders/convolution.fragment" {
  63413. /** @hidden */
  63414. export var convolutionPixelShader: {
  63415. name: string;
  63416. shader: string;
  63417. };
  63418. }
  63419. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  63420. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63421. import { Nullable } from "babylonjs/types";
  63422. import { Camera } from "babylonjs/Cameras/camera";
  63423. import { Engine } from "babylonjs/Engines/engine";
  63424. import "babylonjs/Shaders/convolution.fragment";
  63425. /**
  63426. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  63427. * input texture to perform effects such as edge detection or sharpening
  63428. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63429. */
  63430. export class ConvolutionPostProcess extends PostProcess {
  63431. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63432. kernel: number[];
  63433. /**
  63434. * Creates a new instance ConvolutionPostProcess
  63435. * @param name The name of the effect.
  63436. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  63437. * @param options The required width/height ratio to downsize to before computing the render pass.
  63438. * @param camera The camera to apply the render pass to.
  63439. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63440. * @param engine The engine which the post process will be applied. (default: current engine)
  63441. * @param reusable If the post process can be reused on the same frame. (default: false)
  63442. * @param textureType Type of textures used when performing the post process. (default: 0)
  63443. */
  63444. constructor(name: string,
  63445. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63446. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63447. /**
  63448. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63449. */
  63450. static EdgeDetect0Kernel: number[];
  63451. /**
  63452. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63453. */
  63454. static EdgeDetect1Kernel: number[];
  63455. /**
  63456. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63457. */
  63458. static EdgeDetect2Kernel: number[];
  63459. /**
  63460. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63461. */
  63462. static SharpenKernel: number[];
  63463. /**
  63464. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63465. */
  63466. static EmbossKernel: number[];
  63467. /**
  63468. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63469. */
  63470. static GaussianKernel: number[];
  63471. }
  63472. }
  63473. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  63474. import { Nullable } from "babylonjs/types";
  63475. import { Vector2 } from "babylonjs/Maths/math.vector";
  63476. import { Camera } from "babylonjs/Cameras/camera";
  63477. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63478. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63479. import { Engine } from "babylonjs/Engines/engine";
  63480. import { Scene } from "babylonjs/scene";
  63481. /**
  63482. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  63483. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  63484. * based on samples that have a large difference in distance than the center pixel.
  63485. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  63486. */
  63487. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  63488. direction: Vector2;
  63489. /**
  63490. * Creates a new instance CircleOfConfusionPostProcess
  63491. * @param name The name of the effect.
  63492. * @param scene The scene the effect belongs to.
  63493. * @param direction The direction the blur should be applied.
  63494. * @param kernel The size of the kernel used to blur.
  63495. * @param options The required width/height ratio to downsize to before computing the render pass.
  63496. * @param camera The camera to apply the render pass to.
  63497. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  63498. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  63499. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63500. * @param engine The engine which the post process will be applied. (default: current engine)
  63501. * @param reusable If the post process can be reused on the same frame. (default: false)
  63502. * @param textureType Type of textures used when performing the post process. (default: 0)
  63503. * @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)
  63504. */
  63505. 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);
  63506. }
  63507. }
  63508. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  63509. /** @hidden */
  63510. export var depthOfFieldMergePixelShader: {
  63511. name: string;
  63512. shader: string;
  63513. };
  63514. }
  63515. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  63516. import { Nullable } from "babylonjs/types";
  63517. import { Camera } from "babylonjs/Cameras/camera";
  63518. import { Effect } from "babylonjs/Materials/effect";
  63519. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63520. import { Engine } from "babylonjs/Engines/engine";
  63521. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  63522. /**
  63523. * Options to be set when merging outputs from the default pipeline.
  63524. */
  63525. export class DepthOfFieldMergePostProcessOptions {
  63526. /**
  63527. * The original image to merge on top of
  63528. */
  63529. originalFromInput: PostProcess;
  63530. /**
  63531. * Parameters to perform the merge of the depth of field effect
  63532. */
  63533. depthOfField?: {
  63534. circleOfConfusion: PostProcess;
  63535. blurSteps: Array<PostProcess>;
  63536. };
  63537. /**
  63538. * Parameters to perform the merge of bloom effect
  63539. */
  63540. bloom?: {
  63541. blurred: PostProcess;
  63542. weight: number;
  63543. };
  63544. }
  63545. /**
  63546. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63547. */
  63548. export class DepthOfFieldMergePostProcess extends PostProcess {
  63549. private blurSteps;
  63550. /**
  63551. * Creates a new instance of DepthOfFieldMergePostProcess
  63552. * @param name The name of the effect.
  63553. * @param originalFromInput Post process which's input will be used for the merge.
  63554. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  63555. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  63556. * @param options The required width/height ratio to downsize to before computing the render pass.
  63557. * @param camera The camera to apply the render pass to.
  63558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63559. * @param engine The engine which the post process will be applied. (default: current engine)
  63560. * @param reusable If the post process can be reused on the same frame. (default: false)
  63561. * @param textureType Type of textures used when performing the post process. (default: 0)
  63562. * @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)
  63563. */
  63564. 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);
  63565. /**
  63566. * Updates the effect with the current post process compile time values and recompiles the shader.
  63567. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  63568. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  63569. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  63570. * @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
  63571. * @param onCompiled Called when the shader has been compiled.
  63572. * @param onError Called if there is an error when compiling a shader.
  63573. */
  63574. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  63575. }
  63576. }
  63577. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  63578. import { Nullable } from "babylonjs/types";
  63579. import { Camera } from "babylonjs/Cameras/camera";
  63580. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63581. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63582. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63583. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63584. import { Scene } from "babylonjs/scene";
  63585. /**
  63586. * Specifies the level of max blur that should be applied when using the depth of field effect
  63587. */
  63588. export enum DepthOfFieldEffectBlurLevel {
  63589. /**
  63590. * Subtle blur
  63591. */
  63592. Low = 0,
  63593. /**
  63594. * Medium blur
  63595. */
  63596. Medium = 1,
  63597. /**
  63598. * Large blur
  63599. */
  63600. High = 2
  63601. }
  63602. /**
  63603. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  63604. */
  63605. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  63606. private _circleOfConfusion;
  63607. /**
  63608. * @hidden Internal, blurs from high to low
  63609. */
  63610. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  63611. private _depthOfFieldBlurY;
  63612. private _dofMerge;
  63613. /**
  63614. * @hidden Internal post processes in depth of field effect
  63615. */
  63616. _effects: Array<PostProcess>;
  63617. /**
  63618. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  63619. */
  63620. focalLength: number;
  63621. /**
  63622. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63623. */
  63624. fStop: number;
  63625. /**
  63626. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63627. */
  63628. focusDistance: number;
  63629. /**
  63630. * 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.
  63631. */
  63632. lensSize: number;
  63633. /**
  63634. * Creates a new instance DepthOfFieldEffect
  63635. * @param scene The scene the effect belongs to.
  63636. * @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.
  63637. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63638. * @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)
  63639. */
  63640. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  63641. /**
  63642. * Get the current class name of the current effet
  63643. * @returns "DepthOfFieldEffect"
  63644. */
  63645. getClassName(): string;
  63646. /**
  63647. * 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.
  63648. */
  63649. depthTexture: RenderTargetTexture;
  63650. /**
  63651. * Disposes each of the internal effects for a given camera.
  63652. * @param camera The camera to dispose the effect on.
  63653. */
  63654. disposeEffects(camera: Camera): void;
  63655. /**
  63656. * @hidden Internal
  63657. */
  63658. _updateEffects(): void;
  63659. /**
  63660. * Internal
  63661. * @returns if all the contained post processes are ready.
  63662. * @hidden
  63663. */
  63664. _isReady(): boolean;
  63665. }
  63666. }
  63667. declare module "babylonjs/Shaders/displayPass.fragment" {
  63668. /** @hidden */
  63669. export var displayPassPixelShader: {
  63670. name: string;
  63671. shader: string;
  63672. };
  63673. }
  63674. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  63675. import { Nullable } from "babylonjs/types";
  63676. import { Camera } from "babylonjs/Cameras/camera";
  63677. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63678. import { Engine } from "babylonjs/Engines/engine";
  63679. import "babylonjs/Shaders/displayPass.fragment";
  63680. /**
  63681. * DisplayPassPostProcess which produces an output the same as it's input
  63682. */
  63683. export class DisplayPassPostProcess extends PostProcess {
  63684. /**
  63685. * Creates the DisplayPassPostProcess
  63686. * @param name The name of the effect.
  63687. * @param options The required width/height ratio to downsize to before computing the render pass.
  63688. * @param camera The camera to apply the render pass to.
  63689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63690. * @param engine The engine which the post process will be applied. (default: current engine)
  63691. * @param reusable If the post process can be reused on the same frame. (default: false)
  63692. */
  63693. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63694. }
  63695. }
  63696. declare module "babylonjs/Shaders/filter.fragment" {
  63697. /** @hidden */
  63698. export var filterPixelShader: {
  63699. name: string;
  63700. shader: string;
  63701. };
  63702. }
  63703. declare module "babylonjs/PostProcesses/filterPostProcess" {
  63704. import { Nullable } from "babylonjs/types";
  63705. import { Matrix } from "babylonjs/Maths/math.vector";
  63706. import { Camera } from "babylonjs/Cameras/camera";
  63707. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63708. import { Engine } from "babylonjs/Engines/engine";
  63709. import "babylonjs/Shaders/filter.fragment";
  63710. /**
  63711. * Applies a kernel filter to the image
  63712. */
  63713. export class FilterPostProcess extends PostProcess {
  63714. /** The matrix to be applied to the image */
  63715. kernelMatrix: Matrix;
  63716. /**
  63717. *
  63718. * @param name The name of the effect.
  63719. * @param kernelMatrix The matrix to be applied to the image
  63720. * @param options The required width/height ratio to downsize to before computing the render pass.
  63721. * @param camera The camera to apply the render pass to.
  63722. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63723. * @param engine The engine which the post process will be applied. (default: current engine)
  63724. * @param reusable If the post process can be reused on the same frame. (default: false)
  63725. */
  63726. constructor(name: string,
  63727. /** The matrix to be applied to the image */
  63728. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63729. }
  63730. }
  63731. declare module "babylonjs/Shaders/fxaa.fragment" {
  63732. /** @hidden */
  63733. export var fxaaPixelShader: {
  63734. name: string;
  63735. shader: string;
  63736. };
  63737. }
  63738. declare module "babylonjs/Shaders/fxaa.vertex" {
  63739. /** @hidden */
  63740. export var fxaaVertexShader: {
  63741. name: string;
  63742. shader: string;
  63743. };
  63744. }
  63745. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  63746. import { Nullable } from "babylonjs/types";
  63747. import { Camera } from "babylonjs/Cameras/camera";
  63748. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63749. import { Engine } from "babylonjs/Engines/engine";
  63750. import "babylonjs/Shaders/fxaa.fragment";
  63751. import "babylonjs/Shaders/fxaa.vertex";
  63752. /**
  63753. * Fxaa post process
  63754. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  63755. */
  63756. export class FxaaPostProcess extends PostProcess {
  63757. /** @hidden */
  63758. texelWidth: number;
  63759. /** @hidden */
  63760. texelHeight: number;
  63761. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63762. private _getDefines;
  63763. }
  63764. }
  63765. declare module "babylonjs/Shaders/grain.fragment" {
  63766. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63767. /** @hidden */
  63768. export var grainPixelShader: {
  63769. name: string;
  63770. shader: string;
  63771. };
  63772. }
  63773. declare module "babylonjs/PostProcesses/grainPostProcess" {
  63774. import { Nullable } from "babylonjs/types";
  63775. import { Camera } from "babylonjs/Cameras/camera";
  63776. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63777. import { Engine } from "babylonjs/Engines/engine";
  63778. import "babylonjs/Shaders/grain.fragment";
  63779. /**
  63780. * The GrainPostProcess adds noise to the image at mid luminance levels
  63781. */
  63782. export class GrainPostProcess extends PostProcess {
  63783. /**
  63784. * The intensity of the grain added (default: 30)
  63785. */
  63786. intensity: number;
  63787. /**
  63788. * If the grain should be randomized on every frame
  63789. */
  63790. animated: boolean;
  63791. /**
  63792. * Creates a new instance of @see GrainPostProcess
  63793. * @param name The name of the effect.
  63794. * @param options The required width/height ratio to downsize to before computing the render pass.
  63795. * @param camera The camera to apply the render pass to.
  63796. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63797. * @param engine The engine which the post process will be applied. (default: current engine)
  63798. * @param reusable If the post process can be reused on the same frame. (default: false)
  63799. * @param textureType Type of textures used when performing the post process. (default: 0)
  63800. * @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)
  63801. */
  63802. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63803. }
  63804. }
  63805. declare module "babylonjs/Shaders/highlights.fragment" {
  63806. /** @hidden */
  63807. export var highlightsPixelShader: {
  63808. name: string;
  63809. shader: string;
  63810. };
  63811. }
  63812. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  63813. import { Nullable } from "babylonjs/types";
  63814. import { Camera } from "babylonjs/Cameras/camera";
  63815. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63816. import { Engine } from "babylonjs/Engines/engine";
  63817. import "babylonjs/Shaders/highlights.fragment";
  63818. /**
  63819. * Extracts highlights from the image
  63820. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63821. */
  63822. export class HighlightsPostProcess extends PostProcess {
  63823. /**
  63824. * Extracts highlights from the image
  63825. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63826. * @param name The name of the effect.
  63827. * @param options The required width/height ratio to downsize to before computing the render pass.
  63828. * @param camera The camera to apply the render pass to.
  63829. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63830. * @param engine The engine which the post process will be applied. (default: current engine)
  63831. * @param reusable If the post process can be reused on the same frame. (default: false)
  63832. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  63833. */
  63834. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63835. }
  63836. }
  63837. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  63838. /** @hidden */
  63839. export var mrtFragmentDeclaration: {
  63840. name: string;
  63841. shader: string;
  63842. };
  63843. }
  63844. declare module "babylonjs/Shaders/geometry.fragment" {
  63845. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  63846. /** @hidden */
  63847. export var geometryPixelShader: {
  63848. name: string;
  63849. shader: string;
  63850. };
  63851. }
  63852. declare module "babylonjs/Shaders/geometry.vertex" {
  63853. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63854. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63855. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63856. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63857. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63858. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63859. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63860. /** @hidden */
  63861. export var geometryVertexShader: {
  63862. name: string;
  63863. shader: string;
  63864. };
  63865. }
  63866. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  63867. import { Matrix } from "babylonjs/Maths/math.vector";
  63868. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63869. import { Mesh } from "babylonjs/Meshes/mesh";
  63870. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  63871. import { Effect } from "babylonjs/Materials/effect";
  63872. import { Scene } from "babylonjs/scene";
  63873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63874. import "babylonjs/Shaders/geometry.fragment";
  63875. import "babylonjs/Shaders/geometry.vertex";
  63876. /** @hidden */
  63877. interface ISavedTransformationMatrix {
  63878. world: Matrix;
  63879. viewProjection: Matrix;
  63880. }
  63881. /**
  63882. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  63883. */
  63884. export class GeometryBufferRenderer {
  63885. /**
  63886. * Constant used to retrieve the position texture index in the G-Buffer textures array
  63887. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  63888. */
  63889. static readonly POSITION_TEXTURE_TYPE: number;
  63890. /**
  63891. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  63892. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  63893. */
  63894. static readonly VELOCITY_TEXTURE_TYPE: number;
  63895. /**
  63896. * Dictionary used to store the previous transformation matrices of each rendered mesh
  63897. * in order to compute objects velocities when enableVelocity is set to "true"
  63898. * @hidden
  63899. */
  63900. _previousTransformationMatrices: {
  63901. [index: number]: ISavedTransformationMatrix;
  63902. };
  63903. /**
  63904. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  63905. * in order to compute objects velocities when enableVelocity is set to "true"
  63906. * @hidden
  63907. */
  63908. _previousBonesTransformationMatrices: {
  63909. [index: number]: Float32Array;
  63910. };
  63911. /**
  63912. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  63913. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  63914. */
  63915. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  63916. private _scene;
  63917. private _multiRenderTarget;
  63918. private _ratio;
  63919. private _enablePosition;
  63920. private _enableVelocity;
  63921. private _positionIndex;
  63922. private _velocityIndex;
  63923. protected _effect: Effect;
  63924. protected _cachedDefines: string;
  63925. /**
  63926. * Set the render list (meshes to be rendered) used in the G buffer.
  63927. */
  63928. renderList: Mesh[];
  63929. /**
  63930. * Gets wether or not G buffer are supported by the running hardware.
  63931. * This requires draw buffer supports
  63932. */
  63933. readonly isSupported: boolean;
  63934. /**
  63935. * Returns the index of the given texture type in the G-Buffer textures array
  63936. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  63937. * @returns the index of the given texture type in the G-Buffer textures array
  63938. */
  63939. getTextureIndex(textureType: number): number;
  63940. /**
  63941. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  63942. */
  63943. /**
  63944. * Sets whether or not objects positions are enabled for the G buffer.
  63945. */
  63946. enablePosition: boolean;
  63947. /**
  63948. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  63949. */
  63950. /**
  63951. * Sets wether or not objects velocities are enabled for the G buffer.
  63952. */
  63953. enableVelocity: boolean;
  63954. /**
  63955. * Gets the scene associated with the buffer.
  63956. */
  63957. readonly scene: Scene;
  63958. /**
  63959. * Gets the ratio used by the buffer during its creation.
  63960. * How big is the buffer related to the main canvas.
  63961. */
  63962. readonly ratio: number;
  63963. /** @hidden */
  63964. static _SceneComponentInitialization: (scene: Scene) => void;
  63965. /**
  63966. * Creates a new G Buffer for the scene
  63967. * @param scene The scene the buffer belongs to
  63968. * @param ratio How big is the buffer related to the main canvas.
  63969. */
  63970. constructor(scene: Scene, ratio?: number);
  63971. /**
  63972. * Checks wether everything is ready to render a submesh to the G buffer.
  63973. * @param subMesh the submesh to check readiness for
  63974. * @param useInstances is the mesh drawn using instance or not
  63975. * @returns true if ready otherwise false
  63976. */
  63977. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63978. /**
  63979. * Gets the current underlying G Buffer.
  63980. * @returns the buffer
  63981. */
  63982. getGBuffer(): MultiRenderTarget;
  63983. /**
  63984. * Gets the number of samples used to render the buffer (anti aliasing).
  63985. */
  63986. /**
  63987. * Sets the number of samples used to render the buffer (anti aliasing).
  63988. */
  63989. samples: number;
  63990. /**
  63991. * Disposes the renderer and frees up associated resources.
  63992. */
  63993. dispose(): void;
  63994. protected _createRenderTargets(): void;
  63995. private _copyBonesTransformationMatrices;
  63996. }
  63997. }
  63998. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  63999. import { Nullable } from "babylonjs/types";
  64000. import { Scene } from "babylonjs/scene";
  64001. import { ISceneComponent } from "babylonjs/sceneComponent";
  64002. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  64003. module "babylonjs/scene" {
  64004. interface Scene {
  64005. /** @hidden (Backing field) */
  64006. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64007. /**
  64008. * Gets or Sets the current geometry buffer associated to the scene.
  64009. */
  64010. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64011. /**
  64012. * Enables a GeometryBufferRender and associates it with the scene
  64013. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64014. * @returns the GeometryBufferRenderer
  64015. */
  64016. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64017. /**
  64018. * Disables the GeometryBufferRender associated with the scene
  64019. */
  64020. disableGeometryBufferRenderer(): void;
  64021. }
  64022. }
  64023. /**
  64024. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64025. * in several rendering techniques.
  64026. */
  64027. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64028. /**
  64029. * The component name helpful to identify the component in the list of scene components.
  64030. */
  64031. readonly name: string;
  64032. /**
  64033. * The scene the component belongs to.
  64034. */
  64035. scene: Scene;
  64036. /**
  64037. * Creates a new instance of the component for the given scene
  64038. * @param scene Defines the scene to register the component in
  64039. */
  64040. constructor(scene: Scene);
  64041. /**
  64042. * Registers the component in a given scene
  64043. */
  64044. register(): void;
  64045. /**
  64046. * Rebuilds the elements related to this component in case of
  64047. * context lost for instance.
  64048. */
  64049. rebuild(): void;
  64050. /**
  64051. * Disposes the component and the associated ressources
  64052. */
  64053. dispose(): void;
  64054. private _gatherRenderTargets;
  64055. }
  64056. }
  64057. declare module "babylonjs/Shaders/motionBlur.fragment" {
  64058. /** @hidden */
  64059. export var motionBlurPixelShader: {
  64060. name: string;
  64061. shader: string;
  64062. };
  64063. }
  64064. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  64065. import { Nullable } from "babylonjs/types";
  64066. import { Camera } from "babylonjs/Cameras/camera";
  64067. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64068. import { Scene } from "babylonjs/scene";
  64069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64070. import "babylonjs/Animations/animatable";
  64071. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64072. import "babylonjs/Shaders/motionBlur.fragment";
  64073. import { Engine } from "babylonjs/Engines/engine";
  64074. /**
  64075. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64076. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64077. * As an example, all you have to do is to create the post-process:
  64078. * var mb = new BABYLON.MotionBlurPostProcess(
  64079. * 'mb', // The name of the effect.
  64080. * scene, // The scene containing the objects to blur according to their velocity.
  64081. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64082. * camera // The camera to apply the render pass to.
  64083. * );
  64084. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64085. */
  64086. export class MotionBlurPostProcess extends PostProcess {
  64087. /**
  64088. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64089. */
  64090. motionStrength: number;
  64091. /**
  64092. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64093. */
  64094. /**
  64095. * Sets the number of iterations to be used for motion blur quality
  64096. */
  64097. motionBlurSamples: number;
  64098. private _motionBlurSamples;
  64099. private _geometryBufferRenderer;
  64100. /**
  64101. * Creates a new instance MotionBlurPostProcess
  64102. * @param name The name of the effect.
  64103. * @param scene The scene containing the objects to blur according to their velocity.
  64104. * @param options The required width/height ratio to downsize to before computing the render pass.
  64105. * @param camera The camera to apply the render pass to.
  64106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64107. * @param engine The engine which the post process will be applied. (default: current engine)
  64108. * @param reusable If the post process can be reused on the same frame. (default: false)
  64109. * @param textureType Type of textures used when performing the post process. (default: 0)
  64110. * @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)
  64111. */
  64112. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64113. /**
  64114. * Excludes the given skinned mesh from computing bones velocities.
  64115. * 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.
  64116. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64117. */
  64118. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64119. /**
  64120. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64121. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64122. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64123. */
  64124. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64125. /**
  64126. * Disposes the post process.
  64127. * @param camera The camera to dispose the post process on.
  64128. */
  64129. dispose(camera?: Camera): void;
  64130. }
  64131. }
  64132. declare module "babylonjs/Shaders/refraction.fragment" {
  64133. /** @hidden */
  64134. export var refractionPixelShader: {
  64135. name: string;
  64136. shader: string;
  64137. };
  64138. }
  64139. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  64140. import { Color3 } from "babylonjs/Maths/math.color";
  64141. import { Camera } from "babylonjs/Cameras/camera";
  64142. import { Texture } from "babylonjs/Materials/Textures/texture";
  64143. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64144. import { Engine } from "babylonjs/Engines/engine";
  64145. import "babylonjs/Shaders/refraction.fragment";
  64146. /**
  64147. * Post process which applies a refractin texture
  64148. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64149. */
  64150. export class RefractionPostProcess extends PostProcess {
  64151. /** the base color of the refraction (used to taint the rendering) */
  64152. color: Color3;
  64153. /** simulated refraction depth */
  64154. depth: number;
  64155. /** the coefficient of the base color (0 to remove base color tainting) */
  64156. colorLevel: number;
  64157. private _refTexture;
  64158. private _ownRefractionTexture;
  64159. /**
  64160. * Gets or sets the refraction texture
  64161. * Please note that you are responsible for disposing the texture if you set it manually
  64162. */
  64163. refractionTexture: Texture;
  64164. /**
  64165. * Initializes the RefractionPostProcess
  64166. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64167. * @param name The name of the effect.
  64168. * @param refractionTextureUrl Url of the refraction texture to use
  64169. * @param color the base color of the refraction (used to taint the rendering)
  64170. * @param depth simulated refraction depth
  64171. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64172. * @param camera The camera to apply the render pass to.
  64173. * @param options The required width/height ratio to downsize to before computing the render pass.
  64174. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64175. * @param engine The engine which the post process will be applied. (default: current engine)
  64176. * @param reusable If the post process can be reused on the same frame. (default: false)
  64177. */
  64178. constructor(name: string, refractionTextureUrl: string,
  64179. /** the base color of the refraction (used to taint the rendering) */
  64180. color: Color3,
  64181. /** simulated refraction depth */
  64182. depth: number,
  64183. /** the coefficient of the base color (0 to remove base color tainting) */
  64184. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64185. /**
  64186. * Disposes of the post process
  64187. * @param camera Camera to dispose post process on
  64188. */
  64189. dispose(camera: Camera): void;
  64190. }
  64191. }
  64192. declare module "babylonjs/Shaders/sharpen.fragment" {
  64193. /** @hidden */
  64194. export var sharpenPixelShader: {
  64195. name: string;
  64196. shader: string;
  64197. };
  64198. }
  64199. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  64200. import { Nullable } from "babylonjs/types";
  64201. import { Camera } from "babylonjs/Cameras/camera";
  64202. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64203. import "babylonjs/Shaders/sharpen.fragment";
  64204. import { Engine } from "babylonjs/Engines/engine";
  64205. /**
  64206. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64207. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64208. */
  64209. export class SharpenPostProcess extends PostProcess {
  64210. /**
  64211. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64212. */
  64213. colorAmount: number;
  64214. /**
  64215. * How much sharpness should be applied (default: 0.3)
  64216. */
  64217. edgeAmount: number;
  64218. /**
  64219. * Creates a new instance ConvolutionPostProcess
  64220. * @param name The name of the effect.
  64221. * @param options The required width/height ratio to downsize to before computing the render pass.
  64222. * @param camera The camera to apply the render pass to.
  64223. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64224. * @param engine The engine which the post process will be applied. (default: current engine)
  64225. * @param reusable If the post process can be reused on the same frame. (default: false)
  64226. * @param textureType Type of textures used when performing the post process. (default: 0)
  64227. * @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)
  64228. */
  64229. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64230. }
  64231. }
  64232. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  64233. import { Nullable } from "babylonjs/types";
  64234. import { Camera } from "babylonjs/Cameras/camera";
  64235. import { Engine } from "babylonjs/Engines/engine";
  64236. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64237. import { IInspectable } from "babylonjs/Misc/iInspectable";
  64238. /**
  64239. * PostProcessRenderPipeline
  64240. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64241. */
  64242. export class PostProcessRenderPipeline {
  64243. private engine;
  64244. private _renderEffects;
  64245. private _renderEffectsForIsolatedPass;
  64246. /**
  64247. * List of inspectable custom properties (used by the Inspector)
  64248. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64249. */
  64250. inspectableCustomProperties: IInspectable[];
  64251. /**
  64252. * @hidden
  64253. */
  64254. protected _cameras: Camera[];
  64255. /** @hidden */
  64256. _name: string;
  64257. /**
  64258. * Gets pipeline name
  64259. */
  64260. readonly name: string;
  64261. /** Gets the list of attached cameras */
  64262. readonly cameras: Camera[];
  64263. /**
  64264. * Initializes a PostProcessRenderPipeline
  64265. * @param engine engine to add the pipeline to
  64266. * @param name name of the pipeline
  64267. */
  64268. constructor(engine: Engine, name: string);
  64269. /**
  64270. * Gets the class name
  64271. * @returns "PostProcessRenderPipeline"
  64272. */
  64273. getClassName(): string;
  64274. /**
  64275. * If all the render effects in the pipeline are supported
  64276. */
  64277. readonly isSupported: boolean;
  64278. /**
  64279. * Adds an effect to the pipeline
  64280. * @param renderEffect the effect to add
  64281. */
  64282. addEffect(renderEffect: PostProcessRenderEffect): void;
  64283. /** @hidden */
  64284. _rebuild(): void;
  64285. /** @hidden */
  64286. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64287. /** @hidden */
  64288. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64289. /** @hidden */
  64290. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64291. /** @hidden */
  64292. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64293. /** @hidden */
  64294. _attachCameras(cameras: Camera, unique: boolean): void;
  64295. /** @hidden */
  64296. _attachCameras(cameras: Camera[], unique: boolean): void;
  64297. /** @hidden */
  64298. _detachCameras(cameras: Camera): void;
  64299. /** @hidden */
  64300. _detachCameras(cameras: Nullable<Camera[]>): void;
  64301. /** @hidden */
  64302. _update(): void;
  64303. /** @hidden */
  64304. _reset(): void;
  64305. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  64306. /**
  64307. * Disposes of the pipeline
  64308. */
  64309. dispose(): void;
  64310. }
  64311. }
  64312. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  64313. import { Camera } from "babylonjs/Cameras/camera";
  64314. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64315. /**
  64316. * PostProcessRenderPipelineManager class
  64317. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64318. */
  64319. export class PostProcessRenderPipelineManager {
  64320. private _renderPipelines;
  64321. /**
  64322. * Initializes a PostProcessRenderPipelineManager
  64323. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64324. */
  64325. constructor();
  64326. /**
  64327. * Gets the list of supported render pipelines
  64328. */
  64329. readonly supportedPipelines: PostProcessRenderPipeline[];
  64330. /**
  64331. * Adds a pipeline to the manager
  64332. * @param renderPipeline The pipeline to add
  64333. */
  64334. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  64335. /**
  64336. * Attaches a camera to the pipeline
  64337. * @param renderPipelineName The name of the pipeline to attach to
  64338. * @param cameras the camera to attach
  64339. * @param unique if the camera can be attached multiple times to the pipeline
  64340. */
  64341. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  64342. /**
  64343. * Detaches a camera from the pipeline
  64344. * @param renderPipelineName The name of the pipeline to detach from
  64345. * @param cameras the camera to detach
  64346. */
  64347. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  64348. /**
  64349. * Enables an effect by name on a pipeline
  64350. * @param renderPipelineName the name of the pipeline to enable the effect in
  64351. * @param renderEffectName the name of the effect to enable
  64352. * @param cameras the cameras that the effect should be enabled on
  64353. */
  64354. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64355. /**
  64356. * Disables an effect by name on a pipeline
  64357. * @param renderPipelineName the name of the pipeline to disable the effect in
  64358. * @param renderEffectName the name of the effect to disable
  64359. * @param cameras the cameras that the effect should be disabled on
  64360. */
  64361. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64362. /**
  64363. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  64364. */
  64365. update(): void;
  64366. /** @hidden */
  64367. _rebuild(): void;
  64368. /**
  64369. * Disposes of the manager and pipelines
  64370. */
  64371. dispose(): void;
  64372. }
  64373. }
  64374. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  64375. import { ISceneComponent } from "babylonjs/sceneComponent";
  64376. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64377. import { Scene } from "babylonjs/scene";
  64378. module "babylonjs/scene" {
  64379. interface Scene {
  64380. /** @hidden (Backing field) */
  64381. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64382. /**
  64383. * Gets the postprocess render pipeline manager
  64384. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64385. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64386. */
  64387. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64388. }
  64389. }
  64390. /**
  64391. * Defines the Render Pipeline scene component responsible to rendering pipelines
  64392. */
  64393. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  64394. /**
  64395. * The component name helpfull to identify the component in the list of scene components.
  64396. */
  64397. readonly name: string;
  64398. /**
  64399. * The scene the component belongs to.
  64400. */
  64401. scene: Scene;
  64402. /**
  64403. * Creates a new instance of the component for the given scene
  64404. * @param scene Defines the scene to register the component in
  64405. */
  64406. constructor(scene: Scene);
  64407. /**
  64408. * Registers the component in a given scene
  64409. */
  64410. register(): void;
  64411. /**
  64412. * Rebuilds the elements related to this component in case of
  64413. * context lost for instance.
  64414. */
  64415. rebuild(): void;
  64416. /**
  64417. * Disposes the component and the associated ressources
  64418. */
  64419. dispose(): void;
  64420. private _gatherRenderTargets;
  64421. }
  64422. }
  64423. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  64424. import { Nullable } from "babylonjs/types";
  64425. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64426. import { Camera } from "babylonjs/Cameras/camera";
  64427. import { IDisposable } from "babylonjs/scene";
  64428. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  64429. import { Scene } from "babylonjs/scene";
  64430. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  64431. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64432. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64433. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  64434. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64435. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64436. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  64437. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64438. import { Animation } from "babylonjs/Animations/animation";
  64439. /**
  64440. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  64441. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64442. */
  64443. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64444. private _scene;
  64445. private _camerasToBeAttached;
  64446. /**
  64447. * ID of the sharpen post process,
  64448. */
  64449. private readonly SharpenPostProcessId;
  64450. /**
  64451. * @ignore
  64452. * ID of the image processing post process;
  64453. */
  64454. readonly ImageProcessingPostProcessId: string;
  64455. /**
  64456. * @ignore
  64457. * ID of the Fast Approximate Anti-Aliasing post process;
  64458. */
  64459. readonly FxaaPostProcessId: string;
  64460. /**
  64461. * ID of the chromatic aberration post process,
  64462. */
  64463. private readonly ChromaticAberrationPostProcessId;
  64464. /**
  64465. * ID of the grain post process
  64466. */
  64467. private readonly GrainPostProcessId;
  64468. /**
  64469. * Sharpen post process which will apply a sharpen convolution to enhance edges
  64470. */
  64471. sharpen: SharpenPostProcess;
  64472. private _sharpenEffect;
  64473. private bloom;
  64474. /**
  64475. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  64476. */
  64477. depthOfField: DepthOfFieldEffect;
  64478. /**
  64479. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64480. */
  64481. fxaa: FxaaPostProcess;
  64482. /**
  64483. * Image post processing pass used to perform operations such as tone mapping or color grading.
  64484. */
  64485. imageProcessing: ImageProcessingPostProcess;
  64486. /**
  64487. * Chromatic aberration post process which will shift rgb colors in the image
  64488. */
  64489. chromaticAberration: ChromaticAberrationPostProcess;
  64490. private _chromaticAberrationEffect;
  64491. /**
  64492. * Grain post process which add noise to the image
  64493. */
  64494. grain: GrainPostProcess;
  64495. private _grainEffect;
  64496. /**
  64497. * Glow post process which adds a glow to emissive areas of the image
  64498. */
  64499. private _glowLayer;
  64500. /**
  64501. * Animations which can be used to tweak settings over a period of time
  64502. */
  64503. animations: Animation[];
  64504. private _imageProcessingConfigurationObserver;
  64505. private _sharpenEnabled;
  64506. private _bloomEnabled;
  64507. private _depthOfFieldEnabled;
  64508. private _depthOfFieldBlurLevel;
  64509. private _fxaaEnabled;
  64510. private _imageProcessingEnabled;
  64511. private _defaultPipelineTextureType;
  64512. private _bloomScale;
  64513. private _chromaticAberrationEnabled;
  64514. private _grainEnabled;
  64515. private _buildAllowed;
  64516. /**
  64517. * Gets active scene
  64518. */
  64519. readonly scene: Scene;
  64520. /**
  64521. * Enable or disable the sharpen process from the pipeline
  64522. */
  64523. sharpenEnabled: boolean;
  64524. private _resizeObserver;
  64525. private _hardwareScaleLevel;
  64526. private _bloomKernel;
  64527. /**
  64528. * Specifies the size of the bloom blur kernel, relative to the final output size
  64529. */
  64530. bloomKernel: number;
  64531. /**
  64532. * Specifies the weight of the bloom in the final rendering
  64533. */
  64534. private _bloomWeight;
  64535. /**
  64536. * Specifies the luma threshold for the area that will be blurred by the bloom
  64537. */
  64538. private _bloomThreshold;
  64539. private _hdr;
  64540. /**
  64541. * The strength of the bloom.
  64542. */
  64543. bloomWeight: number;
  64544. /**
  64545. * The strength of the bloom.
  64546. */
  64547. bloomThreshold: number;
  64548. /**
  64549. * The scale of the bloom, lower value will provide better performance.
  64550. */
  64551. bloomScale: number;
  64552. /**
  64553. * Enable or disable the bloom from the pipeline
  64554. */
  64555. bloomEnabled: boolean;
  64556. private _rebuildBloom;
  64557. /**
  64558. * If the depth of field is enabled.
  64559. */
  64560. depthOfFieldEnabled: boolean;
  64561. /**
  64562. * Blur level of the depth of field effect. (Higher blur will effect performance)
  64563. */
  64564. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  64565. /**
  64566. * If the anti aliasing is enabled.
  64567. */
  64568. fxaaEnabled: boolean;
  64569. private _samples;
  64570. /**
  64571. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64572. */
  64573. samples: number;
  64574. /**
  64575. * If image processing is enabled.
  64576. */
  64577. imageProcessingEnabled: boolean;
  64578. /**
  64579. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  64580. */
  64581. glowLayerEnabled: boolean;
  64582. /**
  64583. * Gets the glow layer (or null if not defined)
  64584. */
  64585. readonly glowLayer: Nullable<GlowLayer>;
  64586. /**
  64587. * Enable or disable the chromaticAberration process from the pipeline
  64588. */
  64589. chromaticAberrationEnabled: boolean;
  64590. /**
  64591. * Enable or disable the grain process from the pipeline
  64592. */
  64593. grainEnabled: boolean;
  64594. /**
  64595. * @constructor
  64596. * @param name - The rendering pipeline name (default: "")
  64597. * @param hdr - If high dynamic range textures should be used (default: true)
  64598. * @param scene - The scene linked to this pipeline (default: the last created scene)
  64599. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  64600. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  64601. */
  64602. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  64603. /**
  64604. * Get the class name
  64605. * @returns "DefaultRenderingPipeline"
  64606. */
  64607. getClassName(): string;
  64608. /**
  64609. * Force the compilation of the entire pipeline.
  64610. */
  64611. prepare(): void;
  64612. private _hasCleared;
  64613. private _prevPostProcess;
  64614. private _prevPrevPostProcess;
  64615. private _setAutoClearAndTextureSharing;
  64616. private _depthOfFieldSceneObserver;
  64617. private _buildPipeline;
  64618. private _disposePostProcesses;
  64619. /**
  64620. * Adds a camera to the pipeline
  64621. * @param camera the camera to be added
  64622. */
  64623. addCamera(camera: Camera): void;
  64624. /**
  64625. * Removes a camera from the pipeline
  64626. * @param camera the camera to remove
  64627. */
  64628. removeCamera(camera: Camera): void;
  64629. /**
  64630. * Dispose of the pipeline and stop all post processes
  64631. */
  64632. dispose(): void;
  64633. /**
  64634. * Serialize the rendering pipeline (Used when exporting)
  64635. * @returns the serialized object
  64636. */
  64637. serialize(): any;
  64638. /**
  64639. * Parse the serialized pipeline
  64640. * @param source Source pipeline.
  64641. * @param scene The scene to load the pipeline to.
  64642. * @param rootUrl The URL of the serialized pipeline.
  64643. * @returns An instantiated pipeline from the serialized object.
  64644. */
  64645. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  64646. }
  64647. }
  64648. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  64649. /** @hidden */
  64650. export var lensHighlightsPixelShader: {
  64651. name: string;
  64652. shader: string;
  64653. };
  64654. }
  64655. declare module "babylonjs/Shaders/depthOfField.fragment" {
  64656. /** @hidden */
  64657. export var depthOfFieldPixelShader: {
  64658. name: string;
  64659. shader: string;
  64660. };
  64661. }
  64662. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  64663. import { Camera } from "babylonjs/Cameras/camera";
  64664. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64665. import { Scene } from "babylonjs/scene";
  64666. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64667. import "babylonjs/Shaders/chromaticAberration.fragment";
  64668. import "babylonjs/Shaders/lensHighlights.fragment";
  64669. import "babylonjs/Shaders/depthOfField.fragment";
  64670. /**
  64671. * BABYLON.JS Chromatic Aberration GLSL Shader
  64672. * Author: Olivier Guyot
  64673. * Separates very slightly R, G and B colors on the edges of the screen
  64674. * Inspired by Francois Tarlier & Martins Upitis
  64675. */
  64676. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  64677. /**
  64678. * @ignore
  64679. * The chromatic aberration PostProcess id in the pipeline
  64680. */
  64681. LensChromaticAberrationEffect: string;
  64682. /**
  64683. * @ignore
  64684. * The highlights enhancing PostProcess id in the pipeline
  64685. */
  64686. HighlightsEnhancingEffect: string;
  64687. /**
  64688. * @ignore
  64689. * The depth-of-field PostProcess id in the pipeline
  64690. */
  64691. LensDepthOfFieldEffect: string;
  64692. private _scene;
  64693. private _depthTexture;
  64694. private _grainTexture;
  64695. private _chromaticAberrationPostProcess;
  64696. private _highlightsPostProcess;
  64697. private _depthOfFieldPostProcess;
  64698. private _edgeBlur;
  64699. private _grainAmount;
  64700. private _chromaticAberration;
  64701. private _distortion;
  64702. private _highlightsGain;
  64703. private _highlightsThreshold;
  64704. private _dofDistance;
  64705. private _dofAperture;
  64706. private _dofDarken;
  64707. private _dofPentagon;
  64708. private _blurNoise;
  64709. /**
  64710. * @constructor
  64711. *
  64712. * Effect parameters are as follow:
  64713. * {
  64714. * chromatic_aberration: number; // from 0 to x (1 for realism)
  64715. * edge_blur: number; // from 0 to x (1 for realism)
  64716. * distortion: number; // from 0 to x (1 for realism)
  64717. * grain_amount: number; // from 0 to 1
  64718. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  64719. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  64720. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  64721. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  64722. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  64723. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  64724. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  64725. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  64726. * }
  64727. * Note: if an effect parameter is unset, effect is disabled
  64728. *
  64729. * @param name The rendering pipeline name
  64730. * @param parameters - An object containing all parameters (see above)
  64731. * @param scene The scene linked to this pipeline
  64732. * @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)
  64733. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64734. */
  64735. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  64736. /**
  64737. * Get the class name
  64738. * @returns "LensRenderingPipeline"
  64739. */
  64740. getClassName(): string;
  64741. /**
  64742. * Gets associated scene
  64743. */
  64744. readonly scene: Scene;
  64745. /**
  64746. * Gets or sets the edge blur
  64747. */
  64748. edgeBlur: number;
  64749. /**
  64750. * Gets or sets the grain amount
  64751. */
  64752. grainAmount: number;
  64753. /**
  64754. * Gets or sets the chromatic aberration amount
  64755. */
  64756. chromaticAberration: number;
  64757. /**
  64758. * Gets or sets the depth of field aperture
  64759. */
  64760. dofAperture: number;
  64761. /**
  64762. * Gets or sets the edge distortion
  64763. */
  64764. edgeDistortion: number;
  64765. /**
  64766. * Gets or sets the depth of field distortion
  64767. */
  64768. dofDistortion: number;
  64769. /**
  64770. * Gets or sets the darken out of focus amount
  64771. */
  64772. darkenOutOfFocus: number;
  64773. /**
  64774. * Gets or sets a boolean indicating if blur noise is enabled
  64775. */
  64776. blurNoise: boolean;
  64777. /**
  64778. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  64779. */
  64780. pentagonBokeh: boolean;
  64781. /**
  64782. * Gets or sets the highlight grain amount
  64783. */
  64784. highlightsGain: number;
  64785. /**
  64786. * Gets or sets the highlight threshold
  64787. */
  64788. highlightsThreshold: number;
  64789. /**
  64790. * Sets the amount of blur at the edges
  64791. * @param amount blur amount
  64792. */
  64793. setEdgeBlur(amount: number): void;
  64794. /**
  64795. * Sets edge blur to 0
  64796. */
  64797. disableEdgeBlur(): void;
  64798. /**
  64799. * Sets the amout of grain
  64800. * @param amount Amount of grain
  64801. */
  64802. setGrainAmount(amount: number): void;
  64803. /**
  64804. * Set grain amount to 0
  64805. */
  64806. disableGrain(): void;
  64807. /**
  64808. * Sets the chromatic aberration amount
  64809. * @param amount amount of chromatic aberration
  64810. */
  64811. setChromaticAberration(amount: number): void;
  64812. /**
  64813. * Sets chromatic aberration amount to 0
  64814. */
  64815. disableChromaticAberration(): void;
  64816. /**
  64817. * Sets the EdgeDistortion amount
  64818. * @param amount amount of EdgeDistortion
  64819. */
  64820. setEdgeDistortion(amount: number): void;
  64821. /**
  64822. * Sets edge distortion to 0
  64823. */
  64824. disableEdgeDistortion(): void;
  64825. /**
  64826. * Sets the FocusDistance amount
  64827. * @param amount amount of FocusDistance
  64828. */
  64829. setFocusDistance(amount: number): void;
  64830. /**
  64831. * Disables depth of field
  64832. */
  64833. disableDepthOfField(): void;
  64834. /**
  64835. * Sets the Aperture amount
  64836. * @param amount amount of Aperture
  64837. */
  64838. setAperture(amount: number): void;
  64839. /**
  64840. * Sets the DarkenOutOfFocus amount
  64841. * @param amount amount of DarkenOutOfFocus
  64842. */
  64843. setDarkenOutOfFocus(amount: number): void;
  64844. private _pentagonBokehIsEnabled;
  64845. /**
  64846. * Creates a pentagon bokeh effect
  64847. */
  64848. enablePentagonBokeh(): void;
  64849. /**
  64850. * Disables the pentagon bokeh effect
  64851. */
  64852. disablePentagonBokeh(): void;
  64853. /**
  64854. * Enables noise blur
  64855. */
  64856. enableNoiseBlur(): void;
  64857. /**
  64858. * Disables noise blur
  64859. */
  64860. disableNoiseBlur(): void;
  64861. /**
  64862. * Sets the HighlightsGain amount
  64863. * @param amount amount of HighlightsGain
  64864. */
  64865. setHighlightsGain(amount: number): void;
  64866. /**
  64867. * Sets the HighlightsThreshold amount
  64868. * @param amount amount of HighlightsThreshold
  64869. */
  64870. setHighlightsThreshold(amount: number): void;
  64871. /**
  64872. * Disables highlights
  64873. */
  64874. disableHighlights(): void;
  64875. /**
  64876. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  64877. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  64878. */
  64879. dispose(disableDepthRender?: boolean): void;
  64880. private _createChromaticAberrationPostProcess;
  64881. private _createHighlightsPostProcess;
  64882. private _createDepthOfFieldPostProcess;
  64883. private _createGrainTexture;
  64884. }
  64885. }
  64886. declare module "babylonjs/Shaders/ssao2.fragment" {
  64887. /** @hidden */
  64888. export var ssao2PixelShader: {
  64889. name: string;
  64890. shader: string;
  64891. };
  64892. }
  64893. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  64894. /** @hidden */
  64895. export var ssaoCombinePixelShader: {
  64896. name: string;
  64897. shader: string;
  64898. };
  64899. }
  64900. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  64901. import { Camera } from "babylonjs/Cameras/camera";
  64902. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64903. import { Scene } from "babylonjs/scene";
  64904. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64905. import "babylonjs/Shaders/ssao2.fragment";
  64906. import "babylonjs/Shaders/ssaoCombine.fragment";
  64907. /**
  64908. * Render pipeline to produce ssao effect
  64909. */
  64910. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  64911. /**
  64912. * @ignore
  64913. * The PassPostProcess id in the pipeline that contains the original scene color
  64914. */
  64915. SSAOOriginalSceneColorEffect: string;
  64916. /**
  64917. * @ignore
  64918. * The SSAO PostProcess id in the pipeline
  64919. */
  64920. SSAORenderEffect: string;
  64921. /**
  64922. * @ignore
  64923. * The horizontal blur PostProcess id in the pipeline
  64924. */
  64925. SSAOBlurHRenderEffect: string;
  64926. /**
  64927. * @ignore
  64928. * The vertical blur PostProcess id in the pipeline
  64929. */
  64930. SSAOBlurVRenderEffect: string;
  64931. /**
  64932. * @ignore
  64933. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64934. */
  64935. SSAOCombineRenderEffect: string;
  64936. /**
  64937. * The output strength of the SSAO post-process. Default value is 1.0.
  64938. */
  64939. totalStrength: number;
  64940. /**
  64941. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  64942. */
  64943. maxZ: number;
  64944. /**
  64945. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  64946. */
  64947. minZAspect: number;
  64948. private _samples;
  64949. /**
  64950. * Number of samples used for the SSAO calculations. Default value is 8
  64951. */
  64952. samples: number;
  64953. private _textureSamples;
  64954. /**
  64955. * Number of samples to use for antialiasing
  64956. */
  64957. textureSamples: number;
  64958. /**
  64959. * Ratio object used for SSAO ratio and blur ratio
  64960. */
  64961. private _ratio;
  64962. /**
  64963. * Dynamically generated sphere sampler.
  64964. */
  64965. private _sampleSphere;
  64966. /**
  64967. * Blur filter offsets
  64968. */
  64969. private _samplerOffsets;
  64970. private _expensiveBlur;
  64971. /**
  64972. * If bilateral blur should be used
  64973. */
  64974. expensiveBlur: boolean;
  64975. /**
  64976. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  64977. */
  64978. radius: number;
  64979. /**
  64980. * The base color of the SSAO post-process
  64981. * The final result is "base + ssao" between [0, 1]
  64982. */
  64983. base: number;
  64984. /**
  64985. * Support test.
  64986. */
  64987. static readonly IsSupported: boolean;
  64988. private _scene;
  64989. private _depthTexture;
  64990. private _normalTexture;
  64991. private _randomTexture;
  64992. private _originalColorPostProcess;
  64993. private _ssaoPostProcess;
  64994. private _blurHPostProcess;
  64995. private _blurVPostProcess;
  64996. private _ssaoCombinePostProcess;
  64997. /**
  64998. * Gets active scene
  64999. */
  65000. readonly scene: Scene;
  65001. /**
  65002. * @constructor
  65003. * @param name The rendering pipeline name
  65004. * @param scene The scene linked to this pipeline
  65005. * @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 }
  65006. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65007. */
  65008. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65009. /**
  65010. * Get the class name
  65011. * @returns "SSAO2RenderingPipeline"
  65012. */
  65013. getClassName(): string;
  65014. /**
  65015. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65016. */
  65017. dispose(disableGeometryBufferRenderer?: boolean): void;
  65018. private _createBlurPostProcess;
  65019. /** @hidden */
  65020. _rebuild(): void;
  65021. private _bits;
  65022. private _radicalInverse_VdC;
  65023. private _hammersley;
  65024. private _hemisphereSample_uniform;
  65025. private _generateHemisphere;
  65026. private _createSSAOPostProcess;
  65027. private _createSSAOCombinePostProcess;
  65028. private _createRandomTexture;
  65029. /**
  65030. * Serialize the rendering pipeline (Used when exporting)
  65031. * @returns the serialized object
  65032. */
  65033. serialize(): any;
  65034. /**
  65035. * Parse the serialized pipeline
  65036. * @param source Source pipeline.
  65037. * @param scene The scene to load the pipeline to.
  65038. * @param rootUrl The URL of the serialized pipeline.
  65039. * @returns An instantiated pipeline from the serialized object.
  65040. */
  65041. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65042. }
  65043. }
  65044. declare module "babylonjs/Shaders/ssao.fragment" {
  65045. /** @hidden */
  65046. export var ssaoPixelShader: {
  65047. name: string;
  65048. shader: string;
  65049. };
  65050. }
  65051. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  65052. import { Camera } from "babylonjs/Cameras/camera";
  65053. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65054. import { Scene } from "babylonjs/scene";
  65055. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65056. import "babylonjs/Shaders/ssao.fragment";
  65057. import "babylonjs/Shaders/ssaoCombine.fragment";
  65058. /**
  65059. * Render pipeline to produce ssao effect
  65060. */
  65061. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65062. /**
  65063. * @ignore
  65064. * The PassPostProcess id in the pipeline that contains the original scene color
  65065. */
  65066. SSAOOriginalSceneColorEffect: string;
  65067. /**
  65068. * @ignore
  65069. * The SSAO PostProcess id in the pipeline
  65070. */
  65071. SSAORenderEffect: string;
  65072. /**
  65073. * @ignore
  65074. * The horizontal blur PostProcess id in the pipeline
  65075. */
  65076. SSAOBlurHRenderEffect: string;
  65077. /**
  65078. * @ignore
  65079. * The vertical blur PostProcess id in the pipeline
  65080. */
  65081. SSAOBlurVRenderEffect: string;
  65082. /**
  65083. * @ignore
  65084. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65085. */
  65086. SSAOCombineRenderEffect: string;
  65087. /**
  65088. * The output strength of the SSAO post-process. Default value is 1.0.
  65089. */
  65090. totalStrength: number;
  65091. /**
  65092. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65093. */
  65094. radius: number;
  65095. /**
  65096. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65097. * Must not be equal to fallOff and superior to fallOff.
  65098. * Default value is 0.0075
  65099. */
  65100. area: number;
  65101. /**
  65102. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65103. * Must not be equal to area and inferior to area.
  65104. * Default value is 0.000001
  65105. */
  65106. fallOff: number;
  65107. /**
  65108. * The base color of the SSAO post-process
  65109. * The final result is "base + ssao" between [0, 1]
  65110. */
  65111. base: number;
  65112. private _scene;
  65113. private _depthTexture;
  65114. private _randomTexture;
  65115. private _originalColorPostProcess;
  65116. private _ssaoPostProcess;
  65117. private _blurHPostProcess;
  65118. private _blurVPostProcess;
  65119. private _ssaoCombinePostProcess;
  65120. private _firstUpdate;
  65121. /**
  65122. * Gets active scene
  65123. */
  65124. readonly scene: Scene;
  65125. /**
  65126. * @constructor
  65127. * @param name - The rendering pipeline name
  65128. * @param scene - The scene linked to this pipeline
  65129. * @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 }
  65130. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65131. */
  65132. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65133. /**
  65134. * Get the class name
  65135. * @returns "SSAORenderingPipeline"
  65136. */
  65137. getClassName(): string;
  65138. /**
  65139. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65140. */
  65141. dispose(disableDepthRender?: boolean): void;
  65142. private _createBlurPostProcess;
  65143. /** @hidden */
  65144. _rebuild(): void;
  65145. private _createSSAOPostProcess;
  65146. private _createSSAOCombinePostProcess;
  65147. private _createRandomTexture;
  65148. }
  65149. }
  65150. declare module "babylonjs/Shaders/standard.fragment" {
  65151. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65152. /** @hidden */
  65153. export var standardPixelShader: {
  65154. name: string;
  65155. shader: string;
  65156. };
  65157. }
  65158. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  65159. import { Nullable } from "babylonjs/types";
  65160. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65161. import { Camera } from "babylonjs/Cameras/camera";
  65162. import { Texture } from "babylonjs/Materials/Textures/texture";
  65163. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65164. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65165. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65166. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65167. import { IDisposable } from "babylonjs/scene";
  65168. import { SpotLight } from "babylonjs/Lights/spotLight";
  65169. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  65170. import { Scene } from "babylonjs/scene";
  65171. import { Animation } from "babylonjs/Animations/animation";
  65172. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65173. import "babylonjs/Shaders/standard.fragment";
  65174. /**
  65175. * Standard rendering pipeline
  65176. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65177. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65178. */
  65179. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65180. /**
  65181. * Public members
  65182. */
  65183. /**
  65184. * Post-process which contains the original scene color before the pipeline applies all the effects
  65185. */
  65186. originalPostProcess: Nullable<PostProcess>;
  65187. /**
  65188. * Post-process used to down scale an image x4
  65189. */
  65190. downSampleX4PostProcess: Nullable<PostProcess>;
  65191. /**
  65192. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65193. */
  65194. brightPassPostProcess: Nullable<PostProcess>;
  65195. /**
  65196. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65197. */
  65198. blurHPostProcesses: PostProcess[];
  65199. /**
  65200. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65201. */
  65202. blurVPostProcesses: PostProcess[];
  65203. /**
  65204. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65205. */
  65206. textureAdderPostProcess: Nullable<PostProcess>;
  65207. /**
  65208. * Post-process used to create volumetric lighting effect
  65209. */
  65210. volumetricLightPostProcess: Nullable<PostProcess>;
  65211. /**
  65212. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65213. */
  65214. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65215. /**
  65216. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65217. */
  65218. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65219. /**
  65220. * Post-process used to merge the volumetric light effect and the real scene color
  65221. */
  65222. volumetricLightMergePostProces: Nullable<PostProcess>;
  65223. /**
  65224. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65225. */
  65226. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65227. /**
  65228. * Base post-process used to calculate the average luminance of the final image for HDR
  65229. */
  65230. luminancePostProcess: Nullable<PostProcess>;
  65231. /**
  65232. * Post-processes used to create down sample post-processes in order to get
  65233. * the average luminance of the final image for HDR
  65234. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  65235. */
  65236. luminanceDownSamplePostProcesses: PostProcess[];
  65237. /**
  65238. * Post-process used to create a HDR effect (light adaptation)
  65239. */
  65240. hdrPostProcess: Nullable<PostProcess>;
  65241. /**
  65242. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  65243. */
  65244. textureAdderFinalPostProcess: Nullable<PostProcess>;
  65245. /**
  65246. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  65247. */
  65248. lensFlareFinalPostProcess: Nullable<PostProcess>;
  65249. /**
  65250. * Post-process used to merge the final HDR post-process and the real scene color
  65251. */
  65252. hdrFinalPostProcess: Nullable<PostProcess>;
  65253. /**
  65254. * Post-process used to create a lens flare effect
  65255. */
  65256. lensFlarePostProcess: Nullable<PostProcess>;
  65257. /**
  65258. * Post-process that merges the result of the lens flare post-process and the real scene color
  65259. */
  65260. lensFlareComposePostProcess: Nullable<PostProcess>;
  65261. /**
  65262. * Post-process used to create a motion blur effect
  65263. */
  65264. motionBlurPostProcess: Nullable<PostProcess>;
  65265. /**
  65266. * Post-process used to create a depth of field effect
  65267. */
  65268. depthOfFieldPostProcess: Nullable<PostProcess>;
  65269. /**
  65270. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65271. */
  65272. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65273. /**
  65274. * Represents the brightness threshold in order to configure the illuminated surfaces
  65275. */
  65276. brightThreshold: number;
  65277. /**
  65278. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  65279. */
  65280. blurWidth: number;
  65281. /**
  65282. * Sets if the blur for highlighted surfaces must be only horizontal
  65283. */
  65284. horizontalBlur: boolean;
  65285. /**
  65286. * Gets the overall exposure used by the pipeline
  65287. */
  65288. /**
  65289. * Sets the overall exposure used by the pipeline
  65290. */
  65291. exposure: number;
  65292. /**
  65293. * Texture used typically to simulate "dirty" on camera lens
  65294. */
  65295. lensTexture: Nullable<Texture>;
  65296. /**
  65297. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  65298. */
  65299. volumetricLightCoefficient: number;
  65300. /**
  65301. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  65302. */
  65303. volumetricLightPower: number;
  65304. /**
  65305. * Used the set the blur intensity to smooth the volumetric lights
  65306. */
  65307. volumetricLightBlurScale: number;
  65308. /**
  65309. * Light (spot or directional) used to generate the volumetric lights rays
  65310. * The source light must have a shadow generate so the pipeline can get its
  65311. * depth map
  65312. */
  65313. sourceLight: Nullable<SpotLight | DirectionalLight>;
  65314. /**
  65315. * For eye adaptation, represents the minimum luminance the eye can see
  65316. */
  65317. hdrMinimumLuminance: number;
  65318. /**
  65319. * For eye adaptation, represents the decrease luminance speed
  65320. */
  65321. hdrDecreaseRate: number;
  65322. /**
  65323. * For eye adaptation, represents the increase luminance speed
  65324. */
  65325. hdrIncreaseRate: number;
  65326. /**
  65327. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65328. */
  65329. /**
  65330. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65331. */
  65332. hdrAutoExposure: boolean;
  65333. /**
  65334. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  65335. */
  65336. lensColorTexture: Nullable<Texture>;
  65337. /**
  65338. * The overall strengh for the lens flare effect
  65339. */
  65340. lensFlareStrength: number;
  65341. /**
  65342. * Dispersion coefficient for lens flare ghosts
  65343. */
  65344. lensFlareGhostDispersal: number;
  65345. /**
  65346. * Main lens flare halo width
  65347. */
  65348. lensFlareHaloWidth: number;
  65349. /**
  65350. * Based on the lens distortion effect, defines how much the lens flare result
  65351. * is distorted
  65352. */
  65353. lensFlareDistortionStrength: number;
  65354. /**
  65355. * Configures the blur intensity used for for lens flare (halo)
  65356. */
  65357. lensFlareBlurWidth: number;
  65358. /**
  65359. * Lens star texture must be used to simulate rays on the flares and is available
  65360. * in the documentation
  65361. */
  65362. lensStarTexture: Nullable<Texture>;
  65363. /**
  65364. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  65365. * flare effect by taking account of the dirt texture
  65366. */
  65367. lensFlareDirtTexture: Nullable<Texture>;
  65368. /**
  65369. * Represents the focal length for the depth of field effect
  65370. */
  65371. depthOfFieldDistance: number;
  65372. /**
  65373. * Represents the blur intensity for the blurred part of the depth of field effect
  65374. */
  65375. depthOfFieldBlurWidth: number;
  65376. /**
  65377. * Gets how much the image is blurred by the movement while using the motion blur post-process
  65378. */
  65379. /**
  65380. * Sets how much the image is blurred by the movement while using the motion blur post-process
  65381. */
  65382. motionStrength: number;
  65383. /**
  65384. * Gets wether or not the motion blur post-process is object based or screen based.
  65385. */
  65386. /**
  65387. * Sets wether or not the motion blur post-process should be object based or screen based
  65388. */
  65389. objectBasedMotionBlur: boolean;
  65390. /**
  65391. * List of animations for the pipeline (IAnimatable implementation)
  65392. */
  65393. animations: Animation[];
  65394. /**
  65395. * Private members
  65396. */
  65397. private _scene;
  65398. private _currentDepthOfFieldSource;
  65399. private _basePostProcess;
  65400. private _fixedExposure;
  65401. private _currentExposure;
  65402. private _hdrAutoExposure;
  65403. private _hdrCurrentLuminance;
  65404. private _motionStrength;
  65405. private _isObjectBasedMotionBlur;
  65406. private _floatTextureType;
  65407. private _camerasToBeAttached;
  65408. private _ratio;
  65409. private _bloomEnabled;
  65410. private _depthOfFieldEnabled;
  65411. private _vlsEnabled;
  65412. private _lensFlareEnabled;
  65413. private _hdrEnabled;
  65414. private _motionBlurEnabled;
  65415. private _fxaaEnabled;
  65416. private _motionBlurSamples;
  65417. private _volumetricLightStepsCount;
  65418. private _samples;
  65419. /**
  65420. * @ignore
  65421. * Specifies if the bloom pipeline is enabled
  65422. */
  65423. BloomEnabled: boolean;
  65424. /**
  65425. * @ignore
  65426. * Specifies if the depth of field pipeline is enabed
  65427. */
  65428. DepthOfFieldEnabled: boolean;
  65429. /**
  65430. * @ignore
  65431. * Specifies if the lens flare pipeline is enabed
  65432. */
  65433. LensFlareEnabled: boolean;
  65434. /**
  65435. * @ignore
  65436. * Specifies if the HDR pipeline is enabled
  65437. */
  65438. HDREnabled: boolean;
  65439. /**
  65440. * @ignore
  65441. * Specifies if the volumetric lights scattering effect is enabled
  65442. */
  65443. VLSEnabled: boolean;
  65444. /**
  65445. * @ignore
  65446. * Specifies if the motion blur effect is enabled
  65447. */
  65448. MotionBlurEnabled: boolean;
  65449. /**
  65450. * Specifies if anti-aliasing is enabled
  65451. */
  65452. fxaaEnabled: boolean;
  65453. /**
  65454. * Specifies the number of steps used to calculate the volumetric lights
  65455. * Typically in interval [50, 200]
  65456. */
  65457. volumetricLightStepsCount: number;
  65458. /**
  65459. * Specifies the number of samples used for the motion blur effect
  65460. * Typically in interval [16, 64]
  65461. */
  65462. motionBlurSamples: number;
  65463. /**
  65464. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65465. */
  65466. samples: number;
  65467. /**
  65468. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65469. * @constructor
  65470. * @param name The rendering pipeline name
  65471. * @param scene The scene linked to this pipeline
  65472. * @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)
  65473. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  65474. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65475. */
  65476. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  65477. private _buildPipeline;
  65478. private _createDownSampleX4PostProcess;
  65479. private _createBrightPassPostProcess;
  65480. private _createBlurPostProcesses;
  65481. private _createTextureAdderPostProcess;
  65482. private _createVolumetricLightPostProcess;
  65483. private _createLuminancePostProcesses;
  65484. private _createHdrPostProcess;
  65485. private _createLensFlarePostProcess;
  65486. private _createDepthOfFieldPostProcess;
  65487. private _createMotionBlurPostProcess;
  65488. private _getDepthTexture;
  65489. private _disposePostProcesses;
  65490. /**
  65491. * Dispose of the pipeline and stop all post processes
  65492. */
  65493. dispose(): void;
  65494. /**
  65495. * Serialize the rendering pipeline (Used when exporting)
  65496. * @returns the serialized object
  65497. */
  65498. serialize(): any;
  65499. /**
  65500. * Parse the serialized pipeline
  65501. * @param source Source pipeline.
  65502. * @param scene The scene to load the pipeline to.
  65503. * @param rootUrl The URL of the serialized pipeline.
  65504. * @returns An instantiated pipeline from the serialized object.
  65505. */
  65506. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  65507. /**
  65508. * Luminance steps
  65509. */
  65510. static LuminanceSteps: number;
  65511. }
  65512. }
  65513. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  65514. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  65515. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  65516. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  65517. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  65518. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  65519. }
  65520. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  65521. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  65522. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65523. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65524. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65525. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65526. }
  65527. declare module "babylonjs/Shaders/tonemap.fragment" {
  65528. /** @hidden */
  65529. export var tonemapPixelShader: {
  65530. name: string;
  65531. shader: string;
  65532. };
  65533. }
  65534. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  65535. import { Camera } from "babylonjs/Cameras/camera";
  65536. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65537. import "babylonjs/Shaders/tonemap.fragment";
  65538. import { Engine } from "babylonjs/Engines/engine";
  65539. /** Defines operator used for tonemapping */
  65540. export enum TonemappingOperator {
  65541. /** Hable */
  65542. Hable = 0,
  65543. /** Reinhard */
  65544. Reinhard = 1,
  65545. /** HejiDawson */
  65546. HejiDawson = 2,
  65547. /** Photographic */
  65548. Photographic = 3
  65549. }
  65550. /**
  65551. * Defines a post process to apply tone mapping
  65552. */
  65553. export class TonemapPostProcess extends PostProcess {
  65554. private _operator;
  65555. /** Defines the required exposure adjustement */
  65556. exposureAdjustment: number;
  65557. /**
  65558. * Creates a new TonemapPostProcess
  65559. * @param name defines the name of the postprocess
  65560. * @param _operator defines the operator to use
  65561. * @param exposureAdjustment defines the required exposure adjustement
  65562. * @param camera defines the camera to use (can be null)
  65563. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  65564. * @param engine defines the hosting engine (can be ignore if camera is set)
  65565. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65566. */
  65567. constructor(name: string, _operator: TonemappingOperator,
  65568. /** Defines the required exposure adjustement */
  65569. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  65570. }
  65571. }
  65572. declare module "babylonjs/Shaders/depth.vertex" {
  65573. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65574. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65575. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65576. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65577. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65578. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65579. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65580. /** @hidden */
  65581. export var depthVertexShader: {
  65582. name: string;
  65583. shader: string;
  65584. };
  65585. }
  65586. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  65587. /** @hidden */
  65588. export var volumetricLightScatteringPixelShader: {
  65589. name: string;
  65590. shader: string;
  65591. };
  65592. }
  65593. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  65594. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65595. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65596. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65597. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65598. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65599. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65600. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65601. /** @hidden */
  65602. export var volumetricLightScatteringPassVertexShader: {
  65603. name: string;
  65604. shader: string;
  65605. };
  65606. }
  65607. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  65608. /** @hidden */
  65609. export var volumetricLightScatteringPassPixelShader: {
  65610. name: string;
  65611. shader: string;
  65612. };
  65613. }
  65614. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  65615. import { Vector3 } from "babylonjs/Maths/math.vector";
  65616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65617. import { Mesh } from "babylonjs/Meshes/mesh";
  65618. import { Camera } from "babylonjs/Cameras/camera";
  65619. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65620. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65621. import { Scene } from "babylonjs/scene";
  65622. import "babylonjs/Meshes/Builders/planeBuilder";
  65623. import "babylonjs/Shaders/depth.vertex";
  65624. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  65625. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  65626. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  65627. import { Engine } from "babylonjs/Engines/engine";
  65628. /**
  65629. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  65630. */
  65631. export class VolumetricLightScatteringPostProcess extends PostProcess {
  65632. private _volumetricLightScatteringPass;
  65633. private _volumetricLightScatteringRTT;
  65634. private _viewPort;
  65635. private _screenCoordinates;
  65636. private _cachedDefines;
  65637. /**
  65638. * If not undefined, the mesh position is computed from the attached node position
  65639. */
  65640. attachedNode: {
  65641. position: Vector3;
  65642. };
  65643. /**
  65644. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  65645. */
  65646. customMeshPosition: Vector3;
  65647. /**
  65648. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  65649. */
  65650. useCustomMeshPosition: boolean;
  65651. /**
  65652. * If the post-process should inverse the light scattering direction
  65653. */
  65654. invert: boolean;
  65655. /**
  65656. * The internal mesh used by the post-process
  65657. */
  65658. mesh: Mesh;
  65659. /**
  65660. * @hidden
  65661. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  65662. */
  65663. useDiffuseColor: boolean;
  65664. /**
  65665. * Array containing the excluded meshes not rendered in the internal pass
  65666. */
  65667. excludedMeshes: AbstractMesh[];
  65668. /**
  65669. * Controls the overall intensity of the post-process
  65670. */
  65671. exposure: number;
  65672. /**
  65673. * Dissipates each sample's contribution in range [0, 1]
  65674. */
  65675. decay: number;
  65676. /**
  65677. * Controls the overall intensity of each sample
  65678. */
  65679. weight: number;
  65680. /**
  65681. * Controls the density of each sample
  65682. */
  65683. density: number;
  65684. /**
  65685. * @constructor
  65686. * @param name The post-process name
  65687. * @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)
  65688. * @param camera The camera that the post-process will be attached to
  65689. * @param mesh The mesh used to create the light scattering
  65690. * @param samples The post-process quality, default 100
  65691. * @param samplingModeThe post-process filtering mode
  65692. * @param engine The babylon engine
  65693. * @param reusable If the post-process is reusable
  65694. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  65695. */
  65696. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  65697. /**
  65698. * Returns the string "VolumetricLightScatteringPostProcess"
  65699. * @returns "VolumetricLightScatteringPostProcess"
  65700. */
  65701. getClassName(): string;
  65702. private _isReady;
  65703. /**
  65704. * Sets the new light position for light scattering effect
  65705. * @param position The new custom light position
  65706. */
  65707. setCustomMeshPosition(position: Vector3): void;
  65708. /**
  65709. * Returns the light position for light scattering effect
  65710. * @return Vector3 The custom light position
  65711. */
  65712. getCustomMeshPosition(): Vector3;
  65713. /**
  65714. * Disposes the internal assets and detaches the post-process from the camera
  65715. */
  65716. dispose(camera: Camera): void;
  65717. /**
  65718. * Returns the render target texture used by the post-process
  65719. * @return the render target texture used by the post-process
  65720. */
  65721. getPass(): RenderTargetTexture;
  65722. private _meshExcluded;
  65723. private _createPass;
  65724. private _updateMeshScreenCoordinates;
  65725. /**
  65726. * Creates a default mesh for the Volumeric Light Scattering post-process
  65727. * @param name The mesh name
  65728. * @param scene The scene where to create the mesh
  65729. * @return the default mesh
  65730. */
  65731. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  65732. }
  65733. }
  65734. declare module "babylonjs/PostProcesses/index" {
  65735. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  65736. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  65737. export * from "babylonjs/PostProcesses/bloomEffect";
  65738. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  65739. export * from "babylonjs/PostProcesses/blurPostProcess";
  65740. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65741. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  65742. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  65743. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  65744. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65745. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  65746. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  65747. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  65748. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65749. export * from "babylonjs/PostProcesses/filterPostProcess";
  65750. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  65751. export * from "babylonjs/PostProcesses/grainPostProcess";
  65752. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  65753. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65754. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  65755. export * from "babylonjs/PostProcesses/passPostProcess";
  65756. export * from "babylonjs/PostProcesses/postProcess";
  65757. export * from "babylonjs/PostProcesses/postProcessManager";
  65758. export * from "babylonjs/PostProcesses/refractionPostProcess";
  65759. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  65760. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  65761. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  65762. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  65763. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  65764. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  65765. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  65766. }
  65767. declare module "babylonjs/Probes/index" {
  65768. export * from "babylonjs/Probes/reflectionProbe";
  65769. }
  65770. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  65771. import { Scene } from "babylonjs/scene";
  65772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65773. import { SmartArray } from "babylonjs/Misc/smartArray";
  65774. import { ISceneComponent } from "babylonjs/sceneComponent";
  65775. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  65776. import "babylonjs/Meshes/Builders/boxBuilder";
  65777. import "babylonjs/Shaders/color.fragment";
  65778. import "babylonjs/Shaders/color.vertex";
  65779. import { Color3 } from "babylonjs/Maths/math.color";
  65780. module "babylonjs/scene" {
  65781. interface Scene {
  65782. /** @hidden (Backing field) */
  65783. _boundingBoxRenderer: BoundingBoxRenderer;
  65784. /** @hidden (Backing field) */
  65785. _forceShowBoundingBoxes: boolean;
  65786. /**
  65787. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  65788. */
  65789. forceShowBoundingBoxes: boolean;
  65790. /**
  65791. * Gets the bounding box renderer associated with the scene
  65792. * @returns a BoundingBoxRenderer
  65793. */
  65794. getBoundingBoxRenderer(): BoundingBoxRenderer;
  65795. }
  65796. }
  65797. module "babylonjs/Meshes/abstractMesh" {
  65798. interface AbstractMesh {
  65799. /** @hidden (Backing field) */
  65800. _showBoundingBox: boolean;
  65801. /**
  65802. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  65803. */
  65804. showBoundingBox: boolean;
  65805. }
  65806. }
  65807. /**
  65808. * Component responsible of rendering the bounding box of the meshes in a scene.
  65809. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  65810. */
  65811. export class BoundingBoxRenderer implements ISceneComponent {
  65812. /**
  65813. * The component name helpfull to identify the component in the list of scene components.
  65814. */
  65815. readonly name: string;
  65816. /**
  65817. * The scene the component belongs to.
  65818. */
  65819. scene: Scene;
  65820. /**
  65821. * Color of the bounding box lines placed in front of an object
  65822. */
  65823. frontColor: Color3;
  65824. /**
  65825. * Color of the bounding box lines placed behind an object
  65826. */
  65827. backColor: Color3;
  65828. /**
  65829. * Defines if the renderer should show the back lines or not
  65830. */
  65831. showBackLines: boolean;
  65832. /**
  65833. * @hidden
  65834. */
  65835. renderList: SmartArray<BoundingBox>;
  65836. private _colorShader;
  65837. private _vertexBuffers;
  65838. private _indexBuffer;
  65839. private _fillIndexBuffer;
  65840. private _fillIndexData;
  65841. /**
  65842. * Instantiates a new bounding box renderer in a scene.
  65843. * @param scene the scene the renderer renders in
  65844. */
  65845. constructor(scene: Scene);
  65846. /**
  65847. * Registers the component in a given scene
  65848. */
  65849. register(): void;
  65850. private _evaluateSubMesh;
  65851. private _activeMesh;
  65852. private _prepareRessources;
  65853. private _createIndexBuffer;
  65854. /**
  65855. * Rebuilds the elements related to this component in case of
  65856. * context lost for instance.
  65857. */
  65858. rebuild(): void;
  65859. /**
  65860. * @hidden
  65861. */
  65862. reset(): void;
  65863. /**
  65864. * Render the bounding boxes of a specific rendering group
  65865. * @param renderingGroupId defines the rendering group to render
  65866. */
  65867. render(renderingGroupId: number): void;
  65868. /**
  65869. * In case of occlusion queries, we can render the occlusion bounding box through this method
  65870. * @param mesh Define the mesh to render the occlusion bounding box for
  65871. */
  65872. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  65873. /**
  65874. * Dispose and release the resources attached to this renderer.
  65875. */
  65876. dispose(): void;
  65877. }
  65878. }
  65879. declare module "babylonjs/Shaders/depth.fragment" {
  65880. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65881. /** @hidden */
  65882. export var depthPixelShader: {
  65883. name: string;
  65884. shader: string;
  65885. };
  65886. }
  65887. declare module "babylonjs/Rendering/depthRenderer" {
  65888. import { Nullable } from "babylonjs/types";
  65889. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65890. import { Scene } from "babylonjs/scene";
  65891. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65892. import { Camera } from "babylonjs/Cameras/camera";
  65893. import "babylonjs/Shaders/depth.fragment";
  65894. import "babylonjs/Shaders/depth.vertex";
  65895. /**
  65896. * This represents a depth renderer in Babylon.
  65897. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  65898. */
  65899. export class DepthRenderer {
  65900. private _scene;
  65901. private _depthMap;
  65902. private _effect;
  65903. private readonly _storeNonLinearDepth;
  65904. private readonly _clearColor;
  65905. /** Get if the depth renderer is using packed depth or not */
  65906. readonly isPacked: boolean;
  65907. private _cachedDefines;
  65908. private _camera;
  65909. /**
  65910. * Specifiess that the depth renderer will only be used within
  65911. * the camera it is created for.
  65912. * This can help forcing its rendering during the camera processing.
  65913. */
  65914. useOnlyInActiveCamera: boolean;
  65915. /** @hidden */
  65916. static _SceneComponentInitialization: (scene: Scene) => void;
  65917. /**
  65918. * Instantiates a depth renderer
  65919. * @param scene The scene the renderer belongs to
  65920. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  65921. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  65922. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65923. */
  65924. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  65925. /**
  65926. * Creates the depth rendering effect and checks if the effect is ready.
  65927. * @param subMesh The submesh to be used to render the depth map of
  65928. * @param useInstances If multiple world instances should be used
  65929. * @returns if the depth renderer is ready to render the depth map
  65930. */
  65931. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65932. /**
  65933. * Gets the texture which the depth map will be written to.
  65934. * @returns The depth map texture
  65935. */
  65936. getDepthMap(): RenderTargetTexture;
  65937. /**
  65938. * Disposes of the depth renderer.
  65939. */
  65940. dispose(): void;
  65941. }
  65942. }
  65943. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  65944. import { Nullable } from "babylonjs/types";
  65945. import { Scene } from "babylonjs/scene";
  65946. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  65947. import { Camera } from "babylonjs/Cameras/camera";
  65948. import { ISceneComponent } from "babylonjs/sceneComponent";
  65949. module "babylonjs/scene" {
  65950. interface Scene {
  65951. /** @hidden (Backing field) */
  65952. _depthRenderer: {
  65953. [id: string]: DepthRenderer;
  65954. };
  65955. /**
  65956. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  65957. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  65958. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65959. * @returns the created depth renderer
  65960. */
  65961. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  65962. /**
  65963. * Disables a depth renderer for a given camera
  65964. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  65965. */
  65966. disableDepthRenderer(camera?: Nullable<Camera>): void;
  65967. }
  65968. }
  65969. /**
  65970. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  65971. * in several rendering techniques.
  65972. */
  65973. export class DepthRendererSceneComponent implements ISceneComponent {
  65974. /**
  65975. * The component name helpfull to identify the component in the list of scene components.
  65976. */
  65977. readonly name: string;
  65978. /**
  65979. * The scene the component belongs to.
  65980. */
  65981. scene: Scene;
  65982. /**
  65983. * Creates a new instance of the component for the given scene
  65984. * @param scene Defines the scene to register the component in
  65985. */
  65986. constructor(scene: Scene);
  65987. /**
  65988. * Registers the component in a given scene
  65989. */
  65990. register(): void;
  65991. /**
  65992. * Rebuilds the elements related to this component in case of
  65993. * context lost for instance.
  65994. */
  65995. rebuild(): void;
  65996. /**
  65997. * Disposes the component and the associated ressources
  65998. */
  65999. dispose(): void;
  66000. private _gatherRenderTargets;
  66001. private _gatherActiveCameraRenderTargets;
  66002. }
  66003. }
  66004. declare module "babylonjs/Shaders/outline.fragment" {
  66005. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66006. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  66007. /** @hidden */
  66008. export var outlinePixelShader: {
  66009. name: string;
  66010. shader: string;
  66011. };
  66012. }
  66013. declare module "babylonjs/Shaders/outline.vertex" {
  66014. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66015. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66016. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66017. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66018. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66019. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66020. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66021. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66022. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  66023. /** @hidden */
  66024. export var outlineVertexShader: {
  66025. name: string;
  66026. shader: string;
  66027. };
  66028. }
  66029. declare module "babylonjs/Rendering/outlineRenderer" {
  66030. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66031. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  66032. import { Scene } from "babylonjs/scene";
  66033. import { ISceneComponent } from "babylonjs/sceneComponent";
  66034. import "babylonjs/Shaders/outline.fragment";
  66035. import "babylonjs/Shaders/outline.vertex";
  66036. module "babylonjs/scene" {
  66037. interface Scene {
  66038. /** @hidden */
  66039. _outlineRenderer: OutlineRenderer;
  66040. /**
  66041. * Gets the outline renderer associated with the scene
  66042. * @returns a OutlineRenderer
  66043. */
  66044. getOutlineRenderer(): OutlineRenderer;
  66045. }
  66046. }
  66047. module "babylonjs/Meshes/abstractMesh" {
  66048. interface AbstractMesh {
  66049. /** @hidden (Backing field) */
  66050. _renderOutline: boolean;
  66051. /**
  66052. * Gets or sets a boolean indicating if the outline must be rendered as well
  66053. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66054. */
  66055. renderOutline: boolean;
  66056. /** @hidden (Backing field) */
  66057. _renderOverlay: boolean;
  66058. /**
  66059. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66060. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66061. */
  66062. renderOverlay: boolean;
  66063. }
  66064. }
  66065. /**
  66066. * This class is responsible to draw bothe outline/overlay of meshes.
  66067. * It should not be used directly but through the available method on mesh.
  66068. */
  66069. export class OutlineRenderer implements ISceneComponent {
  66070. /**
  66071. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66072. */
  66073. private static _StencilReference;
  66074. /**
  66075. * The name of the component. Each component must have a unique name.
  66076. */
  66077. name: string;
  66078. /**
  66079. * The scene the component belongs to.
  66080. */
  66081. scene: Scene;
  66082. /**
  66083. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66084. */
  66085. zOffset: number;
  66086. private _engine;
  66087. private _effect;
  66088. private _cachedDefines;
  66089. private _savedDepthWrite;
  66090. /**
  66091. * Instantiates a new outline renderer. (There could be only one per scene).
  66092. * @param scene Defines the scene it belongs to
  66093. */
  66094. constructor(scene: Scene);
  66095. /**
  66096. * Register the component to one instance of a scene.
  66097. */
  66098. register(): void;
  66099. /**
  66100. * Rebuilds the elements related to this component in case of
  66101. * context lost for instance.
  66102. */
  66103. rebuild(): void;
  66104. /**
  66105. * Disposes the component and the associated ressources.
  66106. */
  66107. dispose(): void;
  66108. /**
  66109. * Renders the outline in the canvas.
  66110. * @param subMesh Defines the sumesh to render
  66111. * @param batch Defines the batch of meshes in case of instances
  66112. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66113. */
  66114. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66115. /**
  66116. * Returns whether or not the outline renderer is ready for a given submesh.
  66117. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66118. * @param subMesh Defines the submesh to check readyness for
  66119. * @param useInstances Defines wheter wee are trying to render instances or not
  66120. * @returns true if ready otherwise false
  66121. */
  66122. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66123. private _beforeRenderingMesh;
  66124. private _afterRenderingMesh;
  66125. }
  66126. }
  66127. declare module "babylonjs/Rendering/index" {
  66128. export * from "babylonjs/Rendering/boundingBoxRenderer";
  66129. export * from "babylonjs/Rendering/depthRenderer";
  66130. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  66131. export * from "babylonjs/Rendering/edgesRenderer";
  66132. export * from "babylonjs/Rendering/geometryBufferRenderer";
  66133. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  66134. export * from "babylonjs/Rendering/outlineRenderer";
  66135. export * from "babylonjs/Rendering/renderingGroup";
  66136. export * from "babylonjs/Rendering/renderingManager";
  66137. export * from "babylonjs/Rendering/utilityLayerRenderer";
  66138. }
  66139. declare module "babylonjs/Sprites/spritePackedManager" {
  66140. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  66141. import { Scene } from "babylonjs/scene";
  66142. /**
  66143. * Class used to manage multiple sprites of different sizes on the same spritesheet
  66144. * @see http://doc.babylonjs.com/babylon101/sprites
  66145. */
  66146. export class SpritePackedManager extends SpriteManager {
  66147. /** defines the packed manager's name */
  66148. name: string;
  66149. /**
  66150. * Creates a new sprite manager from a packed sprite sheet
  66151. * @param name defines the manager's name
  66152. * @param imgUrl defines the sprite sheet url
  66153. * @param capacity defines the maximum allowed number of sprites
  66154. * @param scene defines the hosting scene
  66155. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66156. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66157. * @param samplingMode defines the smapling mode to use with spritesheet
  66158. * @param fromPacked set to true; do not alter
  66159. */
  66160. constructor(
  66161. /** defines the packed manager's name */
  66162. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66163. }
  66164. }
  66165. declare module "babylonjs/Sprites/index" {
  66166. export * from "babylonjs/Sprites/sprite";
  66167. export * from "babylonjs/Sprites/spriteManager";
  66168. export * from "babylonjs/Sprites/spritePackedManager";
  66169. export * from "babylonjs/Sprites/spriteSceneComponent";
  66170. }
  66171. declare module "babylonjs/States/index" {
  66172. export * from "babylonjs/States/alphaCullingState";
  66173. export * from "babylonjs/States/depthCullingState";
  66174. export * from "babylonjs/States/stencilState";
  66175. }
  66176. declare module "babylonjs/Misc/assetsManager" {
  66177. import { Scene } from "babylonjs/scene";
  66178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66179. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66180. import { Skeleton } from "babylonjs/Bones/skeleton";
  66181. import { Observable } from "babylonjs/Misc/observable";
  66182. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66183. import { Texture } from "babylonjs/Materials/Textures/texture";
  66184. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66185. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  66186. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66187. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  66188. /**
  66189. * Defines the list of states available for a task inside a AssetsManager
  66190. */
  66191. export enum AssetTaskState {
  66192. /**
  66193. * Initialization
  66194. */
  66195. INIT = 0,
  66196. /**
  66197. * Running
  66198. */
  66199. RUNNING = 1,
  66200. /**
  66201. * Done
  66202. */
  66203. DONE = 2,
  66204. /**
  66205. * Error
  66206. */
  66207. ERROR = 3
  66208. }
  66209. /**
  66210. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  66211. */
  66212. export abstract class AbstractAssetTask {
  66213. /**
  66214. * Task name
  66215. */ name: string;
  66216. /**
  66217. * Callback called when the task is successful
  66218. */
  66219. onSuccess: (task: any) => void;
  66220. /**
  66221. * Callback called when the task is not successful
  66222. */
  66223. onError: (task: any, message?: string, exception?: any) => void;
  66224. /**
  66225. * Creates a new AssetsManager
  66226. * @param name defines the name of the task
  66227. */
  66228. constructor(
  66229. /**
  66230. * Task name
  66231. */ name: string);
  66232. private _isCompleted;
  66233. private _taskState;
  66234. private _errorObject;
  66235. /**
  66236. * Get if the task is completed
  66237. */
  66238. readonly isCompleted: boolean;
  66239. /**
  66240. * Gets the current state of the task
  66241. */
  66242. readonly taskState: AssetTaskState;
  66243. /**
  66244. * Gets the current error object (if task is in error)
  66245. */
  66246. readonly errorObject: {
  66247. message?: string;
  66248. exception?: any;
  66249. };
  66250. /**
  66251. * Internal only
  66252. * @hidden
  66253. */
  66254. _setErrorObject(message?: string, exception?: any): void;
  66255. /**
  66256. * Execute the current task
  66257. * @param scene defines the scene where you want your assets to be loaded
  66258. * @param onSuccess is a callback called when the task is successfully executed
  66259. * @param onError is a callback called if an error occurs
  66260. */
  66261. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66262. /**
  66263. * Execute the current task
  66264. * @param scene defines the scene where you want your assets to be loaded
  66265. * @param onSuccess is a callback called when the task is successfully executed
  66266. * @param onError is a callback called if an error occurs
  66267. */
  66268. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66269. /**
  66270. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  66271. * This can be used with failed tasks that have the reason for failure fixed.
  66272. */
  66273. reset(): void;
  66274. private onErrorCallback;
  66275. private onDoneCallback;
  66276. }
  66277. /**
  66278. * Define the interface used by progress events raised during assets loading
  66279. */
  66280. export interface IAssetsProgressEvent {
  66281. /**
  66282. * Defines the number of remaining tasks to process
  66283. */
  66284. remainingCount: number;
  66285. /**
  66286. * Defines the total number of tasks
  66287. */
  66288. totalCount: number;
  66289. /**
  66290. * Defines the task that was just processed
  66291. */
  66292. task: AbstractAssetTask;
  66293. }
  66294. /**
  66295. * Class used to share progress information about assets loading
  66296. */
  66297. export class AssetsProgressEvent implements IAssetsProgressEvent {
  66298. /**
  66299. * Defines the number of remaining tasks to process
  66300. */
  66301. remainingCount: number;
  66302. /**
  66303. * Defines the total number of tasks
  66304. */
  66305. totalCount: number;
  66306. /**
  66307. * Defines the task that was just processed
  66308. */
  66309. task: AbstractAssetTask;
  66310. /**
  66311. * Creates a AssetsProgressEvent
  66312. * @param remainingCount defines the number of remaining tasks to process
  66313. * @param totalCount defines the total number of tasks
  66314. * @param task defines the task that was just processed
  66315. */
  66316. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  66317. }
  66318. /**
  66319. * Define a task used by AssetsManager to load meshes
  66320. */
  66321. export class MeshAssetTask extends AbstractAssetTask {
  66322. /**
  66323. * Defines the name of the task
  66324. */
  66325. name: string;
  66326. /**
  66327. * Defines the list of mesh's names you want to load
  66328. */
  66329. meshesNames: any;
  66330. /**
  66331. * Defines the root url to use as a base to load your meshes and associated resources
  66332. */
  66333. rootUrl: string;
  66334. /**
  66335. * Defines the filename of the scene to load from
  66336. */
  66337. sceneFilename: string;
  66338. /**
  66339. * Gets the list of loaded meshes
  66340. */
  66341. loadedMeshes: Array<AbstractMesh>;
  66342. /**
  66343. * Gets the list of loaded particle systems
  66344. */
  66345. loadedParticleSystems: Array<IParticleSystem>;
  66346. /**
  66347. * Gets the list of loaded skeletons
  66348. */
  66349. loadedSkeletons: Array<Skeleton>;
  66350. /**
  66351. * Gets the list of loaded animation groups
  66352. */
  66353. loadedAnimationGroups: Array<AnimationGroup>;
  66354. /**
  66355. * Callback called when the task is successful
  66356. */
  66357. onSuccess: (task: MeshAssetTask) => void;
  66358. /**
  66359. * Callback called when the task is successful
  66360. */
  66361. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  66362. /**
  66363. * Creates a new MeshAssetTask
  66364. * @param name defines the name of the task
  66365. * @param meshesNames defines the list of mesh's names you want to load
  66366. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  66367. * @param sceneFilename defines the filename of the scene to load from
  66368. */
  66369. constructor(
  66370. /**
  66371. * Defines the name of the task
  66372. */
  66373. name: string,
  66374. /**
  66375. * Defines the list of mesh's names you want to load
  66376. */
  66377. meshesNames: any,
  66378. /**
  66379. * Defines the root url to use as a base to load your meshes and associated resources
  66380. */
  66381. rootUrl: string,
  66382. /**
  66383. * Defines the filename of the scene to load from
  66384. */
  66385. sceneFilename: string);
  66386. /**
  66387. * Execute the current task
  66388. * @param scene defines the scene where you want your assets to be loaded
  66389. * @param onSuccess is a callback called when the task is successfully executed
  66390. * @param onError is a callback called if an error occurs
  66391. */
  66392. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66393. }
  66394. /**
  66395. * Define a task used by AssetsManager to load text content
  66396. */
  66397. export class TextFileAssetTask extends AbstractAssetTask {
  66398. /**
  66399. * Defines the name of the task
  66400. */
  66401. name: string;
  66402. /**
  66403. * Defines the location of the file to load
  66404. */
  66405. url: string;
  66406. /**
  66407. * Gets the loaded text string
  66408. */
  66409. text: string;
  66410. /**
  66411. * Callback called when the task is successful
  66412. */
  66413. onSuccess: (task: TextFileAssetTask) => void;
  66414. /**
  66415. * Callback called when the task is successful
  66416. */
  66417. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  66418. /**
  66419. * Creates a new TextFileAssetTask object
  66420. * @param name defines the name of the task
  66421. * @param url defines the location of the file to load
  66422. */
  66423. constructor(
  66424. /**
  66425. * Defines the name of the task
  66426. */
  66427. name: string,
  66428. /**
  66429. * Defines the location of the file to load
  66430. */
  66431. url: string);
  66432. /**
  66433. * Execute the current task
  66434. * @param scene defines the scene where you want your assets to be loaded
  66435. * @param onSuccess is a callback called when the task is successfully executed
  66436. * @param onError is a callback called if an error occurs
  66437. */
  66438. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66439. }
  66440. /**
  66441. * Define a task used by AssetsManager to load binary data
  66442. */
  66443. export class BinaryFileAssetTask extends AbstractAssetTask {
  66444. /**
  66445. * Defines the name of the task
  66446. */
  66447. name: string;
  66448. /**
  66449. * Defines the location of the file to load
  66450. */
  66451. url: string;
  66452. /**
  66453. * Gets the lodaded data (as an array buffer)
  66454. */
  66455. data: ArrayBuffer;
  66456. /**
  66457. * Callback called when the task is successful
  66458. */
  66459. onSuccess: (task: BinaryFileAssetTask) => void;
  66460. /**
  66461. * Callback called when the task is successful
  66462. */
  66463. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  66464. /**
  66465. * Creates a new BinaryFileAssetTask object
  66466. * @param name defines the name of the new task
  66467. * @param url defines the location of the file to load
  66468. */
  66469. constructor(
  66470. /**
  66471. * Defines the name of the task
  66472. */
  66473. name: string,
  66474. /**
  66475. * Defines the location of the file to load
  66476. */
  66477. url: string);
  66478. /**
  66479. * Execute the current task
  66480. * @param scene defines the scene where you want your assets to be loaded
  66481. * @param onSuccess is a callback called when the task is successfully executed
  66482. * @param onError is a callback called if an error occurs
  66483. */
  66484. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66485. }
  66486. /**
  66487. * Define a task used by AssetsManager to load images
  66488. */
  66489. export class ImageAssetTask extends AbstractAssetTask {
  66490. /**
  66491. * Defines the name of the task
  66492. */
  66493. name: string;
  66494. /**
  66495. * Defines the location of the image to load
  66496. */
  66497. url: string;
  66498. /**
  66499. * Gets the loaded images
  66500. */
  66501. image: HTMLImageElement;
  66502. /**
  66503. * Callback called when the task is successful
  66504. */
  66505. onSuccess: (task: ImageAssetTask) => void;
  66506. /**
  66507. * Callback called when the task is successful
  66508. */
  66509. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  66510. /**
  66511. * Creates a new ImageAssetTask
  66512. * @param name defines the name of the task
  66513. * @param url defines the location of the image to load
  66514. */
  66515. constructor(
  66516. /**
  66517. * Defines the name of the task
  66518. */
  66519. name: string,
  66520. /**
  66521. * Defines the location of the image to load
  66522. */
  66523. url: string);
  66524. /**
  66525. * Execute the current task
  66526. * @param scene defines the scene where you want your assets to be loaded
  66527. * @param onSuccess is a callback called when the task is successfully executed
  66528. * @param onError is a callback called if an error occurs
  66529. */
  66530. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66531. }
  66532. /**
  66533. * Defines the interface used by texture loading tasks
  66534. */
  66535. export interface ITextureAssetTask<TEX extends BaseTexture> {
  66536. /**
  66537. * Gets the loaded texture
  66538. */
  66539. texture: TEX;
  66540. }
  66541. /**
  66542. * Define a task used by AssetsManager to load 2D textures
  66543. */
  66544. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  66545. /**
  66546. * Defines the name of the task
  66547. */
  66548. name: string;
  66549. /**
  66550. * Defines the location of the file to load
  66551. */
  66552. url: string;
  66553. /**
  66554. * Defines if mipmap should not be generated (default is false)
  66555. */
  66556. noMipmap?: boolean | undefined;
  66557. /**
  66558. * Defines if texture must be inverted on Y axis (default is false)
  66559. */
  66560. invertY?: boolean | undefined;
  66561. /**
  66562. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66563. */
  66564. samplingMode: number;
  66565. /**
  66566. * Gets the loaded texture
  66567. */
  66568. texture: Texture;
  66569. /**
  66570. * Callback called when the task is successful
  66571. */
  66572. onSuccess: (task: TextureAssetTask) => void;
  66573. /**
  66574. * Callback called when the task is successful
  66575. */
  66576. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  66577. /**
  66578. * Creates a new TextureAssetTask object
  66579. * @param name defines the name of the task
  66580. * @param url defines the location of the file to load
  66581. * @param noMipmap defines if mipmap should not be generated (default is false)
  66582. * @param invertY defines if texture must be inverted on Y axis (default is false)
  66583. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66584. */
  66585. constructor(
  66586. /**
  66587. * Defines the name of the task
  66588. */
  66589. name: string,
  66590. /**
  66591. * Defines the location of the file to load
  66592. */
  66593. url: string,
  66594. /**
  66595. * Defines if mipmap should not be generated (default is false)
  66596. */
  66597. noMipmap?: boolean | undefined,
  66598. /**
  66599. * Defines if texture must be inverted on Y axis (default is false)
  66600. */
  66601. invertY?: boolean | undefined,
  66602. /**
  66603. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66604. */
  66605. samplingMode?: number);
  66606. /**
  66607. * Execute the current task
  66608. * @param scene defines the scene where you want your assets to be loaded
  66609. * @param onSuccess is a callback called when the task is successfully executed
  66610. * @param onError is a callback called if an error occurs
  66611. */
  66612. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66613. }
  66614. /**
  66615. * Define a task used by AssetsManager to load cube textures
  66616. */
  66617. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  66618. /**
  66619. * Defines the name of the task
  66620. */
  66621. name: string;
  66622. /**
  66623. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66624. */
  66625. url: string;
  66626. /**
  66627. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66628. */
  66629. extensions?: string[] | undefined;
  66630. /**
  66631. * Defines if mipmaps should not be generated (default is false)
  66632. */
  66633. noMipmap?: boolean | undefined;
  66634. /**
  66635. * Defines the explicit list of files (undefined by default)
  66636. */
  66637. files?: string[] | undefined;
  66638. /**
  66639. * Gets the loaded texture
  66640. */
  66641. texture: CubeTexture;
  66642. /**
  66643. * Callback called when the task is successful
  66644. */
  66645. onSuccess: (task: CubeTextureAssetTask) => void;
  66646. /**
  66647. * Callback called when the task is successful
  66648. */
  66649. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  66650. /**
  66651. * Creates a new CubeTextureAssetTask
  66652. * @param name defines the name of the task
  66653. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66654. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66655. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66656. * @param files defines the explicit list of files (undefined by default)
  66657. */
  66658. constructor(
  66659. /**
  66660. * Defines the name of the task
  66661. */
  66662. name: string,
  66663. /**
  66664. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66665. */
  66666. url: string,
  66667. /**
  66668. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66669. */
  66670. extensions?: string[] | undefined,
  66671. /**
  66672. * Defines if mipmaps should not be generated (default is false)
  66673. */
  66674. noMipmap?: boolean | undefined,
  66675. /**
  66676. * Defines the explicit list of files (undefined by default)
  66677. */
  66678. files?: string[] | undefined);
  66679. /**
  66680. * Execute the current task
  66681. * @param scene defines the scene where you want your assets to be loaded
  66682. * @param onSuccess is a callback called when the task is successfully executed
  66683. * @param onError is a callback called if an error occurs
  66684. */
  66685. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66686. }
  66687. /**
  66688. * Define a task used by AssetsManager to load HDR cube textures
  66689. */
  66690. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  66691. /**
  66692. * Defines the name of the task
  66693. */
  66694. name: string;
  66695. /**
  66696. * Defines the location of the file to load
  66697. */
  66698. url: string;
  66699. /**
  66700. * Defines the desired size (the more it increases the longer the generation will be)
  66701. */
  66702. size: number;
  66703. /**
  66704. * Defines if mipmaps should not be generated (default is false)
  66705. */
  66706. noMipmap: boolean;
  66707. /**
  66708. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66709. */
  66710. generateHarmonics: boolean;
  66711. /**
  66712. * 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)
  66713. */
  66714. gammaSpace: boolean;
  66715. /**
  66716. * Internal Use Only
  66717. */
  66718. reserved: boolean;
  66719. /**
  66720. * Gets the loaded texture
  66721. */
  66722. texture: HDRCubeTexture;
  66723. /**
  66724. * Callback called when the task is successful
  66725. */
  66726. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  66727. /**
  66728. * Callback called when the task is successful
  66729. */
  66730. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  66731. /**
  66732. * Creates a new HDRCubeTextureAssetTask object
  66733. * @param name defines the name of the task
  66734. * @param url defines the location of the file to load
  66735. * @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.
  66736. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66737. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66738. * @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)
  66739. * @param reserved Internal use only
  66740. */
  66741. constructor(
  66742. /**
  66743. * Defines the name of the task
  66744. */
  66745. name: string,
  66746. /**
  66747. * Defines the location of the file to load
  66748. */
  66749. url: string,
  66750. /**
  66751. * Defines the desired size (the more it increases the longer the generation will be)
  66752. */
  66753. size: number,
  66754. /**
  66755. * Defines if mipmaps should not be generated (default is false)
  66756. */
  66757. noMipmap?: boolean,
  66758. /**
  66759. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66760. */
  66761. generateHarmonics?: boolean,
  66762. /**
  66763. * 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)
  66764. */
  66765. gammaSpace?: boolean,
  66766. /**
  66767. * Internal Use Only
  66768. */
  66769. reserved?: boolean);
  66770. /**
  66771. * Execute the current task
  66772. * @param scene defines the scene where you want your assets to be loaded
  66773. * @param onSuccess is a callback called when the task is successfully executed
  66774. * @param onError is a callback called if an error occurs
  66775. */
  66776. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66777. }
  66778. /**
  66779. * Define a task used by AssetsManager to load Equirectangular cube textures
  66780. */
  66781. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  66782. /**
  66783. * Defines the name of the task
  66784. */
  66785. name: string;
  66786. /**
  66787. * Defines the location of the file to load
  66788. */
  66789. url: string;
  66790. /**
  66791. * Defines the desired size (the more it increases the longer the generation will be)
  66792. */
  66793. size: number;
  66794. /**
  66795. * Defines if mipmaps should not be generated (default is false)
  66796. */
  66797. noMipmap: boolean;
  66798. /**
  66799. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66800. * but the standard material would require them in Gamma space) (default is true)
  66801. */
  66802. gammaSpace: boolean;
  66803. /**
  66804. * Gets the loaded texture
  66805. */
  66806. texture: EquiRectangularCubeTexture;
  66807. /**
  66808. * Callback called when the task is successful
  66809. */
  66810. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  66811. /**
  66812. * Callback called when the task is successful
  66813. */
  66814. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  66815. /**
  66816. * Creates a new EquiRectangularCubeTextureAssetTask object
  66817. * @param name defines the name of the task
  66818. * @param url defines the location of the file to load
  66819. * @param size defines the desired size (the more it increases the longer the generation will be)
  66820. * If the size is omitted this implies you are using a preprocessed cubemap.
  66821. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66822. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  66823. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  66824. * (default is true)
  66825. */
  66826. constructor(
  66827. /**
  66828. * Defines the name of the task
  66829. */
  66830. name: string,
  66831. /**
  66832. * Defines the location of the file to load
  66833. */
  66834. url: string,
  66835. /**
  66836. * Defines the desired size (the more it increases the longer the generation will be)
  66837. */
  66838. size: number,
  66839. /**
  66840. * Defines if mipmaps should not be generated (default is false)
  66841. */
  66842. noMipmap?: boolean,
  66843. /**
  66844. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66845. * but the standard material would require them in Gamma space) (default is true)
  66846. */
  66847. gammaSpace?: boolean);
  66848. /**
  66849. * Execute the current task
  66850. * @param scene defines the scene where you want your assets to be loaded
  66851. * @param onSuccess is a callback called when the task is successfully executed
  66852. * @param onError is a callback called if an error occurs
  66853. */
  66854. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66855. }
  66856. /**
  66857. * This class can be used to easily import assets into a scene
  66858. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  66859. */
  66860. export class AssetsManager {
  66861. private _scene;
  66862. private _isLoading;
  66863. protected _tasks: AbstractAssetTask[];
  66864. protected _waitingTasksCount: number;
  66865. protected _totalTasksCount: number;
  66866. /**
  66867. * Callback called when all tasks are processed
  66868. */
  66869. onFinish: (tasks: AbstractAssetTask[]) => void;
  66870. /**
  66871. * Callback called when a task is successful
  66872. */
  66873. onTaskSuccess: (task: AbstractAssetTask) => void;
  66874. /**
  66875. * Callback called when a task had an error
  66876. */
  66877. onTaskError: (task: AbstractAssetTask) => void;
  66878. /**
  66879. * Callback called when a task is done (whatever the result is)
  66880. */
  66881. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  66882. /**
  66883. * Observable called when all tasks are processed
  66884. */
  66885. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  66886. /**
  66887. * Observable called when a task had an error
  66888. */
  66889. onTaskErrorObservable: Observable<AbstractAssetTask>;
  66890. /**
  66891. * Observable called when all tasks were executed
  66892. */
  66893. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  66894. /**
  66895. * Observable called when a task is done (whatever the result is)
  66896. */
  66897. onProgressObservable: Observable<IAssetsProgressEvent>;
  66898. /**
  66899. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  66900. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  66901. */
  66902. useDefaultLoadingScreen: boolean;
  66903. /**
  66904. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  66905. * when all assets have been downloaded.
  66906. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  66907. */
  66908. autoHideLoadingUI: boolean;
  66909. /**
  66910. * Creates a new AssetsManager
  66911. * @param scene defines the scene to work on
  66912. */
  66913. constructor(scene: Scene);
  66914. /**
  66915. * Add a MeshAssetTask to the list of active tasks
  66916. * @param taskName defines the name of the new task
  66917. * @param meshesNames defines the name of meshes to load
  66918. * @param rootUrl defines the root url to use to locate files
  66919. * @param sceneFilename defines the filename of the scene file
  66920. * @returns a new MeshAssetTask object
  66921. */
  66922. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  66923. /**
  66924. * Add a TextFileAssetTask to the list of active tasks
  66925. * @param taskName defines the name of the new task
  66926. * @param url defines the url of the file to load
  66927. * @returns a new TextFileAssetTask object
  66928. */
  66929. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  66930. /**
  66931. * Add a BinaryFileAssetTask to the list of active tasks
  66932. * @param taskName defines the name of the new task
  66933. * @param url defines the url of the file to load
  66934. * @returns a new BinaryFileAssetTask object
  66935. */
  66936. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  66937. /**
  66938. * Add a ImageAssetTask to the list of active tasks
  66939. * @param taskName defines the name of the new task
  66940. * @param url defines the url of the file to load
  66941. * @returns a new ImageAssetTask object
  66942. */
  66943. addImageTask(taskName: string, url: string): ImageAssetTask;
  66944. /**
  66945. * Add a TextureAssetTask to the list of active tasks
  66946. * @param taskName defines the name of the new task
  66947. * @param url defines the url of the file to load
  66948. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66949. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  66950. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66951. * @returns a new TextureAssetTask object
  66952. */
  66953. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  66954. /**
  66955. * Add a CubeTextureAssetTask to the list of active tasks
  66956. * @param taskName defines the name of the new task
  66957. * @param url defines the url of the file to load
  66958. * @param extensions defines the extension to use to load the cube map (can be null)
  66959. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66960. * @param files defines the list of files to load (can be null)
  66961. * @returns a new CubeTextureAssetTask object
  66962. */
  66963. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  66964. /**
  66965. *
  66966. * Add a HDRCubeTextureAssetTask to the list of active tasks
  66967. * @param taskName defines the name of the new task
  66968. * @param url defines the url of the file to load
  66969. * @param size defines the size you want for the cubemap (can be null)
  66970. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66971. * @param generateHarmonics defines if you want to automatically generate (true by default)
  66972. * @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)
  66973. * @param reserved Internal use only
  66974. * @returns a new HDRCubeTextureAssetTask object
  66975. */
  66976. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  66977. /**
  66978. *
  66979. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  66980. * @param taskName defines the name of the new task
  66981. * @param url defines the url of the file to load
  66982. * @param size defines the size you want for the cubemap (can be null)
  66983. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66984. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66985. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66986. * @returns a new EquiRectangularCubeTextureAssetTask object
  66987. */
  66988. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  66989. /**
  66990. * Remove a task from the assets manager.
  66991. * @param task the task to remove
  66992. */
  66993. removeTask(task: AbstractAssetTask): void;
  66994. private _decreaseWaitingTasksCount;
  66995. private _runTask;
  66996. /**
  66997. * Reset the AssetsManager and remove all tasks
  66998. * @return the current instance of the AssetsManager
  66999. */
  67000. reset(): AssetsManager;
  67001. /**
  67002. * Start the loading process
  67003. * @return the current instance of the AssetsManager
  67004. */
  67005. load(): AssetsManager;
  67006. /**
  67007. * Start the loading process as an async operation
  67008. * @return a promise returning the list of failed tasks
  67009. */
  67010. loadAsync(): Promise<void>;
  67011. }
  67012. }
  67013. declare module "babylonjs/Misc/deferred" {
  67014. /**
  67015. * Wrapper class for promise with external resolve and reject.
  67016. */
  67017. export class Deferred<T> {
  67018. /**
  67019. * The promise associated with this deferred object.
  67020. */
  67021. readonly promise: Promise<T>;
  67022. private _resolve;
  67023. private _reject;
  67024. /**
  67025. * The resolve method of the promise associated with this deferred object.
  67026. */
  67027. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  67028. /**
  67029. * The reject method of the promise associated with this deferred object.
  67030. */
  67031. readonly reject: (reason?: any) => void;
  67032. /**
  67033. * Constructor for this deferred object.
  67034. */
  67035. constructor();
  67036. }
  67037. }
  67038. declare module "babylonjs/Misc/meshExploder" {
  67039. import { Mesh } from "babylonjs/Meshes/mesh";
  67040. /**
  67041. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67042. */
  67043. export class MeshExploder {
  67044. private _centerMesh;
  67045. private _meshes;
  67046. private _meshesOrigins;
  67047. private _toCenterVectors;
  67048. private _scaledDirection;
  67049. private _newPosition;
  67050. private _centerPosition;
  67051. /**
  67052. * Explodes meshes from a center mesh.
  67053. * @param meshes The meshes to explode.
  67054. * @param centerMesh The mesh to be center of explosion.
  67055. */
  67056. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67057. private _setCenterMesh;
  67058. /**
  67059. * Get class name
  67060. * @returns "MeshExploder"
  67061. */
  67062. getClassName(): string;
  67063. /**
  67064. * "Exploded meshes"
  67065. * @returns Array of meshes with the centerMesh at index 0.
  67066. */
  67067. getMeshes(): Array<Mesh>;
  67068. /**
  67069. * Explodes meshes giving a specific direction
  67070. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67071. */
  67072. explode(direction?: number): void;
  67073. }
  67074. }
  67075. declare module "babylonjs/Misc/filesInput" {
  67076. import { Engine } from "babylonjs/Engines/engine";
  67077. import { Scene } from "babylonjs/scene";
  67078. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  67079. /**
  67080. * Class used to help managing file picking and drag'n'drop
  67081. */
  67082. export class FilesInput {
  67083. /**
  67084. * List of files ready to be loaded
  67085. */
  67086. static readonly FilesToLoad: {
  67087. [key: string]: File;
  67088. };
  67089. /**
  67090. * Callback called when a file is processed
  67091. */
  67092. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67093. private _engine;
  67094. private _currentScene;
  67095. private _sceneLoadedCallback;
  67096. private _progressCallback;
  67097. private _additionalRenderLoopLogicCallback;
  67098. private _textureLoadingCallback;
  67099. private _startingProcessingFilesCallback;
  67100. private _onReloadCallback;
  67101. private _errorCallback;
  67102. private _elementToMonitor;
  67103. private _sceneFileToLoad;
  67104. private _filesToLoad;
  67105. /**
  67106. * Creates a new FilesInput
  67107. * @param engine defines the rendering engine
  67108. * @param scene defines the hosting scene
  67109. * @param sceneLoadedCallback callback called when scene is loaded
  67110. * @param progressCallback callback called to track progress
  67111. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67112. * @param textureLoadingCallback callback called when a texture is loading
  67113. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67114. * @param onReloadCallback callback called when a reload is requested
  67115. * @param errorCallback callback call if an error occurs
  67116. */
  67117. 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);
  67118. private _dragEnterHandler;
  67119. private _dragOverHandler;
  67120. private _dropHandler;
  67121. /**
  67122. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67123. * @param elementToMonitor defines the DOM element to track
  67124. */
  67125. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67126. /**
  67127. * Release all associated resources
  67128. */
  67129. dispose(): void;
  67130. private renderFunction;
  67131. private drag;
  67132. private drop;
  67133. private _traverseFolder;
  67134. private _processFiles;
  67135. /**
  67136. * Load files from a drop event
  67137. * @param event defines the drop event to use as source
  67138. */
  67139. loadFiles(event: any): void;
  67140. private _processReload;
  67141. /**
  67142. * Reload the current scene from the loaded files
  67143. */
  67144. reload(): void;
  67145. }
  67146. }
  67147. declare module "babylonjs/Misc/HighDynamicRange/index" {
  67148. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  67149. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  67150. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  67151. }
  67152. declare module "babylonjs/Misc/sceneOptimizer" {
  67153. import { Scene, IDisposable } from "babylonjs/scene";
  67154. import { Observable } from "babylonjs/Misc/observable";
  67155. /**
  67156. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67157. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67158. */
  67159. export class SceneOptimization {
  67160. /**
  67161. * Defines the priority of this optimization (0 by default which means first in the list)
  67162. */
  67163. priority: number;
  67164. /**
  67165. * Gets a string describing the action executed by the current optimization
  67166. * @returns description string
  67167. */
  67168. getDescription(): string;
  67169. /**
  67170. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67171. * @param scene defines the current scene where to apply this optimization
  67172. * @param optimizer defines the current optimizer
  67173. * @returns true if everything that can be done was applied
  67174. */
  67175. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67176. /**
  67177. * Creates the SceneOptimization object
  67178. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67179. * @param desc defines the description associated with the optimization
  67180. */
  67181. constructor(
  67182. /**
  67183. * Defines the priority of this optimization (0 by default which means first in the list)
  67184. */
  67185. priority?: number);
  67186. }
  67187. /**
  67188. * Defines an optimization used to reduce the size of render target textures
  67189. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67190. */
  67191. export class TextureOptimization extends SceneOptimization {
  67192. /**
  67193. * Defines the priority of this optimization (0 by default which means first in the list)
  67194. */
  67195. priority: number;
  67196. /**
  67197. * 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
  67198. */
  67199. maximumSize: number;
  67200. /**
  67201. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67202. */
  67203. step: number;
  67204. /**
  67205. * Gets a string describing the action executed by the current optimization
  67206. * @returns description string
  67207. */
  67208. getDescription(): string;
  67209. /**
  67210. * Creates the TextureOptimization object
  67211. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67212. * @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
  67213. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67214. */
  67215. constructor(
  67216. /**
  67217. * Defines the priority of this optimization (0 by default which means first in the list)
  67218. */
  67219. priority?: number,
  67220. /**
  67221. * 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
  67222. */
  67223. maximumSize?: number,
  67224. /**
  67225. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67226. */
  67227. step?: number);
  67228. /**
  67229. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67230. * @param scene defines the current scene where to apply this optimization
  67231. * @param optimizer defines the current optimizer
  67232. * @returns true if everything that can be done was applied
  67233. */
  67234. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67235. }
  67236. /**
  67237. * Defines an optimization used to increase or decrease the rendering resolution
  67238. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67239. */
  67240. export class HardwareScalingOptimization extends SceneOptimization {
  67241. /**
  67242. * Defines the priority of this optimization (0 by default which means first in the list)
  67243. */
  67244. priority: number;
  67245. /**
  67246. * Defines the maximum scale to use (2 by default)
  67247. */
  67248. maximumScale: number;
  67249. /**
  67250. * Defines the step to use between two passes (0.5 by default)
  67251. */
  67252. step: number;
  67253. private _currentScale;
  67254. private _directionOffset;
  67255. /**
  67256. * Gets a string describing the action executed by the current optimization
  67257. * @return description string
  67258. */
  67259. getDescription(): string;
  67260. /**
  67261. * Creates the HardwareScalingOptimization object
  67262. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67263. * @param maximumScale defines the maximum scale to use (2 by default)
  67264. * @param step defines the step to use between two passes (0.5 by default)
  67265. */
  67266. constructor(
  67267. /**
  67268. * Defines the priority of this optimization (0 by default which means first in the list)
  67269. */
  67270. priority?: number,
  67271. /**
  67272. * Defines the maximum scale to use (2 by default)
  67273. */
  67274. maximumScale?: number,
  67275. /**
  67276. * Defines the step to use between two passes (0.5 by default)
  67277. */
  67278. step?: number);
  67279. /**
  67280. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67281. * @param scene defines the current scene where to apply this optimization
  67282. * @param optimizer defines the current optimizer
  67283. * @returns true if everything that can be done was applied
  67284. */
  67285. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67286. }
  67287. /**
  67288. * Defines an optimization used to remove shadows
  67289. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67290. */
  67291. export class ShadowsOptimization extends SceneOptimization {
  67292. /**
  67293. * Gets a string describing the action executed by the current optimization
  67294. * @return description string
  67295. */
  67296. getDescription(): string;
  67297. /**
  67298. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67299. * @param scene defines the current scene where to apply this optimization
  67300. * @param optimizer defines the current optimizer
  67301. * @returns true if everything that can be done was applied
  67302. */
  67303. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67304. }
  67305. /**
  67306. * Defines an optimization used to turn post-processes off
  67307. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67308. */
  67309. export class PostProcessesOptimization extends SceneOptimization {
  67310. /**
  67311. * Gets a string describing the action executed by the current optimization
  67312. * @return description string
  67313. */
  67314. getDescription(): string;
  67315. /**
  67316. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67317. * @param scene defines the current scene where to apply this optimization
  67318. * @param optimizer defines the current optimizer
  67319. * @returns true if everything that can be done was applied
  67320. */
  67321. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67322. }
  67323. /**
  67324. * Defines an optimization used to turn lens flares off
  67325. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67326. */
  67327. export class LensFlaresOptimization extends SceneOptimization {
  67328. /**
  67329. * Gets a string describing the action executed by the current optimization
  67330. * @return description string
  67331. */
  67332. getDescription(): string;
  67333. /**
  67334. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67335. * @param scene defines the current scene where to apply this optimization
  67336. * @param optimizer defines the current optimizer
  67337. * @returns true if everything that can be done was applied
  67338. */
  67339. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67340. }
  67341. /**
  67342. * Defines an optimization based on user defined callback.
  67343. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67344. */
  67345. export class CustomOptimization extends SceneOptimization {
  67346. /**
  67347. * Callback called to apply the custom optimization.
  67348. */
  67349. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  67350. /**
  67351. * Callback called to get custom description
  67352. */
  67353. onGetDescription: () => string;
  67354. /**
  67355. * Gets a string describing the action executed by the current optimization
  67356. * @returns description string
  67357. */
  67358. getDescription(): string;
  67359. /**
  67360. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67361. * @param scene defines the current scene where to apply this optimization
  67362. * @param optimizer defines the current optimizer
  67363. * @returns true if everything that can be done was applied
  67364. */
  67365. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67366. }
  67367. /**
  67368. * Defines an optimization used to turn particles off
  67369. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67370. */
  67371. export class ParticlesOptimization extends SceneOptimization {
  67372. /**
  67373. * Gets a string describing the action executed by the current optimization
  67374. * @return description string
  67375. */
  67376. getDescription(): string;
  67377. /**
  67378. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67379. * @param scene defines the current scene where to apply this optimization
  67380. * @param optimizer defines the current optimizer
  67381. * @returns true if everything that can be done was applied
  67382. */
  67383. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67384. }
  67385. /**
  67386. * Defines an optimization used to turn render targets off
  67387. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67388. */
  67389. export class RenderTargetsOptimization extends SceneOptimization {
  67390. /**
  67391. * Gets a string describing the action executed by the current optimization
  67392. * @return description string
  67393. */
  67394. getDescription(): string;
  67395. /**
  67396. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67397. * @param scene defines the current scene where to apply this optimization
  67398. * @param optimizer defines the current optimizer
  67399. * @returns true if everything that can be done was applied
  67400. */
  67401. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67402. }
  67403. /**
  67404. * Defines an optimization used to merge meshes with compatible materials
  67405. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67406. */
  67407. export class MergeMeshesOptimization extends SceneOptimization {
  67408. private static _UpdateSelectionTree;
  67409. /**
  67410. * Gets or sets a boolean which defines if optimization octree has to be updated
  67411. */
  67412. /**
  67413. * Gets or sets a boolean which defines if optimization octree has to be updated
  67414. */
  67415. static UpdateSelectionTree: boolean;
  67416. /**
  67417. * Gets a string describing the action executed by the current optimization
  67418. * @return description string
  67419. */
  67420. getDescription(): string;
  67421. private _canBeMerged;
  67422. /**
  67423. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67424. * @param scene defines the current scene where to apply this optimization
  67425. * @param optimizer defines the current optimizer
  67426. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  67427. * @returns true if everything that can be done was applied
  67428. */
  67429. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  67430. }
  67431. /**
  67432. * Defines a list of options used by SceneOptimizer
  67433. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67434. */
  67435. export class SceneOptimizerOptions {
  67436. /**
  67437. * Defines the target frame rate to reach (60 by default)
  67438. */
  67439. targetFrameRate: number;
  67440. /**
  67441. * Defines the interval between two checkes (2000ms by default)
  67442. */
  67443. trackerDuration: number;
  67444. /**
  67445. * Gets the list of optimizations to apply
  67446. */
  67447. optimizations: SceneOptimization[];
  67448. /**
  67449. * Creates a new list of options used by SceneOptimizer
  67450. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  67451. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  67452. */
  67453. constructor(
  67454. /**
  67455. * Defines the target frame rate to reach (60 by default)
  67456. */
  67457. targetFrameRate?: number,
  67458. /**
  67459. * Defines the interval between two checkes (2000ms by default)
  67460. */
  67461. trackerDuration?: number);
  67462. /**
  67463. * Add a new optimization
  67464. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  67465. * @returns the current SceneOptimizerOptions
  67466. */
  67467. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  67468. /**
  67469. * Add a new custom optimization
  67470. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  67471. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  67472. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67473. * @returns the current SceneOptimizerOptions
  67474. */
  67475. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  67476. /**
  67477. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  67478. * @param targetFrameRate defines the target frame rate (60 by default)
  67479. * @returns a SceneOptimizerOptions object
  67480. */
  67481. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67482. /**
  67483. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  67484. * @param targetFrameRate defines the target frame rate (60 by default)
  67485. * @returns a SceneOptimizerOptions object
  67486. */
  67487. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67488. /**
  67489. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  67490. * @param targetFrameRate defines the target frame rate (60 by default)
  67491. * @returns a SceneOptimizerOptions object
  67492. */
  67493. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67494. }
  67495. /**
  67496. * Class used to run optimizations in order to reach a target frame rate
  67497. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67498. */
  67499. export class SceneOptimizer implements IDisposable {
  67500. private _isRunning;
  67501. private _options;
  67502. private _scene;
  67503. private _currentPriorityLevel;
  67504. private _targetFrameRate;
  67505. private _trackerDuration;
  67506. private _currentFrameRate;
  67507. private _sceneDisposeObserver;
  67508. private _improvementMode;
  67509. /**
  67510. * Defines an observable called when the optimizer reaches the target frame rate
  67511. */
  67512. onSuccessObservable: Observable<SceneOptimizer>;
  67513. /**
  67514. * Defines an observable called when the optimizer enables an optimization
  67515. */
  67516. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  67517. /**
  67518. * Defines an observable called when the optimizer is not able to reach the target frame rate
  67519. */
  67520. onFailureObservable: Observable<SceneOptimizer>;
  67521. /**
  67522. * Gets a boolean indicating if the optimizer is in improvement mode
  67523. */
  67524. readonly isInImprovementMode: boolean;
  67525. /**
  67526. * Gets the current priority level (0 at start)
  67527. */
  67528. readonly currentPriorityLevel: number;
  67529. /**
  67530. * Gets the current frame rate checked by the SceneOptimizer
  67531. */
  67532. readonly currentFrameRate: number;
  67533. /**
  67534. * Gets or sets the current target frame rate (60 by default)
  67535. */
  67536. /**
  67537. * Gets or sets the current target frame rate (60 by default)
  67538. */
  67539. targetFrameRate: number;
  67540. /**
  67541. * Gets or sets the current interval between two checks (every 2000ms by default)
  67542. */
  67543. /**
  67544. * Gets or sets the current interval between two checks (every 2000ms by default)
  67545. */
  67546. trackerDuration: number;
  67547. /**
  67548. * Gets the list of active optimizations
  67549. */
  67550. readonly optimizations: SceneOptimization[];
  67551. /**
  67552. * Creates a new SceneOptimizer
  67553. * @param scene defines the scene to work on
  67554. * @param options defines the options to use with the SceneOptimizer
  67555. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  67556. * @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)
  67557. */
  67558. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  67559. /**
  67560. * Stops the current optimizer
  67561. */
  67562. stop(): void;
  67563. /**
  67564. * Reset the optimizer to initial step (current priority level = 0)
  67565. */
  67566. reset(): void;
  67567. /**
  67568. * Start the optimizer. By default it will try to reach a specific framerate
  67569. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  67570. */
  67571. start(): void;
  67572. private _checkCurrentState;
  67573. /**
  67574. * Release all resources
  67575. */
  67576. dispose(): void;
  67577. /**
  67578. * Helper function to create a SceneOptimizer with one single line of code
  67579. * @param scene defines the scene to work on
  67580. * @param options defines the options to use with the SceneOptimizer
  67581. * @param onSuccess defines a callback to call on success
  67582. * @param onFailure defines a callback to call on failure
  67583. * @returns the new SceneOptimizer object
  67584. */
  67585. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  67586. }
  67587. }
  67588. declare module "babylonjs/Misc/sceneSerializer" {
  67589. import { Scene } from "babylonjs/scene";
  67590. /**
  67591. * Class used to serialize a scene into a string
  67592. */
  67593. export class SceneSerializer {
  67594. /**
  67595. * Clear cache used by a previous serialization
  67596. */
  67597. static ClearCache(): void;
  67598. /**
  67599. * Serialize a scene into a JSON compatible object
  67600. * @param scene defines the scene to serialize
  67601. * @returns a JSON compatible object
  67602. */
  67603. static Serialize(scene: Scene): any;
  67604. /**
  67605. * Serialize a mesh into a JSON compatible object
  67606. * @param toSerialize defines the mesh to serialize
  67607. * @param withParents defines if parents must be serialized as well
  67608. * @param withChildren defines if children must be serialized as well
  67609. * @returns a JSON compatible object
  67610. */
  67611. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  67612. }
  67613. }
  67614. declare module "babylonjs/Misc/textureTools" {
  67615. import { Texture } from "babylonjs/Materials/Textures/texture";
  67616. /**
  67617. * Class used to host texture specific utilities
  67618. */
  67619. export class TextureTools {
  67620. /**
  67621. * Uses the GPU to create a copy texture rescaled at a given size
  67622. * @param texture Texture to copy from
  67623. * @param width defines the desired width
  67624. * @param height defines the desired height
  67625. * @param useBilinearMode defines if bilinear mode has to be used
  67626. * @return the generated texture
  67627. */
  67628. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  67629. }
  67630. }
  67631. declare module "babylonjs/Misc/videoRecorder" {
  67632. import { Nullable } from "babylonjs/types";
  67633. import { Engine } from "babylonjs/Engines/engine";
  67634. /**
  67635. * This represents the different options available for the video capture.
  67636. */
  67637. export interface VideoRecorderOptions {
  67638. /** Defines the mime type of the video. */
  67639. mimeType: string;
  67640. /** Defines the FPS the video should be recorded at. */
  67641. fps: number;
  67642. /** Defines the chunk size for the recording data. */
  67643. recordChunckSize: number;
  67644. /** The audio tracks to attach to the recording. */
  67645. audioTracks?: MediaStreamTrack[];
  67646. }
  67647. /**
  67648. * This can help with recording videos from BabylonJS.
  67649. * This is based on the available WebRTC functionalities of the browser.
  67650. *
  67651. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  67652. */
  67653. export class VideoRecorder {
  67654. private static readonly _defaultOptions;
  67655. /**
  67656. * Returns whether or not the VideoRecorder is available in your browser.
  67657. * @param engine Defines the Babylon Engine.
  67658. * @returns true if supported otherwise false.
  67659. */
  67660. static IsSupported(engine: Engine): boolean;
  67661. private readonly _options;
  67662. private _canvas;
  67663. private _mediaRecorder;
  67664. private _recordedChunks;
  67665. private _fileName;
  67666. private _resolve;
  67667. private _reject;
  67668. /**
  67669. * True when a recording is already in progress.
  67670. */
  67671. readonly isRecording: boolean;
  67672. /**
  67673. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  67674. * @param engine Defines the BabylonJS Engine you wish to record.
  67675. * @param options Defines options that can be used to customize the capture.
  67676. */
  67677. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  67678. /**
  67679. * Stops the current recording before the default capture timeout passed in the startRecording function.
  67680. */
  67681. stopRecording(): void;
  67682. /**
  67683. * Starts recording the canvas for a max duration specified in parameters.
  67684. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  67685. * If null no automatic download will start and you can rely on the promise to get the data back.
  67686. * @param maxDuration Defines the maximum recording time in seconds.
  67687. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  67688. * @return A promise callback at the end of the recording with the video data in Blob.
  67689. */
  67690. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  67691. /**
  67692. * Releases internal resources used during the recording.
  67693. */
  67694. dispose(): void;
  67695. private _handleDataAvailable;
  67696. private _handleError;
  67697. private _handleStop;
  67698. }
  67699. }
  67700. declare module "babylonjs/Misc/screenshotTools" {
  67701. import { Camera } from "babylonjs/Cameras/camera";
  67702. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  67703. import { Engine } from "babylonjs/Engines/engine";
  67704. /**
  67705. * Class containing a set of static utilities functions for screenshots
  67706. */
  67707. export class ScreenshotTools {
  67708. /**
  67709. * Captures a screenshot of the current rendering
  67710. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67711. * @param engine defines the rendering engine
  67712. * @param camera defines the source camera
  67713. * @param size This parameter can be set to a single number or to an object with the
  67714. * following (optional) properties: precision, width, height. If a single number is passed,
  67715. * it will be used for both width and height. If an object is passed, the screenshot size
  67716. * will be derived from the parameters. The precision property is a multiplier allowing
  67717. * rendering at a higher or lower resolution
  67718. * @param successCallback defines the callback receives a single parameter which contains the
  67719. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67720. * src parameter of an <img> to display it
  67721. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67722. * Check your browser for supported MIME types
  67723. */
  67724. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  67725. /**
  67726. * Captures a screenshot of the current rendering
  67727. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67728. * @param engine defines the rendering engine
  67729. * @param camera defines the source camera
  67730. * @param size This parameter can be set to a single number or to an object with the
  67731. * following (optional) properties: precision, width, height. If a single number is passed,
  67732. * it will be used for both width and height. If an object is passed, the screenshot size
  67733. * will be derived from the parameters. The precision property is a multiplier allowing
  67734. * rendering at a higher or lower resolution
  67735. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67736. * Check your browser for supported MIME types
  67737. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67738. * to the src parameter of an <img> to display it
  67739. */
  67740. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  67741. /**
  67742. * Generates an image screenshot from the specified camera.
  67743. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67744. * @param engine The engine to use for rendering
  67745. * @param camera The camera to use for rendering
  67746. * @param size This parameter can be set to a single number or to an object with the
  67747. * following (optional) properties: precision, width, height. If a single number is passed,
  67748. * it will be used for both width and height. If an object is passed, the screenshot size
  67749. * will be derived from the parameters. The precision property is a multiplier allowing
  67750. * rendering at a higher or lower resolution
  67751. * @param successCallback The callback receives a single parameter which contains the
  67752. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67753. * src parameter of an <img> to display it
  67754. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67755. * Check your browser for supported MIME types
  67756. * @param samples Texture samples (default: 1)
  67757. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67758. * @param fileName A name for for the downloaded file.
  67759. */
  67760. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  67761. /**
  67762. * Generates an image screenshot from the specified camera.
  67763. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67764. * @param engine The engine to use for rendering
  67765. * @param camera The camera to use for rendering
  67766. * @param size This parameter can be set to a single number or to an object with the
  67767. * following (optional) properties: precision, width, height. If a single number is passed,
  67768. * it will be used for both width and height. If an object is passed, the screenshot size
  67769. * will be derived from the parameters. The precision property is a multiplier allowing
  67770. * rendering at a higher or lower resolution
  67771. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67772. * Check your browser for supported MIME types
  67773. * @param samples Texture samples (default: 1)
  67774. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67775. * @param fileName A name for for the downloaded file.
  67776. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67777. * to the src parameter of an <img> to display it
  67778. */
  67779. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  67780. /**
  67781. * Gets height and width for screenshot size
  67782. * @private
  67783. */
  67784. private static _getScreenshotSize;
  67785. }
  67786. }
  67787. declare module "babylonjs/Misc/dataReader" {
  67788. /**
  67789. * Interface for a data buffer
  67790. */
  67791. export interface IDataBuffer {
  67792. /**
  67793. * Reads bytes from the data buffer.
  67794. * @param byteOffset The byte offset to read
  67795. * @param byteLength The byte length to read
  67796. * @returns A promise that resolves when the bytes are read
  67797. */
  67798. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  67799. /**
  67800. * The byte length of the buffer.
  67801. */
  67802. readonly byteLength: number;
  67803. }
  67804. /**
  67805. * Utility class for reading from a data buffer
  67806. */
  67807. export class DataReader {
  67808. /**
  67809. * The data buffer associated with this data reader.
  67810. */
  67811. readonly buffer: IDataBuffer;
  67812. /**
  67813. * The current byte offset from the beginning of the data buffer.
  67814. */
  67815. byteOffset: number;
  67816. private _dataView;
  67817. private _dataByteOffset;
  67818. /**
  67819. * Constructor
  67820. * @param buffer The buffer to read
  67821. */
  67822. constructor(buffer: IDataBuffer);
  67823. /**
  67824. * Loads the given byte length.
  67825. * @param byteLength The byte length to load
  67826. * @returns A promise that resolves when the load is complete
  67827. */
  67828. loadAsync(byteLength: number): Promise<void>;
  67829. /**
  67830. * Read a unsigned 32-bit integer from the currently loaded data range.
  67831. * @returns The 32-bit integer read
  67832. */
  67833. readUint32(): number;
  67834. /**
  67835. * Read a byte array from the currently loaded data range.
  67836. * @param byteLength The byte length to read
  67837. * @returns The byte array read
  67838. */
  67839. readUint8Array(byteLength: number): Uint8Array;
  67840. /**
  67841. * Read a string from the currently loaded data range.
  67842. * @param byteLength The byte length to read
  67843. * @returns The string read
  67844. */
  67845. readString(byteLength: number): string;
  67846. /**
  67847. * Skips the given byte length the currently loaded data range.
  67848. * @param byteLength The byte length to skip
  67849. */
  67850. skipBytes(byteLength: number): void;
  67851. }
  67852. }
  67853. declare module "babylonjs/Misc/index" {
  67854. export * from "babylonjs/Misc/andOrNotEvaluator";
  67855. export * from "babylonjs/Misc/assetsManager";
  67856. export * from "babylonjs/Misc/dds";
  67857. export * from "babylonjs/Misc/decorators";
  67858. export * from "babylonjs/Misc/deferred";
  67859. export * from "babylonjs/Misc/environmentTextureTools";
  67860. export * from "babylonjs/Misc/meshExploder";
  67861. export * from "babylonjs/Misc/filesInput";
  67862. export * from "babylonjs/Misc/HighDynamicRange/index";
  67863. export * from "babylonjs/Misc/khronosTextureContainer";
  67864. export * from "babylonjs/Misc/observable";
  67865. export * from "babylonjs/Misc/performanceMonitor";
  67866. export * from "babylonjs/Misc/promise";
  67867. export * from "babylonjs/Misc/sceneOptimizer";
  67868. export * from "babylonjs/Misc/sceneSerializer";
  67869. export * from "babylonjs/Misc/smartArray";
  67870. export * from "babylonjs/Misc/stringDictionary";
  67871. export * from "babylonjs/Misc/tags";
  67872. export * from "babylonjs/Misc/textureTools";
  67873. export * from "babylonjs/Misc/tga";
  67874. export * from "babylonjs/Misc/tools";
  67875. export * from "babylonjs/Misc/videoRecorder";
  67876. export * from "babylonjs/Misc/virtualJoystick";
  67877. export * from "babylonjs/Misc/workerPool";
  67878. export * from "babylonjs/Misc/logger";
  67879. export * from "babylonjs/Misc/typeStore";
  67880. export * from "babylonjs/Misc/filesInputStore";
  67881. export * from "babylonjs/Misc/deepCopier";
  67882. export * from "babylonjs/Misc/pivotTools";
  67883. export * from "babylonjs/Misc/precisionDate";
  67884. export * from "babylonjs/Misc/screenshotTools";
  67885. export * from "babylonjs/Misc/typeStore";
  67886. export * from "babylonjs/Misc/webRequest";
  67887. export * from "babylonjs/Misc/iInspectable";
  67888. export * from "babylonjs/Misc/brdfTextureTools";
  67889. export * from "babylonjs/Misc/rgbdTextureTools";
  67890. export * from "babylonjs/Misc/gradients";
  67891. export * from "babylonjs/Misc/perfCounter";
  67892. export * from "babylonjs/Misc/fileRequest";
  67893. export * from "babylonjs/Misc/customAnimationFrameRequester";
  67894. export * from "babylonjs/Misc/retryStrategy";
  67895. export * from "babylonjs/Misc/interfaces/screenshotSize";
  67896. export * from "babylonjs/Misc/canvasGenerator";
  67897. export * from "babylonjs/Misc/fileTools";
  67898. export * from "babylonjs/Misc/stringTools";
  67899. export * from "babylonjs/Misc/dataReader";
  67900. }
  67901. declare module "babylonjs/index" {
  67902. export * from "babylonjs/abstractScene";
  67903. export * from "babylonjs/Actions/index";
  67904. export * from "babylonjs/Animations/index";
  67905. export * from "babylonjs/assetContainer";
  67906. export * from "babylonjs/Audio/index";
  67907. export * from "babylonjs/Behaviors/index";
  67908. export * from "babylonjs/Bones/index";
  67909. export * from "babylonjs/Cameras/index";
  67910. export * from "babylonjs/Collisions/index";
  67911. export * from "babylonjs/Culling/index";
  67912. export * from "babylonjs/Debug/index";
  67913. export * from "babylonjs/Engines/index";
  67914. export * from "babylonjs/Events/index";
  67915. export * from "babylonjs/Gamepads/index";
  67916. export * from "babylonjs/Gizmos/index";
  67917. export * from "babylonjs/Helpers/index";
  67918. export * from "babylonjs/Instrumentation/index";
  67919. export * from "babylonjs/Layers/index";
  67920. export * from "babylonjs/LensFlares/index";
  67921. export * from "babylonjs/Lights/index";
  67922. export * from "babylonjs/Loading/index";
  67923. export * from "babylonjs/Materials/index";
  67924. export * from "babylonjs/Maths/index";
  67925. export * from "babylonjs/Meshes/index";
  67926. export * from "babylonjs/Morph/index";
  67927. export * from "babylonjs/Navigation/index";
  67928. export * from "babylonjs/node";
  67929. export * from "babylonjs/Offline/index";
  67930. export * from "babylonjs/Particles/index";
  67931. export * from "babylonjs/Physics/index";
  67932. export * from "babylonjs/PostProcesses/index";
  67933. export * from "babylonjs/Probes/index";
  67934. export * from "babylonjs/Rendering/index";
  67935. export * from "babylonjs/scene";
  67936. export * from "babylonjs/sceneComponent";
  67937. export * from "babylonjs/Sprites/index";
  67938. export * from "babylonjs/States/index";
  67939. export * from "babylonjs/Misc/index";
  67940. export * from "babylonjs/types";
  67941. }
  67942. declare module "babylonjs/Animations/pathCursor" {
  67943. import { Vector3 } from "babylonjs/Maths/math.vector";
  67944. import { Path2 } from "babylonjs/Maths/math.path";
  67945. /**
  67946. * A cursor which tracks a point on a path
  67947. */
  67948. export class PathCursor {
  67949. private path;
  67950. /**
  67951. * Stores path cursor callbacks for when an onchange event is triggered
  67952. */
  67953. private _onchange;
  67954. /**
  67955. * The value of the path cursor
  67956. */
  67957. value: number;
  67958. /**
  67959. * The animation array of the path cursor
  67960. */
  67961. animations: Animation[];
  67962. /**
  67963. * Initializes the path cursor
  67964. * @param path The path to track
  67965. */
  67966. constructor(path: Path2);
  67967. /**
  67968. * Gets the cursor point on the path
  67969. * @returns A point on the path cursor at the cursor location
  67970. */
  67971. getPoint(): Vector3;
  67972. /**
  67973. * Moves the cursor ahead by the step amount
  67974. * @param step The amount to move the cursor forward
  67975. * @returns This path cursor
  67976. */
  67977. moveAhead(step?: number): PathCursor;
  67978. /**
  67979. * Moves the cursor behind by the step amount
  67980. * @param step The amount to move the cursor back
  67981. * @returns This path cursor
  67982. */
  67983. moveBack(step?: number): PathCursor;
  67984. /**
  67985. * Moves the cursor by the step amount
  67986. * If the step amount is greater than one, an exception is thrown
  67987. * @param step The amount to move the cursor
  67988. * @returns This path cursor
  67989. */
  67990. move(step: number): PathCursor;
  67991. /**
  67992. * Ensures that the value is limited between zero and one
  67993. * @returns This path cursor
  67994. */
  67995. private ensureLimits;
  67996. /**
  67997. * Runs onchange callbacks on change (used by the animation engine)
  67998. * @returns This path cursor
  67999. */
  68000. private raiseOnChange;
  68001. /**
  68002. * Executes a function on change
  68003. * @param f A path cursor onchange callback
  68004. * @returns This path cursor
  68005. */
  68006. onchange(f: (cursor: PathCursor) => void): PathCursor;
  68007. }
  68008. }
  68009. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  68010. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  68011. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  68012. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  68013. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  68014. }
  68015. declare module "babylonjs/Engines/Processors/Expressions/index" {
  68016. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  68017. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  68018. }
  68019. declare module "babylonjs/Engines/Processors/index" {
  68020. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  68021. export * from "babylonjs/Engines/Processors/Expressions/index";
  68022. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  68023. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  68024. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  68025. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  68026. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  68027. export * from "babylonjs/Engines/Processors/shaderProcessor";
  68028. }
  68029. declare module "babylonjs/Legacy/legacy" {
  68030. import * as Babylon from "babylonjs/index";
  68031. export * from "babylonjs/index";
  68032. }
  68033. declare module "babylonjs/Shaders/blur.fragment" {
  68034. /** @hidden */
  68035. export var blurPixelShader: {
  68036. name: string;
  68037. shader: string;
  68038. };
  68039. }
  68040. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  68041. /** @hidden */
  68042. export var pointCloudVertexDeclaration: {
  68043. name: string;
  68044. shader: string;
  68045. };
  68046. }
  68047. declare module "babylonjs" {
  68048. export * from "babylonjs/Legacy/legacy";
  68049. }
  68050. declare module BABYLON {
  68051. /** Alias type for value that can be null */
  68052. export type Nullable<T> = T | null;
  68053. /**
  68054. * Alias type for number that are floats
  68055. * @ignorenaming
  68056. */
  68057. export type float = number;
  68058. /**
  68059. * Alias type for number that are doubles.
  68060. * @ignorenaming
  68061. */
  68062. export type double = number;
  68063. /**
  68064. * Alias type for number that are integer
  68065. * @ignorenaming
  68066. */
  68067. export type int = number;
  68068. /** Alias type for number array or Float32Array */
  68069. export type FloatArray = number[] | Float32Array;
  68070. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  68071. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  68072. /**
  68073. * Alias for types that can be used by a Buffer or VertexBuffer.
  68074. */
  68075. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  68076. /**
  68077. * Alias type for primitive types
  68078. * @ignorenaming
  68079. */
  68080. type Primitive = undefined | null | boolean | string | number | Function;
  68081. /**
  68082. * Type modifier to make all the properties of an object Readonly
  68083. */
  68084. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  68085. /**
  68086. * Type modifier to make all the properties of an object Readonly recursively
  68087. */
  68088. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  68089. /**
  68090. * Type modifier to make object properties readonly.
  68091. */
  68092. export type DeepImmutableObject<T> = {
  68093. readonly [K in keyof T]: DeepImmutable<T[K]>;
  68094. };
  68095. /** @hidden */
  68096. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  68097. }
  68098. }
  68099. declare module BABYLON {
  68100. /**
  68101. * A class serves as a medium between the observable and its observers
  68102. */
  68103. export class EventState {
  68104. /**
  68105. * Create a new EventState
  68106. * @param mask defines the mask associated with this state
  68107. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68108. * @param target defines the original target of the state
  68109. * @param currentTarget defines the current target of the state
  68110. */
  68111. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  68112. /**
  68113. * Initialize the current event state
  68114. * @param mask defines the mask associated with this state
  68115. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68116. * @param target defines the original target of the state
  68117. * @param currentTarget defines the current target of the state
  68118. * @returns the current event state
  68119. */
  68120. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  68121. /**
  68122. * An Observer can set this property to true to prevent subsequent observers of being notified
  68123. */
  68124. skipNextObservers: boolean;
  68125. /**
  68126. * Get the mask value that were used to trigger the event corresponding to this EventState object
  68127. */
  68128. mask: number;
  68129. /**
  68130. * The object that originally notified the event
  68131. */
  68132. target?: any;
  68133. /**
  68134. * The current object in the bubbling phase
  68135. */
  68136. currentTarget?: any;
  68137. /**
  68138. * This will be populated with the return value of the last function that was executed.
  68139. * If it is the first function in the callback chain it will be the event data.
  68140. */
  68141. lastReturnValue?: any;
  68142. }
  68143. /**
  68144. * Represent an Observer registered to a given Observable object.
  68145. */
  68146. export class Observer<T> {
  68147. /**
  68148. * Defines the callback to call when the observer is notified
  68149. */
  68150. callback: (eventData: T, eventState: EventState) => void;
  68151. /**
  68152. * Defines the mask of the observer (used to filter notifications)
  68153. */
  68154. mask: number;
  68155. /**
  68156. * Defines the current scope used to restore the JS context
  68157. */
  68158. scope: any;
  68159. /** @hidden */
  68160. _willBeUnregistered: boolean;
  68161. /**
  68162. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  68163. */
  68164. unregisterOnNextCall: boolean;
  68165. /**
  68166. * Creates a new observer
  68167. * @param callback defines the callback to call when the observer is notified
  68168. * @param mask defines the mask of the observer (used to filter notifications)
  68169. * @param scope defines the current scope used to restore the JS context
  68170. */
  68171. constructor(
  68172. /**
  68173. * Defines the callback to call when the observer is notified
  68174. */
  68175. callback: (eventData: T, eventState: EventState) => void,
  68176. /**
  68177. * Defines the mask of the observer (used to filter notifications)
  68178. */
  68179. mask: number,
  68180. /**
  68181. * Defines the current scope used to restore the JS context
  68182. */
  68183. scope?: any);
  68184. }
  68185. /**
  68186. * Represent a list of observers registered to multiple Observables object.
  68187. */
  68188. export class MultiObserver<T> {
  68189. private _observers;
  68190. private _observables;
  68191. /**
  68192. * Release associated resources
  68193. */
  68194. dispose(): void;
  68195. /**
  68196. * Raise a callback when one of the observable will notify
  68197. * @param observables defines a list of observables to watch
  68198. * @param callback defines the callback to call on notification
  68199. * @param mask defines the mask used to filter notifications
  68200. * @param scope defines the current scope used to restore the JS context
  68201. * @returns the new MultiObserver
  68202. */
  68203. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  68204. }
  68205. /**
  68206. * The Observable class is a simple implementation of the Observable pattern.
  68207. *
  68208. * 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.
  68209. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  68210. * 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).
  68211. * 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.
  68212. */
  68213. export class Observable<T> {
  68214. private _observers;
  68215. private _eventState;
  68216. private _onObserverAdded;
  68217. /**
  68218. * Gets the list of observers
  68219. */
  68220. readonly observers: Array<Observer<T>>;
  68221. /**
  68222. * Creates a new observable
  68223. * @param onObserverAdded defines a callback to call when a new observer is added
  68224. */
  68225. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  68226. /**
  68227. * Create a new Observer with the specified callback
  68228. * @param callback the callback that will be executed for that Observer
  68229. * @param mask the mask used to filter observers
  68230. * @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.
  68231. * @param scope optional scope for the callback to be called from
  68232. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  68233. * @returns the new observer created for the callback
  68234. */
  68235. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  68236. /**
  68237. * Create a new Observer with the specified callback and unregisters after the next notification
  68238. * @param callback the callback that will be executed for that Observer
  68239. * @returns the new observer created for the callback
  68240. */
  68241. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  68242. /**
  68243. * Remove an Observer from the Observable object
  68244. * @param observer the instance of the Observer to remove
  68245. * @returns false if it doesn't belong to this Observable
  68246. */
  68247. remove(observer: Nullable<Observer<T>>): boolean;
  68248. /**
  68249. * Remove a callback from the Observable object
  68250. * @param callback the callback to remove
  68251. * @param scope optional scope. If used only the callbacks with this scope will be removed
  68252. * @returns false if it doesn't belong to this Observable
  68253. */
  68254. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  68255. private _deferUnregister;
  68256. private _remove;
  68257. /**
  68258. * Moves the observable to the top of the observer list making it get called first when notified
  68259. * @param observer the observer to move
  68260. */
  68261. makeObserverTopPriority(observer: Observer<T>): void;
  68262. /**
  68263. * Moves the observable to the bottom of the observer list making it get called last when notified
  68264. * @param observer the observer to move
  68265. */
  68266. makeObserverBottomPriority(observer: Observer<T>): void;
  68267. /**
  68268. * Notify all Observers by calling their respective callback with the given data
  68269. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  68270. * @param eventData defines the data to send to all observers
  68271. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  68272. * @param target defines the original target of the state
  68273. * @param currentTarget defines the current target of the state
  68274. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  68275. */
  68276. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  68277. /**
  68278. * Calling this will execute each callback, expecting it to be a promise or return a value.
  68279. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  68280. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  68281. * and it is crucial that all callbacks will be executed.
  68282. * The order of the callbacks is kept, callbacks are not executed parallel.
  68283. *
  68284. * @param eventData The data to be sent to each callback
  68285. * @param mask is used to filter observers defaults to -1
  68286. * @param target defines the callback target (see EventState)
  68287. * @param currentTarget defines he current object in the bubbling phase
  68288. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  68289. */
  68290. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  68291. /**
  68292. * Notify a specific observer
  68293. * @param observer defines the observer to notify
  68294. * @param eventData defines the data to be sent to each callback
  68295. * @param mask is used to filter observers defaults to -1
  68296. */
  68297. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  68298. /**
  68299. * Gets a boolean indicating if the observable has at least one observer
  68300. * @returns true is the Observable has at least one Observer registered
  68301. */
  68302. hasObservers(): boolean;
  68303. /**
  68304. * Clear the list of observers
  68305. */
  68306. clear(): void;
  68307. /**
  68308. * Clone the current observable
  68309. * @returns a new observable
  68310. */
  68311. clone(): Observable<T>;
  68312. /**
  68313. * Does this observable handles observer registered with a given mask
  68314. * @param mask defines the mask to be tested
  68315. * @return whether or not one observer registered with the given mask is handeled
  68316. **/
  68317. hasSpecificMask(mask?: number): boolean;
  68318. }
  68319. }
  68320. declare module BABYLON {
  68321. /**
  68322. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  68323. * Babylon.js
  68324. */
  68325. export class DomManagement {
  68326. /**
  68327. * Checks if the window object exists
  68328. * @returns true if the window object exists
  68329. */
  68330. static IsWindowObjectExist(): boolean;
  68331. /**
  68332. * Checks if the navigator object exists
  68333. * @returns true if the navigator object exists
  68334. */
  68335. static IsNavigatorAvailable(): boolean;
  68336. /**
  68337. * Extracts text content from a DOM element hierarchy
  68338. * @param element defines the root element
  68339. * @returns a string
  68340. */
  68341. static GetDOMTextContent(element: HTMLElement): string;
  68342. }
  68343. }
  68344. declare module BABYLON {
  68345. /**
  68346. * Logger used througouht the application to allow configuration of
  68347. * the log level required for the messages.
  68348. */
  68349. export class Logger {
  68350. /**
  68351. * No log
  68352. */
  68353. static readonly NoneLogLevel: number;
  68354. /**
  68355. * Only message logs
  68356. */
  68357. static readonly MessageLogLevel: number;
  68358. /**
  68359. * Only warning logs
  68360. */
  68361. static readonly WarningLogLevel: number;
  68362. /**
  68363. * Only error logs
  68364. */
  68365. static readonly ErrorLogLevel: number;
  68366. /**
  68367. * All logs
  68368. */
  68369. static readonly AllLogLevel: number;
  68370. private static _LogCache;
  68371. /**
  68372. * Gets a value indicating the number of loading errors
  68373. * @ignorenaming
  68374. */
  68375. static errorsCount: number;
  68376. /**
  68377. * Callback called when a new log is added
  68378. */
  68379. static OnNewCacheEntry: (entry: string) => void;
  68380. private static _AddLogEntry;
  68381. private static _FormatMessage;
  68382. private static _LogDisabled;
  68383. private static _LogEnabled;
  68384. private static _WarnDisabled;
  68385. private static _WarnEnabled;
  68386. private static _ErrorDisabled;
  68387. private static _ErrorEnabled;
  68388. /**
  68389. * Log a message to the console
  68390. */
  68391. static Log: (message: string) => void;
  68392. /**
  68393. * Write a warning message to the console
  68394. */
  68395. static Warn: (message: string) => void;
  68396. /**
  68397. * Write an error message to the console
  68398. */
  68399. static Error: (message: string) => void;
  68400. /**
  68401. * Gets current log cache (list of logs)
  68402. */
  68403. static readonly LogCache: string;
  68404. /**
  68405. * Clears the log cache
  68406. */
  68407. static ClearLogCache(): void;
  68408. /**
  68409. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  68410. */
  68411. static LogLevels: number;
  68412. }
  68413. }
  68414. declare module BABYLON {
  68415. /** @hidden */
  68416. export class _TypeStore {
  68417. /** @hidden */
  68418. static RegisteredTypes: {
  68419. [key: string]: Object;
  68420. };
  68421. /** @hidden */
  68422. static GetClass(fqdn: string): any;
  68423. }
  68424. }
  68425. declare module BABYLON {
  68426. /**
  68427. * Helper to manipulate strings
  68428. */
  68429. export class StringTools {
  68430. /**
  68431. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68432. * @param str Source string
  68433. * @param suffix Suffix to search for in the source string
  68434. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68435. */
  68436. static EndsWith(str: string, suffix: string): boolean;
  68437. /**
  68438. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68439. * @param str Source string
  68440. * @param suffix Suffix to search for in the source string
  68441. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68442. */
  68443. static StartsWith(str: string, suffix: string): boolean;
  68444. /**
  68445. * Decodes a buffer into a string
  68446. * @param buffer The buffer to decode
  68447. * @returns The decoded string
  68448. */
  68449. static Decode(buffer: Uint8Array | Uint16Array): string;
  68450. /**
  68451. * Encode a buffer to a base64 string
  68452. * @param buffer defines the buffer to encode
  68453. * @returns the encoded string
  68454. */
  68455. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  68456. }
  68457. }
  68458. declare module BABYLON {
  68459. /**
  68460. * Class containing a set of static utilities functions for deep copy.
  68461. */
  68462. export class DeepCopier {
  68463. /**
  68464. * Tries to copy an object by duplicating every property
  68465. * @param source defines the source object
  68466. * @param destination defines the target object
  68467. * @param doNotCopyList defines a list of properties to avoid
  68468. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  68469. */
  68470. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  68471. }
  68472. }
  68473. declare module BABYLON {
  68474. /**
  68475. * Class containing a set of static utilities functions for precision date
  68476. */
  68477. export class PrecisionDate {
  68478. /**
  68479. * Gets either window.performance.now() if supported or Date.now() else
  68480. */
  68481. static readonly Now: number;
  68482. }
  68483. }
  68484. declare module BABYLON {
  68485. /** @hidden */
  68486. export class _DevTools {
  68487. static WarnImport(name: string): string;
  68488. }
  68489. }
  68490. declare module BABYLON {
  68491. /**
  68492. * Interface used to define the mechanism to get data from the network
  68493. */
  68494. export interface IWebRequest {
  68495. /**
  68496. * Returns client's response url
  68497. */
  68498. responseURL: string;
  68499. /**
  68500. * Returns client's status
  68501. */
  68502. status: number;
  68503. /**
  68504. * Returns client's status as a text
  68505. */
  68506. statusText: string;
  68507. }
  68508. }
  68509. declare module BABYLON {
  68510. /**
  68511. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  68512. */
  68513. export class WebRequest implements IWebRequest {
  68514. private _xhr;
  68515. /**
  68516. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  68517. * i.e. when loading files, where the server/service expects an Authorization header
  68518. */
  68519. static CustomRequestHeaders: {
  68520. [key: string]: string;
  68521. };
  68522. /**
  68523. * Add callback functions in this array to update all the requests before they get sent to the network
  68524. */
  68525. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  68526. private _injectCustomRequestHeaders;
  68527. /**
  68528. * Gets or sets a function to be called when loading progress changes
  68529. */
  68530. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  68531. /**
  68532. * Returns client's state
  68533. */
  68534. readonly readyState: number;
  68535. /**
  68536. * Returns client's status
  68537. */
  68538. readonly status: number;
  68539. /**
  68540. * Returns client's status as a text
  68541. */
  68542. readonly statusText: string;
  68543. /**
  68544. * Returns client's response
  68545. */
  68546. readonly response: any;
  68547. /**
  68548. * Returns client's response url
  68549. */
  68550. readonly responseURL: string;
  68551. /**
  68552. * Returns client's response as text
  68553. */
  68554. readonly responseText: string;
  68555. /**
  68556. * Gets or sets the expected response type
  68557. */
  68558. responseType: XMLHttpRequestResponseType;
  68559. /** @hidden */
  68560. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  68561. /** @hidden */
  68562. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  68563. /**
  68564. * Cancels any network activity
  68565. */
  68566. abort(): void;
  68567. /**
  68568. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  68569. * @param body defines an optional request body
  68570. */
  68571. send(body?: Document | BodyInit | null): void;
  68572. /**
  68573. * Sets the request method, request URL
  68574. * @param method defines the method to use (GET, POST, etc..)
  68575. * @param url defines the url to connect with
  68576. */
  68577. open(method: string, url: string): void;
  68578. /**
  68579. * Sets the value of a request header.
  68580. * @param name The name of the header whose value is to be set
  68581. * @param value The value to set as the body of the header
  68582. */
  68583. setRequestHeader(name: string, value: string): void;
  68584. /**
  68585. * Get the string containing the text of a particular header's value.
  68586. * @param name The name of the header
  68587. * @returns The string containing the text of the given header name
  68588. */
  68589. getResponseHeader(name: string): Nullable<string>;
  68590. }
  68591. }
  68592. declare module BABYLON {
  68593. /**
  68594. * File request interface
  68595. */
  68596. export interface IFileRequest {
  68597. /**
  68598. * Raised when the request is complete (success or error).
  68599. */
  68600. onCompleteObservable: Observable<IFileRequest>;
  68601. /**
  68602. * Aborts the request for a file.
  68603. */
  68604. abort: () => void;
  68605. }
  68606. }
  68607. declare module BABYLON {
  68608. /**
  68609. * Define options used to create a render target texture
  68610. */
  68611. export class RenderTargetCreationOptions {
  68612. /**
  68613. * Specifies is mipmaps must be generated
  68614. */
  68615. generateMipMaps?: boolean;
  68616. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68617. generateDepthBuffer?: boolean;
  68618. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68619. generateStencilBuffer?: boolean;
  68620. /** Defines texture type (int by default) */
  68621. type?: number;
  68622. /** Defines sampling mode (trilinear by default) */
  68623. samplingMode?: number;
  68624. /** Defines format (RGBA by default) */
  68625. format?: number;
  68626. }
  68627. }
  68628. declare module BABYLON {
  68629. /**
  68630. * @hidden
  68631. **/
  68632. export class _TimeToken {
  68633. _startTimeQuery: Nullable<WebGLQuery>;
  68634. _endTimeQuery: Nullable<WebGLQuery>;
  68635. _timeElapsedQuery: Nullable<WebGLQuery>;
  68636. _timeElapsedQueryEnded: boolean;
  68637. }
  68638. }
  68639. declare module BABYLON {
  68640. /** Defines the cross module used constants to avoid circular dependncies */
  68641. export class Constants {
  68642. /** Defines that alpha blending is disabled */
  68643. static readonly ALPHA_DISABLE: number;
  68644. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68645. static readonly ALPHA_ADD: number;
  68646. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68647. static readonly ALPHA_COMBINE: number;
  68648. /** Defines that alpha blending to DEST - SRC * DEST */
  68649. static readonly ALPHA_SUBTRACT: number;
  68650. /** Defines that alpha blending to SRC * DEST */
  68651. static readonly ALPHA_MULTIPLY: number;
  68652. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68653. static readonly ALPHA_MAXIMIZED: number;
  68654. /** Defines that alpha blending to SRC + DEST */
  68655. static readonly ALPHA_ONEONE: number;
  68656. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68657. static readonly ALPHA_PREMULTIPLIED: number;
  68658. /**
  68659. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68660. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68661. */
  68662. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68663. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68664. static readonly ALPHA_INTERPOLATE: number;
  68665. /**
  68666. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68667. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68668. */
  68669. static readonly ALPHA_SCREENMODE: number;
  68670. /**
  68671. * Defines that alpha blending to SRC + DST
  68672. * Alpha will be set to SRC ALPHA + DST ALPHA
  68673. */
  68674. static readonly ALPHA_ONEONE_ONEONE: number;
  68675. /**
  68676. * Defines that alpha blending to SRC * DST ALPHA + DST
  68677. * Alpha will be set to 0
  68678. */
  68679. static readonly ALPHA_ALPHATOCOLOR: number;
  68680. /**
  68681. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  68682. */
  68683. static readonly ALPHA_REVERSEONEMINUS: number;
  68684. /**
  68685. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  68686. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  68687. */
  68688. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  68689. /**
  68690. * Defines that alpha blending to SRC + DST
  68691. * Alpha will be set to SRC ALPHA
  68692. */
  68693. static readonly ALPHA_ONEONE_ONEZERO: number;
  68694. /** Defines that alpha blending equation a SUM */
  68695. static readonly ALPHA_EQUATION_ADD: number;
  68696. /** Defines that alpha blending equation a SUBSTRACTION */
  68697. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  68698. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  68699. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  68700. /** Defines that alpha blending equation a MAX operation */
  68701. static readonly ALPHA_EQUATION_MAX: number;
  68702. /** Defines that alpha blending equation a MIN operation */
  68703. static readonly ALPHA_EQUATION_MIN: number;
  68704. /**
  68705. * Defines that alpha blending equation a DARKEN operation:
  68706. * It takes the min of the src and sums the alpha channels.
  68707. */
  68708. static readonly ALPHA_EQUATION_DARKEN: number;
  68709. /** Defines that the ressource is not delayed*/
  68710. static readonly DELAYLOADSTATE_NONE: number;
  68711. /** Defines that the ressource was successfully delay loaded */
  68712. static readonly DELAYLOADSTATE_LOADED: number;
  68713. /** Defines that the ressource is currently delay loading */
  68714. static readonly DELAYLOADSTATE_LOADING: number;
  68715. /** Defines that the ressource is delayed and has not started loading */
  68716. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68717. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68718. static readonly NEVER: number;
  68719. /** 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 */
  68720. static readonly ALWAYS: number;
  68721. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68722. static readonly LESS: number;
  68723. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68724. static readonly EQUAL: number;
  68725. /** 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 */
  68726. static readonly LEQUAL: number;
  68727. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68728. static readonly GREATER: number;
  68729. /** 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 */
  68730. static readonly GEQUAL: number;
  68731. /** 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 */
  68732. static readonly NOTEQUAL: number;
  68733. /** Passed to stencilOperation to specify that stencil value must be kept */
  68734. static readonly KEEP: number;
  68735. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68736. static readonly REPLACE: number;
  68737. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68738. static readonly INCR: number;
  68739. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68740. static readonly DECR: number;
  68741. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68742. static readonly INVERT: number;
  68743. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68744. static readonly INCR_WRAP: number;
  68745. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68746. static readonly DECR_WRAP: number;
  68747. /** Texture is not repeating outside of 0..1 UVs */
  68748. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68749. /** Texture is repeating outside of 0..1 UVs */
  68750. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68751. /** Texture is repeating and mirrored */
  68752. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68753. /** ALPHA */
  68754. static readonly TEXTUREFORMAT_ALPHA: number;
  68755. /** LUMINANCE */
  68756. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68757. /** LUMINANCE_ALPHA */
  68758. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68759. /** RGB */
  68760. static readonly TEXTUREFORMAT_RGB: number;
  68761. /** RGBA */
  68762. static readonly TEXTUREFORMAT_RGBA: number;
  68763. /** RED */
  68764. static readonly TEXTUREFORMAT_RED: number;
  68765. /** RED (2nd reference) */
  68766. static readonly TEXTUREFORMAT_R: number;
  68767. /** RG */
  68768. static readonly TEXTUREFORMAT_RG: number;
  68769. /** RED_INTEGER */
  68770. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68771. /** RED_INTEGER (2nd reference) */
  68772. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68773. /** RG_INTEGER */
  68774. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68775. /** RGB_INTEGER */
  68776. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68777. /** RGBA_INTEGER */
  68778. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68779. /** UNSIGNED_BYTE */
  68780. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68781. /** UNSIGNED_BYTE (2nd reference) */
  68782. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68783. /** FLOAT */
  68784. static readonly TEXTURETYPE_FLOAT: number;
  68785. /** HALF_FLOAT */
  68786. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68787. /** BYTE */
  68788. static readonly TEXTURETYPE_BYTE: number;
  68789. /** SHORT */
  68790. static readonly TEXTURETYPE_SHORT: number;
  68791. /** UNSIGNED_SHORT */
  68792. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68793. /** INT */
  68794. static readonly TEXTURETYPE_INT: number;
  68795. /** UNSIGNED_INT */
  68796. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68797. /** UNSIGNED_SHORT_4_4_4_4 */
  68798. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68799. /** UNSIGNED_SHORT_5_5_5_1 */
  68800. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68801. /** UNSIGNED_SHORT_5_6_5 */
  68802. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68803. /** UNSIGNED_INT_2_10_10_10_REV */
  68804. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68805. /** UNSIGNED_INT_24_8 */
  68806. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68807. /** UNSIGNED_INT_10F_11F_11F_REV */
  68808. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68809. /** UNSIGNED_INT_5_9_9_9_REV */
  68810. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68811. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68812. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68813. /** nearest is mag = nearest and min = nearest and mip = linear */
  68814. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68815. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68816. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68817. /** Trilinear is mag = linear and min = linear and mip = linear */
  68818. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68819. /** nearest is mag = nearest and min = nearest and mip = linear */
  68820. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68821. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68822. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68823. /** Trilinear is mag = linear and min = linear and mip = linear */
  68824. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68825. /** mag = nearest and min = nearest and mip = nearest */
  68826. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68827. /** mag = nearest and min = linear and mip = nearest */
  68828. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68829. /** mag = nearest and min = linear and mip = linear */
  68830. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68831. /** mag = nearest and min = linear and mip = none */
  68832. static readonly TEXTURE_NEAREST_LINEAR: number;
  68833. /** mag = nearest and min = nearest and mip = none */
  68834. static readonly TEXTURE_NEAREST_NEAREST: number;
  68835. /** mag = linear and min = nearest and mip = nearest */
  68836. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68837. /** mag = linear and min = nearest and mip = linear */
  68838. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68839. /** mag = linear and min = linear and mip = none */
  68840. static readonly TEXTURE_LINEAR_LINEAR: number;
  68841. /** mag = linear and min = nearest and mip = none */
  68842. static readonly TEXTURE_LINEAR_NEAREST: number;
  68843. /** Explicit coordinates mode */
  68844. static readonly TEXTURE_EXPLICIT_MODE: number;
  68845. /** Spherical coordinates mode */
  68846. static readonly TEXTURE_SPHERICAL_MODE: number;
  68847. /** Planar coordinates mode */
  68848. static readonly TEXTURE_PLANAR_MODE: number;
  68849. /** Cubic coordinates mode */
  68850. static readonly TEXTURE_CUBIC_MODE: number;
  68851. /** Projection coordinates mode */
  68852. static readonly TEXTURE_PROJECTION_MODE: number;
  68853. /** Skybox coordinates mode */
  68854. static readonly TEXTURE_SKYBOX_MODE: number;
  68855. /** Inverse Cubic coordinates mode */
  68856. static readonly TEXTURE_INVCUBIC_MODE: number;
  68857. /** Equirectangular coordinates mode */
  68858. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68859. /** Equirectangular Fixed coordinates mode */
  68860. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68861. /** Equirectangular Fixed Mirrored coordinates mode */
  68862. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68863. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68864. static readonly SCALEMODE_FLOOR: number;
  68865. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68866. static readonly SCALEMODE_NEAREST: number;
  68867. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68868. static readonly SCALEMODE_CEILING: number;
  68869. /**
  68870. * The dirty texture flag value
  68871. */
  68872. static readonly MATERIAL_TextureDirtyFlag: number;
  68873. /**
  68874. * The dirty light flag value
  68875. */
  68876. static readonly MATERIAL_LightDirtyFlag: number;
  68877. /**
  68878. * The dirty fresnel flag value
  68879. */
  68880. static readonly MATERIAL_FresnelDirtyFlag: number;
  68881. /**
  68882. * The dirty attribute flag value
  68883. */
  68884. static readonly MATERIAL_AttributesDirtyFlag: number;
  68885. /**
  68886. * The dirty misc flag value
  68887. */
  68888. static readonly MATERIAL_MiscDirtyFlag: number;
  68889. /**
  68890. * The all dirty flag value
  68891. */
  68892. static readonly MATERIAL_AllDirtyFlag: number;
  68893. /**
  68894. * Returns the triangle fill mode
  68895. */
  68896. static readonly MATERIAL_TriangleFillMode: number;
  68897. /**
  68898. * Returns the wireframe mode
  68899. */
  68900. static readonly MATERIAL_WireFrameFillMode: number;
  68901. /**
  68902. * Returns the point fill mode
  68903. */
  68904. static readonly MATERIAL_PointFillMode: number;
  68905. /**
  68906. * Returns the point list draw mode
  68907. */
  68908. static readonly MATERIAL_PointListDrawMode: number;
  68909. /**
  68910. * Returns the line list draw mode
  68911. */
  68912. static readonly MATERIAL_LineListDrawMode: number;
  68913. /**
  68914. * Returns the line loop draw mode
  68915. */
  68916. static readonly MATERIAL_LineLoopDrawMode: number;
  68917. /**
  68918. * Returns the line strip draw mode
  68919. */
  68920. static readonly MATERIAL_LineStripDrawMode: number;
  68921. /**
  68922. * Returns the triangle strip draw mode
  68923. */
  68924. static readonly MATERIAL_TriangleStripDrawMode: number;
  68925. /**
  68926. * Returns the triangle fan draw mode
  68927. */
  68928. static readonly MATERIAL_TriangleFanDrawMode: number;
  68929. /**
  68930. * Stores the clock-wise side orientation
  68931. */
  68932. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68933. /**
  68934. * Stores the counter clock-wise side orientation
  68935. */
  68936. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68937. /**
  68938. * Nothing
  68939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68940. */
  68941. static readonly ACTION_NothingTrigger: number;
  68942. /**
  68943. * On pick
  68944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68945. */
  68946. static readonly ACTION_OnPickTrigger: number;
  68947. /**
  68948. * On left pick
  68949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68950. */
  68951. static readonly ACTION_OnLeftPickTrigger: number;
  68952. /**
  68953. * On right pick
  68954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68955. */
  68956. static readonly ACTION_OnRightPickTrigger: number;
  68957. /**
  68958. * On center pick
  68959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68960. */
  68961. static readonly ACTION_OnCenterPickTrigger: number;
  68962. /**
  68963. * On pick down
  68964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68965. */
  68966. static readonly ACTION_OnPickDownTrigger: number;
  68967. /**
  68968. * On double pick
  68969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68970. */
  68971. static readonly ACTION_OnDoublePickTrigger: number;
  68972. /**
  68973. * On pick up
  68974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68975. */
  68976. static readonly ACTION_OnPickUpTrigger: number;
  68977. /**
  68978. * On pick out.
  68979. * This trigger will only be raised if you also declared a OnPickDown
  68980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68981. */
  68982. static readonly ACTION_OnPickOutTrigger: number;
  68983. /**
  68984. * On long press
  68985. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68986. */
  68987. static readonly ACTION_OnLongPressTrigger: number;
  68988. /**
  68989. * On pointer over
  68990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68991. */
  68992. static readonly ACTION_OnPointerOverTrigger: number;
  68993. /**
  68994. * On pointer out
  68995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68996. */
  68997. static readonly ACTION_OnPointerOutTrigger: number;
  68998. /**
  68999. * On every frame
  69000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69001. */
  69002. static readonly ACTION_OnEveryFrameTrigger: number;
  69003. /**
  69004. * On intersection enter
  69005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69006. */
  69007. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69008. /**
  69009. * On intersection exit
  69010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69011. */
  69012. static readonly ACTION_OnIntersectionExitTrigger: number;
  69013. /**
  69014. * On key down
  69015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69016. */
  69017. static readonly ACTION_OnKeyDownTrigger: number;
  69018. /**
  69019. * On key up
  69020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69021. */
  69022. static readonly ACTION_OnKeyUpTrigger: number;
  69023. /**
  69024. * Billboard mode will only apply to Y axis
  69025. */
  69026. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69027. /**
  69028. * Billboard mode will apply to all axes
  69029. */
  69030. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69031. /**
  69032. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69033. */
  69034. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69035. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69036. * Test order :
  69037. * Is the bounding sphere outside the frustum ?
  69038. * If not, are the bounding box vertices outside the frustum ?
  69039. * It not, then the cullable object is in the frustum.
  69040. */
  69041. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69042. /** Culling strategy : Bounding Sphere Only.
  69043. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69044. * It's also less accurate than the standard because some not visible objects can still be selected.
  69045. * Test : is the bounding sphere outside the frustum ?
  69046. * If not, then the cullable object is in the frustum.
  69047. */
  69048. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69049. /** Culling strategy : Optimistic Inclusion.
  69050. * This in an inclusion test first, then the standard exclusion test.
  69051. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69052. * 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.
  69053. * Anyway, it's as accurate as the standard strategy.
  69054. * Test :
  69055. * Is the cullable object bounding sphere center in the frustum ?
  69056. * If not, apply the default culling strategy.
  69057. */
  69058. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69059. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69060. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69061. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69062. * 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.
  69063. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69064. * Test :
  69065. * Is the cullable object bounding sphere center in the frustum ?
  69066. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69067. */
  69068. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69069. /**
  69070. * No logging while loading
  69071. */
  69072. static readonly SCENELOADER_NO_LOGGING: number;
  69073. /**
  69074. * Minimal logging while loading
  69075. */
  69076. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69077. /**
  69078. * Summary logging while loading
  69079. */
  69080. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69081. /**
  69082. * Detailled logging while loading
  69083. */
  69084. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69085. }
  69086. }
  69087. declare module BABYLON {
  69088. /**
  69089. * This represents the required contract to create a new type of texture loader.
  69090. */
  69091. export interface IInternalTextureLoader {
  69092. /**
  69093. * Defines wether the loader supports cascade loading the different faces.
  69094. */
  69095. supportCascades: boolean;
  69096. /**
  69097. * This returns if the loader support the current file information.
  69098. * @param extension defines the file extension of the file being loaded
  69099. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69100. * @param fallback defines the fallback internal texture if any
  69101. * @param isBase64 defines whether the texture is encoded as a base64
  69102. * @param isBuffer defines whether the texture data are stored as a buffer
  69103. * @returns true if the loader can load the specified file
  69104. */
  69105. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  69106. /**
  69107. * Transform the url before loading if required.
  69108. * @param rootUrl the url of the texture
  69109. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69110. * @returns the transformed texture
  69111. */
  69112. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  69113. /**
  69114. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  69115. * @param rootUrl the url of the texture
  69116. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69117. * @returns the fallback texture
  69118. */
  69119. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  69120. /**
  69121. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  69122. * @param data contains the texture data
  69123. * @param texture defines the BabylonJS internal texture
  69124. * @param createPolynomials will be true if polynomials have been requested
  69125. * @param onLoad defines the callback to trigger once the texture is ready
  69126. * @param onError defines the callback to trigger in case of error
  69127. */
  69128. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69129. /**
  69130. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  69131. * @param data contains the texture data
  69132. * @param texture defines the BabylonJS internal texture
  69133. * @param callback defines the method to call once ready to upload
  69134. */
  69135. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  69136. }
  69137. }
  69138. declare module BABYLON {
  69139. /**
  69140. * Class used to store and describe the pipeline context associated with an effect
  69141. */
  69142. export interface IPipelineContext {
  69143. /**
  69144. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  69145. */
  69146. isAsync: boolean;
  69147. /**
  69148. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  69149. */
  69150. isReady: boolean;
  69151. /** @hidden */
  69152. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  69153. }
  69154. }
  69155. declare module BABYLON {
  69156. /**
  69157. * Class used to store gfx data (like WebGLBuffer)
  69158. */
  69159. export class DataBuffer {
  69160. /**
  69161. * Gets or sets the number of objects referencing this buffer
  69162. */
  69163. references: number;
  69164. /** Gets or sets the size of the underlying buffer */
  69165. capacity: number;
  69166. /**
  69167. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  69168. */
  69169. is32Bits: boolean;
  69170. /**
  69171. * Gets the underlying buffer
  69172. */
  69173. readonly underlyingResource: any;
  69174. }
  69175. }
  69176. declare module BABYLON {
  69177. /** @hidden */
  69178. export interface IShaderProcessor {
  69179. attributeProcessor?: (attribute: string) => string;
  69180. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  69181. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  69182. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  69183. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  69184. lineProcessor?: (line: string, isFragment: boolean) => string;
  69185. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69186. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69187. }
  69188. }
  69189. declare module BABYLON {
  69190. /** @hidden */
  69191. export interface ProcessingOptions {
  69192. defines: string[];
  69193. indexParameters: any;
  69194. isFragment: boolean;
  69195. shouldUseHighPrecisionShader: boolean;
  69196. supportsUniformBuffers: boolean;
  69197. shadersRepository: string;
  69198. includesShadersStore: {
  69199. [key: string]: string;
  69200. };
  69201. processor?: IShaderProcessor;
  69202. version: string;
  69203. platformName: string;
  69204. lookForClosingBracketForUniformBuffer?: boolean;
  69205. }
  69206. }
  69207. declare module BABYLON {
  69208. /** @hidden */
  69209. export class ShaderCodeNode {
  69210. line: string;
  69211. children: ShaderCodeNode[];
  69212. additionalDefineKey?: string;
  69213. additionalDefineValue?: string;
  69214. isValid(preprocessors: {
  69215. [key: string]: string;
  69216. }): boolean;
  69217. process(preprocessors: {
  69218. [key: string]: string;
  69219. }, options: ProcessingOptions): string;
  69220. }
  69221. }
  69222. declare module BABYLON {
  69223. /** @hidden */
  69224. export class ShaderCodeCursor {
  69225. private _lines;
  69226. lineIndex: number;
  69227. readonly currentLine: string;
  69228. readonly canRead: boolean;
  69229. lines: string[];
  69230. }
  69231. }
  69232. declare module BABYLON {
  69233. /** @hidden */
  69234. export class ShaderCodeConditionNode extends ShaderCodeNode {
  69235. process(preprocessors: {
  69236. [key: string]: string;
  69237. }, options: ProcessingOptions): string;
  69238. }
  69239. }
  69240. declare module BABYLON {
  69241. /** @hidden */
  69242. export class ShaderDefineExpression {
  69243. isTrue(preprocessors: {
  69244. [key: string]: string;
  69245. }): boolean;
  69246. }
  69247. }
  69248. declare module BABYLON {
  69249. /** @hidden */
  69250. export class ShaderCodeTestNode extends ShaderCodeNode {
  69251. testExpression: ShaderDefineExpression;
  69252. isValid(preprocessors: {
  69253. [key: string]: string;
  69254. }): boolean;
  69255. }
  69256. }
  69257. declare module BABYLON {
  69258. /** @hidden */
  69259. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  69260. define: string;
  69261. not: boolean;
  69262. constructor(define: string, not?: boolean);
  69263. isTrue(preprocessors: {
  69264. [key: string]: string;
  69265. }): boolean;
  69266. }
  69267. }
  69268. declare module BABYLON {
  69269. /** @hidden */
  69270. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  69271. leftOperand: ShaderDefineExpression;
  69272. rightOperand: ShaderDefineExpression;
  69273. isTrue(preprocessors: {
  69274. [key: string]: string;
  69275. }): boolean;
  69276. }
  69277. }
  69278. declare module BABYLON {
  69279. /** @hidden */
  69280. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  69281. leftOperand: ShaderDefineExpression;
  69282. rightOperand: ShaderDefineExpression;
  69283. isTrue(preprocessors: {
  69284. [key: string]: string;
  69285. }): boolean;
  69286. }
  69287. }
  69288. declare module BABYLON {
  69289. /** @hidden */
  69290. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  69291. define: string;
  69292. operand: string;
  69293. testValue: string;
  69294. constructor(define: string, operand: string, testValue: string);
  69295. isTrue(preprocessors: {
  69296. [key: string]: string;
  69297. }): boolean;
  69298. }
  69299. }
  69300. declare module BABYLON {
  69301. /**
  69302. * Class used to enable access to offline support
  69303. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69304. */
  69305. export interface IOfflineProvider {
  69306. /**
  69307. * Gets a boolean indicating if scene must be saved in the database
  69308. */
  69309. enableSceneOffline: boolean;
  69310. /**
  69311. * Gets a boolean indicating if textures must be saved in the database
  69312. */
  69313. enableTexturesOffline: boolean;
  69314. /**
  69315. * Open the offline support and make it available
  69316. * @param successCallback defines the callback to call on success
  69317. * @param errorCallback defines the callback to call on error
  69318. */
  69319. open(successCallback: () => void, errorCallback: () => void): void;
  69320. /**
  69321. * Loads an image from the offline support
  69322. * @param url defines the url to load from
  69323. * @param image defines the target DOM image
  69324. */
  69325. loadImage(url: string, image: HTMLImageElement): void;
  69326. /**
  69327. * Loads a file from offline support
  69328. * @param url defines the URL to load from
  69329. * @param sceneLoaded defines a callback to call on success
  69330. * @param progressCallBack defines a callback to call when progress changed
  69331. * @param errorCallback defines a callback to call on error
  69332. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69333. */
  69334. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69335. }
  69336. }
  69337. declare module BABYLON {
  69338. /**
  69339. * Class used to help managing file picking and drag'n'drop
  69340. * File Storage
  69341. */
  69342. export class FilesInputStore {
  69343. /**
  69344. * List of files ready to be loaded
  69345. */
  69346. static FilesToLoad: {
  69347. [key: string]: File;
  69348. };
  69349. }
  69350. }
  69351. declare module BABYLON {
  69352. /**
  69353. * Class used to define a retry strategy when error happens while loading assets
  69354. */
  69355. export class RetryStrategy {
  69356. /**
  69357. * Function used to defines an exponential back off strategy
  69358. * @param maxRetries defines the maximum number of retries (3 by default)
  69359. * @param baseInterval defines the interval between retries
  69360. * @returns the strategy function to use
  69361. */
  69362. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  69363. }
  69364. }
  69365. declare module BABYLON {
  69366. /**
  69367. * @ignore
  69368. * Application error to support additional information when loading a file
  69369. */
  69370. export abstract class BaseError extends Error {
  69371. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  69372. }
  69373. }
  69374. declare module BABYLON {
  69375. /** @ignore */
  69376. export class LoadFileError extends BaseError {
  69377. request?: WebRequest;
  69378. file?: File;
  69379. /**
  69380. * Creates a new LoadFileError
  69381. * @param message defines the message of the error
  69382. * @param request defines the optional web request
  69383. * @param file defines the optional file
  69384. */
  69385. constructor(message: string, object?: WebRequest | File);
  69386. }
  69387. /** @ignore */
  69388. export class RequestFileError extends BaseError {
  69389. request: WebRequest;
  69390. /**
  69391. * Creates a new LoadFileError
  69392. * @param message defines the message of the error
  69393. * @param request defines the optional web request
  69394. */
  69395. constructor(message: string, request: WebRequest);
  69396. }
  69397. /** @ignore */
  69398. export class ReadFileError extends BaseError {
  69399. file: File;
  69400. /**
  69401. * Creates a new ReadFileError
  69402. * @param message defines the message of the error
  69403. * @param file defines the optional file
  69404. */
  69405. constructor(message: string, file: File);
  69406. }
  69407. /**
  69408. * @hidden
  69409. */
  69410. export class FileTools {
  69411. /**
  69412. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  69413. */
  69414. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  69415. /**
  69416. * Gets or sets the base URL to use to load assets
  69417. */
  69418. static BaseUrl: string;
  69419. /**
  69420. * Default behaviour for cors in the application.
  69421. * It can be a string if the expected behavior is identical in the entire app.
  69422. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  69423. */
  69424. static CorsBehavior: string | ((url: string | string[]) => string);
  69425. /**
  69426. * Gets or sets a function used to pre-process url before using them to load assets
  69427. */
  69428. static PreprocessUrl: (url: string) => string;
  69429. /**
  69430. * Removes unwanted characters from an url
  69431. * @param url defines the url to clean
  69432. * @returns the cleaned url
  69433. */
  69434. private static _CleanUrl;
  69435. /**
  69436. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  69437. * @param url define the url we are trying
  69438. * @param element define the dom element where to configure the cors policy
  69439. */
  69440. static SetCorsBehavior(url: string | string[], element: {
  69441. crossOrigin: string | null;
  69442. }): void;
  69443. /**
  69444. * Loads an image as an HTMLImageElement.
  69445. * @param input url string, ArrayBuffer, or Blob to load
  69446. * @param onLoad callback called when the image successfully loads
  69447. * @param onError callback called when the image fails to load
  69448. * @param offlineProvider offline provider for caching
  69449. * @param mimeType optional mime type
  69450. * @returns the HTMLImageElement of the loaded image
  69451. */
  69452. 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>;
  69453. /**
  69454. * Reads a file from a File object
  69455. * @param file defines the file to load
  69456. * @param onSuccess defines the callback to call when data is loaded
  69457. * @param onProgress defines the callback to call during loading process
  69458. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  69459. * @param onError defines the callback to call when an error occurs
  69460. * @returns a file request object
  69461. */
  69462. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  69463. /**
  69464. * Loads a file from a url
  69465. * @param url url to load
  69466. * @param onSuccess callback called when the file successfully loads
  69467. * @param onProgress callback called while file is loading (if the server supports this mode)
  69468. * @param offlineProvider defines the offline provider for caching
  69469. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69470. * @param onError callback called when the file fails to load
  69471. * @returns a file request object
  69472. */
  69473. 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;
  69474. /**
  69475. * Loads a file
  69476. * @param url url to load
  69477. * @param onSuccess callback called when the file successfully loads
  69478. * @param onProgress callback called while file is loading (if the server supports this mode)
  69479. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69480. * @param onError callback called when the file fails to load
  69481. * @param onOpened callback called when the web request is opened
  69482. * @returns a file request object
  69483. */
  69484. 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;
  69485. /**
  69486. * Checks if the loaded document was accessed via `file:`-Protocol.
  69487. * @returns boolean
  69488. */
  69489. static IsFileURL(): boolean;
  69490. }
  69491. }
  69492. declare module BABYLON {
  69493. /** @hidden */
  69494. export class ShaderProcessor {
  69495. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  69496. private static _ProcessPrecision;
  69497. private static _ExtractOperation;
  69498. private static _BuildSubExpression;
  69499. private static _BuildExpression;
  69500. private static _MoveCursorWithinIf;
  69501. private static _MoveCursor;
  69502. private static _EvaluatePreProcessors;
  69503. private static _PreparePreProcessors;
  69504. private static _ProcessShaderConversion;
  69505. private static _ProcessIncludes;
  69506. }
  69507. }
  69508. declare module BABYLON {
  69509. /**
  69510. * @hidden
  69511. */
  69512. export interface IColor4Like {
  69513. r: float;
  69514. g: float;
  69515. b: float;
  69516. a: float;
  69517. }
  69518. /**
  69519. * @hidden
  69520. */
  69521. export interface IColor3Like {
  69522. r: float;
  69523. g: float;
  69524. b: float;
  69525. }
  69526. /**
  69527. * @hidden
  69528. */
  69529. export interface IVector4Like {
  69530. x: float;
  69531. y: float;
  69532. z: float;
  69533. w: float;
  69534. }
  69535. /**
  69536. * @hidden
  69537. */
  69538. export interface IVector3Like {
  69539. x: float;
  69540. y: float;
  69541. z: float;
  69542. }
  69543. /**
  69544. * @hidden
  69545. */
  69546. export interface IVector2Like {
  69547. x: float;
  69548. y: float;
  69549. }
  69550. /**
  69551. * @hidden
  69552. */
  69553. export interface IMatrixLike {
  69554. toArray(): DeepImmutable<Float32Array>;
  69555. updateFlag: int;
  69556. }
  69557. /**
  69558. * @hidden
  69559. */
  69560. export interface IViewportLike {
  69561. x: float;
  69562. y: float;
  69563. width: float;
  69564. height: float;
  69565. }
  69566. /**
  69567. * @hidden
  69568. */
  69569. export interface IPlaneLike {
  69570. normal: IVector3Like;
  69571. d: float;
  69572. normalize(): void;
  69573. }
  69574. }
  69575. declare module BABYLON {
  69576. /**
  69577. * Interface used to define common properties for effect fallbacks
  69578. */
  69579. export interface IEffectFallbacks {
  69580. /**
  69581. * Removes the defines that should be removed when falling back.
  69582. * @param currentDefines defines the current define statements for the shader.
  69583. * @param effect defines the current effect we try to compile
  69584. * @returns The resulting defines with defines of the current rank removed.
  69585. */
  69586. reduce(currentDefines: string, effect: Effect): string;
  69587. /**
  69588. * Removes the fallback from the bound mesh.
  69589. */
  69590. unBindMesh(): void;
  69591. /**
  69592. * Checks to see if more fallbacks are still availible.
  69593. */
  69594. hasMoreFallbacks: boolean;
  69595. }
  69596. }
  69597. declare module BABYLON {
  69598. /**
  69599. * Class used to evalaute queries containing `and` and `or` operators
  69600. */
  69601. export class AndOrNotEvaluator {
  69602. /**
  69603. * Evaluate a query
  69604. * @param query defines the query to evaluate
  69605. * @param evaluateCallback defines the callback used to filter result
  69606. * @returns true if the query matches
  69607. */
  69608. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69609. private static _HandleParenthesisContent;
  69610. private static _SimplifyNegation;
  69611. }
  69612. }
  69613. declare module BABYLON {
  69614. /**
  69615. * Class used to store custom tags
  69616. */
  69617. export class Tags {
  69618. /**
  69619. * Adds support for tags on the given object
  69620. * @param obj defines the object to use
  69621. */
  69622. static EnableFor(obj: any): void;
  69623. /**
  69624. * Removes tags support
  69625. * @param obj defines the object to use
  69626. */
  69627. static DisableFor(obj: any): void;
  69628. /**
  69629. * Gets a boolean indicating if the given object has tags
  69630. * @param obj defines the object to use
  69631. * @returns a boolean
  69632. */
  69633. static HasTags(obj: any): boolean;
  69634. /**
  69635. * Gets the tags available on a given object
  69636. * @param obj defines the object to use
  69637. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69638. * @returns the tags
  69639. */
  69640. static GetTags(obj: any, asString?: boolean): any;
  69641. /**
  69642. * Adds tags to an object
  69643. * @param obj defines the object to use
  69644. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69645. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69646. */
  69647. static AddTagsTo(obj: any, tagsString: string): void;
  69648. /**
  69649. * @hidden
  69650. */
  69651. static _AddTagTo(obj: any, tag: string): void;
  69652. /**
  69653. * Removes specific tags from a specific object
  69654. * @param obj defines the object to use
  69655. * @param tagsString defines the tags to remove
  69656. */
  69657. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69658. /**
  69659. * @hidden
  69660. */
  69661. static _RemoveTagFrom(obj: any, tag: string): void;
  69662. /**
  69663. * Defines if tags hosted on an object match a given query
  69664. * @param obj defines the object to use
  69665. * @param tagsQuery defines the tag query
  69666. * @returns a boolean
  69667. */
  69668. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69669. }
  69670. }
  69671. declare module BABYLON {
  69672. /**
  69673. * Scalar computation library
  69674. */
  69675. export class Scalar {
  69676. /**
  69677. * Two pi constants convenient for computation.
  69678. */
  69679. static TwoPi: number;
  69680. /**
  69681. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69682. * @param a number
  69683. * @param b number
  69684. * @param epsilon (default = 1.401298E-45)
  69685. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69686. */
  69687. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  69688. /**
  69689. * Returns a string : the upper case translation of the number i to hexadecimal.
  69690. * @param i number
  69691. * @returns the upper case translation of the number i to hexadecimal.
  69692. */
  69693. static ToHex(i: number): string;
  69694. /**
  69695. * Returns -1 if value is negative and +1 is value is positive.
  69696. * @param value the value
  69697. * @returns the value itself if it's equal to zero.
  69698. */
  69699. static Sign(value: number): number;
  69700. /**
  69701. * Returns the value itself if it's between min and max.
  69702. * Returns min if the value is lower than min.
  69703. * Returns max if the value is greater than max.
  69704. * @param value the value to clmap
  69705. * @param min the min value to clamp to (default: 0)
  69706. * @param max the max value to clamp to (default: 1)
  69707. * @returns the clamped value
  69708. */
  69709. static Clamp(value: number, min?: number, max?: number): number;
  69710. /**
  69711. * the log2 of value.
  69712. * @param value the value to compute log2 of
  69713. * @returns the log2 of value.
  69714. */
  69715. static Log2(value: number): number;
  69716. /**
  69717. * Loops the value, so that it is never larger than length and never smaller than 0.
  69718. *
  69719. * This is similar to the modulo operator but it works with floating point numbers.
  69720. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  69721. * With t = 5 and length = 2.5, the result would be 0.0.
  69722. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  69723. * @param value the value
  69724. * @param length the length
  69725. * @returns the looped value
  69726. */
  69727. static Repeat(value: number, length: number): number;
  69728. /**
  69729. * Normalize the value between 0.0 and 1.0 using min and max values
  69730. * @param value value to normalize
  69731. * @param min max to normalize between
  69732. * @param max min to normalize between
  69733. * @returns the normalized value
  69734. */
  69735. static Normalize(value: number, min: number, max: number): number;
  69736. /**
  69737. * Denormalize the value from 0.0 and 1.0 using min and max values
  69738. * @param normalized value to denormalize
  69739. * @param min max to denormalize between
  69740. * @param max min to denormalize between
  69741. * @returns the denormalized value
  69742. */
  69743. static Denormalize(normalized: number, min: number, max: number): number;
  69744. /**
  69745. * Calculates the shortest difference between two given angles given in degrees.
  69746. * @param current current angle in degrees
  69747. * @param target target angle in degrees
  69748. * @returns the delta
  69749. */
  69750. static DeltaAngle(current: number, target: number): number;
  69751. /**
  69752. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  69753. * @param tx value
  69754. * @param length length
  69755. * @returns The returned value will move back and forth between 0 and length
  69756. */
  69757. static PingPong(tx: number, length: number): number;
  69758. /**
  69759. * Interpolates between min and max with smoothing at the limits.
  69760. *
  69761. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  69762. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  69763. * @param from from
  69764. * @param to to
  69765. * @param tx value
  69766. * @returns the smooth stepped value
  69767. */
  69768. static SmoothStep(from: number, to: number, tx: number): number;
  69769. /**
  69770. * Moves a value current towards target.
  69771. *
  69772. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  69773. * Negative values of maxDelta pushes the value away from target.
  69774. * @param current current value
  69775. * @param target target value
  69776. * @param maxDelta max distance to move
  69777. * @returns resulting value
  69778. */
  69779. static MoveTowards(current: number, target: number, maxDelta: number): number;
  69780. /**
  69781. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69782. *
  69783. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  69784. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  69785. * @param current current value
  69786. * @param target target value
  69787. * @param maxDelta max distance to move
  69788. * @returns resulting angle
  69789. */
  69790. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  69791. /**
  69792. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  69793. * @param start start value
  69794. * @param end target value
  69795. * @param amount amount to lerp between
  69796. * @returns the lerped value
  69797. */
  69798. static Lerp(start: number, end: number, amount: number): number;
  69799. /**
  69800. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69801. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  69802. * @param start start value
  69803. * @param end target value
  69804. * @param amount amount to lerp between
  69805. * @returns the lerped value
  69806. */
  69807. static LerpAngle(start: number, end: number, amount: number): number;
  69808. /**
  69809. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  69810. * @param a start value
  69811. * @param b target value
  69812. * @param value value between a and b
  69813. * @returns the inverseLerp value
  69814. */
  69815. static InverseLerp(a: number, b: number, value: number): number;
  69816. /**
  69817. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  69818. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  69819. * @param value1 spline value
  69820. * @param tangent1 spline value
  69821. * @param value2 spline value
  69822. * @param tangent2 spline value
  69823. * @param amount input value
  69824. * @returns hermite result
  69825. */
  69826. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  69827. /**
  69828. * Returns a random float number between and min and max values
  69829. * @param min min value of random
  69830. * @param max max value of random
  69831. * @returns random value
  69832. */
  69833. static RandomRange(min: number, max: number): number;
  69834. /**
  69835. * This function returns percentage of a number in a given range.
  69836. *
  69837. * RangeToPercent(40,20,60) will return 0.5 (50%)
  69838. * RangeToPercent(34,0,100) will return 0.34 (34%)
  69839. * @param number to convert to percentage
  69840. * @param min min range
  69841. * @param max max range
  69842. * @returns the percentage
  69843. */
  69844. static RangeToPercent(number: number, min: number, max: number): number;
  69845. /**
  69846. * This function returns number that corresponds to the percentage in a given range.
  69847. *
  69848. * PercentToRange(0.34,0,100) will return 34.
  69849. * @param percent to convert to number
  69850. * @param min min range
  69851. * @param max max range
  69852. * @returns the number
  69853. */
  69854. static PercentToRange(percent: number, min: number, max: number): number;
  69855. /**
  69856. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  69857. * @param angle The angle to normalize in radian.
  69858. * @return The converted angle.
  69859. */
  69860. static NormalizeRadians(angle: number): number;
  69861. }
  69862. }
  69863. declare module BABYLON {
  69864. /**
  69865. * Constant used to convert a value to gamma space
  69866. * @ignorenaming
  69867. */
  69868. export const ToGammaSpace: number;
  69869. /**
  69870. * Constant used to convert a value to linear space
  69871. * @ignorenaming
  69872. */
  69873. export const ToLinearSpace = 2.2;
  69874. /**
  69875. * Constant used to define the minimal number value in Babylon.js
  69876. * @ignorenaming
  69877. */
  69878. let Epsilon: number;
  69879. }
  69880. declare module BABYLON {
  69881. /**
  69882. * Class used to represent a viewport on screen
  69883. */
  69884. export class Viewport {
  69885. /** viewport left coordinate */
  69886. x: number;
  69887. /** viewport top coordinate */
  69888. y: number;
  69889. /**viewport width */
  69890. width: number;
  69891. /** viewport height */
  69892. height: number;
  69893. /**
  69894. * Creates a Viewport object located at (x, y) and sized (width, height)
  69895. * @param x defines viewport left coordinate
  69896. * @param y defines viewport top coordinate
  69897. * @param width defines the viewport width
  69898. * @param height defines the viewport height
  69899. */
  69900. constructor(
  69901. /** viewport left coordinate */
  69902. x: number,
  69903. /** viewport top coordinate */
  69904. y: number,
  69905. /**viewport width */
  69906. width: number,
  69907. /** viewport height */
  69908. height: number);
  69909. /**
  69910. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  69911. * @param renderWidth defines the rendering width
  69912. * @param renderHeight defines the rendering height
  69913. * @returns a new Viewport
  69914. */
  69915. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  69916. /**
  69917. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  69918. * @param renderWidth defines the rendering width
  69919. * @param renderHeight defines the rendering height
  69920. * @param ref defines the target viewport
  69921. * @returns the current viewport
  69922. */
  69923. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  69924. /**
  69925. * Returns a new Viewport copied from the current one
  69926. * @returns a new Viewport
  69927. */
  69928. clone(): Viewport;
  69929. }
  69930. }
  69931. declare module BABYLON {
  69932. /**
  69933. * Class containing a set of static utilities functions for arrays.
  69934. */
  69935. export class ArrayTools {
  69936. /**
  69937. * Returns an array of the given size filled with element built from the given constructor and the paramters
  69938. * @param size the number of element to construct and put in the array
  69939. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  69940. * @returns a new array filled with new objects
  69941. */
  69942. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  69943. }
  69944. }
  69945. declare module BABYLON {
  69946. /**
  69947. * Class representing a vector containing 2 coordinates
  69948. */
  69949. export class Vector2 {
  69950. /** defines the first coordinate */
  69951. x: number;
  69952. /** defines the second coordinate */
  69953. y: number;
  69954. /**
  69955. * Creates a new Vector2 from the given x and y coordinates
  69956. * @param x defines the first coordinate
  69957. * @param y defines the second coordinate
  69958. */
  69959. constructor(
  69960. /** defines the first coordinate */
  69961. x?: number,
  69962. /** defines the second coordinate */
  69963. y?: number);
  69964. /**
  69965. * Gets a string with the Vector2 coordinates
  69966. * @returns a string with the Vector2 coordinates
  69967. */
  69968. toString(): string;
  69969. /**
  69970. * Gets class name
  69971. * @returns the string "Vector2"
  69972. */
  69973. getClassName(): string;
  69974. /**
  69975. * Gets current vector hash code
  69976. * @returns the Vector2 hash code as a number
  69977. */
  69978. getHashCode(): number;
  69979. /**
  69980. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  69981. * @param array defines the source array
  69982. * @param index defines the offset in source array
  69983. * @returns the current Vector2
  69984. */
  69985. toArray(array: FloatArray, index?: number): Vector2;
  69986. /**
  69987. * Copy the current vector to an array
  69988. * @returns a new array with 2 elements: the Vector2 coordinates.
  69989. */
  69990. asArray(): number[];
  69991. /**
  69992. * Sets the Vector2 coordinates with the given Vector2 coordinates
  69993. * @param source defines the source Vector2
  69994. * @returns the current updated Vector2
  69995. */
  69996. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  69997. /**
  69998. * Sets the Vector2 coordinates with the given floats
  69999. * @param x defines the first coordinate
  70000. * @param y defines the second coordinate
  70001. * @returns the current updated Vector2
  70002. */
  70003. copyFromFloats(x: number, y: number): Vector2;
  70004. /**
  70005. * Sets the Vector2 coordinates with the given floats
  70006. * @param x defines the first coordinate
  70007. * @param y defines the second coordinate
  70008. * @returns the current updated Vector2
  70009. */
  70010. set(x: number, y: number): Vector2;
  70011. /**
  70012. * Add another vector with the current one
  70013. * @param otherVector defines the other vector
  70014. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  70015. */
  70016. add(otherVector: DeepImmutable<Vector2>): Vector2;
  70017. /**
  70018. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  70019. * @param otherVector defines the other vector
  70020. * @param result defines the target vector
  70021. * @returns the unmodified current Vector2
  70022. */
  70023. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70024. /**
  70025. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  70026. * @param otherVector defines the other vector
  70027. * @returns the current updated Vector2
  70028. */
  70029. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70030. /**
  70031. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  70032. * @param otherVector defines the other vector
  70033. * @returns a new Vector2
  70034. */
  70035. addVector3(otherVector: Vector3): Vector2;
  70036. /**
  70037. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  70038. * @param otherVector defines the other vector
  70039. * @returns a new Vector2
  70040. */
  70041. subtract(otherVector: Vector2): Vector2;
  70042. /**
  70043. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  70044. * @param otherVector defines the other vector
  70045. * @param result defines the target vector
  70046. * @returns the unmodified current Vector2
  70047. */
  70048. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70049. /**
  70050. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  70051. * @param otherVector defines the other vector
  70052. * @returns the current updated Vector2
  70053. */
  70054. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70055. /**
  70056. * Multiplies in place the current Vector2 coordinates by the given ones
  70057. * @param otherVector defines the other vector
  70058. * @returns the current updated Vector2
  70059. */
  70060. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70061. /**
  70062. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  70063. * @param otherVector defines the other vector
  70064. * @returns a new Vector2
  70065. */
  70066. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  70067. /**
  70068. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  70069. * @param otherVector defines the other vector
  70070. * @param result defines the target vector
  70071. * @returns the unmodified current Vector2
  70072. */
  70073. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70074. /**
  70075. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  70076. * @param x defines the first coordinate
  70077. * @param y defines the second coordinate
  70078. * @returns a new Vector2
  70079. */
  70080. multiplyByFloats(x: number, y: number): Vector2;
  70081. /**
  70082. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  70083. * @param otherVector defines the other vector
  70084. * @returns a new Vector2
  70085. */
  70086. divide(otherVector: Vector2): Vector2;
  70087. /**
  70088. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  70089. * @param otherVector defines the other vector
  70090. * @param result defines the target vector
  70091. * @returns the unmodified current Vector2
  70092. */
  70093. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70094. /**
  70095. * Divides the current Vector2 coordinates by the given ones
  70096. * @param otherVector defines the other vector
  70097. * @returns the current updated Vector2
  70098. */
  70099. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70100. /**
  70101. * Gets a new Vector2 with current Vector2 negated coordinates
  70102. * @returns a new Vector2
  70103. */
  70104. negate(): Vector2;
  70105. /**
  70106. * Multiply the Vector2 coordinates by scale
  70107. * @param scale defines the scaling factor
  70108. * @returns the current updated Vector2
  70109. */
  70110. scaleInPlace(scale: number): Vector2;
  70111. /**
  70112. * Returns a new Vector2 scaled by "scale" from the current Vector2
  70113. * @param scale defines the scaling factor
  70114. * @returns a new Vector2
  70115. */
  70116. scale(scale: number): Vector2;
  70117. /**
  70118. * Scale the current Vector2 values by a factor to a given Vector2
  70119. * @param scale defines the scale factor
  70120. * @param result defines the Vector2 object where to store the result
  70121. * @returns the unmodified current Vector2
  70122. */
  70123. scaleToRef(scale: number, result: Vector2): Vector2;
  70124. /**
  70125. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  70126. * @param scale defines the scale factor
  70127. * @param result defines the Vector2 object where to store the result
  70128. * @returns the unmodified current Vector2
  70129. */
  70130. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  70131. /**
  70132. * Gets a boolean if two vectors are equals
  70133. * @param otherVector defines the other vector
  70134. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  70135. */
  70136. equals(otherVector: DeepImmutable<Vector2>): boolean;
  70137. /**
  70138. * Gets a boolean if two vectors are equals (using an epsilon value)
  70139. * @param otherVector defines the other vector
  70140. * @param epsilon defines the minimal distance to consider equality
  70141. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  70142. */
  70143. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  70144. /**
  70145. * Gets a new Vector2 from current Vector2 floored values
  70146. * @returns a new Vector2
  70147. */
  70148. floor(): Vector2;
  70149. /**
  70150. * Gets a new Vector2 from current Vector2 floored values
  70151. * @returns a new Vector2
  70152. */
  70153. fract(): Vector2;
  70154. /**
  70155. * Gets the length of the vector
  70156. * @returns the vector length (float)
  70157. */
  70158. length(): number;
  70159. /**
  70160. * Gets the vector squared length
  70161. * @returns the vector squared length (float)
  70162. */
  70163. lengthSquared(): number;
  70164. /**
  70165. * Normalize the vector
  70166. * @returns the current updated Vector2
  70167. */
  70168. normalize(): Vector2;
  70169. /**
  70170. * Gets a new Vector2 copied from the Vector2
  70171. * @returns a new Vector2
  70172. */
  70173. clone(): Vector2;
  70174. /**
  70175. * Gets a new Vector2(0, 0)
  70176. * @returns a new Vector2
  70177. */
  70178. static Zero(): Vector2;
  70179. /**
  70180. * Gets a new Vector2(1, 1)
  70181. * @returns a new Vector2
  70182. */
  70183. static One(): Vector2;
  70184. /**
  70185. * Gets a new Vector2 set from the given index element of the given array
  70186. * @param array defines the data source
  70187. * @param offset defines the offset in the data source
  70188. * @returns a new Vector2
  70189. */
  70190. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  70191. /**
  70192. * Sets "result" from the given index element of the given array
  70193. * @param array defines the data source
  70194. * @param offset defines the offset in the data source
  70195. * @param result defines the target vector
  70196. */
  70197. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  70198. /**
  70199. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  70200. * @param value1 defines 1st point of control
  70201. * @param value2 defines 2nd point of control
  70202. * @param value3 defines 3rd point of control
  70203. * @param value4 defines 4th point of control
  70204. * @param amount defines the interpolation factor
  70205. * @returns a new Vector2
  70206. */
  70207. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  70208. /**
  70209. * 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".
  70210. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  70211. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  70212. * @param value defines the value to clamp
  70213. * @param min defines the lower limit
  70214. * @param max defines the upper limit
  70215. * @returns a new Vector2
  70216. */
  70217. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  70218. /**
  70219. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  70220. * @param value1 defines the 1st control point
  70221. * @param tangent1 defines the outgoing tangent
  70222. * @param value2 defines the 2nd control point
  70223. * @param tangent2 defines the incoming tangent
  70224. * @param amount defines the interpolation factor
  70225. * @returns a new Vector2
  70226. */
  70227. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  70228. /**
  70229. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  70230. * @param start defines the start vector
  70231. * @param end defines the end vector
  70232. * @param amount defines the interpolation factor
  70233. * @returns a new Vector2
  70234. */
  70235. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  70236. /**
  70237. * Gets the dot product of the vector "left" and the vector "right"
  70238. * @param left defines first vector
  70239. * @param right defines second vector
  70240. * @returns the dot product (float)
  70241. */
  70242. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  70243. /**
  70244. * Returns a new Vector2 equal to the normalized given vector
  70245. * @param vector defines the vector to normalize
  70246. * @returns a new Vector2
  70247. */
  70248. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  70249. /**
  70250. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  70251. * @param left defines 1st vector
  70252. * @param right defines 2nd vector
  70253. * @returns a new Vector2
  70254. */
  70255. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70256. /**
  70257. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  70258. * @param left defines 1st vector
  70259. * @param right defines 2nd vector
  70260. * @returns a new Vector2
  70261. */
  70262. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70263. /**
  70264. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  70265. * @param vector defines the vector to transform
  70266. * @param transformation defines the matrix to apply
  70267. * @returns a new Vector2
  70268. */
  70269. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  70270. /**
  70271. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  70272. * @param vector defines the vector to transform
  70273. * @param transformation defines the matrix to apply
  70274. * @param result defines the target vector
  70275. */
  70276. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  70277. /**
  70278. * Determines if a given vector is included in a triangle
  70279. * @param p defines the vector to test
  70280. * @param p0 defines 1st triangle point
  70281. * @param p1 defines 2nd triangle point
  70282. * @param p2 defines 3rd triangle point
  70283. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  70284. */
  70285. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  70286. /**
  70287. * Gets the distance between the vectors "value1" and "value2"
  70288. * @param value1 defines first vector
  70289. * @param value2 defines second vector
  70290. * @returns the distance between vectors
  70291. */
  70292. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70293. /**
  70294. * Returns the squared distance between the vectors "value1" and "value2"
  70295. * @param value1 defines first vector
  70296. * @param value2 defines second vector
  70297. * @returns the squared distance between vectors
  70298. */
  70299. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70300. /**
  70301. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  70302. * @param value1 defines first vector
  70303. * @param value2 defines second vector
  70304. * @returns a new Vector2
  70305. */
  70306. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  70307. /**
  70308. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  70309. * @param p defines the middle point
  70310. * @param segA defines one point of the segment
  70311. * @param segB defines the other point of the segment
  70312. * @returns the shortest distance
  70313. */
  70314. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  70315. }
  70316. /**
  70317. * Classed used to store (x,y,z) vector representation
  70318. * A Vector3 is the main object used in 3D geometry
  70319. * It can represent etiher the coordinates of a point the space, either a direction
  70320. * Reminder: js uses a left handed forward facing system
  70321. */
  70322. export class Vector3 {
  70323. /**
  70324. * Defines the first coordinates (on X axis)
  70325. */
  70326. x: number;
  70327. /**
  70328. * Defines the second coordinates (on Y axis)
  70329. */
  70330. y: number;
  70331. /**
  70332. * Defines the third coordinates (on Z axis)
  70333. */
  70334. z: number;
  70335. private static _UpReadOnly;
  70336. private static _ZeroReadOnly;
  70337. /**
  70338. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  70339. * @param x defines the first coordinates (on X axis)
  70340. * @param y defines the second coordinates (on Y axis)
  70341. * @param z defines the third coordinates (on Z axis)
  70342. */
  70343. constructor(
  70344. /**
  70345. * Defines the first coordinates (on X axis)
  70346. */
  70347. x?: number,
  70348. /**
  70349. * Defines the second coordinates (on Y axis)
  70350. */
  70351. y?: number,
  70352. /**
  70353. * Defines the third coordinates (on Z axis)
  70354. */
  70355. z?: number);
  70356. /**
  70357. * Creates a string representation of the Vector3
  70358. * @returns a string with the Vector3 coordinates.
  70359. */
  70360. toString(): string;
  70361. /**
  70362. * Gets the class name
  70363. * @returns the string "Vector3"
  70364. */
  70365. getClassName(): string;
  70366. /**
  70367. * Creates the Vector3 hash code
  70368. * @returns a number which tends to be unique between Vector3 instances
  70369. */
  70370. getHashCode(): number;
  70371. /**
  70372. * Creates an array containing three elements : the coordinates of the Vector3
  70373. * @returns a new array of numbers
  70374. */
  70375. asArray(): number[];
  70376. /**
  70377. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  70378. * @param array defines the destination array
  70379. * @param index defines the offset in the destination array
  70380. * @returns the current Vector3
  70381. */
  70382. toArray(array: FloatArray, index?: number): Vector3;
  70383. /**
  70384. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  70385. * @returns a new Quaternion object, computed from the Vector3 coordinates
  70386. */
  70387. toQuaternion(): Quaternion;
  70388. /**
  70389. * Adds the given vector to the current Vector3
  70390. * @param otherVector defines the second operand
  70391. * @returns the current updated Vector3
  70392. */
  70393. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70394. /**
  70395. * Adds the given coordinates to the current Vector3
  70396. * @param x defines the x coordinate of the operand
  70397. * @param y defines the y coordinate of the operand
  70398. * @param z defines the z coordinate of the operand
  70399. * @returns the current updated Vector3
  70400. */
  70401. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70402. /**
  70403. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  70404. * @param otherVector defines the second operand
  70405. * @returns the resulting Vector3
  70406. */
  70407. add(otherVector: DeepImmutable<Vector3>): Vector3;
  70408. /**
  70409. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  70410. * @param otherVector defines the second operand
  70411. * @param result defines the Vector3 object where to store the result
  70412. * @returns the current Vector3
  70413. */
  70414. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70415. /**
  70416. * Subtract the given vector from the current Vector3
  70417. * @param otherVector defines the second operand
  70418. * @returns the current updated Vector3
  70419. */
  70420. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70421. /**
  70422. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  70423. * @param otherVector defines the second operand
  70424. * @returns the resulting Vector3
  70425. */
  70426. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  70427. /**
  70428. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  70429. * @param otherVector defines the second operand
  70430. * @param result defines the Vector3 object where to store the result
  70431. * @returns the current Vector3
  70432. */
  70433. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70434. /**
  70435. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  70436. * @param x defines the x coordinate of the operand
  70437. * @param y defines the y coordinate of the operand
  70438. * @param z defines the z coordinate of the operand
  70439. * @returns the resulting Vector3
  70440. */
  70441. subtractFromFloats(x: number, y: number, z: number): Vector3;
  70442. /**
  70443. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  70444. * @param x defines the x coordinate of the operand
  70445. * @param y defines the y coordinate of the operand
  70446. * @param z defines the z coordinate of the operand
  70447. * @param result defines the Vector3 object where to store the result
  70448. * @returns the current Vector3
  70449. */
  70450. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  70451. /**
  70452. * Gets a new Vector3 set with the current Vector3 negated coordinates
  70453. * @returns a new Vector3
  70454. */
  70455. negate(): Vector3;
  70456. /**
  70457. * Multiplies the Vector3 coordinates by the float "scale"
  70458. * @param scale defines the multiplier factor
  70459. * @returns the current updated Vector3
  70460. */
  70461. scaleInPlace(scale: number): Vector3;
  70462. /**
  70463. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  70464. * @param scale defines the multiplier factor
  70465. * @returns a new Vector3
  70466. */
  70467. scale(scale: number): Vector3;
  70468. /**
  70469. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  70470. * @param scale defines the multiplier factor
  70471. * @param result defines the Vector3 object where to store the result
  70472. * @returns the current Vector3
  70473. */
  70474. scaleToRef(scale: number, result: Vector3): Vector3;
  70475. /**
  70476. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  70477. * @param scale defines the scale factor
  70478. * @param result defines the Vector3 object where to store the result
  70479. * @returns the unmodified current Vector3
  70480. */
  70481. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  70482. /**
  70483. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  70484. * @param otherVector defines the second operand
  70485. * @returns true if both vectors are equals
  70486. */
  70487. equals(otherVector: DeepImmutable<Vector3>): boolean;
  70488. /**
  70489. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  70490. * @param otherVector defines the second operand
  70491. * @param epsilon defines the minimal distance to define values as equals
  70492. * @returns true if both vectors are distant less than epsilon
  70493. */
  70494. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  70495. /**
  70496. * Returns true if the current Vector3 coordinates equals the given floats
  70497. * @param x defines the x coordinate of the operand
  70498. * @param y defines the y coordinate of the operand
  70499. * @param z defines the z coordinate of the operand
  70500. * @returns true if both vectors are equals
  70501. */
  70502. equalsToFloats(x: number, y: number, z: number): boolean;
  70503. /**
  70504. * Multiplies the current Vector3 coordinates by the given ones
  70505. * @param otherVector defines the second operand
  70506. * @returns the current updated Vector3
  70507. */
  70508. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70509. /**
  70510. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  70511. * @param otherVector defines the second operand
  70512. * @returns the new Vector3
  70513. */
  70514. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  70515. /**
  70516. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  70517. * @param otherVector defines the second operand
  70518. * @param result defines the Vector3 object where to store the result
  70519. * @returns the current Vector3
  70520. */
  70521. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70522. /**
  70523. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  70524. * @param x defines the x coordinate of the operand
  70525. * @param y defines the y coordinate of the operand
  70526. * @param z defines the z coordinate of the operand
  70527. * @returns the new Vector3
  70528. */
  70529. multiplyByFloats(x: number, y: number, z: number): Vector3;
  70530. /**
  70531. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  70532. * @param otherVector defines the second operand
  70533. * @returns the new Vector3
  70534. */
  70535. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  70536. /**
  70537. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  70538. * @param otherVector defines the second operand
  70539. * @param result defines the Vector3 object where to store the result
  70540. * @returns the current Vector3
  70541. */
  70542. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70543. /**
  70544. * Divides the current Vector3 coordinates by the given ones.
  70545. * @param otherVector defines the second operand
  70546. * @returns the current updated Vector3
  70547. */
  70548. divideInPlace(otherVector: Vector3): Vector3;
  70549. /**
  70550. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  70551. * @param other defines the second operand
  70552. * @returns the current updated Vector3
  70553. */
  70554. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70555. /**
  70556. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  70557. * @param other defines the second operand
  70558. * @returns the current updated Vector3
  70559. */
  70560. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70561. /**
  70562. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  70563. * @param x defines the x coordinate of the operand
  70564. * @param y defines the y coordinate of the operand
  70565. * @param z defines the z coordinate of the operand
  70566. * @returns the current updated Vector3
  70567. */
  70568. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70569. /**
  70570. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  70571. * @param x defines the x coordinate of the operand
  70572. * @param y defines the y coordinate of the operand
  70573. * @param z defines the z coordinate of the operand
  70574. * @returns the current updated Vector3
  70575. */
  70576. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70577. /**
  70578. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  70579. * Check if is non uniform within a certain amount of decimal places to account for this
  70580. * @param epsilon the amount the values can differ
  70581. * @returns if the the vector is non uniform to a certain number of decimal places
  70582. */
  70583. isNonUniformWithinEpsilon(epsilon: number): boolean;
  70584. /**
  70585. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  70586. */
  70587. readonly isNonUniform: boolean;
  70588. /**
  70589. * Gets a new Vector3 from current Vector3 floored values
  70590. * @returns a new Vector3
  70591. */
  70592. floor(): Vector3;
  70593. /**
  70594. * Gets a new Vector3 from current Vector3 floored values
  70595. * @returns a new Vector3
  70596. */
  70597. fract(): Vector3;
  70598. /**
  70599. * Gets the length of the Vector3
  70600. * @returns the length of the Vector3
  70601. */
  70602. length(): number;
  70603. /**
  70604. * Gets the squared length of the Vector3
  70605. * @returns squared length of the Vector3
  70606. */
  70607. lengthSquared(): number;
  70608. /**
  70609. * Normalize the current Vector3.
  70610. * Please note that this is an in place operation.
  70611. * @returns the current updated Vector3
  70612. */
  70613. normalize(): Vector3;
  70614. /**
  70615. * Reorders the x y z properties of the vector in place
  70616. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  70617. * @returns the current updated vector
  70618. */
  70619. reorderInPlace(order: string): this;
  70620. /**
  70621. * Rotates the vector around 0,0,0 by a quaternion
  70622. * @param quaternion the rotation quaternion
  70623. * @param result vector to store the result
  70624. * @returns the resulting vector
  70625. */
  70626. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  70627. /**
  70628. * Rotates a vector around a given point
  70629. * @param quaternion the rotation quaternion
  70630. * @param point the point to rotate around
  70631. * @param result vector to store the result
  70632. * @returns the resulting vector
  70633. */
  70634. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  70635. /**
  70636. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  70637. * The cross product is then orthogonal to both current and "other"
  70638. * @param other defines the right operand
  70639. * @returns the cross product
  70640. */
  70641. cross(other: Vector3): Vector3;
  70642. /**
  70643. * Normalize the current Vector3 with the given input length.
  70644. * Please note that this is an in place operation.
  70645. * @param len the length of the vector
  70646. * @returns the current updated Vector3
  70647. */
  70648. normalizeFromLength(len: number): Vector3;
  70649. /**
  70650. * Normalize the current Vector3 to a new vector
  70651. * @returns the new Vector3
  70652. */
  70653. normalizeToNew(): Vector3;
  70654. /**
  70655. * Normalize the current Vector3 to the reference
  70656. * @param reference define the Vector3 to update
  70657. * @returns the updated Vector3
  70658. */
  70659. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  70660. /**
  70661. * Creates a new Vector3 copied from the current Vector3
  70662. * @returns the new Vector3
  70663. */
  70664. clone(): Vector3;
  70665. /**
  70666. * Copies the given vector coordinates to the current Vector3 ones
  70667. * @param source defines the source Vector3
  70668. * @returns the current updated Vector3
  70669. */
  70670. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  70671. /**
  70672. * Copies the given floats to the current Vector3 coordinates
  70673. * @param x defines the x coordinate of the operand
  70674. * @param y defines the y coordinate of the operand
  70675. * @param z defines the z coordinate of the operand
  70676. * @returns the current updated Vector3
  70677. */
  70678. copyFromFloats(x: number, y: number, z: number): Vector3;
  70679. /**
  70680. * Copies the given floats to the current Vector3 coordinates
  70681. * @param x defines the x coordinate of the operand
  70682. * @param y defines the y coordinate of the operand
  70683. * @param z defines the z coordinate of the operand
  70684. * @returns the current updated Vector3
  70685. */
  70686. set(x: number, y: number, z: number): Vector3;
  70687. /**
  70688. * Copies the given float to the current Vector3 coordinates
  70689. * @param v defines the x, y and z coordinates of the operand
  70690. * @returns the current updated Vector3
  70691. */
  70692. setAll(v: number): Vector3;
  70693. /**
  70694. * Get the clip factor between two vectors
  70695. * @param vector0 defines the first operand
  70696. * @param vector1 defines the second operand
  70697. * @param axis defines the axis to use
  70698. * @param size defines the size along the axis
  70699. * @returns the clip factor
  70700. */
  70701. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  70702. /**
  70703. * Get angle between two vectors
  70704. * @param vector0 angle between vector0 and vector1
  70705. * @param vector1 angle between vector0 and vector1
  70706. * @param normal direction of the normal
  70707. * @return the angle between vector0 and vector1
  70708. */
  70709. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  70710. /**
  70711. * Returns a new Vector3 set from the index "offset" of the given array
  70712. * @param array defines the source array
  70713. * @param offset defines the offset in the source array
  70714. * @returns the new Vector3
  70715. */
  70716. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  70717. /**
  70718. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  70719. * This function is deprecated. Use FromArray instead
  70720. * @param array defines the source array
  70721. * @param offset defines the offset in the source array
  70722. * @returns the new Vector3
  70723. */
  70724. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  70725. /**
  70726. * Sets the given vector "result" with the element values from the index "offset" of the given array
  70727. * @param array defines the source array
  70728. * @param offset defines the offset in the source array
  70729. * @param result defines the Vector3 where to store the result
  70730. */
  70731. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  70732. /**
  70733. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  70734. * This function is deprecated. Use FromArrayToRef instead.
  70735. * @param array defines the source array
  70736. * @param offset defines the offset in the source array
  70737. * @param result defines the Vector3 where to store the result
  70738. */
  70739. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  70740. /**
  70741. * Sets the given vector "result" with the given floats.
  70742. * @param x defines the x coordinate of the source
  70743. * @param y defines the y coordinate of the source
  70744. * @param z defines the z coordinate of the source
  70745. * @param result defines the Vector3 where to store the result
  70746. */
  70747. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  70748. /**
  70749. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  70750. * @returns a new empty Vector3
  70751. */
  70752. static Zero(): Vector3;
  70753. /**
  70754. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  70755. * @returns a new unit Vector3
  70756. */
  70757. static One(): Vector3;
  70758. /**
  70759. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  70760. * @returns a new up Vector3
  70761. */
  70762. static Up(): Vector3;
  70763. /**
  70764. * Gets a up Vector3 that must not be updated
  70765. */
  70766. static readonly UpReadOnly: DeepImmutable<Vector3>;
  70767. /**
  70768. * Gets a zero Vector3 that must not be updated
  70769. */
  70770. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  70771. /**
  70772. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  70773. * @returns a new down Vector3
  70774. */
  70775. static Down(): Vector3;
  70776. /**
  70777. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  70778. * @returns a new forward Vector3
  70779. */
  70780. static Forward(): Vector3;
  70781. /**
  70782. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  70783. * @returns a new forward Vector3
  70784. */
  70785. static Backward(): Vector3;
  70786. /**
  70787. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  70788. * @returns a new right Vector3
  70789. */
  70790. static Right(): Vector3;
  70791. /**
  70792. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  70793. * @returns a new left Vector3
  70794. */
  70795. static Left(): Vector3;
  70796. /**
  70797. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  70798. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70799. * @param vector defines the Vector3 to transform
  70800. * @param transformation defines the transformation matrix
  70801. * @returns the transformed Vector3
  70802. */
  70803. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70804. /**
  70805. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  70806. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70807. * @param vector defines the Vector3 to transform
  70808. * @param transformation defines the transformation matrix
  70809. * @param result defines the Vector3 where to store the result
  70810. */
  70811. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70812. /**
  70813. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  70814. * This method computes tranformed coordinates only, not transformed direction vectors
  70815. * @param x define the x coordinate of the source vector
  70816. * @param y define the y coordinate of the source vector
  70817. * @param z define the z coordinate of the source vector
  70818. * @param transformation defines the transformation matrix
  70819. * @param result defines the Vector3 where to store the result
  70820. */
  70821. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70822. /**
  70823. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  70824. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70825. * @param vector defines the Vector3 to transform
  70826. * @param transformation defines the transformation matrix
  70827. * @returns the new Vector3
  70828. */
  70829. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70830. /**
  70831. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  70832. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70833. * @param vector defines the Vector3 to transform
  70834. * @param transformation defines the transformation matrix
  70835. * @param result defines the Vector3 where to store the result
  70836. */
  70837. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70838. /**
  70839. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  70840. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70841. * @param x define the x coordinate of the source vector
  70842. * @param y define the y coordinate of the source vector
  70843. * @param z define the z coordinate of the source vector
  70844. * @param transformation defines the transformation matrix
  70845. * @param result defines the Vector3 where to store the result
  70846. */
  70847. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70848. /**
  70849. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  70850. * @param value1 defines the first control point
  70851. * @param value2 defines the second control point
  70852. * @param value3 defines the third control point
  70853. * @param value4 defines the fourth control point
  70854. * @param amount defines the amount on the spline to use
  70855. * @returns the new Vector3
  70856. */
  70857. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  70858. /**
  70859. * 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"
  70860. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70861. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70862. * @param value defines the current value
  70863. * @param min defines the lower range value
  70864. * @param max defines the upper range value
  70865. * @returns the new Vector3
  70866. */
  70867. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  70868. /**
  70869. * 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"
  70870. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70871. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70872. * @param value defines the current value
  70873. * @param min defines the lower range value
  70874. * @param max defines the upper range value
  70875. * @param result defines the Vector3 where to store the result
  70876. */
  70877. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  70878. /**
  70879. * Checks if a given vector is inside a specific range
  70880. * @param v defines the vector to test
  70881. * @param min defines the minimum range
  70882. * @param max defines the maximum range
  70883. */
  70884. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  70885. /**
  70886. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  70887. * @param value1 defines the first control point
  70888. * @param tangent1 defines the first tangent vector
  70889. * @param value2 defines the second control point
  70890. * @param tangent2 defines the second tangent vector
  70891. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  70892. * @returns the new Vector3
  70893. */
  70894. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  70895. /**
  70896. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  70897. * @param start defines the start value
  70898. * @param end defines the end value
  70899. * @param amount max defines amount between both (between 0 and 1)
  70900. * @returns the new Vector3
  70901. */
  70902. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  70903. /**
  70904. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  70905. * @param start defines the start value
  70906. * @param end defines the end value
  70907. * @param amount max defines amount between both (between 0 and 1)
  70908. * @param result defines the Vector3 where to store the result
  70909. */
  70910. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  70911. /**
  70912. * Returns the dot product (float) between the vectors "left" and "right"
  70913. * @param left defines the left operand
  70914. * @param right defines the right operand
  70915. * @returns the dot product
  70916. */
  70917. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  70918. /**
  70919. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  70920. * The cross product is then orthogonal to both "left" and "right"
  70921. * @param left defines the left operand
  70922. * @param right defines the right operand
  70923. * @returns the cross product
  70924. */
  70925. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70926. /**
  70927. * Sets the given vector "result" with the cross product of "left" and "right"
  70928. * The cross product is then orthogonal to both "left" and "right"
  70929. * @param left defines the left operand
  70930. * @param right defines the right operand
  70931. * @param result defines the Vector3 where to store the result
  70932. */
  70933. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  70934. /**
  70935. * Returns a new Vector3 as the normalization of the given vector
  70936. * @param vector defines the Vector3 to normalize
  70937. * @returns the new Vector3
  70938. */
  70939. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  70940. /**
  70941. * Sets the given vector "result" with the normalization of the given first vector
  70942. * @param vector defines the Vector3 to normalize
  70943. * @param result defines the Vector3 where to store the result
  70944. */
  70945. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  70946. /**
  70947. * Project a Vector3 onto screen space
  70948. * @param vector defines the Vector3 to project
  70949. * @param world defines the world matrix to use
  70950. * @param transform defines the transform (view x projection) matrix to use
  70951. * @param viewport defines the screen viewport to use
  70952. * @returns the new Vector3
  70953. */
  70954. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  70955. /** @hidden */
  70956. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  70957. /**
  70958. * Unproject from screen space to object space
  70959. * @param source defines the screen space Vector3 to use
  70960. * @param viewportWidth defines the current width of the viewport
  70961. * @param viewportHeight defines the current height of the viewport
  70962. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70963. * @param transform defines the transform (view x projection) matrix to use
  70964. * @returns the new Vector3
  70965. */
  70966. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  70967. /**
  70968. * Unproject from screen space to object space
  70969. * @param source defines the screen space Vector3 to use
  70970. * @param viewportWidth defines the current width of the viewport
  70971. * @param viewportHeight defines the current height of the viewport
  70972. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70973. * @param view defines the view matrix to use
  70974. * @param projection defines the projection matrix to use
  70975. * @returns the new Vector3
  70976. */
  70977. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  70978. /**
  70979. * Unproject from screen space to object space
  70980. * @param source defines the screen space Vector3 to use
  70981. * @param viewportWidth defines the current width of the viewport
  70982. * @param viewportHeight defines the current height of the viewport
  70983. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70984. * @param view defines the view matrix to use
  70985. * @param projection defines the projection matrix to use
  70986. * @param result defines the Vector3 where to store the result
  70987. */
  70988. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70989. /**
  70990. * Unproject from screen space to object space
  70991. * @param sourceX defines the screen space x coordinate to use
  70992. * @param sourceY defines the screen space y coordinate to use
  70993. * @param sourceZ defines the screen space z coordinate to use
  70994. * @param viewportWidth defines the current width of the viewport
  70995. * @param viewportHeight defines the current height of the viewport
  70996. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70997. * @param view defines the view matrix to use
  70998. * @param projection defines the projection matrix to use
  70999. * @param result defines the Vector3 where to store the result
  71000. */
  71001. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71002. /**
  71003. * Gets the minimal coordinate values between two Vector3
  71004. * @param left defines the first operand
  71005. * @param right defines the second operand
  71006. * @returns the new Vector3
  71007. */
  71008. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71009. /**
  71010. * Gets the maximal coordinate values between two Vector3
  71011. * @param left defines the first operand
  71012. * @param right defines the second operand
  71013. * @returns the new Vector3
  71014. */
  71015. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71016. /**
  71017. * Returns the distance between the vectors "value1" and "value2"
  71018. * @param value1 defines the first operand
  71019. * @param value2 defines the second operand
  71020. * @returns the distance
  71021. */
  71022. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71023. /**
  71024. * Returns the squared distance between the vectors "value1" and "value2"
  71025. * @param value1 defines the first operand
  71026. * @param value2 defines the second operand
  71027. * @returns the squared distance
  71028. */
  71029. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71030. /**
  71031. * Returns a new Vector3 located at the center between "value1" and "value2"
  71032. * @param value1 defines the first operand
  71033. * @param value2 defines the second operand
  71034. * @returns the new Vector3
  71035. */
  71036. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  71037. /**
  71038. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  71039. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  71040. * to something in order to rotate it from its local system to the given target system
  71041. * Note: axis1, axis2 and axis3 are normalized during this operation
  71042. * @param axis1 defines the first axis
  71043. * @param axis2 defines the second axis
  71044. * @param axis3 defines the third axis
  71045. * @returns a new Vector3
  71046. */
  71047. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  71048. /**
  71049. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  71050. * @param axis1 defines the first axis
  71051. * @param axis2 defines the second axis
  71052. * @param axis3 defines the third axis
  71053. * @param ref defines the Vector3 where to store the result
  71054. */
  71055. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  71056. }
  71057. /**
  71058. * Vector4 class created for EulerAngle class conversion to Quaternion
  71059. */
  71060. export class Vector4 {
  71061. /** x value of the vector */
  71062. x: number;
  71063. /** y value of the vector */
  71064. y: number;
  71065. /** z value of the vector */
  71066. z: number;
  71067. /** w value of the vector */
  71068. w: number;
  71069. /**
  71070. * Creates a Vector4 object from the given floats.
  71071. * @param x x value of the vector
  71072. * @param y y value of the vector
  71073. * @param z z value of the vector
  71074. * @param w w value of the vector
  71075. */
  71076. constructor(
  71077. /** x value of the vector */
  71078. x: number,
  71079. /** y value of the vector */
  71080. y: number,
  71081. /** z value of the vector */
  71082. z: number,
  71083. /** w value of the vector */
  71084. w: number);
  71085. /**
  71086. * Returns the string with the Vector4 coordinates.
  71087. * @returns a string containing all the vector values
  71088. */
  71089. toString(): string;
  71090. /**
  71091. * Returns the string "Vector4".
  71092. * @returns "Vector4"
  71093. */
  71094. getClassName(): string;
  71095. /**
  71096. * Returns the Vector4 hash code.
  71097. * @returns a unique hash code
  71098. */
  71099. getHashCode(): number;
  71100. /**
  71101. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  71102. * @returns the resulting array
  71103. */
  71104. asArray(): number[];
  71105. /**
  71106. * Populates the given array from the given index with the Vector4 coordinates.
  71107. * @param array array to populate
  71108. * @param index index of the array to start at (default: 0)
  71109. * @returns the Vector4.
  71110. */
  71111. toArray(array: FloatArray, index?: number): Vector4;
  71112. /**
  71113. * Adds the given vector to the current Vector4.
  71114. * @param otherVector the vector to add
  71115. * @returns the updated Vector4.
  71116. */
  71117. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71118. /**
  71119. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  71120. * @param otherVector the vector to add
  71121. * @returns the resulting vector
  71122. */
  71123. add(otherVector: DeepImmutable<Vector4>): Vector4;
  71124. /**
  71125. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  71126. * @param otherVector the vector to add
  71127. * @param result the vector to store the result
  71128. * @returns the current Vector4.
  71129. */
  71130. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71131. /**
  71132. * Subtract in place the given vector from the current Vector4.
  71133. * @param otherVector the vector to subtract
  71134. * @returns the updated Vector4.
  71135. */
  71136. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71137. /**
  71138. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  71139. * @param otherVector the vector to add
  71140. * @returns the new vector with the result
  71141. */
  71142. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  71143. /**
  71144. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  71145. * @param otherVector the vector to subtract
  71146. * @param result the vector to store the result
  71147. * @returns the current Vector4.
  71148. */
  71149. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71150. /**
  71151. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71152. */
  71153. /**
  71154. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71155. * @param x value to subtract
  71156. * @param y value to subtract
  71157. * @param z value to subtract
  71158. * @param w value to subtract
  71159. * @returns new vector containing the result
  71160. */
  71161. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71162. /**
  71163. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71164. * @param x value to subtract
  71165. * @param y value to subtract
  71166. * @param z value to subtract
  71167. * @param w value to subtract
  71168. * @param result the vector to store the result in
  71169. * @returns the current Vector4.
  71170. */
  71171. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  71172. /**
  71173. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  71174. * @returns a new vector with the negated values
  71175. */
  71176. negate(): Vector4;
  71177. /**
  71178. * Multiplies the current Vector4 coordinates by scale (float).
  71179. * @param scale the number to scale with
  71180. * @returns the updated Vector4.
  71181. */
  71182. scaleInPlace(scale: number): Vector4;
  71183. /**
  71184. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  71185. * @param scale the number to scale with
  71186. * @returns a new vector with the result
  71187. */
  71188. scale(scale: number): Vector4;
  71189. /**
  71190. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  71191. * @param scale the number to scale with
  71192. * @param result a vector to store the result in
  71193. * @returns the current Vector4.
  71194. */
  71195. scaleToRef(scale: number, result: Vector4): Vector4;
  71196. /**
  71197. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  71198. * @param scale defines the scale factor
  71199. * @param result defines the Vector4 object where to store the result
  71200. * @returns the unmodified current Vector4
  71201. */
  71202. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  71203. /**
  71204. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  71205. * @param otherVector the vector to compare against
  71206. * @returns true if they are equal
  71207. */
  71208. equals(otherVector: DeepImmutable<Vector4>): boolean;
  71209. /**
  71210. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  71211. * @param otherVector vector to compare against
  71212. * @param epsilon (Default: very small number)
  71213. * @returns true if they are equal
  71214. */
  71215. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  71216. /**
  71217. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  71218. * @param x x value to compare against
  71219. * @param y y value to compare against
  71220. * @param z z value to compare against
  71221. * @param w w value to compare against
  71222. * @returns true if equal
  71223. */
  71224. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  71225. /**
  71226. * Multiplies in place the current Vector4 by the given one.
  71227. * @param otherVector vector to multiple with
  71228. * @returns the updated Vector4.
  71229. */
  71230. multiplyInPlace(otherVector: Vector4): Vector4;
  71231. /**
  71232. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  71233. * @param otherVector vector to multiple with
  71234. * @returns resulting new vector
  71235. */
  71236. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  71237. /**
  71238. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  71239. * @param otherVector vector to multiple with
  71240. * @param result vector to store the result
  71241. * @returns the current Vector4.
  71242. */
  71243. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71244. /**
  71245. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  71246. * @param x x value multiply with
  71247. * @param y y value multiply with
  71248. * @param z z value multiply with
  71249. * @param w w value multiply with
  71250. * @returns resulting new vector
  71251. */
  71252. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  71253. /**
  71254. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  71255. * @param otherVector vector to devide with
  71256. * @returns resulting new vector
  71257. */
  71258. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  71259. /**
  71260. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  71261. * @param otherVector vector to devide with
  71262. * @param result vector to store the result
  71263. * @returns the current Vector4.
  71264. */
  71265. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71266. /**
  71267. * Divides the current Vector3 coordinates by the given ones.
  71268. * @param otherVector vector to devide with
  71269. * @returns the updated Vector3.
  71270. */
  71271. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71272. /**
  71273. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  71274. * @param other defines the second operand
  71275. * @returns the current updated Vector4
  71276. */
  71277. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71278. /**
  71279. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  71280. * @param other defines the second operand
  71281. * @returns the current updated Vector4
  71282. */
  71283. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71284. /**
  71285. * Gets a new Vector4 from current Vector4 floored values
  71286. * @returns a new Vector4
  71287. */
  71288. floor(): Vector4;
  71289. /**
  71290. * Gets a new Vector4 from current Vector3 floored values
  71291. * @returns a new Vector4
  71292. */
  71293. fract(): Vector4;
  71294. /**
  71295. * Returns the Vector4 length (float).
  71296. * @returns the length
  71297. */
  71298. length(): number;
  71299. /**
  71300. * Returns the Vector4 squared length (float).
  71301. * @returns the length squared
  71302. */
  71303. lengthSquared(): number;
  71304. /**
  71305. * Normalizes in place the Vector4.
  71306. * @returns the updated Vector4.
  71307. */
  71308. normalize(): Vector4;
  71309. /**
  71310. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  71311. * @returns this converted to a new vector3
  71312. */
  71313. toVector3(): Vector3;
  71314. /**
  71315. * Returns a new Vector4 copied from the current one.
  71316. * @returns the new cloned vector
  71317. */
  71318. clone(): Vector4;
  71319. /**
  71320. * Updates the current Vector4 with the given one coordinates.
  71321. * @param source the source vector to copy from
  71322. * @returns the updated Vector4.
  71323. */
  71324. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  71325. /**
  71326. * Updates the current Vector4 coordinates with the given floats.
  71327. * @param x float to copy from
  71328. * @param y float to copy from
  71329. * @param z float to copy from
  71330. * @param w float to copy from
  71331. * @returns the updated Vector4.
  71332. */
  71333. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71334. /**
  71335. * Updates the current Vector4 coordinates with the given floats.
  71336. * @param x float to set from
  71337. * @param y float to set from
  71338. * @param z float to set from
  71339. * @param w float to set from
  71340. * @returns the updated Vector4.
  71341. */
  71342. set(x: number, y: number, z: number, w: number): Vector4;
  71343. /**
  71344. * Copies the given float to the current Vector3 coordinates
  71345. * @param v defines the x, y, z and w coordinates of the operand
  71346. * @returns the current updated Vector3
  71347. */
  71348. setAll(v: number): Vector4;
  71349. /**
  71350. * Returns a new Vector4 set from the starting index of the given array.
  71351. * @param array the array to pull values from
  71352. * @param offset the offset into the array to start at
  71353. * @returns the new vector
  71354. */
  71355. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  71356. /**
  71357. * Updates the given vector "result" from the starting index of the given array.
  71358. * @param array the array to pull values from
  71359. * @param offset the offset into the array to start at
  71360. * @param result the vector to store the result in
  71361. */
  71362. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  71363. /**
  71364. * Updates the given vector "result" from the starting index of the given Float32Array.
  71365. * @param array the array to pull values from
  71366. * @param offset the offset into the array to start at
  71367. * @param result the vector to store the result in
  71368. */
  71369. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  71370. /**
  71371. * Updates the given vector "result" coordinates from the given floats.
  71372. * @param x float to set from
  71373. * @param y float to set from
  71374. * @param z float to set from
  71375. * @param w float to set from
  71376. * @param result the vector to the floats in
  71377. */
  71378. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  71379. /**
  71380. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  71381. * @returns the new vector
  71382. */
  71383. static Zero(): Vector4;
  71384. /**
  71385. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  71386. * @returns the new vector
  71387. */
  71388. static One(): Vector4;
  71389. /**
  71390. * Returns a new normalized Vector4 from the given one.
  71391. * @param vector the vector to normalize
  71392. * @returns the vector
  71393. */
  71394. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  71395. /**
  71396. * Updates the given vector "result" from the normalization of the given one.
  71397. * @param vector the vector to normalize
  71398. * @param result the vector to store the result in
  71399. */
  71400. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  71401. /**
  71402. * Returns a vector with the minimum values from the left and right vectors
  71403. * @param left left vector to minimize
  71404. * @param right right vector to minimize
  71405. * @returns a new vector with the minimum of the left and right vector values
  71406. */
  71407. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71408. /**
  71409. * Returns a vector with the maximum values from the left and right vectors
  71410. * @param left left vector to maximize
  71411. * @param right right vector to maximize
  71412. * @returns a new vector with the maximum of the left and right vector values
  71413. */
  71414. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71415. /**
  71416. * Returns the distance (float) between the vectors "value1" and "value2".
  71417. * @param value1 value to calulate the distance between
  71418. * @param value2 value to calulate the distance between
  71419. * @return the distance between the two vectors
  71420. */
  71421. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71422. /**
  71423. * Returns the squared distance (float) between the vectors "value1" and "value2".
  71424. * @param value1 value to calulate the distance between
  71425. * @param value2 value to calulate the distance between
  71426. * @return the distance between the two vectors squared
  71427. */
  71428. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71429. /**
  71430. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  71431. * @param value1 value to calulate the center between
  71432. * @param value2 value to calulate the center between
  71433. * @return the center between the two vectors
  71434. */
  71435. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  71436. /**
  71437. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  71438. * This methods computes transformed normalized direction vectors only.
  71439. * @param vector the vector to transform
  71440. * @param transformation the transformation matrix to apply
  71441. * @returns the new vector
  71442. */
  71443. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  71444. /**
  71445. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  71446. * This methods computes transformed normalized direction vectors only.
  71447. * @param vector the vector to transform
  71448. * @param transformation the transformation matrix to apply
  71449. * @param result the vector to store the result in
  71450. */
  71451. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71452. /**
  71453. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  71454. * This methods computes transformed normalized direction vectors only.
  71455. * @param x value to transform
  71456. * @param y value to transform
  71457. * @param z value to transform
  71458. * @param w value to transform
  71459. * @param transformation the transformation matrix to apply
  71460. * @param result the vector to store the results in
  71461. */
  71462. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71463. /**
  71464. * Creates a new Vector4 from a Vector3
  71465. * @param source defines the source data
  71466. * @param w defines the 4th component (default is 0)
  71467. * @returns a new Vector4
  71468. */
  71469. static FromVector3(source: Vector3, w?: number): Vector4;
  71470. }
  71471. /**
  71472. * Class used to store quaternion data
  71473. * @see https://en.wikipedia.org/wiki/Quaternion
  71474. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  71475. */
  71476. export class Quaternion {
  71477. /** defines the first component (0 by default) */
  71478. x: number;
  71479. /** defines the second component (0 by default) */
  71480. y: number;
  71481. /** defines the third component (0 by default) */
  71482. z: number;
  71483. /** defines the fourth component (1.0 by default) */
  71484. w: number;
  71485. /**
  71486. * Creates a new Quaternion from the given floats
  71487. * @param x defines the first component (0 by default)
  71488. * @param y defines the second component (0 by default)
  71489. * @param z defines the third component (0 by default)
  71490. * @param w defines the fourth component (1.0 by default)
  71491. */
  71492. constructor(
  71493. /** defines the first component (0 by default) */
  71494. x?: number,
  71495. /** defines the second component (0 by default) */
  71496. y?: number,
  71497. /** defines the third component (0 by default) */
  71498. z?: number,
  71499. /** defines the fourth component (1.0 by default) */
  71500. w?: number);
  71501. /**
  71502. * Gets a string representation for the current quaternion
  71503. * @returns a string with the Quaternion coordinates
  71504. */
  71505. toString(): string;
  71506. /**
  71507. * Gets the class name of the quaternion
  71508. * @returns the string "Quaternion"
  71509. */
  71510. getClassName(): string;
  71511. /**
  71512. * Gets a hash code for this quaternion
  71513. * @returns the quaternion hash code
  71514. */
  71515. getHashCode(): number;
  71516. /**
  71517. * Copy the quaternion to an array
  71518. * @returns a new array populated with 4 elements from the quaternion coordinates
  71519. */
  71520. asArray(): number[];
  71521. /**
  71522. * Check if two quaternions are equals
  71523. * @param otherQuaternion defines the second operand
  71524. * @return true if the current quaternion and the given one coordinates are strictly equals
  71525. */
  71526. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  71527. /**
  71528. * Clone the current quaternion
  71529. * @returns a new quaternion copied from the current one
  71530. */
  71531. clone(): Quaternion;
  71532. /**
  71533. * Copy a quaternion to the current one
  71534. * @param other defines the other quaternion
  71535. * @returns the updated current quaternion
  71536. */
  71537. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  71538. /**
  71539. * Updates the current quaternion with the given float coordinates
  71540. * @param x defines the x coordinate
  71541. * @param y defines the y coordinate
  71542. * @param z defines the z coordinate
  71543. * @param w defines the w coordinate
  71544. * @returns the updated current quaternion
  71545. */
  71546. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  71547. /**
  71548. * Updates the current quaternion from the given float coordinates
  71549. * @param x defines the x coordinate
  71550. * @param y defines the y coordinate
  71551. * @param z defines the z coordinate
  71552. * @param w defines the w coordinate
  71553. * @returns the updated current quaternion
  71554. */
  71555. set(x: number, y: number, z: number, w: number): Quaternion;
  71556. /**
  71557. * Adds two quaternions
  71558. * @param other defines the second operand
  71559. * @returns a new quaternion as the addition result of the given one and the current quaternion
  71560. */
  71561. add(other: DeepImmutable<Quaternion>): Quaternion;
  71562. /**
  71563. * Add a quaternion to the current one
  71564. * @param other defines the quaternion to add
  71565. * @returns the current quaternion
  71566. */
  71567. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  71568. /**
  71569. * Subtract two quaternions
  71570. * @param other defines the second operand
  71571. * @returns a new quaternion as the subtraction result of the given one from the current one
  71572. */
  71573. subtract(other: Quaternion): Quaternion;
  71574. /**
  71575. * Multiplies the current quaternion by a scale factor
  71576. * @param value defines the scale factor
  71577. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  71578. */
  71579. scale(value: number): Quaternion;
  71580. /**
  71581. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  71582. * @param scale defines the scale factor
  71583. * @param result defines the Quaternion object where to store the result
  71584. * @returns the unmodified current quaternion
  71585. */
  71586. scaleToRef(scale: number, result: Quaternion): Quaternion;
  71587. /**
  71588. * Multiplies in place the current quaternion by a scale factor
  71589. * @param value defines the scale factor
  71590. * @returns the current modified quaternion
  71591. */
  71592. scaleInPlace(value: number): Quaternion;
  71593. /**
  71594. * Scale the current quaternion values by a factor and add the result to a given quaternion
  71595. * @param scale defines the scale factor
  71596. * @param result defines the Quaternion object where to store the result
  71597. * @returns the unmodified current quaternion
  71598. */
  71599. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  71600. /**
  71601. * Multiplies two quaternions
  71602. * @param q1 defines the second operand
  71603. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  71604. */
  71605. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  71606. /**
  71607. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  71608. * @param q1 defines the second operand
  71609. * @param result defines the target quaternion
  71610. * @returns the current quaternion
  71611. */
  71612. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  71613. /**
  71614. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  71615. * @param q1 defines the second operand
  71616. * @returns the currentupdated quaternion
  71617. */
  71618. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  71619. /**
  71620. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  71621. * @param ref defines the target quaternion
  71622. * @returns the current quaternion
  71623. */
  71624. conjugateToRef(ref: Quaternion): Quaternion;
  71625. /**
  71626. * Conjugates in place (1-q) the current quaternion
  71627. * @returns the current updated quaternion
  71628. */
  71629. conjugateInPlace(): Quaternion;
  71630. /**
  71631. * Conjugates in place (1-q) the current quaternion
  71632. * @returns a new quaternion
  71633. */
  71634. conjugate(): Quaternion;
  71635. /**
  71636. * Gets length of current quaternion
  71637. * @returns the quaternion length (float)
  71638. */
  71639. length(): number;
  71640. /**
  71641. * Normalize in place the current quaternion
  71642. * @returns the current updated quaternion
  71643. */
  71644. normalize(): Quaternion;
  71645. /**
  71646. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71647. * @param order is a reserved parameter and is ignore for now
  71648. * @returns a new Vector3 containing the Euler angles
  71649. */
  71650. toEulerAngles(order?: string): Vector3;
  71651. /**
  71652. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  71653. * @param result defines the vector which will be filled with the Euler angles
  71654. * @param order is a reserved parameter and is ignore for now
  71655. * @returns the current unchanged quaternion
  71656. */
  71657. toEulerAnglesToRef(result: Vector3): Quaternion;
  71658. /**
  71659. * Updates the given rotation matrix with the current quaternion values
  71660. * @param result defines the target matrix
  71661. * @returns the current unchanged quaternion
  71662. */
  71663. toRotationMatrix(result: Matrix): Quaternion;
  71664. /**
  71665. * Updates the current quaternion from the given rotation matrix values
  71666. * @param matrix defines the source matrix
  71667. * @returns the current updated quaternion
  71668. */
  71669. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71670. /**
  71671. * Creates a new quaternion from a rotation matrix
  71672. * @param matrix defines the source matrix
  71673. * @returns a new quaternion created from the given rotation matrix values
  71674. */
  71675. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71676. /**
  71677. * Updates the given quaternion with the given rotation matrix values
  71678. * @param matrix defines the source matrix
  71679. * @param result defines the target quaternion
  71680. */
  71681. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  71682. /**
  71683. * Returns the dot product (float) between the quaternions "left" and "right"
  71684. * @param left defines the left operand
  71685. * @param right defines the right operand
  71686. * @returns the dot product
  71687. */
  71688. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  71689. /**
  71690. * Checks if the two quaternions are close to each other
  71691. * @param quat0 defines the first quaternion to check
  71692. * @param quat1 defines the second quaternion to check
  71693. * @returns true if the two quaternions are close to each other
  71694. */
  71695. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  71696. /**
  71697. * Creates an empty quaternion
  71698. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  71699. */
  71700. static Zero(): Quaternion;
  71701. /**
  71702. * Inverse a given quaternion
  71703. * @param q defines the source quaternion
  71704. * @returns a new quaternion as the inverted current quaternion
  71705. */
  71706. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  71707. /**
  71708. * Inverse a given quaternion
  71709. * @param q defines the source quaternion
  71710. * @param result the quaternion the result will be stored in
  71711. * @returns the result quaternion
  71712. */
  71713. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  71714. /**
  71715. * Creates an identity quaternion
  71716. * @returns the identity quaternion
  71717. */
  71718. static Identity(): Quaternion;
  71719. /**
  71720. * Gets a boolean indicating if the given quaternion is identity
  71721. * @param quaternion defines the quaternion to check
  71722. * @returns true if the quaternion is identity
  71723. */
  71724. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  71725. /**
  71726. * Creates a quaternion from a rotation around an axis
  71727. * @param axis defines the axis to use
  71728. * @param angle defines the angle to use
  71729. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  71730. */
  71731. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  71732. /**
  71733. * Creates a rotation around an axis and stores it into the given quaternion
  71734. * @param axis defines the axis to use
  71735. * @param angle defines the angle to use
  71736. * @param result defines the target quaternion
  71737. * @returns the target quaternion
  71738. */
  71739. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  71740. /**
  71741. * Creates a new quaternion from data stored into an array
  71742. * @param array defines the data source
  71743. * @param offset defines the offset in the source array where the data starts
  71744. * @returns a new quaternion
  71745. */
  71746. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  71747. /**
  71748. * Create a quaternion from Euler rotation angles
  71749. * @param x Pitch
  71750. * @param y Yaw
  71751. * @param z Roll
  71752. * @returns the new Quaternion
  71753. */
  71754. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  71755. /**
  71756. * Updates a quaternion from Euler rotation angles
  71757. * @param x Pitch
  71758. * @param y Yaw
  71759. * @param z Roll
  71760. * @param result the quaternion to store the result
  71761. * @returns the updated quaternion
  71762. */
  71763. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  71764. /**
  71765. * Create a quaternion from Euler rotation vector
  71766. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71767. * @returns the new Quaternion
  71768. */
  71769. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  71770. /**
  71771. * Updates a quaternion from Euler rotation vector
  71772. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71773. * @param result the quaternion to store the result
  71774. * @returns the updated quaternion
  71775. */
  71776. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  71777. /**
  71778. * Creates a new quaternion from the given Euler float angles (y, x, z)
  71779. * @param yaw defines the rotation around Y axis
  71780. * @param pitch defines the rotation around X axis
  71781. * @param roll defines the rotation around Z axis
  71782. * @returns the new quaternion
  71783. */
  71784. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  71785. /**
  71786. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  71787. * @param yaw defines the rotation around Y axis
  71788. * @param pitch defines the rotation around X axis
  71789. * @param roll defines the rotation around Z axis
  71790. * @param result defines the target quaternion
  71791. */
  71792. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  71793. /**
  71794. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  71795. * @param alpha defines the rotation around first axis
  71796. * @param beta defines the rotation around second axis
  71797. * @param gamma defines the rotation around third axis
  71798. * @returns the new quaternion
  71799. */
  71800. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  71801. /**
  71802. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  71803. * @param alpha defines the rotation around first axis
  71804. * @param beta defines the rotation around second axis
  71805. * @param gamma defines the rotation around third axis
  71806. * @param result defines the target quaternion
  71807. */
  71808. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  71809. /**
  71810. * 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)
  71811. * @param axis1 defines the first axis
  71812. * @param axis2 defines the second axis
  71813. * @param axis3 defines the third axis
  71814. * @returns the new quaternion
  71815. */
  71816. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  71817. /**
  71818. * 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
  71819. * @param axis1 defines the first axis
  71820. * @param axis2 defines the second axis
  71821. * @param axis3 defines the third axis
  71822. * @param ref defines the target quaternion
  71823. */
  71824. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  71825. /**
  71826. * Interpolates between two quaternions
  71827. * @param left defines first quaternion
  71828. * @param right defines second quaternion
  71829. * @param amount defines the gradient to use
  71830. * @returns the new interpolated quaternion
  71831. */
  71832. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71833. /**
  71834. * Interpolates between two quaternions and stores it into a target quaternion
  71835. * @param left defines first quaternion
  71836. * @param right defines second quaternion
  71837. * @param amount defines the gradient to use
  71838. * @param result defines the target quaternion
  71839. */
  71840. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  71841. /**
  71842. * Interpolate between two quaternions using Hermite interpolation
  71843. * @param value1 defines first quaternion
  71844. * @param tangent1 defines the incoming tangent
  71845. * @param value2 defines second quaternion
  71846. * @param tangent2 defines the outgoing tangent
  71847. * @param amount defines the target quaternion
  71848. * @returns the new interpolated quaternion
  71849. */
  71850. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71851. }
  71852. /**
  71853. * Class used to store matrix data (4x4)
  71854. */
  71855. export class Matrix {
  71856. private static _updateFlagSeed;
  71857. private static _identityReadOnly;
  71858. private _isIdentity;
  71859. private _isIdentityDirty;
  71860. private _isIdentity3x2;
  71861. private _isIdentity3x2Dirty;
  71862. /**
  71863. * Gets the update flag of the matrix which is an unique number for the matrix.
  71864. * It will be incremented every time the matrix data change.
  71865. * You can use it to speed the comparison between two versions of the same matrix.
  71866. */
  71867. updateFlag: number;
  71868. private readonly _m;
  71869. /**
  71870. * Gets the internal data of the matrix
  71871. */
  71872. readonly m: DeepImmutable<Float32Array>;
  71873. /** @hidden */
  71874. _markAsUpdated(): void;
  71875. /** @hidden */
  71876. private _updateIdentityStatus;
  71877. /**
  71878. * Creates an empty matrix (filled with zeros)
  71879. */
  71880. constructor();
  71881. /**
  71882. * Check if the current matrix is identity
  71883. * @returns true is the matrix is the identity matrix
  71884. */
  71885. isIdentity(): boolean;
  71886. /**
  71887. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71888. * @returns true is the matrix is the identity matrix
  71889. */
  71890. isIdentityAs3x2(): boolean;
  71891. /**
  71892. * Gets the determinant of the matrix
  71893. * @returns the matrix determinant
  71894. */
  71895. determinant(): number;
  71896. /**
  71897. * Returns the matrix as a Float32Array
  71898. * @returns the matrix underlying array
  71899. */
  71900. toArray(): DeepImmutable<Float32Array>;
  71901. /**
  71902. * Returns the matrix as a Float32Array
  71903. * @returns the matrix underlying array.
  71904. */
  71905. asArray(): DeepImmutable<Float32Array>;
  71906. /**
  71907. * Inverts the current matrix in place
  71908. * @returns the current inverted matrix
  71909. */
  71910. invert(): Matrix;
  71911. /**
  71912. * Sets all the matrix elements to zero
  71913. * @returns the current matrix
  71914. */
  71915. reset(): Matrix;
  71916. /**
  71917. * Adds the current matrix with a second one
  71918. * @param other defines the matrix to add
  71919. * @returns a new matrix as the addition of the current matrix and the given one
  71920. */
  71921. add(other: DeepImmutable<Matrix>): Matrix;
  71922. /**
  71923. * Sets the given matrix "result" to the addition of the current matrix and the given one
  71924. * @param other defines the matrix to add
  71925. * @param result defines the target matrix
  71926. * @returns the current matrix
  71927. */
  71928. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71929. /**
  71930. * Adds in place the given matrix to the current matrix
  71931. * @param other defines the second operand
  71932. * @returns the current updated matrix
  71933. */
  71934. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  71935. /**
  71936. * Sets the given matrix to the current inverted Matrix
  71937. * @param other defines the target matrix
  71938. * @returns the unmodified current matrix
  71939. */
  71940. invertToRef(other: Matrix): Matrix;
  71941. /**
  71942. * add a value at the specified position in the current Matrix
  71943. * @param index the index of the value within the matrix. between 0 and 15.
  71944. * @param value the value to be added
  71945. * @returns the current updated matrix
  71946. */
  71947. addAtIndex(index: number, value: number): Matrix;
  71948. /**
  71949. * mutiply the specified position in the current Matrix by a value
  71950. * @param index the index of the value within the matrix. between 0 and 15.
  71951. * @param value the value to be added
  71952. * @returns the current updated matrix
  71953. */
  71954. multiplyAtIndex(index: number, value: number): Matrix;
  71955. /**
  71956. * Inserts the translation vector (using 3 floats) in the current matrix
  71957. * @param x defines the 1st component of the translation
  71958. * @param y defines the 2nd component of the translation
  71959. * @param z defines the 3rd component of the translation
  71960. * @returns the current updated matrix
  71961. */
  71962. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71963. /**
  71964. * Adds the translation vector (using 3 floats) in the current matrix
  71965. * @param x defines the 1st component of the translation
  71966. * @param y defines the 2nd component of the translation
  71967. * @param z defines the 3rd component of the translation
  71968. * @returns the current updated matrix
  71969. */
  71970. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71971. /**
  71972. * Inserts the translation vector in the current matrix
  71973. * @param vector3 defines the translation to insert
  71974. * @returns the current updated matrix
  71975. */
  71976. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  71977. /**
  71978. * Gets the translation value of the current matrix
  71979. * @returns a new Vector3 as the extracted translation from the matrix
  71980. */
  71981. getTranslation(): Vector3;
  71982. /**
  71983. * Fill a Vector3 with the extracted translation from the matrix
  71984. * @param result defines the Vector3 where to store the translation
  71985. * @returns the current matrix
  71986. */
  71987. getTranslationToRef(result: Vector3): Matrix;
  71988. /**
  71989. * Remove rotation and scaling part from the matrix
  71990. * @returns the updated matrix
  71991. */
  71992. removeRotationAndScaling(): Matrix;
  71993. /**
  71994. * Multiply two matrices
  71995. * @param other defines the second operand
  71996. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  71997. */
  71998. multiply(other: DeepImmutable<Matrix>): Matrix;
  71999. /**
  72000. * Copy the current matrix from the given one
  72001. * @param other defines the source matrix
  72002. * @returns the current updated matrix
  72003. */
  72004. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  72005. /**
  72006. * Populates the given array from the starting index with the current matrix values
  72007. * @param array defines the target array
  72008. * @param offset defines the offset in the target array where to start storing values
  72009. * @returns the current matrix
  72010. */
  72011. copyToArray(array: Float32Array, offset?: number): Matrix;
  72012. /**
  72013. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  72014. * @param other defines the second operand
  72015. * @param result defines the matrix where to store the multiplication
  72016. * @returns the current matrix
  72017. */
  72018. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72019. /**
  72020. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  72021. * @param other defines the second operand
  72022. * @param result defines the array where to store the multiplication
  72023. * @param offset defines the offset in the target array where to start storing values
  72024. * @returns the current matrix
  72025. */
  72026. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  72027. /**
  72028. * Check equality between this matrix and a second one
  72029. * @param value defines the second matrix to compare
  72030. * @returns true is the current matrix and the given one values are strictly equal
  72031. */
  72032. equals(value: DeepImmutable<Matrix>): boolean;
  72033. /**
  72034. * Clone the current matrix
  72035. * @returns a new matrix from the current matrix
  72036. */
  72037. clone(): Matrix;
  72038. /**
  72039. * Returns the name of the current matrix class
  72040. * @returns the string "Matrix"
  72041. */
  72042. getClassName(): string;
  72043. /**
  72044. * Gets the hash code of the current matrix
  72045. * @returns the hash code
  72046. */
  72047. getHashCode(): number;
  72048. /**
  72049. * Decomposes the current Matrix into a translation, rotation and scaling components
  72050. * @param scale defines the scale vector3 given as a reference to update
  72051. * @param rotation defines the rotation quaternion given as a reference to update
  72052. * @param translation defines the translation vector3 given as a reference to update
  72053. * @returns true if operation was successful
  72054. */
  72055. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  72056. /**
  72057. * Gets specific row of the matrix
  72058. * @param index defines the number of the row to get
  72059. * @returns the index-th row of the current matrix as a new Vector4
  72060. */
  72061. getRow(index: number): Nullable<Vector4>;
  72062. /**
  72063. * Sets the index-th row of the current matrix to the vector4 values
  72064. * @param index defines the number of the row to set
  72065. * @param row defines the target vector4
  72066. * @returns the updated current matrix
  72067. */
  72068. setRow(index: number, row: Vector4): Matrix;
  72069. /**
  72070. * Compute the transpose of the matrix
  72071. * @returns the new transposed matrix
  72072. */
  72073. transpose(): Matrix;
  72074. /**
  72075. * Compute the transpose of the matrix and store it in a given matrix
  72076. * @param result defines the target matrix
  72077. * @returns the current matrix
  72078. */
  72079. transposeToRef(result: Matrix): Matrix;
  72080. /**
  72081. * Sets the index-th row of the current matrix with the given 4 x float values
  72082. * @param index defines the row index
  72083. * @param x defines the x component to set
  72084. * @param y defines the y component to set
  72085. * @param z defines the z component to set
  72086. * @param w defines the w component to set
  72087. * @returns the updated current matrix
  72088. */
  72089. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  72090. /**
  72091. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  72092. * @param scale defines the scale factor
  72093. * @returns a new matrix
  72094. */
  72095. scale(scale: number): Matrix;
  72096. /**
  72097. * Scale the current matrix values by a factor to a given result matrix
  72098. * @param scale defines the scale factor
  72099. * @param result defines the matrix to store the result
  72100. * @returns the current matrix
  72101. */
  72102. scaleToRef(scale: number, result: Matrix): Matrix;
  72103. /**
  72104. * Scale the current matrix values by a factor and add the result to a given matrix
  72105. * @param scale defines the scale factor
  72106. * @param result defines the Matrix to store the result
  72107. * @returns the current matrix
  72108. */
  72109. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  72110. /**
  72111. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  72112. * @param ref matrix to store the result
  72113. */
  72114. toNormalMatrix(ref: Matrix): void;
  72115. /**
  72116. * Gets only rotation part of the current matrix
  72117. * @returns a new matrix sets to the extracted rotation matrix from the current one
  72118. */
  72119. getRotationMatrix(): Matrix;
  72120. /**
  72121. * Extracts the rotation matrix from the current one and sets it as the given "result"
  72122. * @param result defines the target matrix to store data to
  72123. * @returns the current matrix
  72124. */
  72125. getRotationMatrixToRef(result: Matrix): Matrix;
  72126. /**
  72127. * Toggles model matrix from being right handed to left handed in place and vice versa
  72128. */
  72129. toggleModelMatrixHandInPlace(): void;
  72130. /**
  72131. * Toggles projection matrix from being right handed to left handed in place and vice versa
  72132. */
  72133. toggleProjectionMatrixHandInPlace(): void;
  72134. /**
  72135. * Creates a matrix from an array
  72136. * @param array defines the source array
  72137. * @param offset defines an offset in the source array
  72138. * @returns a new Matrix set from the starting index of the given array
  72139. */
  72140. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  72141. /**
  72142. * Copy the content of an array into a given matrix
  72143. * @param array defines the source array
  72144. * @param offset defines an offset in the source array
  72145. * @param result defines the target matrix
  72146. */
  72147. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  72148. /**
  72149. * Stores an array into a matrix after having multiplied each component by a given factor
  72150. * @param array defines the source array
  72151. * @param offset defines the offset in the source array
  72152. * @param scale defines the scaling factor
  72153. * @param result defines the target matrix
  72154. */
  72155. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  72156. /**
  72157. * Gets an identity matrix that must not be updated
  72158. */
  72159. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  72160. /**
  72161. * Stores a list of values (16) inside a given matrix
  72162. * @param initialM11 defines 1st value of 1st row
  72163. * @param initialM12 defines 2nd value of 1st row
  72164. * @param initialM13 defines 3rd value of 1st row
  72165. * @param initialM14 defines 4th value of 1st row
  72166. * @param initialM21 defines 1st value of 2nd row
  72167. * @param initialM22 defines 2nd value of 2nd row
  72168. * @param initialM23 defines 3rd value of 2nd row
  72169. * @param initialM24 defines 4th value of 2nd row
  72170. * @param initialM31 defines 1st value of 3rd row
  72171. * @param initialM32 defines 2nd value of 3rd row
  72172. * @param initialM33 defines 3rd value of 3rd row
  72173. * @param initialM34 defines 4th value of 3rd row
  72174. * @param initialM41 defines 1st value of 4th row
  72175. * @param initialM42 defines 2nd value of 4th row
  72176. * @param initialM43 defines 3rd value of 4th row
  72177. * @param initialM44 defines 4th value of 4th row
  72178. * @param result defines the target matrix
  72179. */
  72180. 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;
  72181. /**
  72182. * Creates new matrix from a list of values (16)
  72183. * @param initialM11 defines 1st value of 1st row
  72184. * @param initialM12 defines 2nd value of 1st row
  72185. * @param initialM13 defines 3rd value of 1st row
  72186. * @param initialM14 defines 4th value of 1st row
  72187. * @param initialM21 defines 1st value of 2nd row
  72188. * @param initialM22 defines 2nd value of 2nd row
  72189. * @param initialM23 defines 3rd value of 2nd row
  72190. * @param initialM24 defines 4th value of 2nd row
  72191. * @param initialM31 defines 1st value of 3rd row
  72192. * @param initialM32 defines 2nd value of 3rd row
  72193. * @param initialM33 defines 3rd value of 3rd row
  72194. * @param initialM34 defines 4th value of 3rd row
  72195. * @param initialM41 defines 1st value of 4th row
  72196. * @param initialM42 defines 2nd value of 4th row
  72197. * @param initialM43 defines 3rd value of 4th row
  72198. * @param initialM44 defines 4th value of 4th row
  72199. * @returns the new matrix
  72200. */
  72201. 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;
  72202. /**
  72203. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72204. * @param scale defines the scale vector3
  72205. * @param rotation defines the rotation quaternion
  72206. * @param translation defines the translation vector3
  72207. * @returns a new matrix
  72208. */
  72209. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  72210. /**
  72211. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72212. * @param scale defines the scale vector3
  72213. * @param rotation defines the rotation quaternion
  72214. * @param translation defines the translation vector3
  72215. * @param result defines the target matrix
  72216. */
  72217. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  72218. /**
  72219. * Creates a new identity matrix
  72220. * @returns a new identity matrix
  72221. */
  72222. static Identity(): Matrix;
  72223. /**
  72224. * Creates a new identity matrix and stores the result in a given matrix
  72225. * @param result defines the target matrix
  72226. */
  72227. static IdentityToRef(result: Matrix): void;
  72228. /**
  72229. * Creates a new zero matrix
  72230. * @returns a new zero matrix
  72231. */
  72232. static Zero(): Matrix;
  72233. /**
  72234. * Creates a new rotation matrix for "angle" radians around the X axis
  72235. * @param angle defines the angle (in radians) to use
  72236. * @return the new matrix
  72237. */
  72238. static RotationX(angle: number): Matrix;
  72239. /**
  72240. * Creates a new matrix as the invert of a given matrix
  72241. * @param source defines the source matrix
  72242. * @returns the new matrix
  72243. */
  72244. static Invert(source: DeepImmutable<Matrix>): Matrix;
  72245. /**
  72246. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  72247. * @param angle defines the angle (in radians) to use
  72248. * @param result defines the target matrix
  72249. */
  72250. static RotationXToRef(angle: number, result: Matrix): void;
  72251. /**
  72252. * Creates a new rotation matrix for "angle" radians around the Y axis
  72253. * @param angle defines the angle (in radians) to use
  72254. * @return the new matrix
  72255. */
  72256. static RotationY(angle: number): Matrix;
  72257. /**
  72258. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  72259. * @param angle defines the angle (in radians) to use
  72260. * @param result defines the target matrix
  72261. */
  72262. static RotationYToRef(angle: number, result: Matrix): void;
  72263. /**
  72264. * Creates a new rotation matrix for "angle" radians around the Z axis
  72265. * @param angle defines the angle (in radians) to use
  72266. * @return the new matrix
  72267. */
  72268. static RotationZ(angle: number): Matrix;
  72269. /**
  72270. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  72271. * @param angle defines the angle (in radians) to use
  72272. * @param result defines the target matrix
  72273. */
  72274. static RotationZToRef(angle: number, result: Matrix): void;
  72275. /**
  72276. * Creates a new rotation matrix for "angle" radians around the given axis
  72277. * @param axis defines the axis to use
  72278. * @param angle defines the angle (in radians) to use
  72279. * @return the new matrix
  72280. */
  72281. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  72282. /**
  72283. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  72284. * @param axis defines the axis to use
  72285. * @param angle defines the angle (in radians) to use
  72286. * @param result defines the target matrix
  72287. */
  72288. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  72289. /**
  72290. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  72291. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  72292. * @param from defines the vector to align
  72293. * @param to defines the vector to align to
  72294. * @param result defines the target matrix
  72295. */
  72296. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  72297. /**
  72298. * Creates a rotation matrix
  72299. * @param yaw defines the yaw angle in radians (Y axis)
  72300. * @param pitch defines the pitch angle in radians (X axis)
  72301. * @param roll defines the roll angle in radians (X axis)
  72302. * @returns the new rotation matrix
  72303. */
  72304. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  72305. /**
  72306. * Creates a rotation matrix and stores it in a given matrix
  72307. * @param yaw defines the yaw angle in radians (Y axis)
  72308. * @param pitch defines the pitch angle in radians (X axis)
  72309. * @param roll defines the roll angle in radians (X axis)
  72310. * @param result defines the target matrix
  72311. */
  72312. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  72313. /**
  72314. * Creates a scaling matrix
  72315. * @param x defines the scale factor on X axis
  72316. * @param y defines the scale factor on Y axis
  72317. * @param z defines the scale factor on Z axis
  72318. * @returns the new matrix
  72319. */
  72320. static Scaling(x: number, y: number, z: number): Matrix;
  72321. /**
  72322. * Creates a scaling matrix and stores it in a given matrix
  72323. * @param x defines the scale factor on X axis
  72324. * @param y defines the scale factor on Y axis
  72325. * @param z defines the scale factor on Z axis
  72326. * @param result defines the target matrix
  72327. */
  72328. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  72329. /**
  72330. * Creates a translation matrix
  72331. * @param x defines the translation on X axis
  72332. * @param y defines the translation on Y axis
  72333. * @param z defines the translationon Z axis
  72334. * @returns the new matrix
  72335. */
  72336. static Translation(x: number, y: number, z: number): Matrix;
  72337. /**
  72338. * Creates a translation matrix and stores it in a given matrix
  72339. * @param x defines the translation on X axis
  72340. * @param y defines the translation on Y axis
  72341. * @param z defines the translationon Z axis
  72342. * @param result defines the target matrix
  72343. */
  72344. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  72345. /**
  72346. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72347. * @param startValue defines the start value
  72348. * @param endValue defines the end value
  72349. * @param gradient defines the gradient factor
  72350. * @returns the new matrix
  72351. */
  72352. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72353. /**
  72354. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72355. * @param startValue defines the start value
  72356. * @param endValue defines the end value
  72357. * @param gradient defines the gradient factor
  72358. * @param result defines the Matrix object where to store data
  72359. */
  72360. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72361. /**
  72362. * Builds a new matrix whose values are computed by:
  72363. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72364. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72365. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72366. * @param startValue defines the first matrix
  72367. * @param endValue defines the second matrix
  72368. * @param gradient defines the gradient between the two matrices
  72369. * @returns the new matrix
  72370. */
  72371. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72372. /**
  72373. * Update a matrix to values which are computed by:
  72374. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72375. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72376. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72377. * @param startValue defines the first matrix
  72378. * @param endValue defines the second matrix
  72379. * @param gradient defines the gradient between the two matrices
  72380. * @param result defines the target matrix
  72381. */
  72382. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72383. /**
  72384. * 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"
  72385. * This function works in left handed mode
  72386. * @param eye defines the final position of the entity
  72387. * @param target defines where the entity should look at
  72388. * @param up defines the up vector for the entity
  72389. * @returns the new matrix
  72390. */
  72391. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72392. /**
  72393. * 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".
  72394. * This function works in left handed mode
  72395. * @param eye defines the final position of the entity
  72396. * @param target defines where the entity should look at
  72397. * @param up defines the up vector for the entity
  72398. * @param result defines the target matrix
  72399. */
  72400. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72401. /**
  72402. * 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"
  72403. * This function works in right handed mode
  72404. * @param eye defines the final position of the entity
  72405. * @param target defines where the entity should look at
  72406. * @param up defines the up vector for the entity
  72407. * @returns the new matrix
  72408. */
  72409. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72410. /**
  72411. * 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".
  72412. * This function works in right handed mode
  72413. * @param eye defines the final position of the entity
  72414. * @param target defines where the entity should look at
  72415. * @param up defines the up vector for the entity
  72416. * @param result defines the target matrix
  72417. */
  72418. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72419. /**
  72420. * Create a left-handed orthographic projection matrix
  72421. * @param width defines the viewport width
  72422. * @param height defines the viewport height
  72423. * @param znear defines the near clip plane
  72424. * @param zfar defines the far clip plane
  72425. * @returns a new matrix as a left-handed orthographic projection matrix
  72426. */
  72427. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72428. /**
  72429. * Store a left-handed orthographic projection to a given matrix
  72430. * @param width defines the viewport width
  72431. * @param height defines the viewport height
  72432. * @param znear defines the near clip plane
  72433. * @param zfar defines the far clip plane
  72434. * @param result defines the target matrix
  72435. */
  72436. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  72437. /**
  72438. * Create a left-handed orthographic projection matrix
  72439. * @param left defines the viewport left coordinate
  72440. * @param right defines the viewport right coordinate
  72441. * @param bottom defines the viewport bottom coordinate
  72442. * @param top defines the viewport top coordinate
  72443. * @param znear defines the near clip plane
  72444. * @param zfar defines the far clip plane
  72445. * @returns a new matrix as a left-handed orthographic projection matrix
  72446. */
  72447. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72448. /**
  72449. * Stores a left-handed orthographic projection into a given matrix
  72450. * @param left defines the viewport left coordinate
  72451. * @param right defines the viewport right coordinate
  72452. * @param bottom defines the viewport bottom coordinate
  72453. * @param top defines the viewport top coordinate
  72454. * @param znear defines the near clip plane
  72455. * @param zfar defines the far clip plane
  72456. * @param result defines the target matrix
  72457. */
  72458. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72459. /**
  72460. * Creates a right-handed orthographic projection matrix
  72461. * @param left defines the viewport left coordinate
  72462. * @param right defines the viewport right coordinate
  72463. * @param bottom defines the viewport bottom coordinate
  72464. * @param top defines the viewport top coordinate
  72465. * @param znear defines the near clip plane
  72466. * @param zfar defines the far clip plane
  72467. * @returns a new matrix as a right-handed orthographic projection matrix
  72468. */
  72469. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72470. /**
  72471. * Stores a right-handed orthographic projection into a given matrix
  72472. * @param left defines the viewport left coordinate
  72473. * @param right defines the viewport right coordinate
  72474. * @param bottom defines the viewport bottom coordinate
  72475. * @param top defines the viewport top coordinate
  72476. * @param znear defines the near clip plane
  72477. * @param zfar defines the far clip plane
  72478. * @param result defines the target matrix
  72479. */
  72480. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72481. /**
  72482. * Creates a left-handed perspective projection matrix
  72483. * @param width defines the viewport width
  72484. * @param height defines the viewport height
  72485. * @param znear defines the near clip plane
  72486. * @param zfar defines the far clip plane
  72487. * @returns a new matrix as a left-handed perspective projection matrix
  72488. */
  72489. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72490. /**
  72491. * Creates a left-handed perspective projection matrix
  72492. * @param fov defines the horizontal field of view
  72493. * @param aspect defines the aspect ratio
  72494. * @param znear defines the near clip plane
  72495. * @param zfar defines the far clip plane
  72496. * @returns a new matrix as a left-handed perspective projection matrix
  72497. */
  72498. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72499. /**
  72500. * Stores a left-handed perspective projection into a given matrix
  72501. * @param fov defines the horizontal field of view
  72502. * @param aspect defines the aspect ratio
  72503. * @param znear defines the near clip plane
  72504. * @param zfar defines the far clip plane
  72505. * @param result defines the target matrix
  72506. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72507. */
  72508. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72509. /**
  72510. * Creates a right-handed perspective projection matrix
  72511. * @param fov defines the horizontal field of view
  72512. * @param aspect defines the aspect ratio
  72513. * @param znear defines the near clip plane
  72514. * @param zfar defines the far clip plane
  72515. * @returns a new matrix as a right-handed perspective projection matrix
  72516. */
  72517. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72518. /**
  72519. * Stores a right-handed perspective projection into a given matrix
  72520. * @param fov defines the horizontal field of view
  72521. * @param aspect defines the aspect ratio
  72522. * @param znear defines the near clip plane
  72523. * @param zfar defines the far clip plane
  72524. * @param result defines the target matrix
  72525. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72526. */
  72527. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72528. /**
  72529. * Stores a perspective projection for WebVR info a given matrix
  72530. * @param fov defines the field of view
  72531. * @param znear defines the near clip plane
  72532. * @param zfar defines the far clip plane
  72533. * @param result defines the target matrix
  72534. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  72535. */
  72536. static PerspectiveFovWebVRToRef(fov: {
  72537. upDegrees: number;
  72538. downDegrees: number;
  72539. leftDegrees: number;
  72540. rightDegrees: number;
  72541. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  72542. /**
  72543. * Computes a complete transformation matrix
  72544. * @param viewport defines the viewport to use
  72545. * @param world defines the world matrix
  72546. * @param view defines the view matrix
  72547. * @param projection defines the projection matrix
  72548. * @param zmin defines the near clip plane
  72549. * @param zmax defines the far clip plane
  72550. * @returns the transformation matrix
  72551. */
  72552. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  72553. /**
  72554. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  72555. * @param matrix defines the matrix to use
  72556. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  72557. */
  72558. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  72559. /**
  72560. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  72561. * @param matrix defines the matrix to use
  72562. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  72563. */
  72564. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  72565. /**
  72566. * Compute the transpose of a given matrix
  72567. * @param matrix defines the matrix to transpose
  72568. * @returns the new matrix
  72569. */
  72570. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  72571. /**
  72572. * Compute the transpose of a matrix and store it in a target matrix
  72573. * @param matrix defines the matrix to transpose
  72574. * @param result defines the target matrix
  72575. */
  72576. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  72577. /**
  72578. * Computes a reflection matrix from a plane
  72579. * @param plane defines the reflection plane
  72580. * @returns a new matrix
  72581. */
  72582. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  72583. /**
  72584. * Computes a reflection matrix from a plane
  72585. * @param plane defines the reflection plane
  72586. * @param result defines the target matrix
  72587. */
  72588. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  72589. /**
  72590. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  72591. * @param xaxis defines the value of the 1st axis
  72592. * @param yaxis defines the value of the 2nd axis
  72593. * @param zaxis defines the value of the 3rd axis
  72594. * @param result defines the target matrix
  72595. */
  72596. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  72597. /**
  72598. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  72599. * @param quat defines the quaternion to use
  72600. * @param result defines the target matrix
  72601. */
  72602. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  72603. }
  72604. /**
  72605. * @hidden
  72606. */
  72607. export class TmpVectors {
  72608. static Vector2: Vector2[];
  72609. static Vector3: Vector3[];
  72610. static Vector4: Vector4[];
  72611. static Quaternion: Quaternion[];
  72612. static Matrix: Matrix[];
  72613. }
  72614. }
  72615. declare module BABYLON {
  72616. /**
  72617. * Defines potential orientation for back face culling
  72618. */
  72619. export enum Orientation {
  72620. /**
  72621. * Clockwise
  72622. */
  72623. CW = 0,
  72624. /** Counter clockwise */
  72625. CCW = 1
  72626. }
  72627. /** Class used to represent a Bezier curve */
  72628. export class BezierCurve {
  72629. /**
  72630. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  72631. * @param t defines the time
  72632. * @param x1 defines the left coordinate on X axis
  72633. * @param y1 defines the left coordinate on Y axis
  72634. * @param x2 defines the right coordinate on X axis
  72635. * @param y2 defines the right coordinate on Y axis
  72636. * @returns the interpolated value
  72637. */
  72638. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  72639. }
  72640. /**
  72641. * Defines angle representation
  72642. */
  72643. export class Angle {
  72644. private _radians;
  72645. /**
  72646. * Creates an Angle object of "radians" radians (float).
  72647. * @param radians the angle in radians
  72648. */
  72649. constructor(radians: number);
  72650. /**
  72651. * Get value in degrees
  72652. * @returns the Angle value in degrees (float)
  72653. */
  72654. degrees(): number;
  72655. /**
  72656. * Get value in radians
  72657. * @returns the Angle value in radians (float)
  72658. */
  72659. radians(): number;
  72660. /**
  72661. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  72662. * @param a defines first vector
  72663. * @param b defines second vector
  72664. * @returns a new Angle
  72665. */
  72666. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  72667. /**
  72668. * Gets a new Angle object from the given float in radians
  72669. * @param radians defines the angle value in radians
  72670. * @returns a new Angle
  72671. */
  72672. static FromRadians(radians: number): Angle;
  72673. /**
  72674. * Gets a new Angle object from the given float in degrees
  72675. * @param degrees defines the angle value in degrees
  72676. * @returns a new Angle
  72677. */
  72678. static FromDegrees(degrees: number): Angle;
  72679. }
  72680. /**
  72681. * This represents an arc in a 2d space.
  72682. */
  72683. export class Arc2 {
  72684. /** Defines the start point of the arc */
  72685. startPoint: Vector2;
  72686. /** Defines the mid point of the arc */
  72687. midPoint: Vector2;
  72688. /** Defines the end point of the arc */
  72689. endPoint: Vector2;
  72690. /**
  72691. * Defines the center point of the arc.
  72692. */
  72693. centerPoint: Vector2;
  72694. /**
  72695. * Defines the radius of the arc.
  72696. */
  72697. radius: number;
  72698. /**
  72699. * Defines the angle of the arc (from mid point to end point).
  72700. */
  72701. angle: Angle;
  72702. /**
  72703. * Defines the start angle of the arc (from start point to middle point).
  72704. */
  72705. startAngle: Angle;
  72706. /**
  72707. * Defines the orientation of the arc (clock wise/counter clock wise).
  72708. */
  72709. orientation: Orientation;
  72710. /**
  72711. * Creates an Arc object from the three given points : start, middle and end.
  72712. * @param startPoint Defines the start point of the arc
  72713. * @param midPoint Defines the midlle point of the arc
  72714. * @param endPoint Defines the end point of the arc
  72715. */
  72716. constructor(
  72717. /** Defines the start point of the arc */
  72718. startPoint: Vector2,
  72719. /** Defines the mid point of the arc */
  72720. midPoint: Vector2,
  72721. /** Defines the end point of the arc */
  72722. endPoint: Vector2);
  72723. }
  72724. /**
  72725. * Represents a 2D path made up of multiple 2D points
  72726. */
  72727. export class Path2 {
  72728. private _points;
  72729. private _length;
  72730. /**
  72731. * If the path start and end point are the same
  72732. */
  72733. closed: boolean;
  72734. /**
  72735. * Creates a Path2 object from the starting 2D coordinates x and y.
  72736. * @param x the starting points x value
  72737. * @param y the starting points y value
  72738. */
  72739. constructor(x: number, y: number);
  72740. /**
  72741. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  72742. * @param x the added points x value
  72743. * @param y the added points y value
  72744. * @returns the updated Path2.
  72745. */
  72746. addLineTo(x: number, y: number): Path2;
  72747. /**
  72748. * 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.
  72749. * @param midX middle point x value
  72750. * @param midY middle point y value
  72751. * @param endX end point x value
  72752. * @param endY end point y value
  72753. * @param numberOfSegments (default: 36)
  72754. * @returns the updated Path2.
  72755. */
  72756. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  72757. /**
  72758. * Closes the Path2.
  72759. * @returns the Path2.
  72760. */
  72761. close(): Path2;
  72762. /**
  72763. * Gets the sum of the distance between each sequential point in the path
  72764. * @returns the Path2 total length (float).
  72765. */
  72766. length(): number;
  72767. /**
  72768. * Gets the points which construct the path
  72769. * @returns the Path2 internal array of points.
  72770. */
  72771. getPoints(): Vector2[];
  72772. /**
  72773. * Retreives the point at the distance aways from the starting point
  72774. * @param normalizedLengthPosition the length along the path to retreive the point from
  72775. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  72776. */
  72777. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  72778. /**
  72779. * Creates a new path starting from an x and y position
  72780. * @param x starting x value
  72781. * @param y starting y value
  72782. * @returns a new Path2 starting at the coordinates (x, y).
  72783. */
  72784. static StartingAt(x: number, y: number): Path2;
  72785. }
  72786. /**
  72787. * Represents a 3D path made up of multiple 3D points
  72788. */
  72789. export class Path3D {
  72790. /**
  72791. * an array of Vector3, the curve axis of the Path3D
  72792. */
  72793. path: Vector3[];
  72794. private _curve;
  72795. private _distances;
  72796. private _tangents;
  72797. private _normals;
  72798. private _binormals;
  72799. private _raw;
  72800. /**
  72801. * new Path3D(path, normal, raw)
  72802. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  72803. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  72804. * @param path an array of Vector3, the curve axis of the Path3D
  72805. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  72806. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  72807. */
  72808. constructor(
  72809. /**
  72810. * an array of Vector3, the curve axis of the Path3D
  72811. */
  72812. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  72813. /**
  72814. * Returns the Path3D array of successive Vector3 designing its curve.
  72815. * @returns the Path3D array of successive Vector3 designing its curve.
  72816. */
  72817. getCurve(): Vector3[];
  72818. /**
  72819. * Returns an array populated with tangent vectors on each Path3D curve point.
  72820. * @returns an array populated with tangent vectors on each Path3D curve point.
  72821. */
  72822. getTangents(): Vector3[];
  72823. /**
  72824. * Returns an array populated with normal vectors on each Path3D curve point.
  72825. * @returns an array populated with normal vectors on each Path3D curve point.
  72826. */
  72827. getNormals(): Vector3[];
  72828. /**
  72829. * Returns an array populated with binormal vectors on each Path3D curve point.
  72830. * @returns an array populated with binormal vectors on each Path3D curve point.
  72831. */
  72832. getBinormals(): Vector3[];
  72833. /**
  72834. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72835. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72836. */
  72837. getDistances(): number[];
  72838. /**
  72839. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  72840. * @param path path which all values are copied into the curves points
  72841. * @param firstNormal which should be projected onto the curve
  72842. * @returns the same object updated.
  72843. */
  72844. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  72845. private _compute;
  72846. private _getFirstNonNullVector;
  72847. private _getLastNonNullVector;
  72848. private _normalVector;
  72849. }
  72850. /**
  72851. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72852. * A Curve3 is designed from a series of successive Vector3.
  72853. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  72854. */
  72855. export class Curve3 {
  72856. private _points;
  72857. private _length;
  72858. /**
  72859. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  72860. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  72861. * @param v1 (Vector3) the control point
  72862. * @param v2 (Vector3) the end point of the Quadratic Bezier
  72863. * @param nbPoints (integer) the wanted number of points in the curve
  72864. * @returns the created Curve3
  72865. */
  72866. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72867. /**
  72868. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  72869. * @param v0 (Vector3) the origin point of the Cubic Bezier
  72870. * @param v1 (Vector3) the first control point
  72871. * @param v2 (Vector3) the second control point
  72872. * @param v3 (Vector3) the end point of the Cubic Bezier
  72873. * @param nbPoints (integer) the wanted number of points in the curve
  72874. * @returns the created Curve3
  72875. */
  72876. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72877. /**
  72878. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  72879. * @param p1 (Vector3) the origin point of the Hermite Spline
  72880. * @param t1 (Vector3) the tangent vector at the origin point
  72881. * @param p2 (Vector3) the end point of the Hermite Spline
  72882. * @param t2 (Vector3) the tangent vector at the end point
  72883. * @param nbPoints (integer) the wanted number of points in the curve
  72884. * @returns the created Curve3
  72885. */
  72886. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72887. /**
  72888. * Returns a Curve3 object along a CatmullRom Spline curve :
  72889. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  72890. * @param nbPoints (integer) the wanted number of points between each curve control points
  72891. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  72892. * @returns the created Curve3
  72893. */
  72894. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  72895. /**
  72896. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72897. * A Curve3 is designed from a series of successive Vector3.
  72898. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  72899. * @param points points which make up the curve
  72900. */
  72901. constructor(points: Vector3[]);
  72902. /**
  72903. * @returns the Curve3 stored array of successive Vector3
  72904. */
  72905. getPoints(): Vector3[];
  72906. /**
  72907. * @returns the computed length (float) of the curve.
  72908. */
  72909. length(): number;
  72910. /**
  72911. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  72912. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  72913. * curveA and curveB keep unchanged.
  72914. * @param curve the curve to continue from this curve
  72915. * @returns the newly constructed curve
  72916. */
  72917. continue(curve: DeepImmutable<Curve3>): Curve3;
  72918. private _computeLength;
  72919. }
  72920. }
  72921. declare module BABYLON {
  72922. /**
  72923. * This represents the main contract an easing function should follow.
  72924. * Easing functions are used throughout the animation system.
  72925. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72926. */
  72927. export interface IEasingFunction {
  72928. /**
  72929. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72930. * of the easing function.
  72931. * The link below provides some of the most common examples of easing functions.
  72932. * @see https://easings.net/
  72933. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72934. * @returns the corresponding value on the curve defined by the easing function
  72935. */
  72936. ease(gradient: number): number;
  72937. }
  72938. /**
  72939. * Base class used for every default easing function.
  72940. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72941. */
  72942. export class EasingFunction implements IEasingFunction {
  72943. /**
  72944. * Interpolation follows the mathematical formula associated with the easing function.
  72945. */
  72946. static readonly EASINGMODE_EASEIN: number;
  72947. /**
  72948. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72949. */
  72950. static readonly EASINGMODE_EASEOUT: number;
  72951. /**
  72952. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72953. */
  72954. static readonly EASINGMODE_EASEINOUT: number;
  72955. private _easingMode;
  72956. /**
  72957. * Sets the easing mode of the current function.
  72958. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72959. */
  72960. setEasingMode(easingMode: number): void;
  72961. /**
  72962. * Gets the current easing mode.
  72963. * @returns the easing mode
  72964. */
  72965. getEasingMode(): number;
  72966. /**
  72967. * @hidden
  72968. */
  72969. easeInCore(gradient: number): number;
  72970. /**
  72971. * Given an input gradient between 0 and 1, this returns the corresponding value
  72972. * of the easing function.
  72973. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72974. * @returns the corresponding value on the curve defined by the easing function
  72975. */
  72976. ease(gradient: number): number;
  72977. }
  72978. /**
  72979. * Easing function with a circle shape (see link below).
  72980. * @see https://easings.net/#easeInCirc
  72981. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72982. */
  72983. export class CircleEase extends EasingFunction implements IEasingFunction {
  72984. /** @hidden */
  72985. easeInCore(gradient: number): number;
  72986. }
  72987. /**
  72988. * Easing function with a ease back shape (see link below).
  72989. * @see https://easings.net/#easeInBack
  72990. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72991. */
  72992. export class BackEase extends EasingFunction implements IEasingFunction {
  72993. /** Defines the amplitude of the function */
  72994. amplitude: number;
  72995. /**
  72996. * Instantiates a back ease easing
  72997. * @see https://easings.net/#easeInBack
  72998. * @param amplitude Defines the amplitude of the function
  72999. */
  73000. constructor(
  73001. /** Defines the amplitude of the function */
  73002. amplitude?: number);
  73003. /** @hidden */
  73004. easeInCore(gradient: number): number;
  73005. }
  73006. /**
  73007. * Easing function with a bouncing shape (see link below).
  73008. * @see https://easings.net/#easeInBounce
  73009. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73010. */
  73011. export class BounceEase extends EasingFunction implements IEasingFunction {
  73012. /** Defines the number of bounces */
  73013. bounces: number;
  73014. /** Defines the amplitude of the bounce */
  73015. bounciness: number;
  73016. /**
  73017. * Instantiates a bounce easing
  73018. * @see https://easings.net/#easeInBounce
  73019. * @param bounces Defines the number of bounces
  73020. * @param bounciness Defines the amplitude of the bounce
  73021. */
  73022. constructor(
  73023. /** Defines the number of bounces */
  73024. bounces?: number,
  73025. /** Defines the amplitude of the bounce */
  73026. bounciness?: number);
  73027. /** @hidden */
  73028. easeInCore(gradient: number): number;
  73029. }
  73030. /**
  73031. * Easing function with a power of 3 shape (see link below).
  73032. * @see https://easings.net/#easeInCubic
  73033. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73034. */
  73035. export class CubicEase extends EasingFunction implements IEasingFunction {
  73036. /** @hidden */
  73037. easeInCore(gradient: number): number;
  73038. }
  73039. /**
  73040. * Easing function with an elastic shape (see link below).
  73041. * @see https://easings.net/#easeInElastic
  73042. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73043. */
  73044. export class ElasticEase extends EasingFunction implements IEasingFunction {
  73045. /** Defines the number of oscillations*/
  73046. oscillations: number;
  73047. /** Defines the amplitude of the oscillations*/
  73048. springiness: number;
  73049. /**
  73050. * Instantiates an elastic easing function
  73051. * @see https://easings.net/#easeInElastic
  73052. * @param oscillations Defines the number of oscillations
  73053. * @param springiness Defines the amplitude of the oscillations
  73054. */
  73055. constructor(
  73056. /** Defines the number of oscillations*/
  73057. oscillations?: number,
  73058. /** Defines the amplitude of the oscillations*/
  73059. springiness?: number);
  73060. /** @hidden */
  73061. easeInCore(gradient: number): number;
  73062. }
  73063. /**
  73064. * Easing function with an exponential shape (see link below).
  73065. * @see https://easings.net/#easeInExpo
  73066. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73067. */
  73068. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  73069. /** Defines the exponent of the function */
  73070. exponent: number;
  73071. /**
  73072. * Instantiates an exponential easing function
  73073. * @see https://easings.net/#easeInExpo
  73074. * @param exponent Defines the exponent of the function
  73075. */
  73076. constructor(
  73077. /** Defines the exponent of the function */
  73078. exponent?: number);
  73079. /** @hidden */
  73080. easeInCore(gradient: number): number;
  73081. }
  73082. /**
  73083. * Easing function with a power shape (see link below).
  73084. * @see https://easings.net/#easeInQuad
  73085. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73086. */
  73087. export class PowerEase extends EasingFunction implements IEasingFunction {
  73088. /** Defines the power of the function */
  73089. power: number;
  73090. /**
  73091. * Instantiates an power base easing function
  73092. * @see https://easings.net/#easeInQuad
  73093. * @param power Defines the power of the function
  73094. */
  73095. constructor(
  73096. /** Defines the power of the function */
  73097. power?: number);
  73098. /** @hidden */
  73099. easeInCore(gradient: number): number;
  73100. }
  73101. /**
  73102. * Easing function with a power of 2 shape (see link below).
  73103. * @see https://easings.net/#easeInQuad
  73104. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73105. */
  73106. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  73107. /** @hidden */
  73108. easeInCore(gradient: number): number;
  73109. }
  73110. /**
  73111. * Easing function with a power of 4 shape (see link below).
  73112. * @see https://easings.net/#easeInQuart
  73113. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73114. */
  73115. export class QuarticEase extends EasingFunction implements IEasingFunction {
  73116. /** @hidden */
  73117. easeInCore(gradient: number): number;
  73118. }
  73119. /**
  73120. * Easing function with a power of 5 shape (see link below).
  73121. * @see https://easings.net/#easeInQuint
  73122. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73123. */
  73124. export class QuinticEase extends EasingFunction implements IEasingFunction {
  73125. /** @hidden */
  73126. easeInCore(gradient: number): number;
  73127. }
  73128. /**
  73129. * Easing function with a sin shape (see link below).
  73130. * @see https://easings.net/#easeInSine
  73131. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73132. */
  73133. export class SineEase extends EasingFunction implements IEasingFunction {
  73134. /** @hidden */
  73135. easeInCore(gradient: number): number;
  73136. }
  73137. /**
  73138. * Easing function with a bezier shape (see link below).
  73139. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73140. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73141. */
  73142. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  73143. /** Defines the x component of the start tangent in the bezier curve */
  73144. x1: number;
  73145. /** Defines the y component of the start tangent in the bezier curve */
  73146. y1: number;
  73147. /** Defines the x component of the end tangent in the bezier curve */
  73148. x2: number;
  73149. /** Defines the y component of the end tangent in the bezier curve */
  73150. y2: number;
  73151. /**
  73152. * Instantiates a bezier function
  73153. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73154. * @param x1 Defines the x component of the start tangent in the bezier curve
  73155. * @param y1 Defines the y component of the start tangent in the bezier curve
  73156. * @param x2 Defines the x component of the end tangent in the bezier curve
  73157. * @param y2 Defines the y component of the end tangent in the bezier curve
  73158. */
  73159. constructor(
  73160. /** Defines the x component of the start tangent in the bezier curve */
  73161. x1?: number,
  73162. /** Defines the y component of the start tangent in the bezier curve */
  73163. y1?: number,
  73164. /** Defines the x component of the end tangent in the bezier curve */
  73165. x2?: number,
  73166. /** Defines the y component of the end tangent in the bezier curve */
  73167. y2?: number);
  73168. /** @hidden */
  73169. easeInCore(gradient: number): number;
  73170. }
  73171. }
  73172. declare module BABYLON {
  73173. /**
  73174. * Class used to hold a RBG color
  73175. */
  73176. export class Color3 {
  73177. /**
  73178. * Defines the red component (between 0 and 1, default is 0)
  73179. */
  73180. r: number;
  73181. /**
  73182. * Defines the green component (between 0 and 1, default is 0)
  73183. */
  73184. g: number;
  73185. /**
  73186. * Defines the blue component (between 0 and 1, default is 0)
  73187. */
  73188. b: number;
  73189. /**
  73190. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  73191. * @param r defines the red component (between 0 and 1, default is 0)
  73192. * @param g defines the green component (between 0 and 1, default is 0)
  73193. * @param b defines the blue component (between 0 and 1, default is 0)
  73194. */
  73195. constructor(
  73196. /**
  73197. * Defines the red component (between 0 and 1, default is 0)
  73198. */
  73199. r?: number,
  73200. /**
  73201. * Defines the green component (between 0 and 1, default is 0)
  73202. */
  73203. g?: number,
  73204. /**
  73205. * Defines the blue component (between 0 and 1, default is 0)
  73206. */
  73207. b?: number);
  73208. /**
  73209. * Creates a string with the Color3 current values
  73210. * @returns the string representation of the Color3 object
  73211. */
  73212. toString(): string;
  73213. /**
  73214. * Returns the string "Color3"
  73215. * @returns "Color3"
  73216. */
  73217. getClassName(): string;
  73218. /**
  73219. * Compute the Color3 hash code
  73220. * @returns an unique number that can be used to hash Color3 objects
  73221. */
  73222. getHashCode(): number;
  73223. /**
  73224. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  73225. * @param array defines the array where to store the r,g,b components
  73226. * @param index defines an optional index in the target array to define where to start storing values
  73227. * @returns the current Color3 object
  73228. */
  73229. toArray(array: FloatArray, index?: number): Color3;
  73230. /**
  73231. * Returns a new Color4 object from the current Color3 and the given alpha
  73232. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  73233. * @returns a new Color4 object
  73234. */
  73235. toColor4(alpha?: number): Color4;
  73236. /**
  73237. * Returns a new array populated with 3 numeric elements : red, green and blue values
  73238. * @returns the new array
  73239. */
  73240. asArray(): number[];
  73241. /**
  73242. * Returns the luminance value
  73243. * @returns a float value
  73244. */
  73245. toLuminance(): number;
  73246. /**
  73247. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  73248. * @param otherColor defines the second operand
  73249. * @returns the new Color3 object
  73250. */
  73251. multiply(otherColor: DeepImmutable<Color3>): Color3;
  73252. /**
  73253. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  73254. * @param otherColor defines the second operand
  73255. * @param result defines the Color3 object where to store the result
  73256. * @returns the current Color3
  73257. */
  73258. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73259. /**
  73260. * Determines equality between Color3 objects
  73261. * @param otherColor defines the second operand
  73262. * @returns true if the rgb values are equal to the given ones
  73263. */
  73264. equals(otherColor: DeepImmutable<Color3>): boolean;
  73265. /**
  73266. * Determines equality between the current Color3 object and a set of r,b,g values
  73267. * @param r defines the red component to check
  73268. * @param g defines the green component to check
  73269. * @param b defines the blue component to check
  73270. * @returns true if the rgb values are equal to the given ones
  73271. */
  73272. equalsFloats(r: number, g: number, b: number): boolean;
  73273. /**
  73274. * Multiplies in place each rgb value by scale
  73275. * @param scale defines the scaling factor
  73276. * @returns the updated Color3
  73277. */
  73278. scale(scale: number): Color3;
  73279. /**
  73280. * Multiplies the rgb values by scale and stores the result into "result"
  73281. * @param scale defines the scaling factor
  73282. * @param result defines the Color3 object where to store the result
  73283. * @returns the unmodified current Color3
  73284. */
  73285. scaleToRef(scale: number, result: Color3): Color3;
  73286. /**
  73287. * Scale the current Color3 values by a factor and add the result to a given Color3
  73288. * @param scale defines the scale factor
  73289. * @param result defines color to store the result into
  73290. * @returns the unmodified current Color3
  73291. */
  73292. scaleAndAddToRef(scale: number, result: Color3): Color3;
  73293. /**
  73294. * Clamps the rgb values by the min and max values and stores the result into "result"
  73295. * @param min defines minimum clamping value (default is 0)
  73296. * @param max defines maximum clamping value (default is 1)
  73297. * @param result defines color to store the result into
  73298. * @returns the original Color3
  73299. */
  73300. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  73301. /**
  73302. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  73303. * @param otherColor defines the second operand
  73304. * @returns the new Color3
  73305. */
  73306. add(otherColor: DeepImmutable<Color3>): Color3;
  73307. /**
  73308. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  73309. * @param otherColor defines the second operand
  73310. * @param result defines Color3 object to store the result into
  73311. * @returns the unmodified current Color3
  73312. */
  73313. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73314. /**
  73315. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  73316. * @param otherColor defines the second operand
  73317. * @returns the new Color3
  73318. */
  73319. subtract(otherColor: DeepImmutable<Color3>): Color3;
  73320. /**
  73321. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  73322. * @param otherColor defines the second operand
  73323. * @param result defines Color3 object to store the result into
  73324. * @returns the unmodified current Color3
  73325. */
  73326. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73327. /**
  73328. * Copy the current object
  73329. * @returns a new Color3 copied the current one
  73330. */
  73331. clone(): Color3;
  73332. /**
  73333. * Copies the rgb values from the source in the current Color3
  73334. * @param source defines the source Color3 object
  73335. * @returns the updated Color3 object
  73336. */
  73337. copyFrom(source: DeepImmutable<Color3>): Color3;
  73338. /**
  73339. * Updates the Color3 rgb values from the given floats
  73340. * @param r defines the red component to read from
  73341. * @param g defines the green component to read from
  73342. * @param b defines the blue component to read from
  73343. * @returns the current Color3 object
  73344. */
  73345. copyFromFloats(r: number, g: number, b: number): Color3;
  73346. /**
  73347. * Updates the Color3 rgb values from the given floats
  73348. * @param r defines the red component to read from
  73349. * @param g defines the green component to read from
  73350. * @param b defines the blue component to read from
  73351. * @returns the current Color3 object
  73352. */
  73353. set(r: number, g: number, b: number): Color3;
  73354. /**
  73355. * Compute the Color3 hexadecimal code as a string
  73356. * @returns a string containing the hexadecimal representation of the Color3 object
  73357. */
  73358. toHexString(): string;
  73359. /**
  73360. * Computes a new Color3 converted from the current one to linear space
  73361. * @returns a new Color3 object
  73362. */
  73363. toLinearSpace(): Color3;
  73364. /**
  73365. * Converts current color in rgb space to HSV values
  73366. * @returns a new color3 representing the HSV values
  73367. */
  73368. toHSV(): Color3;
  73369. /**
  73370. * Converts current color in rgb space to HSV values
  73371. * @param result defines the Color3 where to store the HSV values
  73372. */
  73373. toHSVToRef(result: Color3): void;
  73374. /**
  73375. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  73376. * @param convertedColor defines the Color3 object where to store the linear space version
  73377. * @returns the unmodified Color3
  73378. */
  73379. toLinearSpaceToRef(convertedColor: Color3): Color3;
  73380. /**
  73381. * Computes a new Color3 converted from the current one to gamma space
  73382. * @returns a new Color3 object
  73383. */
  73384. toGammaSpace(): Color3;
  73385. /**
  73386. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  73387. * @param convertedColor defines the Color3 object where to store the gamma space version
  73388. * @returns the unmodified Color3
  73389. */
  73390. toGammaSpaceToRef(convertedColor: Color3): Color3;
  73391. private static _BlackReadOnly;
  73392. /**
  73393. * Convert Hue, saturation and value to a Color3 (RGB)
  73394. * @param hue defines the hue
  73395. * @param saturation defines the saturation
  73396. * @param value defines the value
  73397. * @param result defines the Color3 where to store the RGB values
  73398. */
  73399. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  73400. /**
  73401. * Creates a new Color3 from the string containing valid hexadecimal values
  73402. * @param hex defines a string containing valid hexadecimal values
  73403. * @returns a new Color3 object
  73404. */
  73405. static FromHexString(hex: string): Color3;
  73406. /**
  73407. * Creates a new Color3 from the starting index of the given array
  73408. * @param array defines the source array
  73409. * @param offset defines an offset in the source array
  73410. * @returns a new Color3 object
  73411. */
  73412. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  73413. /**
  73414. * Creates a new Color3 from integer values (< 256)
  73415. * @param r defines the red component to read from (value between 0 and 255)
  73416. * @param g defines the green component to read from (value between 0 and 255)
  73417. * @param b defines the blue component to read from (value between 0 and 255)
  73418. * @returns a new Color3 object
  73419. */
  73420. static FromInts(r: number, g: number, b: number): Color3;
  73421. /**
  73422. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73423. * @param start defines the start Color3 value
  73424. * @param end defines the end Color3 value
  73425. * @param amount defines the gradient value between start and end
  73426. * @returns a new Color3 object
  73427. */
  73428. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  73429. /**
  73430. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73431. * @param left defines the start value
  73432. * @param right defines the end value
  73433. * @param amount defines the gradient factor
  73434. * @param result defines the Color3 object where to store the result
  73435. */
  73436. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  73437. /**
  73438. * Returns a Color3 value containing a red color
  73439. * @returns a new Color3 object
  73440. */
  73441. static Red(): Color3;
  73442. /**
  73443. * Returns a Color3 value containing a green color
  73444. * @returns a new Color3 object
  73445. */
  73446. static Green(): Color3;
  73447. /**
  73448. * Returns a Color3 value containing a blue color
  73449. * @returns a new Color3 object
  73450. */
  73451. static Blue(): Color3;
  73452. /**
  73453. * Returns a Color3 value containing a black color
  73454. * @returns a new Color3 object
  73455. */
  73456. static Black(): Color3;
  73457. /**
  73458. * Gets a Color3 value containing a black color that must not be updated
  73459. */
  73460. static readonly BlackReadOnly: DeepImmutable<Color3>;
  73461. /**
  73462. * Returns a Color3 value containing a white color
  73463. * @returns a new Color3 object
  73464. */
  73465. static White(): Color3;
  73466. /**
  73467. * Returns a Color3 value containing a purple color
  73468. * @returns a new Color3 object
  73469. */
  73470. static Purple(): Color3;
  73471. /**
  73472. * Returns a Color3 value containing a magenta color
  73473. * @returns a new Color3 object
  73474. */
  73475. static Magenta(): Color3;
  73476. /**
  73477. * Returns a Color3 value containing a yellow color
  73478. * @returns a new Color3 object
  73479. */
  73480. static Yellow(): Color3;
  73481. /**
  73482. * Returns a Color3 value containing a gray color
  73483. * @returns a new Color3 object
  73484. */
  73485. static Gray(): Color3;
  73486. /**
  73487. * Returns a Color3 value containing a teal color
  73488. * @returns a new Color3 object
  73489. */
  73490. static Teal(): Color3;
  73491. /**
  73492. * Returns a Color3 value containing a random color
  73493. * @returns a new Color3 object
  73494. */
  73495. static Random(): Color3;
  73496. }
  73497. /**
  73498. * Class used to hold a RBGA color
  73499. */
  73500. export class Color4 {
  73501. /**
  73502. * Defines the red component (between 0 and 1, default is 0)
  73503. */
  73504. r: number;
  73505. /**
  73506. * Defines the green component (between 0 and 1, default is 0)
  73507. */
  73508. g: number;
  73509. /**
  73510. * Defines the blue component (between 0 and 1, default is 0)
  73511. */
  73512. b: number;
  73513. /**
  73514. * Defines the alpha component (between 0 and 1, default is 1)
  73515. */
  73516. a: number;
  73517. /**
  73518. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  73519. * @param r defines the red component (between 0 and 1, default is 0)
  73520. * @param g defines the green component (between 0 and 1, default is 0)
  73521. * @param b defines the blue component (between 0 and 1, default is 0)
  73522. * @param a defines the alpha component (between 0 and 1, default is 1)
  73523. */
  73524. constructor(
  73525. /**
  73526. * Defines the red component (between 0 and 1, default is 0)
  73527. */
  73528. r?: number,
  73529. /**
  73530. * Defines the green component (between 0 and 1, default is 0)
  73531. */
  73532. g?: number,
  73533. /**
  73534. * Defines the blue component (between 0 and 1, default is 0)
  73535. */
  73536. b?: number,
  73537. /**
  73538. * Defines the alpha component (between 0 and 1, default is 1)
  73539. */
  73540. a?: number);
  73541. /**
  73542. * Adds in place the given Color4 values to the current Color4 object
  73543. * @param right defines the second operand
  73544. * @returns the current updated Color4 object
  73545. */
  73546. addInPlace(right: DeepImmutable<Color4>): Color4;
  73547. /**
  73548. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  73549. * @returns the new array
  73550. */
  73551. asArray(): number[];
  73552. /**
  73553. * Stores from the starting index in the given array the Color4 successive values
  73554. * @param array defines the array where to store the r,g,b components
  73555. * @param index defines an optional index in the target array to define where to start storing values
  73556. * @returns the current Color4 object
  73557. */
  73558. toArray(array: number[], index?: number): Color4;
  73559. /**
  73560. * Determines equality between Color4 objects
  73561. * @param otherColor defines the second operand
  73562. * @returns true if the rgba values are equal to the given ones
  73563. */
  73564. equals(otherColor: DeepImmutable<Color4>): boolean;
  73565. /**
  73566. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  73567. * @param right defines the second operand
  73568. * @returns a new Color4 object
  73569. */
  73570. add(right: DeepImmutable<Color4>): Color4;
  73571. /**
  73572. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  73573. * @param right defines the second operand
  73574. * @returns a new Color4 object
  73575. */
  73576. subtract(right: DeepImmutable<Color4>): Color4;
  73577. /**
  73578. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  73579. * @param right defines the second operand
  73580. * @param result defines the Color4 object where to store the result
  73581. * @returns the current Color4 object
  73582. */
  73583. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  73584. /**
  73585. * Creates a new Color4 with the current Color4 values multiplied by scale
  73586. * @param scale defines the scaling factor to apply
  73587. * @returns a new Color4 object
  73588. */
  73589. scale(scale: number): Color4;
  73590. /**
  73591. * Multiplies the current Color4 values by scale and stores the result in "result"
  73592. * @param scale defines the scaling factor to apply
  73593. * @param result defines the Color4 object where to store the result
  73594. * @returns the current unmodified Color4
  73595. */
  73596. scaleToRef(scale: number, result: Color4): Color4;
  73597. /**
  73598. * Scale the current Color4 values by a factor and add the result to a given Color4
  73599. * @param scale defines the scale factor
  73600. * @param result defines the Color4 object where to store the result
  73601. * @returns the unmodified current Color4
  73602. */
  73603. scaleAndAddToRef(scale: number, result: Color4): Color4;
  73604. /**
  73605. * Clamps the rgb values by the min and max values and stores the result into "result"
  73606. * @param min defines minimum clamping value (default is 0)
  73607. * @param max defines maximum clamping value (default is 1)
  73608. * @param result defines color to store the result into.
  73609. * @returns the cuurent Color4
  73610. */
  73611. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  73612. /**
  73613. * Multipy an Color4 value by another and return a new Color4 object
  73614. * @param color defines the Color4 value to multiply by
  73615. * @returns a new Color4 object
  73616. */
  73617. multiply(color: Color4): Color4;
  73618. /**
  73619. * Multipy a Color4 value by another and push the result in a reference value
  73620. * @param color defines the Color4 value to multiply by
  73621. * @param result defines the Color4 to fill the result in
  73622. * @returns the result Color4
  73623. */
  73624. multiplyToRef(color: Color4, result: Color4): Color4;
  73625. /**
  73626. * Creates a string with the Color4 current values
  73627. * @returns the string representation of the Color4 object
  73628. */
  73629. toString(): string;
  73630. /**
  73631. * Returns the string "Color4"
  73632. * @returns "Color4"
  73633. */
  73634. getClassName(): string;
  73635. /**
  73636. * Compute the Color4 hash code
  73637. * @returns an unique number that can be used to hash Color4 objects
  73638. */
  73639. getHashCode(): number;
  73640. /**
  73641. * Creates a new Color4 copied from the current one
  73642. * @returns a new Color4 object
  73643. */
  73644. clone(): Color4;
  73645. /**
  73646. * Copies the given Color4 values into the current one
  73647. * @param source defines the source Color4 object
  73648. * @returns the current updated Color4 object
  73649. */
  73650. copyFrom(source: Color4): Color4;
  73651. /**
  73652. * Copies the given float values into the current one
  73653. * @param r defines the red component to read from
  73654. * @param g defines the green component to read from
  73655. * @param b defines the blue component to read from
  73656. * @param a defines the alpha component to read from
  73657. * @returns the current updated Color4 object
  73658. */
  73659. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  73660. /**
  73661. * Copies the given float values into the current one
  73662. * @param r defines the red component to read from
  73663. * @param g defines the green component to read from
  73664. * @param b defines the blue component to read from
  73665. * @param a defines the alpha component to read from
  73666. * @returns the current updated Color4 object
  73667. */
  73668. set(r: number, g: number, b: number, a: number): Color4;
  73669. /**
  73670. * Compute the Color4 hexadecimal code as a string
  73671. * @returns a string containing the hexadecimal representation of the Color4 object
  73672. */
  73673. toHexString(): string;
  73674. /**
  73675. * Computes a new Color4 converted from the current one to linear space
  73676. * @returns a new Color4 object
  73677. */
  73678. toLinearSpace(): Color4;
  73679. /**
  73680. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  73681. * @param convertedColor defines the Color4 object where to store the linear space version
  73682. * @returns the unmodified Color4
  73683. */
  73684. toLinearSpaceToRef(convertedColor: Color4): Color4;
  73685. /**
  73686. * Computes a new Color4 converted from the current one to gamma space
  73687. * @returns a new Color4 object
  73688. */
  73689. toGammaSpace(): Color4;
  73690. /**
  73691. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  73692. * @param convertedColor defines the Color4 object where to store the gamma space version
  73693. * @returns the unmodified Color4
  73694. */
  73695. toGammaSpaceToRef(convertedColor: Color4): Color4;
  73696. /**
  73697. * Creates a new Color4 from the string containing valid hexadecimal values
  73698. * @param hex defines a string containing valid hexadecimal values
  73699. * @returns a new Color4 object
  73700. */
  73701. static FromHexString(hex: string): Color4;
  73702. /**
  73703. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73704. * @param left defines the start value
  73705. * @param right defines the end value
  73706. * @param amount defines the gradient factor
  73707. * @returns a new Color4 object
  73708. */
  73709. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  73710. /**
  73711. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73712. * @param left defines the start value
  73713. * @param right defines the end value
  73714. * @param amount defines the gradient factor
  73715. * @param result defines the Color4 object where to store data
  73716. */
  73717. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  73718. /**
  73719. * Creates a new Color4 from a Color3 and an alpha value
  73720. * @param color3 defines the source Color3 to read from
  73721. * @param alpha defines the alpha component (1.0 by default)
  73722. * @returns a new Color4 object
  73723. */
  73724. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  73725. /**
  73726. * Creates a new Color4 from the starting index element of the given array
  73727. * @param array defines the source array to read from
  73728. * @param offset defines the offset in the source array
  73729. * @returns a new Color4 object
  73730. */
  73731. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  73732. /**
  73733. * Creates a new Color3 from integer values (< 256)
  73734. * @param r defines the red component to read from (value between 0 and 255)
  73735. * @param g defines the green component to read from (value between 0 and 255)
  73736. * @param b defines the blue component to read from (value between 0 and 255)
  73737. * @param a defines the alpha component to read from (value between 0 and 255)
  73738. * @returns a new Color3 object
  73739. */
  73740. static FromInts(r: number, g: number, b: number, a: number): Color4;
  73741. /**
  73742. * Check the content of a given array and convert it to an array containing RGBA data
  73743. * If the original array was already containing count * 4 values then it is returned directly
  73744. * @param colors defines the array to check
  73745. * @param count defines the number of RGBA data to expect
  73746. * @returns an array containing count * 4 values (RGBA)
  73747. */
  73748. static CheckColors4(colors: number[], count: number): number[];
  73749. }
  73750. /**
  73751. * @hidden
  73752. */
  73753. export class TmpColors {
  73754. static Color3: Color3[];
  73755. static Color4: Color4[];
  73756. }
  73757. }
  73758. declare module BABYLON {
  73759. /**
  73760. * Defines an interface which represents an animation key frame
  73761. */
  73762. export interface IAnimationKey {
  73763. /**
  73764. * Frame of the key frame
  73765. */
  73766. frame: number;
  73767. /**
  73768. * Value at the specifies key frame
  73769. */
  73770. value: any;
  73771. /**
  73772. * The input tangent for the cubic hermite spline
  73773. */
  73774. inTangent?: any;
  73775. /**
  73776. * The output tangent for the cubic hermite spline
  73777. */
  73778. outTangent?: any;
  73779. /**
  73780. * The animation interpolation type
  73781. */
  73782. interpolation?: AnimationKeyInterpolation;
  73783. }
  73784. /**
  73785. * Enum for the animation key frame interpolation type
  73786. */
  73787. export enum AnimationKeyInterpolation {
  73788. /**
  73789. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  73790. */
  73791. STEP = 1
  73792. }
  73793. }
  73794. declare module BABYLON {
  73795. /**
  73796. * Represents the range of an animation
  73797. */
  73798. export class AnimationRange {
  73799. /**The name of the animation range**/
  73800. name: string;
  73801. /**The starting frame of the animation */
  73802. from: number;
  73803. /**The ending frame of the animation*/
  73804. to: number;
  73805. /**
  73806. * Initializes the range of an animation
  73807. * @param name The name of the animation range
  73808. * @param from The starting frame of the animation
  73809. * @param to The ending frame of the animation
  73810. */
  73811. constructor(
  73812. /**The name of the animation range**/
  73813. name: string,
  73814. /**The starting frame of the animation */
  73815. from: number,
  73816. /**The ending frame of the animation*/
  73817. to: number);
  73818. /**
  73819. * Makes a copy of the animation range
  73820. * @returns A copy of the animation range
  73821. */
  73822. clone(): AnimationRange;
  73823. }
  73824. }
  73825. declare module BABYLON {
  73826. /**
  73827. * Composed of a frame, and an action function
  73828. */
  73829. export class AnimationEvent {
  73830. /** The frame for which the event is triggered **/
  73831. frame: number;
  73832. /** The event to perform when triggered **/
  73833. action: (currentFrame: number) => void;
  73834. /** Specifies if the event should be triggered only once**/
  73835. onlyOnce?: boolean | undefined;
  73836. /**
  73837. * Specifies if the animation event is done
  73838. */
  73839. isDone: boolean;
  73840. /**
  73841. * Initializes the animation event
  73842. * @param frame The frame for which the event is triggered
  73843. * @param action The event to perform when triggered
  73844. * @param onlyOnce Specifies if the event should be triggered only once
  73845. */
  73846. constructor(
  73847. /** The frame for which the event is triggered **/
  73848. frame: number,
  73849. /** The event to perform when triggered **/
  73850. action: (currentFrame: number) => void,
  73851. /** Specifies if the event should be triggered only once**/
  73852. onlyOnce?: boolean | undefined);
  73853. /** @hidden */
  73854. _clone(): AnimationEvent;
  73855. }
  73856. }
  73857. declare module BABYLON {
  73858. /**
  73859. * Interface used to define a behavior
  73860. */
  73861. export interface Behavior<T> {
  73862. /** gets or sets behavior's name */
  73863. name: string;
  73864. /**
  73865. * Function called when the behavior needs to be initialized (after attaching it to a target)
  73866. */
  73867. init(): void;
  73868. /**
  73869. * Called when the behavior is attached to a target
  73870. * @param target defines the target where the behavior is attached to
  73871. */
  73872. attach(target: T): void;
  73873. /**
  73874. * Called when the behavior is detached from its target
  73875. */
  73876. detach(): void;
  73877. }
  73878. /**
  73879. * Interface implemented by classes supporting behaviors
  73880. */
  73881. export interface IBehaviorAware<T> {
  73882. /**
  73883. * Attach a behavior
  73884. * @param behavior defines the behavior to attach
  73885. * @returns the current host
  73886. */
  73887. addBehavior(behavior: Behavior<T>): T;
  73888. /**
  73889. * Remove a behavior from the current object
  73890. * @param behavior defines the behavior to detach
  73891. * @returns the current host
  73892. */
  73893. removeBehavior(behavior: Behavior<T>): T;
  73894. /**
  73895. * Gets a behavior using its name to search
  73896. * @param name defines the name to search
  73897. * @returns the behavior or null if not found
  73898. */
  73899. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  73900. }
  73901. }
  73902. declare module BABYLON {
  73903. /**
  73904. * Defines an array and its length.
  73905. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  73906. */
  73907. export interface ISmartArrayLike<T> {
  73908. /**
  73909. * The data of the array.
  73910. */
  73911. data: Array<T>;
  73912. /**
  73913. * The active length of the array.
  73914. */
  73915. length: number;
  73916. }
  73917. /**
  73918. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73919. */
  73920. export class SmartArray<T> implements ISmartArrayLike<T> {
  73921. /**
  73922. * The full set of data from the array.
  73923. */
  73924. data: Array<T>;
  73925. /**
  73926. * The active length of the array.
  73927. */
  73928. length: number;
  73929. protected _id: number;
  73930. /**
  73931. * Instantiates a Smart Array.
  73932. * @param capacity defines the default capacity of the array.
  73933. */
  73934. constructor(capacity: number);
  73935. /**
  73936. * Pushes a value at the end of the active data.
  73937. * @param value defines the object to push in the array.
  73938. */
  73939. push(value: T): void;
  73940. /**
  73941. * Iterates over the active data and apply the lambda to them.
  73942. * @param func defines the action to apply on each value.
  73943. */
  73944. forEach(func: (content: T) => void): void;
  73945. /**
  73946. * Sorts the full sets of data.
  73947. * @param compareFn defines the comparison function to apply.
  73948. */
  73949. sort(compareFn: (a: T, b: T) => number): void;
  73950. /**
  73951. * Resets the active data to an empty array.
  73952. */
  73953. reset(): void;
  73954. /**
  73955. * Releases all the data from the array as well as the array.
  73956. */
  73957. dispose(): void;
  73958. /**
  73959. * Concats the active data with a given array.
  73960. * @param array defines the data to concatenate with.
  73961. */
  73962. concat(array: any): void;
  73963. /**
  73964. * Returns the position of a value in the active data.
  73965. * @param value defines the value to find the index for
  73966. * @returns the index if found in the active data otherwise -1
  73967. */
  73968. indexOf(value: T): number;
  73969. /**
  73970. * Returns whether an element is part of the active data.
  73971. * @param value defines the value to look for
  73972. * @returns true if found in the active data otherwise false
  73973. */
  73974. contains(value: T): boolean;
  73975. private static _GlobalId;
  73976. }
  73977. /**
  73978. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73979. * The data in this array can only be present once
  73980. */
  73981. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  73982. private _duplicateId;
  73983. /**
  73984. * Pushes a value at the end of the active data.
  73985. * THIS DOES NOT PREVENT DUPPLICATE DATA
  73986. * @param value defines the object to push in the array.
  73987. */
  73988. push(value: T): void;
  73989. /**
  73990. * Pushes a value at the end of the active data.
  73991. * If the data is already present, it won t be added again
  73992. * @param value defines the object to push in the array.
  73993. * @returns true if added false if it was already present
  73994. */
  73995. pushNoDuplicate(value: T): boolean;
  73996. /**
  73997. * Resets the active data to an empty array.
  73998. */
  73999. reset(): void;
  74000. /**
  74001. * Concats the active data with a given array.
  74002. * This ensures no dupplicate will be present in the result.
  74003. * @param array defines the data to concatenate with.
  74004. */
  74005. concatWithNoDuplicate(array: any): void;
  74006. }
  74007. }
  74008. declare module BABYLON {
  74009. /**
  74010. * @ignore
  74011. * This is a list of all the different input types that are available in the application.
  74012. * Fo instance: ArcRotateCameraGamepadInput...
  74013. */
  74014. export var CameraInputTypes: {};
  74015. /**
  74016. * This is the contract to implement in order to create a new input class.
  74017. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  74018. */
  74019. export interface ICameraInput<TCamera extends Camera> {
  74020. /**
  74021. * Defines the camera the input is attached to.
  74022. */
  74023. camera: Nullable<TCamera>;
  74024. /**
  74025. * Gets the class name of the current intput.
  74026. * @returns the class name
  74027. */
  74028. getClassName(): string;
  74029. /**
  74030. * Get the friendly name associated with the input class.
  74031. * @returns the input friendly name
  74032. */
  74033. getSimpleName(): string;
  74034. /**
  74035. * Attach the input controls to a specific dom element to get the input from.
  74036. * @param element Defines the element the controls should be listened from
  74037. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74038. */
  74039. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74040. /**
  74041. * Detach the current controls from the specified dom element.
  74042. * @param element Defines the element to stop listening the inputs from
  74043. */
  74044. detachControl(element: Nullable<HTMLElement>): void;
  74045. /**
  74046. * Update the current camera state depending on the inputs that have been used this frame.
  74047. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74048. */
  74049. checkInputs?: () => void;
  74050. }
  74051. /**
  74052. * Represents a map of input types to input instance or input index to input instance.
  74053. */
  74054. export interface CameraInputsMap<TCamera extends Camera> {
  74055. /**
  74056. * Accessor to the input by input type.
  74057. */
  74058. [name: string]: ICameraInput<TCamera>;
  74059. /**
  74060. * Accessor to the input by input index.
  74061. */
  74062. [idx: number]: ICameraInput<TCamera>;
  74063. }
  74064. /**
  74065. * This represents the input manager used within a camera.
  74066. * It helps dealing with all the different kind of input attached to a camera.
  74067. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74068. */
  74069. export class CameraInputsManager<TCamera extends Camera> {
  74070. /**
  74071. * Defines the list of inputs attahed to the camera.
  74072. */
  74073. attached: CameraInputsMap<TCamera>;
  74074. /**
  74075. * Defines the dom element the camera is collecting inputs from.
  74076. * This is null if the controls have not been attached.
  74077. */
  74078. attachedElement: Nullable<HTMLElement>;
  74079. /**
  74080. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74081. */
  74082. noPreventDefault: boolean;
  74083. /**
  74084. * Defined the camera the input manager belongs to.
  74085. */
  74086. camera: TCamera;
  74087. /**
  74088. * Update the current camera state depending on the inputs that have been used this frame.
  74089. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74090. */
  74091. checkInputs: () => void;
  74092. /**
  74093. * Instantiate a new Camera Input Manager.
  74094. * @param camera Defines the camera the input manager blongs to
  74095. */
  74096. constructor(camera: TCamera);
  74097. /**
  74098. * Add an input method to a camera
  74099. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74100. * @param input camera input method
  74101. */
  74102. add(input: ICameraInput<TCamera>): void;
  74103. /**
  74104. * Remove a specific input method from a camera
  74105. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  74106. * @param inputToRemove camera input method
  74107. */
  74108. remove(inputToRemove: ICameraInput<TCamera>): void;
  74109. /**
  74110. * Remove a specific input type from a camera
  74111. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  74112. * @param inputType the type of the input to remove
  74113. */
  74114. removeByType(inputType: string): void;
  74115. private _addCheckInputs;
  74116. /**
  74117. * Attach the input controls to the currently attached dom element to listen the events from.
  74118. * @param input Defines the input to attach
  74119. */
  74120. attachInput(input: ICameraInput<TCamera>): void;
  74121. /**
  74122. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  74123. * @param element Defines the dom element to collect the events from
  74124. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74125. */
  74126. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  74127. /**
  74128. * Detach the current manager inputs controls from a specific dom element.
  74129. * @param element Defines the dom element to collect the events from
  74130. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  74131. */
  74132. detachElement(element: HTMLElement, disconnect?: boolean): void;
  74133. /**
  74134. * Rebuild the dynamic inputCheck function from the current list of
  74135. * defined inputs in the manager.
  74136. */
  74137. rebuildInputCheck(): void;
  74138. /**
  74139. * Remove all attached input methods from a camera
  74140. */
  74141. clear(): void;
  74142. /**
  74143. * Serialize the current input manager attached to a camera.
  74144. * This ensures than once parsed,
  74145. * the input associated to the camera will be identical to the current ones
  74146. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  74147. */
  74148. serialize(serializedCamera: any): void;
  74149. /**
  74150. * Parses an input manager serialized JSON to restore the previous list of inputs
  74151. * and states associated to a camera.
  74152. * @param parsedCamera Defines the JSON to parse
  74153. */
  74154. parse(parsedCamera: any): void;
  74155. }
  74156. }
  74157. declare module BABYLON {
  74158. /**
  74159. * Class used to store data that will be store in GPU memory
  74160. */
  74161. export class Buffer {
  74162. private _engine;
  74163. private _buffer;
  74164. /** @hidden */
  74165. _data: Nullable<DataArray>;
  74166. private _updatable;
  74167. private _instanced;
  74168. private _divisor;
  74169. /**
  74170. * Gets the byte stride.
  74171. */
  74172. readonly byteStride: number;
  74173. /**
  74174. * Constructor
  74175. * @param engine the engine
  74176. * @param data the data to use for this buffer
  74177. * @param updatable whether the data is updatable
  74178. * @param stride the stride (optional)
  74179. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74180. * @param instanced whether the buffer is instanced (optional)
  74181. * @param useBytes set to true if the stride in in bytes (optional)
  74182. * @param divisor sets an optional divisor for instances (1 by default)
  74183. */
  74184. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  74185. /**
  74186. * Create a new VertexBuffer based on the current buffer
  74187. * @param kind defines the vertex buffer kind (position, normal, etc.)
  74188. * @param offset defines offset in the buffer (0 by default)
  74189. * @param size defines the size in floats of attributes (position is 3 for instance)
  74190. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  74191. * @param instanced defines if the vertex buffer contains indexed data
  74192. * @param useBytes defines if the offset and stride are in bytes *
  74193. * @param divisor sets an optional divisor for instances (1 by default)
  74194. * @returns the new vertex buffer
  74195. */
  74196. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  74197. /**
  74198. * Gets a boolean indicating if the Buffer is updatable?
  74199. * @returns true if the buffer is updatable
  74200. */
  74201. isUpdatable(): boolean;
  74202. /**
  74203. * Gets current buffer's data
  74204. * @returns a DataArray or null
  74205. */
  74206. getData(): Nullable<DataArray>;
  74207. /**
  74208. * Gets underlying native buffer
  74209. * @returns underlying native buffer
  74210. */
  74211. getBuffer(): Nullable<DataBuffer>;
  74212. /**
  74213. * Gets the stride in float32 units (i.e. byte stride / 4).
  74214. * May not be an integer if the byte stride is not divisible by 4.
  74215. * DEPRECATED. Use byteStride instead.
  74216. * @returns the stride in float32 units
  74217. */
  74218. getStrideSize(): number;
  74219. /**
  74220. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74221. * @param data defines the data to store
  74222. */
  74223. create(data?: Nullable<DataArray>): void;
  74224. /** @hidden */
  74225. _rebuild(): void;
  74226. /**
  74227. * Update current buffer data
  74228. * @param data defines the data to store
  74229. */
  74230. update(data: DataArray): void;
  74231. /**
  74232. * Updates the data directly.
  74233. * @param data the new data
  74234. * @param offset the new offset
  74235. * @param vertexCount the vertex count (optional)
  74236. * @param useBytes set to true if the offset is in bytes
  74237. */
  74238. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  74239. /**
  74240. * Release all resources
  74241. */
  74242. dispose(): void;
  74243. }
  74244. /**
  74245. * Specialized buffer used to store vertex data
  74246. */
  74247. export class VertexBuffer {
  74248. /** @hidden */
  74249. _buffer: Buffer;
  74250. private _kind;
  74251. private _size;
  74252. private _ownsBuffer;
  74253. private _instanced;
  74254. private _instanceDivisor;
  74255. /**
  74256. * The byte type.
  74257. */
  74258. static readonly BYTE: number;
  74259. /**
  74260. * The unsigned byte type.
  74261. */
  74262. static readonly UNSIGNED_BYTE: number;
  74263. /**
  74264. * The short type.
  74265. */
  74266. static readonly SHORT: number;
  74267. /**
  74268. * The unsigned short type.
  74269. */
  74270. static readonly UNSIGNED_SHORT: number;
  74271. /**
  74272. * The integer type.
  74273. */
  74274. static readonly INT: number;
  74275. /**
  74276. * The unsigned integer type.
  74277. */
  74278. static readonly UNSIGNED_INT: number;
  74279. /**
  74280. * The float type.
  74281. */
  74282. static readonly FLOAT: number;
  74283. /**
  74284. * Gets or sets the instance divisor when in instanced mode
  74285. */
  74286. instanceDivisor: number;
  74287. /**
  74288. * Gets the byte stride.
  74289. */
  74290. readonly byteStride: number;
  74291. /**
  74292. * Gets the byte offset.
  74293. */
  74294. readonly byteOffset: number;
  74295. /**
  74296. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  74297. */
  74298. readonly normalized: boolean;
  74299. /**
  74300. * Gets the data type of each component in the array.
  74301. */
  74302. readonly type: number;
  74303. /**
  74304. * Constructor
  74305. * @param engine the engine
  74306. * @param data the data to use for this vertex buffer
  74307. * @param kind the vertex buffer kind
  74308. * @param updatable whether the data is updatable
  74309. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74310. * @param stride the stride (optional)
  74311. * @param instanced whether the buffer is instanced (optional)
  74312. * @param offset the offset of the data (optional)
  74313. * @param size the number of components (optional)
  74314. * @param type the type of the component (optional)
  74315. * @param normalized whether the data contains normalized data (optional)
  74316. * @param useBytes set to true if stride and offset are in bytes (optional)
  74317. * @param divisor defines the instance divisor to use (1 by default)
  74318. */
  74319. 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);
  74320. /** @hidden */
  74321. _rebuild(): void;
  74322. /**
  74323. * Returns the kind of the VertexBuffer (string)
  74324. * @returns a string
  74325. */
  74326. getKind(): string;
  74327. /**
  74328. * Gets a boolean indicating if the VertexBuffer is updatable?
  74329. * @returns true if the buffer is updatable
  74330. */
  74331. isUpdatable(): boolean;
  74332. /**
  74333. * Gets current buffer's data
  74334. * @returns a DataArray or null
  74335. */
  74336. getData(): Nullable<DataArray>;
  74337. /**
  74338. * Gets underlying native buffer
  74339. * @returns underlying native buffer
  74340. */
  74341. getBuffer(): Nullable<DataBuffer>;
  74342. /**
  74343. * Gets the stride in float32 units (i.e. byte stride / 4).
  74344. * May not be an integer if the byte stride is not divisible by 4.
  74345. * DEPRECATED. Use byteStride instead.
  74346. * @returns the stride in float32 units
  74347. */
  74348. getStrideSize(): number;
  74349. /**
  74350. * Returns the offset as a multiple of the type byte length.
  74351. * DEPRECATED. Use byteOffset instead.
  74352. * @returns the offset in bytes
  74353. */
  74354. getOffset(): number;
  74355. /**
  74356. * Returns the number of components per vertex attribute (integer)
  74357. * @returns the size in float
  74358. */
  74359. getSize(): number;
  74360. /**
  74361. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  74362. * @returns true if this buffer is instanced
  74363. */
  74364. getIsInstanced(): boolean;
  74365. /**
  74366. * Returns the instancing divisor, zero for non-instanced (integer).
  74367. * @returns a number
  74368. */
  74369. getInstanceDivisor(): number;
  74370. /**
  74371. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74372. * @param data defines the data to store
  74373. */
  74374. create(data?: DataArray): void;
  74375. /**
  74376. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  74377. * This function will create a new buffer if the current one is not updatable
  74378. * @param data defines the data to store
  74379. */
  74380. update(data: DataArray): void;
  74381. /**
  74382. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  74383. * Returns the directly updated WebGLBuffer.
  74384. * @param data the new data
  74385. * @param offset the new offset
  74386. * @param useBytes set to true if the offset is in bytes
  74387. */
  74388. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  74389. /**
  74390. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  74391. */
  74392. dispose(): void;
  74393. /**
  74394. * Enumerates each value of this vertex buffer as numbers.
  74395. * @param count the number of values to enumerate
  74396. * @param callback the callback function called for each value
  74397. */
  74398. forEach(count: number, callback: (value: number, index: number) => void): void;
  74399. /**
  74400. * Positions
  74401. */
  74402. static readonly PositionKind: string;
  74403. /**
  74404. * Normals
  74405. */
  74406. static readonly NormalKind: string;
  74407. /**
  74408. * Tangents
  74409. */
  74410. static readonly TangentKind: string;
  74411. /**
  74412. * Texture coordinates
  74413. */
  74414. static readonly UVKind: string;
  74415. /**
  74416. * Texture coordinates 2
  74417. */
  74418. static readonly UV2Kind: string;
  74419. /**
  74420. * Texture coordinates 3
  74421. */
  74422. static readonly UV3Kind: string;
  74423. /**
  74424. * Texture coordinates 4
  74425. */
  74426. static readonly UV4Kind: string;
  74427. /**
  74428. * Texture coordinates 5
  74429. */
  74430. static readonly UV5Kind: string;
  74431. /**
  74432. * Texture coordinates 6
  74433. */
  74434. static readonly UV6Kind: string;
  74435. /**
  74436. * Colors
  74437. */
  74438. static readonly ColorKind: string;
  74439. /**
  74440. * Matrix indices (for bones)
  74441. */
  74442. static readonly MatricesIndicesKind: string;
  74443. /**
  74444. * Matrix weights (for bones)
  74445. */
  74446. static readonly MatricesWeightsKind: string;
  74447. /**
  74448. * Additional matrix indices (for bones)
  74449. */
  74450. static readonly MatricesIndicesExtraKind: string;
  74451. /**
  74452. * Additional matrix weights (for bones)
  74453. */
  74454. static readonly MatricesWeightsExtraKind: string;
  74455. /**
  74456. * Deduces the stride given a kind.
  74457. * @param kind The kind string to deduce
  74458. * @returns The deduced stride
  74459. */
  74460. static DeduceStride(kind: string): number;
  74461. /**
  74462. * Gets the byte length of the given type.
  74463. * @param type the type
  74464. * @returns the number of bytes
  74465. */
  74466. static GetTypeByteLength(type: number): number;
  74467. /**
  74468. * Enumerates each value of the given parameters as numbers.
  74469. * @param data the data to enumerate
  74470. * @param byteOffset the byte offset of the data
  74471. * @param byteStride the byte stride of the data
  74472. * @param componentCount the number of components per element
  74473. * @param componentType the type of the component
  74474. * @param count the number of values to enumerate
  74475. * @param normalized whether the data is normalized
  74476. * @param callback the callback function called for each value
  74477. */
  74478. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  74479. private static _GetFloatValue;
  74480. }
  74481. }
  74482. declare module BABYLON {
  74483. /**
  74484. * @hidden
  74485. */
  74486. export class IntersectionInfo {
  74487. bu: Nullable<number>;
  74488. bv: Nullable<number>;
  74489. distance: number;
  74490. faceId: number;
  74491. subMeshId: number;
  74492. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  74493. }
  74494. }
  74495. declare module BABYLON {
  74496. /**
  74497. * Represens a plane by the equation ax + by + cz + d = 0
  74498. */
  74499. export class Plane {
  74500. private static _TmpMatrix;
  74501. /**
  74502. * Normal of the plane (a,b,c)
  74503. */
  74504. normal: Vector3;
  74505. /**
  74506. * d component of the plane
  74507. */
  74508. d: number;
  74509. /**
  74510. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  74511. * @param a a component of the plane
  74512. * @param b b component of the plane
  74513. * @param c c component of the plane
  74514. * @param d d component of the plane
  74515. */
  74516. constructor(a: number, b: number, c: number, d: number);
  74517. /**
  74518. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  74519. */
  74520. asArray(): number[];
  74521. /**
  74522. * @returns a new plane copied from the current Plane.
  74523. */
  74524. clone(): Plane;
  74525. /**
  74526. * @returns the string "Plane".
  74527. */
  74528. getClassName(): string;
  74529. /**
  74530. * @returns the Plane hash code.
  74531. */
  74532. getHashCode(): number;
  74533. /**
  74534. * Normalize the current Plane in place.
  74535. * @returns the updated Plane.
  74536. */
  74537. normalize(): Plane;
  74538. /**
  74539. * Applies a transformation the plane and returns the result
  74540. * @param transformation the transformation matrix to be applied to the plane
  74541. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  74542. */
  74543. transform(transformation: DeepImmutable<Matrix>): Plane;
  74544. /**
  74545. * Calcualtte the dot product between the point and the plane normal
  74546. * @param point point to calculate the dot product with
  74547. * @returns the dot product (float) of the point coordinates and the plane normal.
  74548. */
  74549. dotCoordinate(point: DeepImmutable<Vector3>): number;
  74550. /**
  74551. * Updates the current Plane from the plane defined by the three given points.
  74552. * @param point1 one of the points used to contruct the plane
  74553. * @param point2 one of the points used to contruct the plane
  74554. * @param point3 one of the points used to contruct the plane
  74555. * @returns the updated Plane.
  74556. */
  74557. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74558. /**
  74559. * Checks if the plane is facing a given direction
  74560. * @param direction the direction to check if the plane is facing
  74561. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  74562. * @returns True is the vector "direction" is the same side than the plane normal.
  74563. */
  74564. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  74565. /**
  74566. * Calculates the distance to a point
  74567. * @param point point to calculate distance to
  74568. * @returns the signed distance (float) from the given point to the Plane.
  74569. */
  74570. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  74571. /**
  74572. * Creates a plane from an array
  74573. * @param array the array to create a plane from
  74574. * @returns a new Plane from the given array.
  74575. */
  74576. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  74577. /**
  74578. * Creates a plane from three points
  74579. * @param point1 point used to create the plane
  74580. * @param point2 point used to create the plane
  74581. * @param point3 point used to create the plane
  74582. * @returns a new Plane defined by the three given points.
  74583. */
  74584. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74585. /**
  74586. * Creates a plane from an origin point and a normal
  74587. * @param origin origin of the plane to be constructed
  74588. * @param normal normal of the plane to be constructed
  74589. * @returns a new Plane the normal vector to this plane at the given origin point.
  74590. * Note : the vector "normal" is updated because normalized.
  74591. */
  74592. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  74593. /**
  74594. * Calculates the distance from a plane and a point
  74595. * @param origin origin of the plane to be constructed
  74596. * @param normal normal of the plane to be constructed
  74597. * @param point point to calculate distance to
  74598. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  74599. */
  74600. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  74601. }
  74602. }
  74603. declare module BABYLON {
  74604. /**
  74605. * Class used to store bounding sphere information
  74606. */
  74607. export class BoundingSphere {
  74608. /**
  74609. * Gets the center of the bounding sphere in local space
  74610. */
  74611. readonly center: Vector3;
  74612. /**
  74613. * Radius of the bounding sphere in local space
  74614. */
  74615. radius: number;
  74616. /**
  74617. * Gets the center of the bounding sphere in world space
  74618. */
  74619. readonly centerWorld: Vector3;
  74620. /**
  74621. * Radius of the bounding sphere in world space
  74622. */
  74623. radiusWorld: number;
  74624. /**
  74625. * Gets the minimum vector in local space
  74626. */
  74627. readonly minimum: Vector3;
  74628. /**
  74629. * Gets the maximum vector in local space
  74630. */
  74631. readonly maximum: Vector3;
  74632. private _worldMatrix;
  74633. private static readonly TmpVector3;
  74634. /**
  74635. * Creates a new bounding sphere
  74636. * @param min defines the minimum vector (in local space)
  74637. * @param max defines the maximum vector (in local space)
  74638. * @param worldMatrix defines the new world matrix
  74639. */
  74640. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74641. /**
  74642. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  74643. * @param min defines the new minimum vector (in local space)
  74644. * @param max defines the new maximum vector (in local space)
  74645. * @param worldMatrix defines the new world matrix
  74646. */
  74647. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74648. /**
  74649. * Scale the current bounding sphere by applying a scale factor
  74650. * @param factor defines the scale factor to apply
  74651. * @returns the current bounding box
  74652. */
  74653. scale(factor: number): BoundingSphere;
  74654. /**
  74655. * Gets the world matrix of the bounding box
  74656. * @returns a matrix
  74657. */
  74658. getWorldMatrix(): DeepImmutable<Matrix>;
  74659. /** @hidden */
  74660. _update(worldMatrix: DeepImmutable<Matrix>): void;
  74661. /**
  74662. * Tests if the bounding sphere is intersecting the frustum planes
  74663. * @param frustumPlanes defines the frustum planes to test
  74664. * @returns true if there is an intersection
  74665. */
  74666. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74667. /**
  74668. * Tests if the bounding sphere center is in between the frustum planes.
  74669. * Used for optimistic fast inclusion.
  74670. * @param frustumPlanes defines the frustum planes to test
  74671. * @returns true if the sphere center is in between the frustum planes
  74672. */
  74673. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74674. /**
  74675. * Tests if a point is inside the bounding sphere
  74676. * @param point defines the point to test
  74677. * @returns true if the point is inside the bounding sphere
  74678. */
  74679. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74680. /**
  74681. * Checks if two sphere intersct
  74682. * @param sphere0 sphere 0
  74683. * @param sphere1 sphere 1
  74684. * @returns true if the speres intersect
  74685. */
  74686. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  74687. }
  74688. }
  74689. declare module BABYLON {
  74690. /**
  74691. * Class used to store bounding box information
  74692. */
  74693. export class BoundingBox implements ICullable {
  74694. /**
  74695. * Gets the 8 vectors representing the bounding box in local space
  74696. */
  74697. readonly vectors: Vector3[];
  74698. /**
  74699. * Gets the center of the bounding box in local space
  74700. */
  74701. readonly center: Vector3;
  74702. /**
  74703. * Gets the center of the bounding box in world space
  74704. */
  74705. readonly centerWorld: Vector3;
  74706. /**
  74707. * Gets the extend size in local space
  74708. */
  74709. readonly extendSize: Vector3;
  74710. /**
  74711. * Gets the extend size in world space
  74712. */
  74713. readonly extendSizeWorld: Vector3;
  74714. /**
  74715. * Gets the OBB (object bounding box) directions
  74716. */
  74717. readonly directions: Vector3[];
  74718. /**
  74719. * Gets the 8 vectors representing the bounding box in world space
  74720. */
  74721. readonly vectorsWorld: Vector3[];
  74722. /**
  74723. * Gets the minimum vector in world space
  74724. */
  74725. readonly minimumWorld: Vector3;
  74726. /**
  74727. * Gets the maximum vector in world space
  74728. */
  74729. readonly maximumWorld: Vector3;
  74730. /**
  74731. * Gets the minimum vector in local space
  74732. */
  74733. readonly minimum: Vector3;
  74734. /**
  74735. * Gets the maximum vector in local space
  74736. */
  74737. readonly maximum: Vector3;
  74738. private _worldMatrix;
  74739. private static readonly TmpVector3;
  74740. /**
  74741. * @hidden
  74742. */
  74743. _tag: number;
  74744. /**
  74745. * Creates a new bounding box
  74746. * @param min defines the minimum vector (in local space)
  74747. * @param max defines the maximum vector (in local space)
  74748. * @param worldMatrix defines the new world matrix
  74749. */
  74750. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74751. /**
  74752. * Recreates the entire bounding box from scratch as if we call the constructor in place
  74753. * @param min defines the new minimum vector (in local space)
  74754. * @param max defines the new maximum vector (in local space)
  74755. * @param worldMatrix defines the new world matrix
  74756. */
  74757. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74758. /**
  74759. * Scale the current bounding box by applying a scale factor
  74760. * @param factor defines the scale factor to apply
  74761. * @returns the current bounding box
  74762. */
  74763. scale(factor: number): BoundingBox;
  74764. /**
  74765. * Gets the world matrix of the bounding box
  74766. * @returns a matrix
  74767. */
  74768. getWorldMatrix(): DeepImmutable<Matrix>;
  74769. /** @hidden */
  74770. _update(world: DeepImmutable<Matrix>): void;
  74771. /**
  74772. * Tests if the bounding box is intersecting the frustum planes
  74773. * @param frustumPlanes defines the frustum planes to test
  74774. * @returns true if there is an intersection
  74775. */
  74776. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74777. /**
  74778. * Tests if the bounding box is entirely inside the frustum planes
  74779. * @param frustumPlanes defines the frustum planes to test
  74780. * @returns true if there is an inclusion
  74781. */
  74782. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74783. /**
  74784. * Tests if a point is inside the bounding box
  74785. * @param point defines the point to test
  74786. * @returns true if the point is inside the bounding box
  74787. */
  74788. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74789. /**
  74790. * Tests if the bounding box intersects with a bounding sphere
  74791. * @param sphere defines the sphere to test
  74792. * @returns true if there is an intersection
  74793. */
  74794. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  74795. /**
  74796. * Tests if the bounding box intersects with a box defined by a min and max vectors
  74797. * @param min defines the min vector to use
  74798. * @param max defines the max vector to use
  74799. * @returns true if there is an intersection
  74800. */
  74801. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  74802. /**
  74803. * Tests if two bounding boxes are intersections
  74804. * @param box0 defines the first box to test
  74805. * @param box1 defines the second box to test
  74806. * @returns true if there is an intersection
  74807. */
  74808. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  74809. /**
  74810. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  74811. * @param minPoint defines the minimum vector of the bounding box
  74812. * @param maxPoint defines the maximum vector of the bounding box
  74813. * @param sphereCenter defines the sphere center
  74814. * @param sphereRadius defines the sphere radius
  74815. * @returns true if there is an intersection
  74816. */
  74817. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  74818. /**
  74819. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  74820. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74821. * @param frustumPlanes defines the frustum planes to test
  74822. * @return true if there is an inclusion
  74823. */
  74824. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74825. /**
  74826. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  74827. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74828. * @param frustumPlanes defines the frustum planes to test
  74829. * @return true if there is an intersection
  74830. */
  74831. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74832. }
  74833. }
  74834. declare module BABYLON {
  74835. /** @hidden */
  74836. export class Collider {
  74837. /** Define if a collision was found */
  74838. collisionFound: boolean;
  74839. /**
  74840. * Define last intersection point in local space
  74841. */
  74842. intersectionPoint: Vector3;
  74843. /**
  74844. * Define last collided mesh
  74845. */
  74846. collidedMesh: Nullable<AbstractMesh>;
  74847. private _collisionPoint;
  74848. private _planeIntersectionPoint;
  74849. private _tempVector;
  74850. private _tempVector2;
  74851. private _tempVector3;
  74852. private _tempVector4;
  74853. private _edge;
  74854. private _baseToVertex;
  74855. private _destinationPoint;
  74856. private _slidePlaneNormal;
  74857. private _displacementVector;
  74858. /** @hidden */
  74859. _radius: Vector3;
  74860. /** @hidden */
  74861. _retry: number;
  74862. private _velocity;
  74863. private _basePoint;
  74864. private _epsilon;
  74865. /** @hidden */
  74866. _velocityWorldLength: number;
  74867. /** @hidden */
  74868. _basePointWorld: Vector3;
  74869. private _velocityWorld;
  74870. private _normalizedVelocity;
  74871. /** @hidden */
  74872. _initialVelocity: Vector3;
  74873. /** @hidden */
  74874. _initialPosition: Vector3;
  74875. private _nearestDistance;
  74876. private _collisionMask;
  74877. collisionMask: number;
  74878. /**
  74879. * Gets the plane normal used to compute the sliding response (in local space)
  74880. */
  74881. readonly slidePlaneNormal: Vector3;
  74882. /** @hidden */
  74883. _initialize(source: Vector3, dir: Vector3, e: number): void;
  74884. /** @hidden */
  74885. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  74886. /** @hidden */
  74887. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  74888. /** @hidden */
  74889. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74890. /** @hidden */
  74891. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74892. /** @hidden */
  74893. _getResponse(pos: Vector3, vel: Vector3): void;
  74894. }
  74895. }
  74896. declare module BABYLON {
  74897. /**
  74898. * Interface for cullable objects
  74899. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  74900. */
  74901. export interface ICullable {
  74902. /**
  74903. * Checks if the object or part of the object is in the frustum
  74904. * @param frustumPlanes Camera near/planes
  74905. * @returns true if the object is in frustum otherwise false
  74906. */
  74907. isInFrustum(frustumPlanes: Plane[]): boolean;
  74908. /**
  74909. * Checks if a cullable object (mesh...) is in the camera frustum
  74910. * Unlike isInFrustum this cheks the full bounding box
  74911. * @param frustumPlanes Camera near/planes
  74912. * @returns true if the object is in frustum otherwise false
  74913. */
  74914. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  74915. }
  74916. /**
  74917. * Info for a bounding data of a mesh
  74918. */
  74919. export class BoundingInfo implements ICullable {
  74920. /**
  74921. * Bounding box for the mesh
  74922. */
  74923. readonly boundingBox: BoundingBox;
  74924. /**
  74925. * Bounding sphere for the mesh
  74926. */
  74927. readonly boundingSphere: BoundingSphere;
  74928. private _isLocked;
  74929. private static readonly TmpVector3;
  74930. /**
  74931. * Constructs bounding info
  74932. * @param minimum min vector of the bounding box/sphere
  74933. * @param maximum max vector of the bounding box/sphere
  74934. * @param worldMatrix defines the new world matrix
  74935. */
  74936. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74937. /**
  74938. * Recreates the entire bounding info from scratch as if we call the constructor in place
  74939. * @param min defines the new minimum vector (in local space)
  74940. * @param max defines the new maximum vector (in local space)
  74941. * @param worldMatrix defines the new world matrix
  74942. */
  74943. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74944. /**
  74945. * min vector of the bounding box/sphere
  74946. */
  74947. readonly minimum: Vector3;
  74948. /**
  74949. * max vector of the bounding box/sphere
  74950. */
  74951. readonly maximum: Vector3;
  74952. /**
  74953. * If the info is locked and won't be updated to avoid perf overhead
  74954. */
  74955. isLocked: boolean;
  74956. /**
  74957. * Updates the bounding sphere and box
  74958. * @param world world matrix to be used to update
  74959. */
  74960. update(world: DeepImmutable<Matrix>): void;
  74961. /**
  74962. * Recreate the bounding info to be centered around a specific point given a specific extend.
  74963. * @param center New center of the bounding info
  74964. * @param extend New extend of the bounding info
  74965. * @returns the current bounding info
  74966. */
  74967. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  74968. /**
  74969. * Scale the current bounding info by applying a scale factor
  74970. * @param factor defines the scale factor to apply
  74971. * @returns the current bounding info
  74972. */
  74973. scale(factor: number): BoundingInfo;
  74974. /**
  74975. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  74976. * @param frustumPlanes defines the frustum to test
  74977. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  74978. * @returns true if the bounding info is in the frustum planes
  74979. */
  74980. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  74981. /**
  74982. * Gets the world distance between the min and max points of the bounding box
  74983. */
  74984. readonly diagonalLength: number;
  74985. /**
  74986. * Checks if a cullable object (mesh...) is in the camera frustum
  74987. * Unlike isInFrustum this cheks the full bounding box
  74988. * @param frustumPlanes Camera near/planes
  74989. * @returns true if the object is in frustum otherwise false
  74990. */
  74991. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74992. /** @hidden */
  74993. _checkCollision(collider: Collider): boolean;
  74994. /**
  74995. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  74996. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74997. * @param point the point to check intersection with
  74998. * @returns if the point intersects
  74999. */
  75000. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75001. /**
  75002. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  75003. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75004. * @param boundingInfo the bounding info to check intersection with
  75005. * @param precise if the intersection should be done using OBB
  75006. * @returns if the bounding info intersects
  75007. */
  75008. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  75009. }
  75010. }
  75011. declare module BABYLON {
  75012. /**
  75013. * Extracts minimum and maximum values from a list of indexed positions
  75014. * @param positions defines the positions to use
  75015. * @param indices defines the indices to the positions
  75016. * @param indexStart defines the start index
  75017. * @param indexCount defines the end index
  75018. * @param bias defines bias value to add to the result
  75019. * @return minimum and maximum values
  75020. */
  75021. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  75022. minimum: Vector3;
  75023. maximum: Vector3;
  75024. };
  75025. /**
  75026. * Extracts minimum and maximum values from a list of positions
  75027. * @param positions defines the positions to use
  75028. * @param start defines the start index in the positions array
  75029. * @param count defines the number of positions to handle
  75030. * @param bias defines bias value to add to the result
  75031. * @param stride defines the stride size to use (distance between two positions in the positions array)
  75032. * @return minimum and maximum values
  75033. */
  75034. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  75035. minimum: Vector3;
  75036. maximum: Vector3;
  75037. };
  75038. }
  75039. declare module BABYLON {
  75040. /** @hidden */
  75041. export class WebGLDataBuffer extends DataBuffer {
  75042. private _buffer;
  75043. constructor(resource: WebGLBuffer);
  75044. readonly underlyingResource: any;
  75045. }
  75046. }
  75047. declare module BABYLON {
  75048. /** @hidden */
  75049. export class WebGLPipelineContext implements IPipelineContext {
  75050. engine: ThinEngine;
  75051. program: Nullable<WebGLProgram>;
  75052. context?: WebGLRenderingContext;
  75053. vertexShader?: WebGLShader;
  75054. fragmentShader?: WebGLShader;
  75055. isParallelCompiled: boolean;
  75056. onCompiled?: () => void;
  75057. transformFeedback?: WebGLTransformFeedback | null;
  75058. readonly isAsync: boolean;
  75059. readonly isReady: boolean;
  75060. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  75061. }
  75062. }
  75063. declare module BABYLON {
  75064. interface ThinEngine {
  75065. /**
  75066. * Create an uniform buffer
  75067. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75068. * @param elements defines the content of the uniform buffer
  75069. * @returns the webGL uniform buffer
  75070. */
  75071. createUniformBuffer(elements: FloatArray): DataBuffer;
  75072. /**
  75073. * Create a dynamic uniform buffer
  75074. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75075. * @param elements defines the content of the uniform buffer
  75076. * @returns the webGL uniform buffer
  75077. */
  75078. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  75079. /**
  75080. * Update an existing uniform buffer
  75081. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75082. * @param uniformBuffer defines the target uniform buffer
  75083. * @param elements defines the content to update
  75084. * @param offset defines the offset in the uniform buffer where update should start
  75085. * @param count defines the size of the data to update
  75086. */
  75087. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  75088. /**
  75089. * Bind an uniform buffer to the current webGL context
  75090. * @param buffer defines the buffer to bind
  75091. */
  75092. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  75093. /**
  75094. * Bind a buffer to the current webGL context at a given location
  75095. * @param buffer defines the buffer to bind
  75096. * @param location defines the index where to bind the buffer
  75097. */
  75098. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  75099. /**
  75100. * Bind a specific block at a given index in a specific shader program
  75101. * @param pipelineContext defines the pipeline context to use
  75102. * @param blockName defines the block name
  75103. * @param index defines the index where to bind the block
  75104. */
  75105. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  75106. }
  75107. }
  75108. declare module BABYLON {
  75109. /**
  75110. * Uniform buffer objects.
  75111. *
  75112. * Handles blocks of uniform on the GPU.
  75113. *
  75114. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75115. *
  75116. * For more information, please refer to :
  75117. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75118. */
  75119. export class UniformBuffer {
  75120. private _engine;
  75121. private _buffer;
  75122. private _data;
  75123. private _bufferData;
  75124. private _dynamic?;
  75125. private _uniformLocations;
  75126. private _uniformSizes;
  75127. private _uniformLocationPointer;
  75128. private _needSync;
  75129. private _noUBO;
  75130. private _currentEffect;
  75131. /** @hidden */
  75132. _alreadyBound: boolean;
  75133. private static _MAX_UNIFORM_SIZE;
  75134. private static _tempBuffer;
  75135. /**
  75136. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  75137. * This is dynamic to allow compat with webgl 1 and 2.
  75138. * You will need to pass the name of the uniform as well as the value.
  75139. */
  75140. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  75141. /**
  75142. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  75143. * This is dynamic to allow compat with webgl 1 and 2.
  75144. * You will need to pass the name of the uniform as well as the value.
  75145. */
  75146. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  75147. /**
  75148. * Lambda to Update a single float in a uniform buffer.
  75149. * This is dynamic to allow compat with webgl 1 and 2.
  75150. * You will need to pass the name of the uniform as well as the value.
  75151. */
  75152. updateFloat: (name: string, x: number) => void;
  75153. /**
  75154. * Lambda to Update a vec2 of float in a uniform buffer.
  75155. * This is dynamic to allow compat with webgl 1 and 2.
  75156. * You will need to pass the name of the uniform as well as the value.
  75157. */
  75158. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  75159. /**
  75160. * Lambda to Update a vec3 of float in a uniform buffer.
  75161. * This is dynamic to allow compat with webgl 1 and 2.
  75162. * You will need to pass the name of the uniform as well as the value.
  75163. */
  75164. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  75165. /**
  75166. * Lambda to Update a vec4 of float in a uniform buffer.
  75167. * This is dynamic to allow compat with webgl 1 and 2.
  75168. * You will need to pass the name of the uniform as well as the value.
  75169. */
  75170. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  75171. /**
  75172. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  75173. * This is dynamic to allow compat with webgl 1 and 2.
  75174. * You will need to pass the name of the uniform as well as the value.
  75175. */
  75176. updateMatrix: (name: string, mat: Matrix) => void;
  75177. /**
  75178. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  75179. * This is dynamic to allow compat with webgl 1 and 2.
  75180. * You will need to pass the name of the uniform as well as the value.
  75181. */
  75182. updateVector3: (name: string, vector: Vector3) => void;
  75183. /**
  75184. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  75185. * This is dynamic to allow compat with webgl 1 and 2.
  75186. * You will need to pass the name of the uniform as well as the value.
  75187. */
  75188. updateVector4: (name: string, vector: Vector4) => void;
  75189. /**
  75190. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  75191. * This is dynamic to allow compat with webgl 1 and 2.
  75192. * You will need to pass the name of the uniform as well as the value.
  75193. */
  75194. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  75195. /**
  75196. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  75197. * This is dynamic to allow compat with webgl 1 and 2.
  75198. * You will need to pass the name of the uniform as well as the value.
  75199. */
  75200. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  75201. /**
  75202. * Instantiates a new Uniform buffer objects.
  75203. *
  75204. * Handles blocks of uniform on the GPU.
  75205. *
  75206. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75207. *
  75208. * For more information, please refer to :
  75209. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75210. * @param engine Define the engine the buffer is associated with
  75211. * @param data Define the data contained in the buffer
  75212. * @param dynamic Define if the buffer is updatable
  75213. */
  75214. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  75215. /**
  75216. * Indicates if the buffer is using the WebGL2 UBO implementation,
  75217. * or just falling back on setUniformXXX calls.
  75218. */
  75219. readonly useUbo: boolean;
  75220. /**
  75221. * Indicates if the WebGL underlying uniform buffer is in sync
  75222. * with the javascript cache data.
  75223. */
  75224. readonly isSync: boolean;
  75225. /**
  75226. * Indicates if the WebGL underlying uniform buffer is dynamic.
  75227. * Also, a dynamic UniformBuffer will disable cache verification and always
  75228. * update the underlying WebGL uniform buffer to the GPU.
  75229. * @returns if Dynamic, otherwise false
  75230. */
  75231. isDynamic(): boolean;
  75232. /**
  75233. * The data cache on JS side.
  75234. * @returns the underlying data as a float array
  75235. */
  75236. getData(): Float32Array;
  75237. /**
  75238. * The underlying WebGL Uniform buffer.
  75239. * @returns the webgl buffer
  75240. */
  75241. getBuffer(): Nullable<DataBuffer>;
  75242. /**
  75243. * std140 layout specifies how to align data within an UBO structure.
  75244. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  75245. * for specs.
  75246. */
  75247. private _fillAlignment;
  75248. /**
  75249. * Adds an uniform in the buffer.
  75250. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  75251. * for the layout to be correct !
  75252. * @param name Name of the uniform, as used in the uniform block in the shader.
  75253. * @param size Data size, or data directly.
  75254. */
  75255. addUniform(name: string, size: number | number[]): void;
  75256. /**
  75257. * Adds a Matrix 4x4 to the uniform buffer.
  75258. * @param name Name of the uniform, as used in the uniform block in the shader.
  75259. * @param mat A 4x4 matrix.
  75260. */
  75261. addMatrix(name: string, mat: Matrix): void;
  75262. /**
  75263. * Adds a vec2 to the uniform buffer.
  75264. * @param name Name of the uniform, as used in the uniform block in the shader.
  75265. * @param x Define the x component value of the vec2
  75266. * @param y Define the y component value of the vec2
  75267. */
  75268. addFloat2(name: string, x: number, y: number): void;
  75269. /**
  75270. * Adds a vec3 to the uniform buffer.
  75271. * @param name Name of the uniform, as used in the uniform block in the shader.
  75272. * @param x Define the x component value of the vec3
  75273. * @param y Define the y component value of the vec3
  75274. * @param z Define the z component value of the vec3
  75275. */
  75276. addFloat3(name: string, x: number, y: number, z: number): void;
  75277. /**
  75278. * Adds a vec3 to the uniform buffer.
  75279. * @param name Name of the uniform, as used in the uniform block in the shader.
  75280. * @param color Define the vec3 from a Color
  75281. */
  75282. addColor3(name: string, color: Color3): void;
  75283. /**
  75284. * Adds a vec4 to the uniform buffer.
  75285. * @param name Name of the uniform, as used in the uniform block in the shader.
  75286. * @param color Define the rgb components from a Color
  75287. * @param alpha Define the a component of the vec4
  75288. */
  75289. addColor4(name: string, color: Color3, alpha: number): void;
  75290. /**
  75291. * Adds a vec3 to the uniform buffer.
  75292. * @param name Name of the uniform, as used in the uniform block in the shader.
  75293. * @param vector Define the vec3 components from a Vector
  75294. */
  75295. addVector3(name: string, vector: Vector3): void;
  75296. /**
  75297. * Adds a Matrix 3x3 to the uniform buffer.
  75298. * @param name Name of the uniform, as used in the uniform block in the shader.
  75299. */
  75300. addMatrix3x3(name: string): void;
  75301. /**
  75302. * Adds a Matrix 2x2 to the uniform buffer.
  75303. * @param name Name of the uniform, as used in the uniform block in the shader.
  75304. */
  75305. addMatrix2x2(name: string): void;
  75306. /**
  75307. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  75308. */
  75309. create(): void;
  75310. /** @hidden */
  75311. _rebuild(): void;
  75312. /**
  75313. * Updates the WebGL Uniform Buffer on the GPU.
  75314. * If the `dynamic` flag is set to true, no cache comparison is done.
  75315. * Otherwise, the buffer will be updated only if the cache differs.
  75316. */
  75317. update(): void;
  75318. /**
  75319. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  75320. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75321. * @param data Define the flattened data
  75322. * @param size Define the size of the data.
  75323. */
  75324. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  75325. private _valueCache;
  75326. private _cacheMatrix;
  75327. private _updateMatrix3x3ForUniform;
  75328. private _updateMatrix3x3ForEffect;
  75329. private _updateMatrix2x2ForEffect;
  75330. private _updateMatrix2x2ForUniform;
  75331. private _updateFloatForEffect;
  75332. private _updateFloatForUniform;
  75333. private _updateFloat2ForEffect;
  75334. private _updateFloat2ForUniform;
  75335. private _updateFloat3ForEffect;
  75336. private _updateFloat3ForUniform;
  75337. private _updateFloat4ForEffect;
  75338. private _updateFloat4ForUniform;
  75339. private _updateMatrixForEffect;
  75340. private _updateMatrixForUniform;
  75341. private _updateVector3ForEffect;
  75342. private _updateVector3ForUniform;
  75343. private _updateVector4ForEffect;
  75344. private _updateVector4ForUniform;
  75345. private _updateColor3ForEffect;
  75346. private _updateColor3ForUniform;
  75347. private _updateColor4ForEffect;
  75348. private _updateColor4ForUniform;
  75349. /**
  75350. * Sets a sampler uniform on the effect.
  75351. * @param name Define the name of the sampler.
  75352. * @param texture Define the texture to set in the sampler
  75353. */
  75354. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  75355. /**
  75356. * Directly updates the value of the uniform in the cache AND on the GPU.
  75357. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75358. * @param data Define the flattened data
  75359. */
  75360. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  75361. /**
  75362. * Binds this uniform buffer to an effect.
  75363. * @param effect Define the effect to bind the buffer to
  75364. * @param name Name of the uniform block in the shader.
  75365. */
  75366. bindToEffect(effect: Effect, name: string): void;
  75367. /**
  75368. * Disposes the uniform buffer.
  75369. */
  75370. dispose(): void;
  75371. }
  75372. }
  75373. declare module BABYLON {
  75374. /**
  75375. * Enum that determines the text-wrapping mode to use.
  75376. */
  75377. export enum InspectableType {
  75378. /**
  75379. * Checkbox for booleans
  75380. */
  75381. Checkbox = 0,
  75382. /**
  75383. * Sliders for numbers
  75384. */
  75385. Slider = 1,
  75386. /**
  75387. * Vector3
  75388. */
  75389. Vector3 = 2,
  75390. /**
  75391. * Quaternions
  75392. */
  75393. Quaternion = 3,
  75394. /**
  75395. * Color3
  75396. */
  75397. Color3 = 4,
  75398. /**
  75399. * String
  75400. */
  75401. String = 5
  75402. }
  75403. /**
  75404. * Interface used to define custom inspectable properties.
  75405. * This interface is used by the inspector to display custom property grids
  75406. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75407. */
  75408. export interface IInspectable {
  75409. /**
  75410. * Gets the label to display
  75411. */
  75412. label: string;
  75413. /**
  75414. * Gets the name of the property to edit
  75415. */
  75416. propertyName: string;
  75417. /**
  75418. * Gets the type of the editor to use
  75419. */
  75420. type: InspectableType;
  75421. /**
  75422. * Gets the minimum value of the property when using in "slider" mode
  75423. */
  75424. min?: number;
  75425. /**
  75426. * Gets the maximum value of the property when using in "slider" mode
  75427. */
  75428. max?: number;
  75429. /**
  75430. * Gets the setp to use when using in "slider" mode
  75431. */
  75432. step?: number;
  75433. }
  75434. }
  75435. declare module BABYLON {
  75436. /**
  75437. * Class used to provide helper for timing
  75438. */
  75439. export class TimingTools {
  75440. /**
  75441. * Polyfill for setImmediate
  75442. * @param action defines the action to execute after the current execution block
  75443. */
  75444. static SetImmediate(action: () => void): void;
  75445. }
  75446. }
  75447. declare module BABYLON {
  75448. /**
  75449. * Class used to enable instatition of objects by class name
  75450. */
  75451. export class InstantiationTools {
  75452. /**
  75453. * Use this object to register external classes like custom textures or material
  75454. * to allow the laoders to instantiate them
  75455. */
  75456. static RegisteredExternalClasses: {
  75457. [key: string]: Object;
  75458. };
  75459. /**
  75460. * Tries to instantiate a new object from a given class name
  75461. * @param className defines the class name to instantiate
  75462. * @returns the new object or null if the system was not able to do the instantiation
  75463. */
  75464. static Instantiate(className: string): any;
  75465. }
  75466. }
  75467. declare module BABYLON {
  75468. /**
  75469. * Define options used to create a depth texture
  75470. */
  75471. export class DepthTextureCreationOptions {
  75472. /** Specifies whether or not a stencil should be allocated in the texture */
  75473. generateStencil?: boolean;
  75474. /** Specifies whether or not bilinear filtering is enable on the texture */
  75475. bilinearFiltering?: boolean;
  75476. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  75477. comparisonFunction?: number;
  75478. /** Specifies if the created texture is a cube texture */
  75479. isCube?: boolean;
  75480. }
  75481. }
  75482. declare module BABYLON {
  75483. interface ThinEngine {
  75484. /**
  75485. * Creates a depth stencil cube texture.
  75486. * This is only available in WebGL 2.
  75487. * @param size The size of face edge in the cube texture.
  75488. * @param options The options defining the cube texture.
  75489. * @returns The cube texture
  75490. */
  75491. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  75492. /**
  75493. * Creates a cube texture
  75494. * @param rootUrl defines the url where the files to load is located
  75495. * @param scene defines the current scene
  75496. * @param files defines the list of files to load (1 per face)
  75497. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75498. * @param onLoad defines an optional callback raised when the texture is loaded
  75499. * @param onError defines an optional callback raised if there is an issue to load the texture
  75500. * @param format defines the format of the data
  75501. * @param forcedExtension defines the extension to use to pick the right loader
  75502. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75503. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75504. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75505. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  75506. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  75507. * @returns the cube texture as an InternalTexture
  75508. */
  75509. 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;
  75510. /**
  75511. * Creates a cube texture
  75512. * @param rootUrl defines the url where the files to load is located
  75513. * @param scene defines the current scene
  75514. * @param files defines the list of files to load (1 per face)
  75515. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75516. * @param onLoad defines an optional callback raised when the texture is loaded
  75517. * @param onError defines an optional callback raised if there is an issue to load the texture
  75518. * @param format defines the format of the data
  75519. * @param forcedExtension defines the extension to use to pick the right loader
  75520. * @returns the cube texture as an InternalTexture
  75521. */
  75522. 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;
  75523. /**
  75524. * Creates a cube texture
  75525. * @param rootUrl defines the url where the files to load is located
  75526. * @param scene defines the current scene
  75527. * @param files defines the list of files to load (1 per face)
  75528. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75529. * @param onLoad defines an optional callback raised when the texture is loaded
  75530. * @param onError defines an optional callback raised if there is an issue to load the texture
  75531. * @param format defines the format of the data
  75532. * @param forcedExtension defines the extension to use to pick the right loader
  75533. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75534. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75535. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75536. * @returns the cube texture as an InternalTexture
  75537. */
  75538. 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;
  75539. /** @hidden */
  75540. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  75541. /** @hidden */
  75542. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  75543. /** @hidden */
  75544. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75545. /** @hidden */
  75546. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75547. /**
  75548. * @hidden
  75549. */
  75550. _setCubeMapTextureParams(loadMipmap: boolean): void;
  75551. }
  75552. }
  75553. declare module BABYLON {
  75554. /**
  75555. * Class for creating a cube texture
  75556. */
  75557. export class CubeTexture extends BaseTexture {
  75558. private _delayedOnLoad;
  75559. /**
  75560. * The url of the texture
  75561. */
  75562. url: string;
  75563. /**
  75564. * Gets or sets the center of the bounding box associated with the cube texture.
  75565. * It must define where the camera used to render the texture was set
  75566. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75567. */
  75568. boundingBoxPosition: Vector3;
  75569. private _boundingBoxSize;
  75570. /**
  75571. * Gets or sets the size of the bounding box associated with the cube texture
  75572. * When defined, the cubemap will switch to local mode
  75573. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75574. * @example https://www.babylonjs-playground.com/#RNASML
  75575. */
  75576. /**
  75577. * Returns the bounding box size
  75578. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75579. */
  75580. boundingBoxSize: Vector3;
  75581. protected _rotationY: number;
  75582. /**
  75583. * Sets texture matrix rotation angle around Y axis in radians.
  75584. */
  75585. /**
  75586. * Gets texture matrix rotation angle around Y axis radians.
  75587. */
  75588. rotationY: number;
  75589. /**
  75590. * Are mip maps generated for this texture or not.
  75591. */
  75592. readonly noMipmap: boolean;
  75593. private _noMipmap;
  75594. private _files;
  75595. protected _forcedExtension: Nullable<string>;
  75596. private _extensions;
  75597. private _textureMatrix;
  75598. private _format;
  75599. private _createPolynomials;
  75600. /** @hidden */
  75601. _prefiltered: boolean;
  75602. /**
  75603. * Creates a cube texture from an array of image urls
  75604. * @param files defines an array of image urls
  75605. * @param scene defines the hosting scene
  75606. * @param noMipmap specifies if mip maps are not used
  75607. * @returns a cube texture
  75608. */
  75609. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  75610. /**
  75611. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  75612. * @param url defines the url of the prefiltered texture
  75613. * @param scene defines the scene the texture is attached to
  75614. * @param forcedExtension defines the extension of the file if different from the url
  75615. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75616. * @return the prefiltered texture
  75617. */
  75618. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  75619. /**
  75620. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  75621. * as prefiltered data.
  75622. * @param rootUrl defines the url of the texture or the root name of the six images
  75623. * @param scene defines the scene the texture is attached to
  75624. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  75625. * @param noMipmap defines if mipmaps should be created or not
  75626. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  75627. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  75628. * @param onError defines a callback triggered in case of error during load
  75629. * @param format defines the internal format to use for the texture once loaded
  75630. * @param prefiltered defines whether or not the texture is created from prefiltered data
  75631. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  75632. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75633. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75634. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75635. * @return the cube texture
  75636. */
  75637. 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);
  75638. /**
  75639. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  75640. */
  75641. readonly isPrefiltered: boolean;
  75642. /**
  75643. * Get the current class name of the texture useful for serialization or dynamic coding.
  75644. * @returns "CubeTexture"
  75645. */
  75646. getClassName(): string;
  75647. /**
  75648. * Update the url (and optional buffer) of this texture if url was null during construction.
  75649. * @param url the url of the texture
  75650. * @param forcedExtension defines the extension to use
  75651. * @param onLoad callback called when the texture is loaded (defaults to null)
  75652. */
  75653. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  75654. /**
  75655. * Delays loading of the cube texture
  75656. * @param forcedExtension defines the extension to use
  75657. */
  75658. delayLoad(forcedExtension?: string): void;
  75659. /**
  75660. * Returns the reflection texture matrix
  75661. * @returns the reflection texture matrix
  75662. */
  75663. getReflectionTextureMatrix(): Matrix;
  75664. /**
  75665. * Sets the reflection texture matrix
  75666. * @param value Reflection texture matrix
  75667. */
  75668. setReflectionTextureMatrix(value: Matrix): void;
  75669. /**
  75670. * Parses text to create a cube texture
  75671. * @param parsedTexture define the serialized text to read from
  75672. * @param scene defines the hosting scene
  75673. * @param rootUrl defines the root url of the cube texture
  75674. * @returns a cube texture
  75675. */
  75676. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  75677. /**
  75678. * Makes a clone, or deep copy, of the cube texture
  75679. * @returns a new cube texture
  75680. */
  75681. clone(): CubeTexture;
  75682. }
  75683. }
  75684. declare module BABYLON {
  75685. /**
  75686. * Manages the defines for the Material
  75687. */
  75688. export class MaterialDefines {
  75689. /** @hidden */
  75690. protected _keys: string[];
  75691. private _isDirty;
  75692. /** @hidden */
  75693. _renderId: number;
  75694. /** @hidden */
  75695. _areLightsDirty: boolean;
  75696. /** @hidden */
  75697. _areLightsDisposed: boolean;
  75698. /** @hidden */
  75699. _areAttributesDirty: boolean;
  75700. /** @hidden */
  75701. _areTexturesDirty: boolean;
  75702. /** @hidden */
  75703. _areFresnelDirty: boolean;
  75704. /** @hidden */
  75705. _areMiscDirty: boolean;
  75706. /** @hidden */
  75707. _areImageProcessingDirty: boolean;
  75708. /** @hidden */
  75709. _normals: boolean;
  75710. /** @hidden */
  75711. _uvs: boolean;
  75712. /** @hidden */
  75713. _needNormals: boolean;
  75714. /** @hidden */
  75715. _needUVs: boolean;
  75716. [id: string]: any;
  75717. /**
  75718. * Specifies if the material needs to be re-calculated
  75719. */
  75720. readonly isDirty: boolean;
  75721. /**
  75722. * Marks the material to indicate that it has been re-calculated
  75723. */
  75724. markAsProcessed(): void;
  75725. /**
  75726. * Marks the material to indicate that it needs to be re-calculated
  75727. */
  75728. markAsUnprocessed(): void;
  75729. /**
  75730. * Marks the material to indicate all of its defines need to be re-calculated
  75731. */
  75732. markAllAsDirty(): void;
  75733. /**
  75734. * Marks the material to indicate that image processing needs to be re-calculated
  75735. */
  75736. markAsImageProcessingDirty(): void;
  75737. /**
  75738. * Marks the material to indicate the lights need to be re-calculated
  75739. * @param disposed Defines whether the light is dirty due to dispose or not
  75740. */
  75741. markAsLightDirty(disposed?: boolean): void;
  75742. /**
  75743. * Marks the attribute state as changed
  75744. */
  75745. markAsAttributesDirty(): void;
  75746. /**
  75747. * Marks the texture state as changed
  75748. */
  75749. markAsTexturesDirty(): void;
  75750. /**
  75751. * Marks the fresnel state as changed
  75752. */
  75753. markAsFresnelDirty(): void;
  75754. /**
  75755. * Marks the misc state as changed
  75756. */
  75757. markAsMiscDirty(): void;
  75758. /**
  75759. * Rebuilds the material defines
  75760. */
  75761. rebuild(): void;
  75762. /**
  75763. * Specifies if two material defines are equal
  75764. * @param other - A material define instance to compare to
  75765. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  75766. */
  75767. isEqual(other: MaterialDefines): boolean;
  75768. /**
  75769. * Clones this instance's defines to another instance
  75770. * @param other - material defines to clone values to
  75771. */
  75772. cloneTo(other: MaterialDefines): void;
  75773. /**
  75774. * Resets the material define values
  75775. */
  75776. reset(): void;
  75777. /**
  75778. * Converts the material define values to a string
  75779. * @returns - String of material define information
  75780. */
  75781. toString(): string;
  75782. }
  75783. }
  75784. declare module BABYLON {
  75785. /**
  75786. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  75787. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  75788. * 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;
  75789. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  75790. */
  75791. export class ColorCurves {
  75792. private _dirty;
  75793. private _tempColor;
  75794. private _globalCurve;
  75795. private _highlightsCurve;
  75796. private _midtonesCurve;
  75797. private _shadowsCurve;
  75798. private _positiveCurve;
  75799. private _negativeCurve;
  75800. private _globalHue;
  75801. private _globalDensity;
  75802. private _globalSaturation;
  75803. private _globalExposure;
  75804. /**
  75805. * Gets the global Hue value.
  75806. * 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).
  75807. */
  75808. /**
  75809. * Sets the global Hue value.
  75810. * 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).
  75811. */
  75812. globalHue: number;
  75813. /**
  75814. * Gets the global Density value.
  75815. * 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.
  75816. * Values less than zero provide a filter of opposite hue.
  75817. */
  75818. /**
  75819. * Sets the global Density value.
  75820. * 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.
  75821. * Values less than zero provide a filter of opposite hue.
  75822. */
  75823. globalDensity: number;
  75824. /**
  75825. * Gets the global Saturation value.
  75826. * 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.
  75827. */
  75828. /**
  75829. * Sets the global Saturation value.
  75830. * 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.
  75831. */
  75832. globalSaturation: number;
  75833. /**
  75834. * Gets the global Exposure value.
  75835. * 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.
  75836. */
  75837. /**
  75838. * Sets the global Exposure value.
  75839. * 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.
  75840. */
  75841. globalExposure: number;
  75842. private _highlightsHue;
  75843. private _highlightsDensity;
  75844. private _highlightsSaturation;
  75845. private _highlightsExposure;
  75846. /**
  75847. * Gets the highlights Hue value.
  75848. * 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).
  75849. */
  75850. /**
  75851. * Sets the highlights Hue value.
  75852. * 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).
  75853. */
  75854. highlightsHue: number;
  75855. /**
  75856. * Gets the highlights Density value.
  75857. * 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.
  75858. * Values less than zero provide a filter of opposite hue.
  75859. */
  75860. /**
  75861. * Sets the highlights Density value.
  75862. * 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.
  75863. * Values less than zero provide a filter of opposite hue.
  75864. */
  75865. highlightsDensity: number;
  75866. /**
  75867. * Gets the highlights Saturation value.
  75868. * 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.
  75869. */
  75870. /**
  75871. * Sets the highlights Saturation value.
  75872. * 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.
  75873. */
  75874. highlightsSaturation: number;
  75875. /**
  75876. * Gets the highlights Exposure value.
  75877. * 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.
  75878. */
  75879. /**
  75880. * Sets the highlights Exposure value.
  75881. * 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.
  75882. */
  75883. highlightsExposure: number;
  75884. private _midtonesHue;
  75885. private _midtonesDensity;
  75886. private _midtonesSaturation;
  75887. private _midtonesExposure;
  75888. /**
  75889. * Gets the midtones Hue value.
  75890. * 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).
  75891. */
  75892. /**
  75893. * Sets the midtones Hue value.
  75894. * 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).
  75895. */
  75896. midtonesHue: number;
  75897. /**
  75898. * Gets the midtones Density value.
  75899. * 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.
  75900. * Values less than zero provide a filter of opposite hue.
  75901. */
  75902. /**
  75903. * Sets the midtones Density value.
  75904. * 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.
  75905. * Values less than zero provide a filter of opposite hue.
  75906. */
  75907. midtonesDensity: number;
  75908. /**
  75909. * Gets the midtones Saturation value.
  75910. * 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.
  75911. */
  75912. /**
  75913. * Sets the midtones Saturation value.
  75914. * 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.
  75915. */
  75916. midtonesSaturation: number;
  75917. /**
  75918. * Gets the midtones Exposure value.
  75919. * 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.
  75920. */
  75921. /**
  75922. * Sets the midtones Exposure value.
  75923. * 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.
  75924. */
  75925. midtonesExposure: number;
  75926. private _shadowsHue;
  75927. private _shadowsDensity;
  75928. private _shadowsSaturation;
  75929. private _shadowsExposure;
  75930. /**
  75931. * Gets the shadows Hue value.
  75932. * 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).
  75933. */
  75934. /**
  75935. * Sets the shadows Hue value.
  75936. * 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).
  75937. */
  75938. shadowsHue: number;
  75939. /**
  75940. * Gets the shadows Density value.
  75941. * 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.
  75942. * Values less than zero provide a filter of opposite hue.
  75943. */
  75944. /**
  75945. * Sets the shadows Density value.
  75946. * 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.
  75947. * Values less than zero provide a filter of opposite hue.
  75948. */
  75949. shadowsDensity: number;
  75950. /**
  75951. * Gets the shadows Saturation value.
  75952. * 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.
  75953. */
  75954. /**
  75955. * Sets the shadows Saturation value.
  75956. * 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.
  75957. */
  75958. shadowsSaturation: number;
  75959. /**
  75960. * Gets the shadows Exposure value.
  75961. * 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.
  75962. */
  75963. /**
  75964. * Sets the shadows Exposure value.
  75965. * 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.
  75966. */
  75967. shadowsExposure: number;
  75968. /**
  75969. * Returns the class name
  75970. * @returns The class name
  75971. */
  75972. getClassName(): string;
  75973. /**
  75974. * Binds the color curves to the shader.
  75975. * @param colorCurves The color curve to bind
  75976. * @param effect The effect to bind to
  75977. * @param positiveUniform The positive uniform shader parameter
  75978. * @param neutralUniform The neutral uniform shader parameter
  75979. * @param negativeUniform The negative uniform shader parameter
  75980. */
  75981. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  75982. /**
  75983. * Prepare the list of uniforms associated with the ColorCurves effects.
  75984. * @param uniformsList The list of uniforms used in the effect
  75985. */
  75986. static PrepareUniforms(uniformsList: string[]): void;
  75987. /**
  75988. * Returns color grading data based on a hue, density, saturation and exposure value.
  75989. * @param filterHue The hue of the color filter.
  75990. * @param filterDensity The density of the color filter.
  75991. * @param saturation The saturation.
  75992. * @param exposure The exposure.
  75993. * @param result The result data container.
  75994. */
  75995. private getColorGradingDataToRef;
  75996. /**
  75997. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  75998. * @param value The input slider value in range [-100,100].
  75999. * @returns Adjusted value.
  76000. */
  76001. private static applyColorGradingSliderNonlinear;
  76002. /**
  76003. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  76004. * @param hue The hue (H) input.
  76005. * @param saturation The saturation (S) input.
  76006. * @param brightness The brightness (B) input.
  76007. * @result An RGBA color represented as Vector4.
  76008. */
  76009. private static fromHSBToRef;
  76010. /**
  76011. * Returns a value clamped between min and max
  76012. * @param value The value to clamp
  76013. * @param min The minimum of value
  76014. * @param max The maximum of value
  76015. * @returns The clamped value.
  76016. */
  76017. private static clamp;
  76018. /**
  76019. * Clones the current color curve instance.
  76020. * @return The cloned curves
  76021. */
  76022. clone(): ColorCurves;
  76023. /**
  76024. * Serializes the current color curve instance to a json representation.
  76025. * @return a JSON representation
  76026. */
  76027. serialize(): any;
  76028. /**
  76029. * Parses the color curve from a json representation.
  76030. * @param source the JSON source to parse
  76031. * @return The parsed curves
  76032. */
  76033. static Parse(source: any): ColorCurves;
  76034. }
  76035. }
  76036. declare module BABYLON {
  76037. /**
  76038. * Interface to follow in your material defines to integrate easily the
  76039. * Image proccessing functions.
  76040. * @hidden
  76041. */
  76042. export interface IImageProcessingConfigurationDefines {
  76043. IMAGEPROCESSING: boolean;
  76044. VIGNETTE: boolean;
  76045. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76046. VIGNETTEBLENDMODEOPAQUE: boolean;
  76047. TONEMAPPING: boolean;
  76048. TONEMAPPING_ACES: boolean;
  76049. CONTRAST: boolean;
  76050. EXPOSURE: boolean;
  76051. COLORCURVES: boolean;
  76052. COLORGRADING: boolean;
  76053. COLORGRADING3D: boolean;
  76054. SAMPLER3DGREENDEPTH: boolean;
  76055. SAMPLER3DBGRMAP: boolean;
  76056. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76057. }
  76058. /**
  76059. * @hidden
  76060. */
  76061. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  76062. IMAGEPROCESSING: boolean;
  76063. VIGNETTE: boolean;
  76064. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76065. VIGNETTEBLENDMODEOPAQUE: boolean;
  76066. TONEMAPPING: boolean;
  76067. TONEMAPPING_ACES: boolean;
  76068. CONTRAST: boolean;
  76069. COLORCURVES: boolean;
  76070. COLORGRADING: boolean;
  76071. COLORGRADING3D: boolean;
  76072. SAMPLER3DGREENDEPTH: boolean;
  76073. SAMPLER3DBGRMAP: boolean;
  76074. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76075. EXPOSURE: boolean;
  76076. constructor();
  76077. }
  76078. /**
  76079. * This groups together the common properties used for image processing either in direct forward pass
  76080. * or through post processing effect depending on the use of the image processing pipeline in your scene
  76081. * or not.
  76082. */
  76083. export class ImageProcessingConfiguration {
  76084. /**
  76085. * Default tone mapping applied in BabylonJS.
  76086. */
  76087. static readonly TONEMAPPING_STANDARD: number;
  76088. /**
  76089. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  76090. * to other engines rendering to increase portability.
  76091. */
  76092. static readonly TONEMAPPING_ACES: number;
  76093. /**
  76094. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  76095. */
  76096. colorCurves: Nullable<ColorCurves>;
  76097. private _colorCurvesEnabled;
  76098. /**
  76099. * Gets wether the color curves effect is enabled.
  76100. */
  76101. /**
  76102. * Sets wether the color curves effect is enabled.
  76103. */
  76104. colorCurvesEnabled: boolean;
  76105. private _colorGradingTexture;
  76106. /**
  76107. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76108. */
  76109. /**
  76110. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76111. */
  76112. colorGradingTexture: Nullable<BaseTexture>;
  76113. private _colorGradingEnabled;
  76114. /**
  76115. * Gets wether the color grading effect is enabled.
  76116. */
  76117. /**
  76118. * Sets wether the color grading effect is enabled.
  76119. */
  76120. colorGradingEnabled: boolean;
  76121. private _colorGradingWithGreenDepth;
  76122. /**
  76123. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  76124. */
  76125. /**
  76126. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  76127. */
  76128. colorGradingWithGreenDepth: boolean;
  76129. private _colorGradingBGR;
  76130. /**
  76131. * Gets wether the color grading texture contains BGR values.
  76132. */
  76133. /**
  76134. * Sets wether the color grading texture contains BGR values.
  76135. */
  76136. colorGradingBGR: boolean;
  76137. /** @hidden */
  76138. _exposure: number;
  76139. /**
  76140. * Gets the Exposure used in the effect.
  76141. */
  76142. /**
  76143. * Sets the Exposure used in the effect.
  76144. */
  76145. exposure: number;
  76146. private _toneMappingEnabled;
  76147. /**
  76148. * Gets wether the tone mapping effect is enabled.
  76149. */
  76150. /**
  76151. * Sets wether the tone mapping effect is enabled.
  76152. */
  76153. toneMappingEnabled: boolean;
  76154. private _toneMappingType;
  76155. /**
  76156. * Gets the type of tone mapping effect.
  76157. */
  76158. /**
  76159. * Sets the type of tone mapping effect used in BabylonJS.
  76160. */
  76161. toneMappingType: number;
  76162. protected _contrast: number;
  76163. /**
  76164. * Gets the contrast used in the effect.
  76165. */
  76166. /**
  76167. * Sets the contrast used in the effect.
  76168. */
  76169. contrast: number;
  76170. /**
  76171. * Vignette stretch size.
  76172. */
  76173. vignetteStretch: number;
  76174. /**
  76175. * Vignette centre X Offset.
  76176. */
  76177. vignetteCentreX: number;
  76178. /**
  76179. * Vignette centre Y Offset.
  76180. */
  76181. vignetteCentreY: number;
  76182. /**
  76183. * Vignette weight or intensity of the vignette effect.
  76184. */
  76185. vignetteWeight: number;
  76186. /**
  76187. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  76188. * if vignetteEnabled is set to true.
  76189. */
  76190. vignetteColor: Color4;
  76191. /**
  76192. * Camera field of view used by the Vignette effect.
  76193. */
  76194. vignetteCameraFov: number;
  76195. private _vignetteBlendMode;
  76196. /**
  76197. * Gets the vignette blend mode allowing different kind of effect.
  76198. */
  76199. /**
  76200. * Sets the vignette blend mode allowing different kind of effect.
  76201. */
  76202. vignetteBlendMode: number;
  76203. private _vignetteEnabled;
  76204. /**
  76205. * Gets wether the vignette effect is enabled.
  76206. */
  76207. /**
  76208. * Sets wether the vignette effect is enabled.
  76209. */
  76210. vignetteEnabled: boolean;
  76211. private _applyByPostProcess;
  76212. /**
  76213. * Gets wether the image processing is applied through a post process or not.
  76214. */
  76215. /**
  76216. * Sets wether the image processing is applied through a post process or not.
  76217. */
  76218. applyByPostProcess: boolean;
  76219. private _isEnabled;
  76220. /**
  76221. * Gets wether the image processing is enabled or not.
  76222. */
  76223. /**
  76224. * Sets wether the image processing is enabled or not.
  76225. */
  76226. isEnabled: boolean;
  76227. /**
  76228. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  76229. */
  76230. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  76231. /**
  76232. * Method called each time the image processing information changes requires to recompile the effect.
  76233. */
  76234. protected _updateParameters(): void;
  76235. /**
  76236. * Gets the current class name.
  76237. * @return "ImageProcessingConfiguration"
  76238. */
  76239. getClassName(): string;
  76240. /**
  76241. * Prepare the list of uniforms associated with the Image Processing effects.
  76242. * @param uniforms The list of uniforms used in the effect
  76243. * @param defines the list of defines currently in use
  76244. */
  76245. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  76246. /**
  76247. * Prepare the list of samplers associated with the Image Processing effects.
  76248. * @param samplersList The list of uniforms used in the effect
  76249. * @param defines the list of defines currently in use
  76250. */
  76251. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  76252. /**
  76253. * Prepare the list of defines associated to the shader.
  76254. * @param defines the list of defines to complete
  76255. * @param forPostProcess Define if we are currently in post process mode or not
  76256. */
  76257. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  76258. /**
  76259. * Returns true if all the image processing information are ready.
  76260. * @returns True if ready, otherwise, false
  76261. */
  76262. isReady(): boolean;
  76263. /**
  76264. * Binds the image processing to the shader.
  76265. * @param effect The effect to bind to
  76266. * @param overrideAspectRatio Override the aspect ratio of the effect
  76267. */
  76268. bind(effect: Effect, overrideAspectRatio?: number): void;
  76269. /**
  76270. * Clones the current image processing instance.
  76271. * @return The cloned image processing
  76272. */
  76273. clone(): ImageProcessingConfiguration;
  76274. /**
  76275. * Serializes the current image processing instance to a json representation.
  76276. * @return a JSON representation
  76277. */
  76278. serialize(): any;
  76279. /**
  76280. * Parses the image processing from a json representation.
  76281. * @param source the JSON source to parse
  76282. * @return The parsed image processing
  76283. */
  76284. static Parse(source: any): ImageProcessingConfiguration;
  76285. private static _VIGNETTEMODE_MULTIPLY;
  76286. private static _VIGNETTEMODE_OPAQUE;
  76287. /**
  76288. * Used to apply the vignette as a mix with the pixel color.
  76289. */
  76290. static readonly VIGNETTEMODE_MULTIPLY: number;
  76291. /**
  76292. * Used to apply the vignette as a replacement of the pixel color.
  76293. */
  76294. static readonly VIGNETTEMODE_OPAQUE: number;
  76295. }
  76296. }
  76297. declare module BABYLON {
  76298. /** @hidden */
  76299. export var postprocessVertexShader: {
  76300. name: string;
  76301. shader: string;
  76302. };
  76303. }
  76304. declare module BABYLON {
  76305. interface ThinEngine {
  76306. /**
  76307. * Creates a new render target texture
  76308. * @param size defines the size of the texture
  76309. * @param options defines the options used to create the texture
  76310. * @returns a new render target texture stored in an InternalTexture
  76311. */
  76312. createRenderTargetTexture(size: number | {
  76313. width: number;
  76314. height: number;
  76315. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  76316. /**
  76317. * Creates a depth stencil texture.
  76318. * This is only available in WebGL 2 or with the depth texture extension available.
  76319. * @param size The size of face edge in the texture.
  76320. * @param options The options defining the texture.
  76321. * @returns The texture
  76322. */
  76323. createDepthStencilTexture(size: number | {
  76324. width: number;
  76325. height: number;
  76326. }, options: DepthTextureCreationOptions): InternalTexture;
  76327. /** @hidden */
  76328. _createDepthStencilTexture(size: number | {
  76329. width: number;
  76330. height: number;
  76331. }, options: DepthTextureCreationOptions): InternalTexture;
  76332. }
  76333. }
  76334. declare module BABYLON {
  76335. /** Defines supported spaces */
  76336. export enum Space {
  76337. /** Local (object) space */
  76338. LOCAL = 0,
  76339. /** World space */
  76340. WORLD = 1,
  76341. /** Bone space */
  76342. BONE = 2
  76343. }
  76344. /** Defines the 3 main axes */
  76345. export class Axis {
  76346. /** X axis */
  76347. static X: Vector3;
  76348. /** Y axis */
  76349. static Y: Vector3;
  76350. /** Z axis */
  76351. static Z: Vector3;
  76352. }
  76353. }
  76354. declare module BABYLON {
  76355. /**
  76356. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  76357. * This is the base of the follow, arc rotate cameras and Free camera
  76358. * @see http://doc.babylonjs.com/features/cameras
  76359. */
  76360. export class TargetCamera extends Camera {
  76361. private static _RigCamTransformMatrix;
  76362. private static _TargetTransformMatrix;
  76363. private static _TargetFocalPoint;
  76364. /**
  76365. * Define the current direction the camera is moving to
  76366. */
  76367. cameraDirection: Vector3;
  76368. /**
  76369. * Define the current rotation the camera is rotating to
  76370. */
  76371. cameraRotation: Vector2;
  76372. /**
  76373. * When set, the up vector of the camera will be updated by the rotation of the camera
  76374. */
  76375. updateUpVectorFromRotation: boolean;
  76376. private _tmpQuaternion;
  76377. /**
  76378. * Define the current rotation of the camera
  76379. */
  76380. rotation: Vector3;
  76381. /**
  76382. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  76383. */
  76384. rotationQuaternion: Quaternion;
  76385. /**
  76386. * Define the current speed of the camera
  76387. */
  76388. speed: number;
  76389. /**
  76390. * Add cconstraint to the camera to prevent it to move freely in all directions and
  76391. * around all axis.
  76392. */
  76393. noRotationConstraint: boolean;
  76394. /**
  76395. * Define the current target of the camera as an object or a position.
  76396. */
  76397. lockedTarget: any;
  76398. /** @hidden */
  76399. _currentTarget: Vector3;
  76400. /** @hidden */
  76401. _initialFocalDistance: number;
  76402. /** @hidden */
  76403. _viewMatrix: Matrix;
  76404. /** @hidden */
  76405. _camMatrix: Matrix;
  76406. /** @hidden */
  76407. _cameraTransformMatrix: Matrix;
  76408. /** @hidden */
  76409. _cameraRotationMatrix: Matrix;
  76410. /** @hidden */
  76411. _referencePoint: Vector3;
  76412. /** @hidden */
  76413. _transformedReferencePoint: Vector3;
  76414. protected _globalCurrentTarget: Vector3;
  76415. protected _globalCurrentUpVector: Vector3;
  76416. /** @hidden */
  76417. _reset: () => void;
  76418. private _defaultUp;
  76419. /**
  76420. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  76421. * This is the base of the follow, arc rotate cameras and Free camera
  76422. * @see http://doc.babylonjs.com/features/cameras
  76423. * @param name Defines the name of the camera in the scene
  76424. * @param position Defines the start position of the camera in the scene
  76425. * @param scene Defines the scene the camera belongs to
  76426. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76427. */
  76428. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76429. /**
  76430. * Gets the position in front of the camera at a given distance.
  76431. * @param distance The distance from the camera we want the position to be
  76432. * @returns the position
  76433. */
  76434. getFrontPosition(distance: number): Vector3;
  76435. /** @hidden */
  76436. _getLockedTargetPosition(): Nullable<Vector3>;
  76437. private _storedPosition;
  76438. private _storedRotation;
  76439. private _storedRotationQuaternion;
  76440. /**
  76441. * Store current camera state of the camera (fov, position, rotation, etc..)
  76442. * @returns the camera
  76443. */
  76444. storeState(): Camera;
  76445. /**
  76446. * Restored camera state. You must call storeState() first
  76447. * @returns whether it was successful or not
  76448. * @hidden
  76449. */
  76450. _restoreStateValues(): boolean;
  76451. /** @hidden */
  76452. _initCache(): void;
  76453. /** @hidden */
  76454. _updateCache(ignoreParentClass?: boolean): void;
  76455. /** @hidden */
  76456. _isSynchronizedViewMatrix(): boolean;
  76457. /** @hidden */
  76458. _computeLocalCameraSpeed(): number;
  76459. /**
  76460. * Defines the target the camera should look at.
  76461. * @param target Defines the new target as a Vector or a mesh
  76462. */
  76463. setTarget(target: Vector3): void;
  76464. /**
  76465. * Return the current target position of the camera. This value is expressed in local space.
  76466. * @returns the target position
  76467. */
  76468. getTarget(): Vector3;
  76469. /** @hidden */
  76470. _decideIfNeedsToMove(): boolean;
  76471. /** @hidden */
  76472. _updatePosition(): void;
  76473. /** @hidden */
  76474. _checkInputs(): void;
  76475. protected _updateCameraRotationMatrix(): void;
  76476. /**
  76477. * 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)
  76478. * @returns the current camera
  76479. */
  76480. private _rotateUpVectorWithCameraRotationMatrix;
  76481. private _cachedRotationZ;
  76482. private _cachedQuaternionRotationZ;
  76483. /** @hidden */
  76484. _getViewMatrix(): Matrix;
  76485. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  76486. /**
  76487. * @hidden
  76488. */
  76489. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  76490. /**
  76491. * @hidden
  76492. */
  76493. _updateRigCameras(): void;
  76494. private _getRigCamPositionAndTarget;
  76495. /**
  76496. * Gets the current object class name.
  76497. * @return the class name
  76498. */
  76499. getClassName(): string;
  76500. }
  76501. }
  76502. declare module BABYLON {
  76503. /**
  76504. * Gather the list of keyboard event types as constants.
  76505. */
  76506. export class KeyboardEventTypes {
  76507. /**
  76508. * The keydown event is fired when a key becomes active (pressed).
  76509. */
  76510. static readonly KEYDOWN: number;
  76511. /**
  76512. * The keyup event is fired when a key has been released.
  76513. */
  76514. static readonly KEYUP: number;
  76515. }
  76516. /**
  76517. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76518. */
  76519. export class KeyboardInfo {
  76520. /**
  76521. * Defines the type of event (KeyboardEventTypes)
  76522. */
  76523. type: number;
  76524. /**
  76525. * Defines the related dom event
  76526. */
  76527. event: KeyboardEvent;
  76528. /**
  76529. * Instantiates a new keyboard info.
  76530. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76531. * @param type Defines the type of event (KeyboardEventTypes)
  76532. * @param event Defines the related dom event
  76533. */
  76534. constructor(
  76535. /**
  76536. * Defines the type of event (KeyboardEventTypes)
  76537. */
  76538. type: number,
  76539. /**
  76540. * Defines the related dom event
  76541. */
  76542. event: KeyboardEvent);
  76543. }
  76544. /**
  76545. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76546. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  76547. */
  76548. export class KeyboardInfoPre extends KeyboardInfo {
  76549. /**
  76550. * Defines the type of event (KeyboardEventTypes)
  76551. */
  76552. type: number;
  76553. /**
  76554. * Defines the related dom event
  76555. */
  76556. event: KeyboardEvent;
  76557. /**
  76558. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  76559. */
  76560. skipOnPointerObservable: boolean;
  76561. /**
  76562. * Instantiates a new keyboard pre info.
  76563. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76564. * @param type Defines the type of event (KeyboardEventTypes)
  76565. * @param event Defines the related dom event
  76566. */
  76567. constructor(
  76568. /**
  76569. * Defines the type of event (KeyboardEventTypes)
  76570. */
  76571. type: number,
  76572. /**
  76573. * Defines the related dom event
  76574. */
  76575. event: KeyboardEvent);
  76576. }
  76577. }
  76578. declare module BABYLON {
  76579. /**
  76580. * Manage the keyboard inputs to control the movement of a free camera.
  76581. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76582. */
  76583. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  76584. /**
  76585. * Defines the camera the input is attached to.
  76586. */
  76587. camera: FreeCamera;
  76588. /**
  76589. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  76590. */
  76591. keysUp: number[];
  76592. /**
  76593. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  76594. */
  76595. keysDown: number[];
  76596. /**
  76597. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  76598. */
  76599. keysLeft: number[];
  76600. /**
  76601. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  76602. */
  76603. keysRight: number[];
  76604. private _keys;
  76605. private _onCanvasBlurObserver;
  76606. private _onKeyboardObserver;
  76607. private _engine;
  76608. private _scene;
  76609. /**
  76610. * Attach the input controls to a specific dom element to get the input from.
  76611. * @param element Defines the element the controls should be listened from
  76612. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76613. */
  76614. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76615. /**
  76616. * Detach the current controls from the specified dom element.
  76617. * @param element Defines the element to stop listening the inputs from
  76618. */
  76619. detachControl(element: Nullable<HTMLElement>): void;
  76620. /**
  76621. * Update the current camera state depending on the inputs that have been used this frame.
  76622. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76623. */
  76624. checkInputs(): void;
  76625. /**
  76626. * Gets the class name of the current intput.
  76627. * @returns the class name
  76628. */
  76629. getClassName(): string;
  76630. /** @hidden */
  76631. _onLostFocus(): void;
  76632. /**
  76633. * Get the friendly name associated with the input class.
  76634. * @returns the input friendly name
  76635. */
  76636. getSimpleName(): string;
  76637. }
  76638. }
  76639. declare module BABYLON {
  76640. /**
  76641. * Interface describing all the common properties and methods a shadow light needs to implement.
  76642. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  76643. * as well as binding the different shadow properties to the effects.
  76644. */
  76645. export interface IShadowLight extends Light {
  76646. /**
  76647. * The light id in the scene (used in scene.findLighById for instance)
  76648. */
  76649. id: string;
  76650. /**
  76651. * The position the shdow will be casted from.
  76652. */
  76653. position: Vector3;
  76654. /**
  76655. * In 2d mode (needCube being false), the direction used to cast the shadow.
  76656. */
  76657. direction: Vector3;
  76658. /**
  76659. * The transformed position. Position of the light in world space taking parenting in account.
  76660. */
  76661. transformedPosition: Vector3;
  76662. /**
  76663. * The transformed direction. Direction of the light in world space taking parenting in account.
  76664. */
  76665. transformedDirection: Vector3;
  76666. /**
  76667. * The friendly name of the light in the scene.
  76668. */
  76669. name: string;
  76670. /**
  76671. * Defines the shadow projection clipping minimum z value.
  76672. */
  76673. shadowMinZ: number;
  76674. /**
  76675. * Defines the shadow projection clipping maximum z value.
  76676. */
  76677. shadowMaxZ: number;
  76678. /**
  76679. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76680. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76681. */
  76682. computeTransformedInformation(): boolean;
  76683. /**
  76684. * Gets the scene the light belongs to.
  76685. * @returns The scene
  76686. */
  76687. getScene(): Scene;
  76688. /**
  76689. * Callback defining a custom Projection Matrix Builder.
  76690. * This can be used to override the default projection matrix computation.
  76691. */
  76692. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76693. /**
  76694. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76695. * @param matrix The materix to updated with the projection information
  76696. * @param viewMatrix The transform matrix of the light
  76697. * @param renderList The list of mesh to render in the map
  76698. * @returns The current light
  76699. */
  76700. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76701. /**
  76702. * Gets the current depth scale used in ESM.
  76703. * @returns The scale
  76704. */
  76705. getDepthScale(): number;
  76706. /**
  76707. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76708. * @returns true if a cube texture needs to be use
  76709. */
  76710. needCube(): boolean;
  76711. /**
  76712. * Detects if the projection matrix requires to be recomputed this frame.
  76713. * @returns true if it requires to be recomputed otherwise, false.
  76714. */
  76715. needProjectionMatrixCompute(): boolean;
  76716. /**
  76717. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76718. */
  76719. forceProjectionMatrixCompute(): void;
  76720. /**
  76721. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76722. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76723. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76724. */
  76725. getShadowDirection(faceIndex?: number): Vector3;
  76726. /**
  76727. * Gets the minZ used for shadow according to both the scene and the light.
  76728. * @param activeCamera The camera we are returning the min for
  76729. * @returns the depth min z
  76730. */
  76731. getDepthMinZ(activeCamera: Camera): number;
  76732. /**
  76733. * Gets the maxZ used for shadow according to both the scene and the light.
  76734. * @param activeCamera The camera we are returning the max for
  76735. * @returns the depth max z
  76736. */
  76737. getDepthMaxZ(activeCamera: Camera): number;
  76738. }
  76739. /**
  76740. * Base implementation IShadowLight
  76741. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  76742. */
  76743. export abstract class ShadowLight extends Light implements IShadowLight {
  76744. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  76745. protected _position: Vector3;
  76746. protected _setPosition(value: Vector3): void;
  76747. /**
  76748. * Sets the position the shadow will be casted from. Also use as the light position for both
  76749. * point and spot lights.
  76750. */
  76751. /**
  76752. * Sets the position the shadow will be casted from. Also use as the light position for both
  76753. * point and spot lights.
  76754. */
  76755. position: Vector3;
  76756. protected _direction: Vector3;
  76757. protected _setDirection(value: Vector3): void;
  76758. /**
  76759. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  76760. * Also use as the light direction on spot and directional lights.
  76761. */
  76762. /**
  76763. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  76764. * Also use as the light direction on spot and directional lights.
  76765. */
  76766. direction: Vector3;
  76767. private _shadowMinZ;
  76768. /**
  76769. * Gets the shadow projection clipping minimum z value.
  76770. */
  76771. /**
  76772. * Sets the shadow projection clipping minimum z value.
  76773. */
  76774. shadowMinZ: number;
  76775. private _shadowMaxZ;
  76776. /**
  76777. * Sets the shadow projection clipping maximum z value.
  76778. */
  76779. /**
  76780. * Gets the shadow projection clipping maximum z value.
  76781. */
  76782. shadowMaxZ: number;
  76783. /**
  76784. * Callback defining a custom Projection Matrix Builder.
  76785. * This can be used to override the default projection matrix computation.
  76786. */
  76787. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76788. /**
  76789. * The transformed position. Position of the light in world space taking parenting in account.
  76790. */
  76791. transformedPosition: Vector3;
  76792. /**
  76793. * The transformed direction. Direction of the light in world space taking parenting in account.
  76794. */
  76795. transformedDirection: Vector3;
  76796. private _needProjectionMatrixCompute;
  76797. /**
  76798. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76799. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76800. */
  76801. computeTransformedInformation(): boolean;
  76802. /**
  76803. * Return the depth scale used for the shadow map.
  76804. * @returns the depth scale.
  76805. */
  76806. getDepthScale(): number;
  76807. /**
  76808. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76809. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76810. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76811. */
  76812. getShadowDirection(faceIndex?: number): Vector3;
  76813. /**
  76814. * Returns the ShadowLight absolute position in the World.
  76815. * @returns the position vector in world space
  76816. */
  76817. getAbsolutePosition(): Vector3;
  76818. /**
  76819. * Sets the ShadowLight direction toward the passed target.
  76820. * @param target The point to target in local space
  76821. * @returns the updated ShadowLight direction
  76822. */
  76823. setDirectionToTarget(target: Vector3): Vector3;
  76824. /**
  76825. * Returns the light rotation in euler definition.
  76826. * @returns the x y z rotation in local space.
  76827. */
  76828. getRotation(): Vector3;
  76829. /**
  76830. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76831. * @returns true if a cube texture needs to be use
  76832. */
  76833. needCube(): boolean;
  76834. /**
  76835. * Detects if the projection matrix requires to be recomputed this frame.
  76836. * @returns true if it requires to be recomputed otherwise, false.
  76837. */
  76838. needProjectionMatrixCompute(): boolean;
  76839. /**
  76840. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76841. */
  76842. forceProjectionMatrixCompute(): void;
  76843. /** @hidden */
  76844. _initCache(): void;
  76845. /** @hidden */
  76846. _isSynchronized(): boolean;
  76847. /**
  76848. * Computes the world matrix of the node
  76849. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  76850. * @returns the world matrix
  76851. */
  76852. computeWorldMatrix(force?: boolean): Matrix;
  76853. /**
  76854. * Gets the minZ used for shadow according to both the scene and the light.
  76855. * @param activeCamera The camera we are returning the min for
  76856. * @returns the depth min z
  76857. */
  76858. getDepthMinZ(activeCamera: Camera): number;
  76859. /**
  76860. * Gets the maxZ used for shadow according to both the scene and the light.
  76861. * @param activeCamera The camera we are returning the max for
  76862. * @returns the depth max z
  76863. */
  76864. getDepthMaxZ(activeCamera: Camera): number;
  76865. /**
  76866. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76867. * @param matrix The materix to updated with the projection information
  76868. * @param viewMatrix The transform matrix of the light
  76869. * @param renderList The list of mesh to render in the map
  76870. * @returns The current light
  76871. */
  76872. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76873. }
  76874. }
  76875. declare module BABYLON {
  76876. /**
  76877. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  76878. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  76879. */
  76880. export class EffectFallbacks implements IEffectFallbacks {
  76881. private _defines;
  76882. private _currentRank;
  76883. private _maxRank;
  76884. private _mesh;
  76885. /**
  76886. * Removes the fallback from the bound mesh.
  76887. */
  76888. unBindMesh(): void;
  76889. /**
  76890. * Adds a fallback on the specified property.
  76891. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76892. * @param define The name of the define in the shader
  76893. */
  76894. addFallback(rank: number, define: string): void;
  76895. /**
  76896. * Sets the mesh to use CPU skinning when needing to fallback.
  76897. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76898. * @param mesh The mesh to use the fallbacks.
  76899. */
  76900. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  76901. /**
  76902. * Checks to see if more fallbacks are still availible.
  76903. */
  76904. readonly hasMoreFallbacks: boolean;
  76905. /**
  76906. * Removes the defines that should be removed when falling back.
  76907. * @param currentDefines defines the current define statements for the shader.
  76908. * @param effect defines the current effect we try to compile
  76909. * @returns The resulting defines with defines of the current rank removed.
  76910. */
  76911. reduce(currentDefines: string, effect: Effect): string;
  76912. }
  76913. }
  76914. declare module BABYLON {
  76915. /**
  76916. * "Static Class" containing the most commonly used helper while dealing with material for
  76917. * rendering purpose.
  76918. *
  76919. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  76920. *
  76921. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  76922. */
  76923. export class MaterialHelper {
  76924. /**
  76925. * Bind the current view position to an effect.
  76926. * @param effect The effect to be bound
  76927. * @param scene The scene the eyes position is used from
  76928. */
  76929. static BindEyePosition(effect: Effect, scene: Scene): void;
  76930. /**
  76931. * Helps preparing the defines values about the UVs in used in the effect.
  76932. * UVs are shared as much as we can accross channels in the shaders.
  76933. * @param texture The texture we are preparing the UVs for
  76934. * @param defines The defines to update
  76935. * @param key The channel key "diffuse", "specular"... used in the shader
  76936. */
  76937. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  76938. /**
  76939. * Binds a texture matrix value to its corrsponding uniform
  76940. * @param texture The texture to bind the matrix for
  76941. * @param uniformBuffer The uniform buffer receivin the data
  76942. * @param key The channel key "diffuse", "specular"... used in the shader
  76943. */
  76944. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  76945. /**
  76946. * Gets the current status of the fog (should it be enabled?)
  76947. * @param mesh defines the mesh to evaluate for fog support
  76948. * @param scene defines the hosting scene
  76949. * @returns true if fog must be enabled
  76950. */
  76951. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  76952. /**
  76953. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  76954. * @param mesh defines the current mesh
  76955. * @param scene defines the current scene
  76956. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  76957. * @param pointsCloud defines if point cloud rendering has to be turned on
  76958. * @param fogEnabled defines if fog has to be turned on
  76959. * @param alphaTest defines if alpha testing has to be turned on
  76960. * @param defines defines the current list of defines
  76961. */
  76962. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  76963. /**
  76964. * Helper used to prepare the list of defines associated with frame values for shader compilation
  76965. * @param scene defines the current scene
  76966. * @param engine defines the current engine
  76967. * @param defines specifies the list of active defines
  76968. * @param useInstances defines if instances have to be turned on
  76969. * @param useClipPlane defines if clip plane have to be turned on
  76970. */
  76971. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  76972. /**
  76973. * Prepares the defines for bones
  76974. * @param mesh The mesh containing the geometry data we will draw
  76975. * @param defines The defines to update
  76976. */
  76977. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  76978. /**
  76979. * Prepares the defines for morph targets
  76980. * @param mesh The mesh containing the geometry data we will draw
  76981. * @param defines The defines to update
  76982. */
  76983. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  76984. /**
  76985. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  76986. * @param mesh The mesh containing the geometry data we will draw
  76987. * @param defines The defines to update
  76988. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  76989. * @param useBones Precise whether bones should be used or not (override mesh info)
  76990. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  76991. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  76992. * @returns false if defines are considered not dirty and have not been checked
  76993. */
  76994. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  76995. /**
  76996. * Prepares the defines related to multiview
  76997. * @param scene The scene we are intending to draw
  76998. * @param defines The defines to update
  76999. */
  77000. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  77001. /**
  77002. * Prepares the defines related to the light information passed in parameter
  77003. * @param scene The scene we are intending to draw
  77004. * @param mesh The mesh the effect is compiling for
  77005. * @param light The light the effect is compiling for
  77006. * @param lightIndex The index of the light
  77007. * @param defines The defines to update
  77008. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77009. * @param state Defines the current state regarding what is needed (normals, etc...)
  77010. */
  77011. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  77012. needNormals: boolean;
  77013. needRebuild: boolean;
  77014. shadowEnabled: boolean;
  77015. specularEnabled: boolean;
  77016. lightmapMode: boolean;
  77017. }): void;
  77018. /**
  77019. * Prepares the defines related to the light information passed in parameter
  77020. * @param scene The scene we are intending to draw
  77021. * @param mesh The mesh the effect is compiling for
  77022. * @param defines The defines to update
  77023. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77024. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  77025. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  77026. * @returns true if normals will be required for the rest of the effect
  77027. */
  77028. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  77029. /**
  77030. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  77031. * @param lightIndex defines the light index
  77032. * @param uniformsList The uniform list
  77033. * @param samplersList The sampler list
  77034. * @param projectedLightTexture defines if projected texture must be used
  77035. * @param uniformBuffersList defines an optional list of uniform buffers
  77036. */
  77037. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  77038. /**
  77039. * Prepares the uniforms and samplers list to be used in the effect
  77040. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  77041. * @param samplersList The sampler list
  77042. * @param defines The defines helping in the list generation
  77043. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  77044. */
  77045. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  77046. /**
  77047. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  77048. * @param defines The defines to update while falling back
  77049. * @param fallbacks The authorized effect fallbacks
  77050. * @param maxSimultaneousLights The maximum number of lights allowed
  77051. * @param rank the current rank of the Effect
  77052. * @returns The newly affected rank
  77053. */
  77054. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  77055. private static _TmpMorphInfluencers;
  77056. /**
  77057. * Prepares the list of attributes required for morph targets according to the effect defines.
  77058. * @param attribs The current list of supported attribs
  77059. * @param mesh The mesh to prepare the morph targets attributes for
  77060. * @param influencers The number of influencers
  77061. */
  77062. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  77063. /**
  77064. * Prepares the list of attributes required for morph targets according to the effect defines.
  77065. * @param attribs The current list of supported attribs
  77066. * @param mesh The mesh to prepare the morph targets attributes for
  77067. * @param defines The current Defines of the effect
  77068. */
  77069. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  77070. /**
  77071. * Prepares the list of attributes required for bones according to the effect defines.
  77072. * @param attribs The current list of supported attribs
  77073. * @param mesh The mesh to prepare the bones attributes for
  77074. * @param defines The current Defines of the effect
  77075. * @param fallbacks The current efffect fallback strategy
  77076. */
  77077. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  77078. /**
  77079. * Check and prepare the list of attributes required for instances according to the effect defines.
  77080. * @param attribs The current list of supported attribs
  77081. * @param defines The current MaterialDefines of the effect
  77082. */
  77083. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  77084. /**
  77085. * Add the list of attributes required for instances to the attribs array.
  77086. * @param attribs The current list of supported attribs
  77087. */
  77088. static PushAttributesForInstances(attribs: string[]): void;
  77089. /**
  77090. * Binds the light information to the effect.
  77091. * @param light The light containing the generator
  77092. * @param effect The effect we are binding the data to
  77093. * @param lightIndex The light index in the effect used to render
  77094. */
  77095. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  77096. /**
  77097. * Binds the lights information from the scene to the effect for the given mesh.
  77098. * @param light Light to bind
  77099. * @param lightIndex Light index
  77100. * @param scene The scene where the light belongs to
  77101. * @param effect The effect we are binding the data to
  77102. * @param useSpecular Defines if specular is supported
  77103. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77104. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77105. */
  77106. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77107. /**
  77108. * Binds the lights information from the scene to the effect for the given mesh.
  77109. * @param scene The scene the lights belongs to
  77110. * @param mesh The mesh we are binding the information to render
  77111. * @param effect The effect we are binding the data to
  77112. * @param defines The generated defines for the effect
  77113. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  77114. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77115. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77116. */
  77117. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77118. private static _tempFogColor;
  77119. /**
  77120. * Binds the fog information from the scene to the effect for the given mesh.
  77121. * @param scene The scene the lights belongs to
  77122. * @param mesh The mesh we are binding the information to render
  77123. * @param effect The effect we are binding the data to
  77124. * @param linearSpace Defines if the fog effect is applied in linear space
  77125. */
  77126. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  77127. /**
  77128. * Binds the bones information from the mesh to the effect.
  77129. * @param mesh The mesh we are binding the information to render
  77130. * @param effect The effect we are binding the data to
  77131. */
  77132. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  77133. /**
  77134. * Binds the morph targets information from the mesh to the effect.
  77135. * @param abstractMesh The mesh we are binding the information to render
  77136. * @param effect The effect we are binding the data to
  77137. */
  77138. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  77139. /**
  77140. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  77141. * @param defines The generated defines used in the effect
  77142. * @param effect The effect we are binding the data to
  77143. * @param scene The scene we are willing to render with logarithmic scale for
  77144. */
  77145. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  77146. /**
  77147. * Binds the clip plane information from the scene to the effect.
  77148. * @param scene The scene the clip plane information are extracted from
  77149. * @param effect The effect we are binding the data to
  77150. */
  77151. static BindClipPlane(effect: Effect, scene: Scene): void;
  77152. }
  77153. }
  77154. declare module BABYLON {
  77155. /** @hidden */
  77156. export var packingFunctions: {
  77157. name: string;
  77158. shader: string;
  77159. };
  77160. }
  77161. declare module BABYLON {
  77162. /** @hidden */
  77163. export var shadowMapPixelShader: {
  77164. name: string;
  77165. shader: string;
  77166. };
  77167. }
  77168. declare module BABYLON {
  77169. /** @hidden */
  77170. export var bonesDeclaration: {
  77171. name: string;
  77172. shader: string;
  77173. };
  77174. }
  77175. declare module BABYLON {
  77176. /** @hidden */
  77177. export var morphTargetsVertexGlobalDeclaration: {
  77178. name: string;
  77179. shader: string;
  77180. };
  77181. }
  77182. declare module BABYLON {
  77183. /** @hidden */
  77184. export var morphTargetsVertexDeclaration: {
  77185. name: string;
  77186. shader: string;
  77187. };
  77188. }
  77189. declare module BABYLON {
  77190. /** @hidden */
  77191. export var instancesDeclaration: {
  77192. name: string;
  77193. shader: string;
  77194. };
  77195. }
  77196. declare module BABYLON {
  77197. /** @hidden */
  77198. export var helperFunctions: {
  77199. name: string;
  77200. shader: string;
  77201. };
  77202. }
  77203. declare module BABYLON {
  77204. /** @hidden */
  77205. export var morphTargetsVertex: {
  77206. name: string;
  77207. shader: string;
  77208. };
  77209. }
  77210. declare module BABYLON {
  77211. /** @hidden */
  77212. export var instancesVertex: {
  77213. name: string;
  77214. shader: string;
  77215. };
  77216. }
  77217. declare module BABYLON {
  77218. /** @hidden */
  77219. export var bonesVertex: {
  77220. name: string;
  77221. shader: string;
  77222. };
  77223. }
  77224. declare module BABYLON {
  77225. /** @hidden */
  77226. export var shadowMapVertexShader: {
  77227. name: string;
  77228. shader: string;
  77229. };
  77230. }
  77231. declare module BABYLON {
  77232. /** @hidden */
  77233. export var depthBoxBlurPixelShader: {
  77234. name: string;
  77235. shader: string;
  77236. };
  77237. }
  77238. declare module BABYLON {
  77239. /**
  77240. * Defines the options associated with the creation of a custom shader for a shadow generator.
  77241. */
  77242. export interface ICustomShaderOptions {
  77243. /**
  77244. * Gets or sets the custom shader name to use
  77245. */
  77246. shaderName: string;
  77247. /**
  77248. * The list of attribute names used in the shader
  77249. */
  77250. attributes?: string[];
  77251. /**
  77252. * The list of unifrom names used in the shader
  77253. */
  77254. uniforms?: string[];
  77255. /**
  77256. * The list of sampler names used in the shader
  77257. */
  77258. samplers?: string[];
  77259. /**
  77260. * The list of defines used in the shader
  77261. */
  77262. defines?: string[];
  77263. }
  77264. /**
  77265. * Interface to implement to create a shadow generator compatible with BJS.
  77266. */
  77267. export interface IShadowGenerator {
  77268. /**
  77269. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77270. * @returns The render target texture if present otherwise, null
  77271. */
  77272. getShadowMap(): Nullable<RenderTargetTexture>;
  77273. /**
  77274. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77275. * @returns The render target texture if the shadow map is present otherwise, null
  77276. */
  77277. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77278. /**
  77279. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77280. * @param subMesh The submesh we want to render in the shadow map
  77281. * @param useInstances Defines wether will draw in the map using instances
  77282. * @returns true if ready otherwise, false
  77283. */
  77284. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77285. /**
  77286. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77287. * @param defines Defines of the material we want to update
  77288. * @param lightIndex Index of the light in the enabled light list of the material
  77289. */
  77290. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  77291. /**
  77292. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77293. * defined in the generator but impacting the effect).
  77294. * It implies the unifroms available on the materials are the standard BJS ones.
  77295. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77296. * @param effect The effect we are binfing the information for
  77297. */
  77298. bindShadowLight(lightIndex: string, effect: Effect): void;
  77299. /**
  77300. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77301. * (eq to shadow prjection matrix * light transform matrix)
  77302. * @returns The transform matrix used to create the shadow map
  77303. */
  77304. getTransformMatrix(): Matrix;
  77305. /**
  77306. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77307. * Cube and 2D textures for instance.
  77308. */
  77309. recreateShadowMap(): void;
  77310. /**
  77311. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77312. * @param onCompiled Callback triggered at the and of the effects compilation
  77313. * @param options Sets of optional options forcing the compilation with different modes
  77314. */
  77315. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77316. useInstances: boolean;
  77317. }>): void;
  77318. /**
  77319. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77320. * @param options Sets of optional options forcing the compilation with different modes
  77321. * @returns A promise that resolves when the compilation completes
  77322. */
  77323. forceCompilationAsync(options?: Partial<{
  77324. useInstances: boolean;
  77325. }>): Promise<void>;
  77326. /**
  77327. * Serializes the shadow generator setup to a json object.
  77328. * @returns The serialized JSON object
  77329. */
  77330. serialize(): any;
  77331. /**
  77332. * Disposes the Shadow map and related Textures and effects.
  77333. */
  77334. dispose(): void;
  77335. }
  77336. /**
  77337. * Default implementation IShadowGenerator.
  77338. * This is the main object responsible of generating shadows in the framework.
  77339. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  77340. */
  77341. export class ShadowGenerator implements IShadowGenerator {
  77342. /**
  77343. * Shadow generator mode None: no filtering applied.
  77344. */
  77345. static readonly FILTER_NONE: number;
  77346. /**
  77347. * Shadow generator mode ESM: Exponential Shadow Mapping.
  77348. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77349. */
  77350. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  77351. /**
  77352. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  77353. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  77354. */
  77355. static readonly FILTER_POISSONSAMPLING: number;
  77356. /**
  77357. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  77358. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77359. */
  77360. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  77361. /**
  77362. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  77363. * edge artifacts on steep falloff.
  77364. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77365. */
  77366. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  77367. /**
  77368. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  77369. * edge artifacts on steep falloff.
  77370. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77371. */
  77372. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  77373. /**
  77374. * Shadow generator mode PCF: Percentage Closer Filtering
  77375. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77376. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  77377. */
  77378. static readonly FILTER_PCF: number;
  77379. /**
  77380. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  77381. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77382. * Contact Hardening
  77383. */
  77384. static readonly FILTER_PCSS: number;
  77385. /**
  77386. * Reserved for PCF and PCSS
  77387. * Highest Quality.
  77388. *
  77389. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  77390. *
  77391. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  77392. */
  77393. static readonly QUALITY_HIGH: number;
  77394. /**
  77395. * Reserved for PCF and PCSS
  77396. * Good tradeoff for quality/perf cross devices
  77397. *
  77398. * Execute PCF on a 3*3 kernel.
  77399. *
  77400. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  77401. */
  77402. static readonly QUALITY_MEDIUM: number;
  77403. /**
  77404. * Reserved for PCF and PCSS
  77405. * The lowest quality but the fastest.
  77406. *
  77407. * Execute PCF on a 1*1 kernel.
  77408. *
  77409. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  77410. */
  77411. static readonly QUALITY_LOW: number;
  77412. /** Gets or sets the custom shader name to use */
  77413. customShaderOptions: ICustomShaderOptions;
  77414. /**
  77415. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  77416. */
  77417. onBeforeShadowMapRenderObservable: Observable<Effect>;
  77418. /**
  77419. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  77420. */
  77421. onAfterShadowMapRenderObservable: Observable<Effect>;
  77422. /**
  77423. * Observable triggered before a mesh is rendered in the shadow map.
  77424. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  77425. */
  77426. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  77427. /**
  77428. * Observable triggered after a mesh is rendered in the shadow map.
  77429. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  77430. */
  77431. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  77432. private _bias;
  77433. /**
  77434. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  77435. */
  77436. /**
  77437. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  77438. */
  77439. bias: number;
  77440. private _normalBias;
  77441. /**
  77442. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77443. */
  77444. /**
  77445. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77446. */
  77447. normalBias: number;
  77448. private _blurBoxOffset;
  77449. /**
  77450. * Gets the blur box offset: offset applied during the blur pass.
  77451. * Only useful if useKernelBlur = false
  77452. */
  77453. /**
  77454. * Sets the blur box offset: offset applied during the blur pass.
  77455. * Only useful if useKernelBlur = false
  77456. */
  77457. blurBoxOffset: number;
  77458. private _blurScale;
  77459. /**
  77460. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  77461. * 2 means half of the size.
  77462. */
  77463. /**
  77464. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  77465. * 2 means half of the size.
  77466. */
  77467. blurScale: number;
  77468. private _blurKernel;
  77469. /**
  77470. * Gets the blur kernel: kernel size of the blur pass.
  77471. * Only useful if useKernelBlur = true
  77472. */
  77473. /**
  77474. * Sets the blur kernel: kernel size of the blur pass.
  77475. * Only useful if useKernelBlur = true
  77476. */
  77477. blurKernel: number;
  77478. private _useKernelBlur;
  77479. /**
  77480. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  77481. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77482. */
  77483. /**
  77484. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  77485. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77486. */
  77487. useKernelBlur: boolean;
  77488. private _depthScale;
  77489. /**
  77490. * Gets the depth scale used in ESM mode.
  77491. */
  77492. /**
  77493. * Sets the depth scale used in ESM mode.
  77494. * This can override the scale stored on the light.
  77495. */
  77496. depthScale: number;
  77497. private _filter;
  77498. /**
  77499. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  77500. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77501. */
  77502. /**
  77503. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  77504. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77505. */
  77506. filter: number;
  77507. /**
  77508. * Gets if the current filter is set to Poisson Sampling.
  77509. */
  77510. /**
  77511. * Sets the current filter to Poisson Sampling.
  77512. */
  77513. usePoissonSampling: boolean;
  77514. /**
  77515. * Gets if the current filter is set to ESM.
  77516. */
  77517. /**
  77518. * Sets the current filter is to ESM.
  77519. */
  77520. useExponentialShadowMap: boolean;
  77521. /**
  77522. * Gets if the current filter is set to filtered ESM.
  77523. */
  77524. /**
  77525. * Gets if the current filter is set to filtered ESM.
  77526. */
  77527. useBlurExponentialShadowMap: boolean;
  77528. /**
  77529. * Gets if the current filter is set to "close ESM" (using the inverse of the
  77530. * exponential to prevent steep falloff artifacts).
  77531. */
  77532. /**
  77533. * Sets the current filter to "close ESM" (using the inverse of the
  77534. * exponential to prevent steep falloff artifacts).
  77535. */
  77536. useCloseExponentialShadowMap: boolean;
  77537. /**
  77538. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  77539. * exponential to prevent steep falloff artifacts).
  77540. */
  77541. /**
  77542. * Sets the current filter to filtered "close ESM" (using the inverse of the
  77543. * exponential to prevent steep falloff artifacts).
  77544. */
  77545. useBlurCloseExponentialShadowMap: boolean;
  77546. /**
  77547. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  77548. */
  77549. /**
  77550. * Sets the current filter to "PCF" (percentage closer filtering).
  77551. */
  77552. usePercentageCloserFiltering: boolean;
  77553. private _filteringQuality;
  77554. /**
  77555. * Gets the PCF or PCSS Quality.
  77556. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77557. */
  77558. /**
  77559. * Sets the PCF or PCSS Quality.
  77560. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77561. */
  77562. filteringQuality: number;
  77563. /**
  77564. * Gets if the current filter is set to "PCSS" (contact hardening).
  77565. */
  77566. /**
  77567. * Sets the current filter to "PCSS" (contact hardening).
  77568. */
  77569. useContactHardeningShadow: boolean;
  77570. private _contactHardeningLightSizeUVRatio;
  77571. /**
  77572. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77573. * Using a ratio helps keeping shape stability independently of the map size.
  77574. *
  77575. * It does not account for the light projection as it was having too much
  77576. * instability during the light setup or during light position changes.
  77577. *
  77578. * Only valid if useContactHardeningShadow is true.
  77579. */
  77580. /**
  77581. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77582. * Using a ratio helps keeping shape stability independently of the map size.
  77583. *
  77584. * It does not account for the light projection as it was having too much
  77585. * instability during the light setup or during light position changes.
  77586. *
  77587. * Only valid if useContactHardeningShadow is true.
  77588. */
  77589. contactHardeningLightSizeUVRatio: number;
  77590. private _darkness;
  77591. /** Gets or sets the actual darkness of a shadow */
  77592. darkness: number;
  77593. /**
  77594. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  77595. * 0 means strongest and 1 would means no shadow.
  77596. * @returns the darkness.
  77597. */
  77598. getDarkness(): number;
  77599. /**
  77600. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  77601. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  77602. * @returns the shadow generator allowing fluent coding.
  77603. */
  77604. setDarkness(darkness: number): ShadowGenerator;
  77605. private _transparencyShadow;
  77606. /** Gets or sets the ability to have transparent shadow */
  77607. transparencyShadow: boolean;
  77608. /**
  77609. * Sets the ability to have transparent shadow (boolean).
  77610. * @param transparent True if transparent else False
  77611. * @returns the shadow generator allowing fluent coding
  77612. */
  77613. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  77614. private _shadowMap;
  77615. private _shadowMap2;
  77616. /**
  77617. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77618. * @returns The render target texture if present otherwise, null
  77619. */
  77620. getShadowMap(): Nullable<RenderTargetTexture>;
  77621. /**
  77622. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77623. * @returns The render target texture if the shadow map is present otherwise, null
  77624. */
  77625. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77626. /**
  77627. * Gets the class name of that object
  77628. * @returns "ShadowGenerator"
  77629. */
  77630. getClassName(): string;
  77631. /**
  77632. * Helper function to add a mesh and its descendants to the list of shadow casters.
  77633. * @param mesh Mesh to add
  77634. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  77635. * @returns the Shadow Generator itself
  77636. */
  77637. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77638. /**
  77639. * Helper function to remove a mesh and its descendants from the list of shadow casters
  77640. * @param mesh Mesh to remove
  77641. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  77642. * @returns the Shadow Generator itself
  77643. */
  77644. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77645. /**
  77646. * Controls the extent to which the shadows fade out at the edge of the frustum
  77647. * Used only by directionals and spots
  77648. */
  77649. frustumEdgeFalloff: number;
  77650. private _light;
  77651. /**
  77652. * Returns the associated light object.
  77653. * @returns the light generating the shadow
  77654. */
  77655. getLight(): IShadowLight;
  77656. /**
  77657. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  77658. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  77659. * It might on the other hand introduce peter panning.
  77660. */
  77661. forceBackFacesOnly: boolean;
  77662. private _scene;
  77663. private _lightDirection;
  77664. private _effect;
  77665. private _viewMatrix;
  77666. private _projectionMatrix;
  77667. private _transformMatrix;
  77668. private _cachedPosition;
  77669. private _cachedDirection;
  77670. private _cachedDefines;
  77671. private _currentRenderID;
  77672. private _boxBlurPostprocess;
  77673. private _kernelBlurXPostprocess;
  77674. private _kernelBlurYPostprocess;
  77675. private _blurPostProcesses;
  77676. private _mapSize;
  77677. private _currentFaceIndex;
  77678. private _currentFaceIndexCache;
  77679. private _textureType;
  77680. private _defaultTextureMatrix;
  77681. private _storedUniqueId;
  77682. /** @hidden */
  77683. static _SceneComponentInitialization: (scene: Scene) => void;
  77684. /**
  77685. * Creates a ShadowGenerator object.
  77686. * A ShadowGenerator is the required tool to use the shadows.
  77687. * Each light casting shadows needs to use its own ShadowGenerator.
  77688. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  77689. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  77690. * @param light The light object generating the shadows.
  77691. * @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.
  77692. */
  77693. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  77694. private _initializeGenerator;
  77695. private _initializeShadowMap;
  77696. private _initializeBlurRTTAndPostProcesses;
  77697. private _renderForShadowMap;
  77698. private _renderSubMeshForShadowMap;
  77699. private _applyFilterValues;
  77700. /**
  77701. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77702. * @param onCompiled Callback triggered at the and of the effects compilation
  77703. * @param options Sets of optional options forcing the compilation with different modes
  77704. */
  77705. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77706. useInstances: boolean;
  77707. }>): void;
  77708. /**
  77709. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77710. * @param options Sets of optional options forcing the compilation with different modes
  77711. * @returns A promise that resolves when the compilation completes
  77712. */
  77713. forceCompilationAsync(options?: Partial<{
  77714. useInstances: boolean;
  77715. }>): Promise<void>;
  77716. /**
  77717. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77718. * @param subMesh The submesh we want to render in the shadow map
  77719. * @param useInstances Defines wether will draw in the map using instances
  77720. * @returns true if ready otherwise, false
  77721. */
  77722. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77723. /**
  77724. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77725. * @param defines Defines of the material we want to update
  77726. * @param lightIndex Index of the light in the enabled light list of the material
  77727. */
  77728. prepareDefines(defines: any, lightIndex: number): void;
  77729. /**
  77730. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77731. * defined in the generator but impacting the effect).
  77732. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77733. * @param effect The effect we are binfing the information for
  77734. */
  77735. bindShadowLight(lightIndex: string, effect: Effect): void;
  77736. /**
  77737. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77738. * (eq to shadow prjection matrix * light transform matrix)
  77739. * @returns The transform matrix used to create the shadow map
  77740. */
  77741. getTransformMatrix(): Matrix;
  77742. /**
  77743. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77744. * Cube and 2D textures for instance.
  77745. */
  77746. recreateShadowMap(): void;
  77747. private _disposeBlurPostProcesses;
  77748. private _disposeRTTandPostProcesses;
  77749. /**
  77750. * Disposes the ShadowGenerator.
  77751. * Returns nothing.
  77752. */
  77753. dispose(): void;
  77754. /**
  77755. * Serializes the shadow generator setup to a json object.
  77756. * @returns The serialized JSON object
  77757. */
  77758. serialize(): any;
  77759. /**
  77760. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  77761. * @param parsedShadowGenerator The JSON object to parse
  77762. * @param scene The scene to create the shadow map for
  77763. * @returns The parsed shadow generator
  77764. */
  77765. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  77766. }
  77767. }
  77768. declare module BABYLON {
  77769. /**
  77770. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  77771. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  77772. * 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.
  77773. */
  77774. export abstract class Light extends Node {
  77775. /**
  77776. * Falloff Default: light is falling off following the material specification:
  77777. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  77778. */
  77779. static readonly FALLOFF_DEFAULT: number;
  77780. /**
  77781. * Falloff Physical: light is falling off following the inverse squared distance law.
  77782. */
  77783. static readonly FALLOFF_PHYSICAL: number;
  77784. /**
  77785. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  77786. * to enhance interoperability with other engines.
  77787. */
  77788. static readonly FALLOFF_GLTF: number;
  77789. /**
  77790. * Falloff Standard: light is falling off like in the standard material
  77791. * to enhance interoperability with other materials.
  77792. */
  77793. static readonly FALLOFF_STANDARD: number;
  77794. /**
  77795. * If every light affecting the material is in this lightmapMode,
  77796. * material.lightmapTexture adds or multiplies
  77797. * (depends on material.useLightmapAsShadowmap)
  77798. * after every other light calculations.
  77799. */
  77800. static readonly LIGHTMAP_DEFAULT: number;
  77801. /**
  77802. * material.lightmapTexture as only diffuse lighting from this light
  77803. * adds only specular lighting from this light
  77804. * adds dynamic shadows
  77805. */
  77806. static readonly LIGHTMAP_SPECULAR: number;
  77807. /**
  77808. * material.lightmapTexture as only lighting
  77809. * no light calculation from this light
  77810. * only adds dynamic shadows from this light
  77811. */
  77812. static readonly LIGHTMAP_SHADOWSONLY: number;
  77813. /**
  77814. * Each light type uses the default quantity according to its type:
  77815. * point/spot lights use luminous intensity
  77816. * directional lights use illuminance
  77817. */
  77818. static readonly INTENSITYMODE_AUTOMATIC: number;
  77819. /**
  77820. * lumen (lm)
  77821. */
  77822. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  77823. /**
  77824. * candela (lm/sr)
  77825. */
  77826. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  77827. /**
  77828. * lux (lm/m^2)
  77829. */
  77830. static readonly INTENSITYMODE_ILLUMINANCE: number;
  77831. /**
  77832. * nit (cd/m^2)
  77833. */
  77834. static readonly INTENSITYMODE_LUMINANCE: number;
  77835. /**
  77836. * Light type const id of the point light.
  77837. */
  77838. static readonly LIGHTTYPEID_POINTLIGHT: number;
  77839. /**
  77840. * Light type const id of the directional light.
  77841. */
  77842. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  77843. /**
  77844. * Light type const id of the spot light.
  77845. */
  77846. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  77847. /**
  77848. * Light type const id of the hemispheric light.
  77849. */
  77850. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  77851. /**
  77852. * Diffuse gives the basic color to an object.
  77853. */
  77854. diffuse: Color3;
  77855. /**
  77856. * Specular produces a highlight color on an object.
  77857. * Note: This is note affecting PBR materials.
  77858. */
  77859. specular: Color3;
  77860. /**
  77861. * Defines the falloff type for this light. This lets overrriding how punctual light are
  77862. * falling off base on range or angle.
  77863. * This can be set to any values in Light.FALLOFF_x.
  77864. *
  77865. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  77866. * other types of materials.
  77867. */
  77868. falloffType: number;
  77869. /**
  77870. * Strength of the light.
  77871. * Note: By default it is define in the framework own unit.
  77872. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  77873. */
  77874. intensity: number;
  77875. private _range;
  77876. protected _inverseSquaredRange: number;
  77877. /**
  77878. * Defines how far from the source the light is impacting in scene units.
  77879. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77880. */
  77881. /**
  77882. * Defines how far from the source the light is impacting in scene units.
  77883. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77884. */
  77885. range: number;
  77886. /**
  77887. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  77888. * of light.
  77889. */
  77890. private _photometricScale;
  77891. private _intensityMode;
  77892. /**
  77893. * Gets the photometric scale used to interpret the intensity.
  77894. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77895. */
  77896. /**
  77897. * Sets the photometric scale used to interpret the intensity.
  77898. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77899. */
  77900. intensityMode: number;
  77901. private _radius;
  77902. /**
  77903. * Gets the light radius used by PBR Materials to simulate soft area lights.
  77904. */
  77905. /**
  77906. * sets the light radius used by PBR Materials to simulate soft area lights.
  77907. */
  77908. radius: number;
  77909. private _renderPriority;
  77910. /**
  77911. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  77912. * exceeding the number allowed of the materials.
  77913. */
  77914. renderPriority: number;
  77915. private _shadowEnabled;
  77916. /**
  77917. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77918. * the current shadow generator.
  77919. */
  77920. /**
  77921. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77922. * the current shadow generator.
  77923. */
  77924. shadowEnabled: boolean;
  77925. private _includedOnlyMeshes;
  77926. /**
  77927. * Gets the only meshes impacted by this light.
  77928. */
  77929. /**
  77930. * Sets the only meshes impacted by this light.
  77931. */
  77932. includedOnlyMeshes: AbstractMesh[];
  77933. private _excludedMeshes;
  77934. /**
  77935. * Gets the meshes not impacted by this light.
  77936. */
  77937. /**
  77938. * Sets the meshes not impacted by this light.
  77939. */
  77940. excludedMeshes: AbstractMesh[];
  77941. private _excludeWithLayerMask;
  77942. /**
  77943. * Gets the layer id use to find what meshes are not impacted by the light.
  77944. * Inactive if 0
  77945. */
  77946. /**
  77947. * Sets the layer id use to find what meshes are not impacted by the light.
  77948. * Inactive if 0
  77949. */
  77950. excludeWithLayerMask: number;
  77951. private _includeOnlyWithLayerMask;
  77952. /**
  77953. * Gets the layer id use to find what meshes are impacted by the light.
  77954. * Inactive if 0
  77955. */
  77956. /**
  77957. * Sets the layer id use to find what meshes are impacted by the light.
  77958. * Inactive if 0
  77959. */
  77960. includeOnlyWithLayerMask: number;
  77961. private _lightmapMode;
  77962. /**
  77963. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77964. */
  77965. /**
  77966. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77967. */
  77968. lightmapMode: number;
  77969. /**
  77970. * Shadow generator associted to the light.
  77971. * @hidden Internal use only.
  77972. */
  77973. _shadowGenerator: Nullable<IShadowGenerator>;
  77974. /**
  77975. * @hidden Internal use only.
  77976. */
  77977. _excludedMeshesIds: string[];
  77978. /**
  77979. * @hidden Internal use only.
  77980. */
  77981. _includedOnlyMeshesIds: string[];
  77982. /**
  77983. * The current light unifom buffer.
  77984. * @hidden Internal use only.
  77985. */
  77986. _uniformBuffer: UniformBuffer;
  77987. /** @hidden */
  77988. _renderId: number;
  77989. /**
  77990. * Creates a Light object in the scene.
  77991. * Documentation : https://doc.babylonjs.com/babylon101/lights
  77992. * @param name The firendly name of the light
  77993. * @param scene The scene the light belongs too
  77994. */
  77995. constructor(name: string, scene: Scene);
  77996. protected abstract _buildUniformLayout(): void;
  77997. /**
  77998. * Sets the passed Effect "effect" with the Light information.
  77999. * @param effect The effect to update
  78000. * @param lightIndex The index of the light in the effect to update
  78001. * @returns The light
  78002. */
  78003. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  78004. /**
  78005. * Sets the passed Effect "effect" with the Light information.
  78006. * @param effect The effect to update
  78007. * @param lightDataUniformName The uniform used to store light data (position or direction)
  78008. * @returns The light
  78009. */
  78010. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  78011. /**
  78012. * Returns the string "Light".
  78013. * @returns the class name
  78014. */
  78015. getClassName(): string;
  78016. /** @hidden */
  78017. readonly _isLight: boolean;
  78018. /**
  78019. * Converts the light information to a readable string for debug purpose.
  78020. * @param fullDetails Supports for multiple levels of logging within scene loading
  78021. * @returns the human readable light info
  78022. */
  78023. toString(fullDetails?: boolean): string;
  78024. /** @hidden */
  78025. protected _syncParentEnabledState(): void;
  78026. /**
  78027. * Set the enabled state of this node.
  78028. * @param value - the new enabled state
  78029. */
  78030. setEnabled(value: boolean): void;
  78031. /**
  78032. * Returns the Light associated shadow generator if any.
  78033. * @return the associated shadow generator.
  78034. */
  78035. getShadowGenerator(): Nullable<IShadowGenerator>;
  78036. /**
  78037. * Returns a Vector3, the absolute light position in the World.
  78038. * @returns the world space position of the light
  78039. */
  78040. getAbsolutePosition(): Vector3;
  78041. /**
  78042. * Specifies if the light will affect the passed mesh.
  78043. * @param mesh The mesh to test against the light
  78044. * @return true the mesh is affected otherwise, false.
  78045. */
  78046. canAffectMesh(mesh: AbstractMesh): boolean;
  78047. /**
  78048. * Sort function to order lights for rendering.
  78049. * @param a First Light object to compare to second.
  78050. * @param b Second Light object to compare first.
  78051. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  78052. */
  78053. static CompareLightsPriority(a: Light, b: Light): number;
  78054. /**
  78055. * Releases resources associated with this node.
  78056. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78057. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78058. */
  78059. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78060. /**
  78061. * Returns the light type ID (integer).
  78062. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78063. */
  78064. getTypeID(): number;
  78065. /**
  78066. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  78067. * @returns the scaled intensity in intensity mode unit
  78068. */
  78069. getScaledIntensity(): number;
  78070. /**
  78071. * Returns a new Light object, named "name", from the current one.
  78072. * @param name The name of the cloned light
  78073. * @returns the new created light
  78074. */
  78075. clone(name: string): Nullable<Light>;
  78076. /**
  78077. * Serializes the current light into a Serialization object.
  78078. * @returns the serialized object.
  78079. */
  78080. serialize(): any;
  78081. /**
  78082. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  78083. * This new light is named "name" and added to the passed scene.
  78084. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  78085. * @param name The friendly name of the light
  78086. * @param scene The scene the new light will belong to
  78087. * @returns the constructor function
  78088. */
  78089. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  78090. /**
  78091. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  78092. * @param parsedLight The JSON representation of the light
  78093. * @param scene The scene to create the parsed light in
  78094. * @returns the created light after parsing
  78095. */
  78096. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  78097. private _hookArrayForExcluded;
  78098. private _hookArrayForIncludedOnly;
  78099. private _resyncMeshes;
  78100. /**
  78101. * Forces the meshes to update their light related information in their rendering used effects
  78102. * @hidden Internal Use Only
  78103. */
  78104. _markMeshesAsLightDirty(): void;
  78105. /**
  78106. * Recomputes the cached photometric scale if needed.
  78107. */
  78108. private _computePhotometricScale;
  78109. /**
  78110. * Returns the Photometric Scale according to the light type and intensity mode.
  78111. */
  78112. private _getPhotometricScale;
  78113. /**
  78114. * Reorder the light in the scene according to their defined priority.
  78115. * @hidden Internal Use Only
  78116. */
  78117. _reorderLightsInScene(): void;
  78118. /**
  78119. * Prepares the list of defines specific to the light type.
  78120. * @param defines the list of defines
  78121. * @param lightIndex defines the index of the light for the effect
  78122. */
  78123. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78124. }
  78125. }
  78126. declare module BABYLON {
  78127. /**
  78128. * Interface used to define Action
  78129. */
  78130. export interface IAction {
  78131. /**
  78132. * Trigger for the action
  78133. */
  78134. trigger: number;
  78135. /** Options of the trigger */
  78136. triggerOptions: any;
  78137. /**
  78138. * Gets the trigger parameters
  78139. * @returns the trigger parameters
  78140. */
  78141. getTriggerParameter(): any;
  78142. /**
  78143. * Internal only - executes current action event
  78144. * @hidden
  78145. */
  78146. _executeCurrent(evt?: ActionEvent): void;
  78147. /**
  78148. * Serialize placeholder for child classes
  78149. * @param parent of child
  78150. * @returns the serialized object
  78151. */
  78152. serialize(parent: any): any;
  78153. /**
  78154. * Internal only
  78155. * @hidden
  78156. */
  78157. _prepare(): void;
  78158. /**
  78159. * Internal only - manager for action
  78160. * @hidden
  78161. */
  78162. _actionManager: AbstractActionManager;
  78163. /**
  78164. * Adds action to chain of actions, may be a DoNothingAction
  78165. * @param action defines the next action to execute
  78166. * @returns The action passed in
  78167. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78168. */
  78169. then(action: IAction): IAction;
  78170. }
  78171. /**
  78172. * The action to be carried out following a trigger
  78173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  78174. */
  78175. export class Action implements IAction {
  78176. /** the trigger, with or without parameters, for the action */
  78177. triggerOptions: any;
  78178. /**
  78179. * Trigger for the action
  78180. */
  78181. trigger: number;
  78182. /**
  78183. * Internal only - manager for action
  78184. * @hidden
  78185. */
  78186. _actionManager: ActionManager;
  78187. private _nextActiveAction;
  78188. private _child;
  78189. private _condition?;
  78190. private _triggerParameter;
  78191. /**
  78192. * An event triggered prior to action being executed.
  78193. */
  78194. onBeforeExecuteObservable: Observable<Action>;
  78195. /**
  78196. * Creates a new Action
  78197. * @param triggerOptions the trigger, with or without parameters, for the action
  78198. * @param condition an optional determinant of action
  78199. */
  78200. constructor(
  78201. /** the trigger, with or without parameters, for the action */
  78202. triggerOptions: any, condition?: Condition);
  78203. /**
  78204. * Internal only
  78205. * @hidden
  78206. */
  78207. _prepare(): void;
  78208. /**
  78209. * Gets the trigger parameters
  78210. * @returns the trigger parameters
  78211. */
  78212. getTriggerParameter(): any;
  78213. /**
  78214. * Internal only - executes current action event
  78215. * @hidden
  78216. */
  78217. _executeCurrent(evt?: ActionEvent): void;
  78218. /**
  78219. * Execute placeholder for child classes
  78220. * @param evt optional action event
  78221. */
  78222. execute(evt?: ActionEvent): void;
  78223. /**
  78224. * Skips to next active action
  78225. */
  78226. skipToNextActiveAction(): void;
  78227. /**
  78228. * Adds action to chain of actions, may be a DoNothingAction
  78229. * @param action defines the next action to execute
  78230. * @returns The action passed in
  78231. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78232. */
  78233. then(action: Action): Action;
  78234. /**
  78235. * Internal only
  78236. * @hidden
  78237. */
  78238. _getProperty(propertyPath: string): string;
  78239. /**
  78240. * Internal only
  78241. * @hidden
  78242. */
  78243. _getEffectiveTarget(target: any, propertyPath: string): any;
  78244. /**
  78245. * Serialize placeholder for child classes
  78246. * @param parent of child
  78247. * @returns the serialized object
  78248. */
  78249. serialize(parent: any): any;
  78250. /**
  78251. * Internal only called by serialize
  78252. * @hidden
  78253. */
  78254. protected _serialize(serializedAction: any, parent?: any): any;
  78255. /**
  78256. * Internal only
  78257. * @hidden
  78258. */
  78259. static _SerializeValueAsString: (value: any) => string;
  78260. /**
  78261. * Internal only
  78262. * @hidden
  78263. */
  78264. static _GetTargetProperty: (target: Node | Scene) => {
  78265. name: string;
  78266. targetType: string;
  78267. value: string;
  78268. };
  78269. }
  78270. }
  78271. declare module BABYLON {
  78272. /**
  78273. * A Condition applied to an Action
  78274. */
  78275. export class Condition {
  78276. /**
  78277. * Internal only - manager for action
  78278. * @hidden
  78279. */
  78280. _actionManager: ActionManager;
  78281. /**
  78282. * Internal only
  78283. * @hidden
  78284. */
  78285. _evaluationId: number;
  78286. /**
  78287. * Internal only
  78288. * @hidden
  78289. */
  78290. _currentResult: boolean;
  78291. /**
  78292. * Creates a new Condition
  78293. * @param actionManager the manager of the action the condition is applied to
  78294. */
  78295. constructor(actionManager: ActionManager);
  78296. /**
  78297. * Check if the current condition is valid
  78298. * @returns a boolean
  78299. */
  78300. isValid(): boolean;
  78301. /**
  78302. * Internal only
  78303. * @hidden
  78304. */
  78305. _getProperty(propertyPath: string): string;
  78306. /**
  78307. * Internal only
  78308. * @hidden
  78309. */
  78310. _getEffectiveTarget(target: any, propertyPath: string): any;
  78311. /**
  78312. * Serialize placeholder for child classes
  78313. * @returns the serialized object
  78314. */
  78315. serialize(): any;
  78316. /**
  78317. * Internal only
  78318. * @hidden
  78319. */
  78320. protected _serialize(serializedCondition: any): any;
  78321. }
  78322. /**
  78323. * Defines specific conditional operators as extensions of Condition
  78324. */
  78325. export class ValueCondition extends Condition {
  78326. /** path to specify the property of the target the conditional operator uses */
  78327. propertyPath: string;
  78328. /** the value compared by the conditional operator against the current value of the property */
  78329. value: any;
  78330. /** the conditional operator, default ValueCondition.IsEqual */
  78331. operator: number;
  78332. /**
  78333. * Internal only
  78334. * @hidden
  78335. */
  78336. private static _IsEqual;
  78337. /**
  78338. * Internal only
  78339. * @hidden
  78340. */
  78341. private static _IsDifferent;
  78342. /**
  78343. * Internal only
  78344. * @hidden
  78345. */
  78346. private static _IsGreater;
  78347. /**
  78348. * Internal only
  78349. * @hidden
  78350. */
  78351. private static _IsLesser;
  78352. /**
  78353. * returns the number for IsEqual
  78354. */
  78355. static readonly IsEqual: number;
  78356. /**
  78357. * Returns the number for IsDifferent
  78358. */
  78359. static readonly IsDifferent: number;
  78360. /**
  78361. * Returns the number for IsGreater
  78362. */
  78363. static readonly IsGreater: number;
  78364. /**
  78365. * Returns the number for IsLesser
  78366. */
  78367. static readonly IsLesser: number;
  78368. /**
  78369. * Internal only The action manager for the condition
  78370. * @hidden
  78371. */
  78372. _actionManager: ActionManager;
  78373. /**
  78374. * Internal only
  78375. * @hidden
  78376. */
  78377. private _target;
  78378. /**
  78379. * Internal only
  78380. * @hidden
  78381. */
  78382. private _effectiveTarget;
  78383. /**
  78384. * Internal only
  78385. * @hidden
  78386. */
  78387. private _property;
  78388. /**
  78389. * Creates a new ValueCondition
  78390. * @param actionManager manager for the action the condition applies to
  78391. * @param target for the action
  78392. * @param propertyPath path to specify the property of the target the conditional operator uses
  78393. * @param value the value compared by the conditional operator against the current value of the property
  78394. * @param operator the conditional operator, default ValueCondition.IsEqual
  78395. */
  78396. constructor(actionManager: ActionManager, target: any,
  78397. /** path to specify the property of the target the conditional operator uses */
  78398. propertyPath: string,
  78399. /** the value compared by the conditional operator against the current value of the property */
  78400. value: any,
  78401. /** the conditional operator, default ValueCondition.IsEqual */
  78402. operator?: number);
  78403. /**
  78404. * Compares the given value with the property value for the specified conditional operator
  78405. * @returns the result of the comparison
  78406. */
  78407. isValid(): boolean;
  78408. /**
  78409. * Serialize the ValueCondition into a JSON compatible object
  78410. * @returns serialization object
  78411. */
  78412. serialize(): any;
  78413. /**
  78414. * Gets the name of the conditional operator for the ValueCondition
  78415. * @param operator the conditional operator
  78416. * @returns the name
  78417. */
  78418. static GetOperatorName(operator: number): string;
  78419. }
  78420. /**
  78421. * Defines a predicate condition as an extension of Condition
  78422. */
  78423. export class PredicateCondition extends Condition {
  78424. /** defines the predicate function used to validate the condition */
  78425. predicate: () => boolean;
  78426. /**
  78427. * Internal only - manager for action
  78428. * @hidden
  78429. */
  78430. _actionManager: ActionManager;
  78431. /**
  78432. * Creates a new PredicateCondition
  78433. * @param actionManager manager for the action the condition applies to
  78434. * @param predicate defines the predicate function used to validate the condition
  78435. */
  78436. constructor(actionManager: ActionManager,
  78437. /** defines the predicate function used to validate the condition */
  78438. predicate: () => boolean);
  78439. /**
  78440. * @returns the validity of the predicate condition
  78441. */
  78442. isValid(): boolean;
  78443. }
  78444. /**
  78445. * Defines a state condition as an extension of Condition
  78446. */
  78447. export class StateCondition extends Condition {
  78448. /** Value to compare with target state */
  78449. value: string;
  78450. /**
  78451. * Internal only - manager for action
  78452. * @hidden
  78453. */
  78454. _actionManager: ActionManager;
  78455. /**
  78456. * Internal only
  78457. * @hidden
  78458. */
  78459. private _target;
  78460. /**
  78461. * Creates a new StateCondition
  78462. * @param actionManager manager for the action the condition applies to
  78463. * @param target of the condition
  78464. * @param value to compare with target state
  78465. */
  78466. constructor(actionManager: ActionManager, target: any,
  78467. /** Value to compare with target state */
  78468. value: string);
  78469. /**
  78470. * Gets a boolean indicating if the current condition is met
  78471. * @returns the validity of the state
  78472. */
  78473. isValid(): boolean;
  78474. /**
  78475. * Serialize the StateCondition into a JSON compatible object
  78476. * @returns serialization object
  78477. */
  78478. serialize(): any;
  78479. }
  78480. }
  78481. declare module BABYLON {
  78482. /**
  78483. * This defines an action responsible to toggle a boolean once triggered.
  78484. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78485. */
  78486. export class SwitchBooleanAction extends Action {
  78487. /**
  78488. * The path to the boolean property in the target object
  78489. */
  78490. propertyPath: string;
  78491. private _target;
  78492. private _effectiveTarget;
  78493. private _property;
  78494. /**
  78495. * Instantiate the action
  78496. * @param triggerOptions defines the trigger options
  78497. * @param target defines the object containing the boolean
  78498. * @param propertyPath defines the path to the boolean property in the target object
  78499. * @param condition defines the trigger related conditions
  78500. */
  78501. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78502. /** @hidden */
  78503. _prepare(): void;
  78504. /**
  78505. * Execute the action toggle the boolean value.
  78506. */
  78507. execute(): void;
  78508. /**
  78509. * Serializes the actions and its related information.
  78510. * @param parent defines the object to serialize in
  78511. * @returns the serialized object
  78512. */
  78513. serialize(parent: any): any;
  78514. }
  78515. /**
  78516. * This defines an action responsible to set a the state field of the target
  78517. * to a desired value once triggered.
  78518. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78519. */
  78520. export class SetStateAction extends Action {
  78521. /**
  78522. * The value to store in the state field.
  78523. */
  78524. value: string;
  78525. private _target;
  78526. /**
  78527. * Instantiate the action
  78528. * @param triggerOptions defines the trigger options
  78529. * @param target defines the object containing the state property
  78530. * @param value defines the value to store in the state field
  78531. * @param condition defines the trigger related conditions
  78532. */
  78533. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78534. /**
  78535. * Execute the action and store the value on the target state property.
  78536. */
  78537. execute(): void;
  78538. /**
  78539. * Serializes the actions and its related information.
  78540. * @param parent defines the object to serialize in
  78541. * @returns the serialized object
  78542. */
  78543. serialize(parent: any): any;
  78544. }
  78545. /**
  78546. * This defines an action responsible to set a property of the target
  78547. * to a desired value once triggered.
  78548. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78549. */
  78550. export class SetValueAction extends Action {
  78551. /**
  78552. * The path of the property to set in the target.
  78553. */
  78554. propertyPath: string;
  78555. /**
  78556. * The value to set in the property
  78557. */
  78558. value: any;
  78559. private _target;
  78560. private _effectiveTarget;
  78561. private _property;
  78562. /**
  78563. * Instantiate the action
  78564. * @param triggerOptions defines the trigger options
  78565. * @param target defines the object containing the property
  78566. * @param propertyPath defines the path of the property to set in the target
  78567. * @param value defines the value to set in the property
  78568. * @param condition defines the trigger related conditions
  78569. */
  78570. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78571. /** @hidden */
  78572. _prepare(): void;
  78573. /**
  78574. * Execute the action and set the targetted property to the desired value.
  78575. */
  78576. execute(): void;
  78577. /**
  78578. * Serializes the actions and its related information.
  78579. * @param parent defines the object to serialize in
  78580. * @returns the serialized object
  78581. */
  78582. serialize(parent: any): any;
  78583. }
  78584. /**
  78585. * This defines an action responsible to increment the target value
  78586. * to a desired value once triggered.
  78587. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78588. */
  78589. export class IncrementValueAction extends Action {
  78590. /**
  78591. * The path of the property to increment in the target.
  78592. */
  78593. propertyPath: string;
  78594. /**
  78595. * The value we should increment the property by.
  78596. */
  78597. value: any;
  78598. private _target;
  78599. private _effectiveTarget;
  78600. private _property;
  78601. /**
  78602. * Instantiate the action
  78603. * @param triggerOptions defines the trigger options
  78604. * @param target defines the object containing the property
  78605. * @param propertyPath defines the path of the property to increment in the target
  78606. * @param value defines the value value we should increment the property by
  78607. * @param condition defines the trigger related conditions
  78608. */
  78609. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78610. /** @hidden */
  78611. _prepare(): void;
  78612. /**
  78613. * Execute the action and increment the target of the value amount.
  78614. */
  78615. execute(): void;
  78616. /**
  78617. * Serializes the actions and its related information.
  78618. * @param parent defines the object to serialize in
  78619. * @returns the serialized object
  78620. */
  78621. serialize(parent: any): any;
  78622. }
  78623. /**
  78624. * This defines an action responsible to start an animation once triggered.
  78625. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78626. */
  78627. export class PlayAnimationAction extends Action {
  78628. /**
  78629. * Where the animation should start (animation frame)
  78630. */
  78631. from: number;
  78632. /**
  78633. * Where the animation should stop (animation frame)
  78634. */
  78635. to: number;
  78636. /**
  78637. * Define if the animation should loop or stop after the first play.
  78638. */
  78639. loop?: boolean;
  78640. private _target;
  78641. /**
  78642. * Instantiate the action
  78643. * @param triggerOptions defines the trigger options
  78644. * @param target defines the target animation or animation name
  78645. * @param from defines from where the animation should start (animation frame)
  78646. * @param end defines where the animation should stop (animation frame)
  78647. * @param loop defines if the animation should loop or stop after the first play
  78648. * @param condition defines the trigger related conditions
  78649. */
  78650. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78651. /** @hidden */
  78652. _prepare(): void;
  78653. /**
  78654. * Execute the action and play the animation.
  78655. */
  78656. execute(): void;
  78657. /**
  78658. * Serializes the actions and its related information.
  78659. * @param parent defines the object to serialize in
  78660. * @returns the serialized object
  78661. */
  78662. serialize(parent: any): any;
  78663. }
  78664. /**
  78665. * This defines an action responsible to stop an animation once triggered.
  78666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78667. */
  78668. export class StopAnimationAction extends Action {
  78669. private _target;
  78670. /**
  78671. * Instantiate the action
  78672. * @param triggerOptions defines the trigger options
  78673. * @param target defines the target animation or animation name
  78674. * @param condition defines the trigger related conditions
  78675. */
  78676. constructor(triggerOptions: any, target: any, condition?: Condition);
  78677. /** @hidden */
  78678. _prepare(): void;
  78679. /**
  78680. * Execute the action and stop the animation.
  78681. */
  78682. execute(): void;
  78683. /**
  78684. * Serializes the actions and its related information.
  78685. * @param parent defines the object to serialize in
  78686. * @returns the serialized object
  78687. */
  78688. serialize(parent: any): any;
  78689. }
  78690. /**
  78691. * This defines an action responsible that does nothing once triggered.
  78692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78693. */
  78694. export class DoNothingAction extends Action {
  78695. /**
  78696. * Instantiate the action
  78697. * @param triggerOptions defines the trigger options
  78698. * @param condition defines the trigger related conditions
  78699. */
  78700. constructor(triggerOptions?: any, condition?: Condition);
  78701. /**
  78702. * Execute the action and do nothing.
  78703. */
  78704. execute(): void;
  78705. /**
  78706. * Serializes the actions and its related information.
  78707. * @param parent defines the object to serialize in
  78708. * @returns the serialized object
  78709. */
  78710. serialize(parent: any): any;
  78711. }
  78712. /**
  78713. * This defines an action responsible to trigger several actions once triggered.
  78714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78715. */
  78716. export class CombineAction extends Action {
  78717. /**
  78718. * The list of aggregated animations to run.
  78719. */
  78720. children: Action[];
  78721. /**
  78722. * Instantiate the action
  78723. * @param triggerOptions defines the trigger options
  78724. * @param children defines the list of aggregated animations to run
  78725. * @param condition defines the trigger related conditions
  78726. */
  78727. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78728. /** @hidden */
  78729. _prepare(): void;
  78730. /**
  78731. * Execute the action and executes all the aggregated actions.
  78732. */
  78733. execute(evt: ActionEvent): void;
  78734. /**
  78735. * Serializes the actions and its related information.
  78736. * @param parent defines the object to serialize in
  78737. * @returns the serialized object
  78738. */
  78739. serialize(parent: any): any;
  78740. }
  78741. /**
  78742. * This defines an action responsible to run code (external event) once triggered.
  78743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78744. */
  78745. export class ExecuteCodeAction extends Action {
  78746. /**
  78747. * The callback function to run.
  78748. */
  78749. func: (evt: ActionEvent) => void;
  78750. /**
  78751. * Instantiate the action
  78752. * @param triggerOptions defines the trigger options
  78753. * @param func defines the callback function to run
  78754. * @param condition defines the trigger related conditions
  78755. */
  78756. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78757. /**
  78758. * Execute the action and run the attached code.
  78759. */
  78760. execute(evt: ActionEvent): void;
  78761. }
  78762. /**
  78763. * This defines an action responsible to set the parent property of the target once triggered.
  78764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78765. */
  78766. export class SetParentAction extends Action {
  78767. private _parent;
  78768. private _target;
  78769. /**
  78770. * Instantiate the action
  78771. * @param triggerOptions defines the trigger options
  78772. * @param target defines the target containing the parent property
  78773. * @param parent defines from where the animation should start (animation frame)
  78774. * @param condition defines the trigger related conditions
  78775. */
  78776. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78777. /** @hidden */
  78778. _prepare(): void;
  78779. /**
  78780. * Execute the action and set the parent property.
  78781. */
  78782. execute(): void;
  78783. /**
  78784. * Serializes the actions and its related information.
  78785. * @param parent defines the object to serialize in
  78786. * @returns the serialized object
  78787. */
  78788. serialize(parent: any): any;
  78789. }
  78790. }
  78791. declare module BABYLON {
  78792. /**
  78793. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78794. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78796. */
  78797. export class ActionManager extends AbstractActionManager {
  78798. /**
  78799. * Nothing
  78800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78801. */
  78802. static readonly NothingTrigger: number;
  78803. /**
  78804. * On pick
  78805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78806. */
  78807. static readonly OnPickTrigger: number;
  78808. /**
  78809. * On left pick
  78810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78811. */
  78812. static readonly OnLeftPickTrigger: number;
  78813. /**
  78814. * On right pick
  78815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78816. */
  78817. static readonly OnRightPickTrigger: number;
  78818. /**
  78819. * On center pick
  78820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78821. */
  78822. static readonly OnCenterPickTrigger: number;
  78823. /**
  78824. * On pick down
  78825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78826. */
  78827. static readonly OnPickDownTrigger: number;
  78828. /**
  78829. * On double pick
  78830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78831. */
  78832. static readonly OnDoublePickTrigger: number;
  78833. /**
  78834. * On pick up
  78835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78836. */
  78837. static readonly OnPickUpTrigger: number;
  78838. /**
  78839. * On pick out.
  78840. * This trigger will only be raised if you also declared a OnPickDown
  78841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78842. */
  78843. static readonly OnPickOutTrigger: number;
  78844. /**
  78845. * On long press
  78846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78847. */
  78848. static readonly OnLongPressTrigger: number;
  78849. /**
  78850. * On pointer over
  78851. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78852. */
  78853. static readonly OnPointerOverTrigger: number;
  78854. /**
  78855. * On pointer out
  78856. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78857. */
  78858. static readonly OnPointerOutTrigger: number;
  78859. /**
  78860. * On every frame
  78861. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78862. */
  78863. static readonly OnEveryFrameTrigger: number;
  78864. /**
  78865. * On intersection enter
  78866. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78867. */
  78868. static readonly OnIntersectionEnterTrigger: number;
  78869. /**
  78870. * On intersection exit
  78871. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78872. */
  78873. static readonly OnIntersectionExitTrigger: number;
  78874. /**
  78875. * On key down
  78876. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78877. */
  78878. static readonly OnKeyDownTrigger: number;
  78879. /**
  78880. * On key up
  78881. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78882. */
  78883. static readonly OnKeyUpTrigger: number;
  78884. private _scene;
  78885. /**
  78886. * Creates a new action manager
  78887. * @param scene defines the hosting scene
  78888. */
  78889. constructor(scene: Scene);
  78890. /**
  78891. * Releases all associated resources
  78892. */
  78893. dispose(): void;
  78894. /**
  78895. * Gets hosting scene
  78896. * @returns the hosting scene
  78897. */
  78898. getScene(): Scene;
  78899. /**
  78900. * Does this action manager handles actions of any of the given triggers
  78901. * @param triggers defines the triggers to be tested
  78902. * @return a boolean indicating whether one (or more) of the triggers is handled
  78903. */
  78904. hasSpecificTriggers(triggers: number[]): boolean;
  78905. /**
  78906. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78907. * speed.
  78908. * @param triggerA defines the trigger to be tested
  78909. * @param triggerB defines the trigger to be tested
  78910. * @return a boolean indicating whether one (or more) of the triggers is handled
  78911. */
  78912. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78913. /**
  78914. * Does this action manager handles actions of a given trigger
  78915. * @param trigger defines the trigger to be tested
  78916. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78917. * @return whether the trigger is handled
  78918. */
  78919. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78920. /**
  78921. * Does this action manager has pointer triggers
  78922. */
  78923. readonly hasPointerTriggers: boolean;
  78924. /**
  78925. * Does this action manager has pick triggers
  78926. */
  78927. readonly hasPickTriggers: boolean;
  78928. /**
  78929. * Registers an action to this action manager
  78930. * @param action defines the action to be registered
  78931. * @return the action amended (prepared) after registration
  78932. */
  78933. registerAction(action: IAction): Nullable<IAction>;
  78934. /**
  78935. * Unregisters an action to this action manager
  78936. * @param action defines the action to be unregistered
  78937. * @return a boolean indicating whether the action has been unregistered
  78938. */
  78939. unregisterAction(action: IAction): Boolean;
  78940. /**
  78941. * Process a specific trigger
  78942. * @param trigger defines the trigger to process
  78943. * @param evt defines the event details to be processed
  78944. */
  78945. processTrigger(trigger: number, evt?: IActionEvent): void;
  78946. /** @hidden */
  78947. _getEffectiveTarget(target: any, propertyPath: string): any;
  78948. /** @hidden */
  78949. _getProperty(propertyPath: string): string;
  78950. /**
  78951. * Serialize this manager to a JSON object
  78952. * @param name defines the property name to store this manager
  78953. * @returns a JSON representation of this manager
  78954. */
  78955. serialize(name: string): any;
  78956. /**
  78957. * Creates a new ActionManager from a JSON data
  78958. * @param parsedActions defines the JSON data to read from
  78959. * @param object defines the hosting mesh
  78960. * @param scene defines the hosting scene
  78961. */
  78962. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78963. /**
  78964. * Get a trigger name by index
  78965. * @param trigger defines the trigger index
  78966. * @returns a trigger name
  78967. */
  78968. static GetTriggerName(trigger: number): string;
  78969. }
  78970. }
  78971. declare module BABYLON {
  78972. /**
  78973. * Class representing a ray with position and direction
  78974. */
  78975. export class Ray {
  78976. /** origin point */
  78977. origin: Vector3;
  78978. /** direction */
  78979. direction: Vector3;
  78980. /** length of the ray */
  78981. length: number;
  78982. private static readonly TmpVector3;
  78983. private _tmpRay;
  78984. /**
  78985. * Creates a new ray
  78986. * @param origin origin point
  78987. * @param direction direction
  78988. * @param length length of the ray
  78989. */
  78990. constructor(
  78991. /** origin point */
  78992. origin: Vector3,
  78993. /** direction */
  78994. direction: Vector3,
  78995. /** length of the ray */
  78996. length?: number);
  78997. /**
  78998. * Checks if the ray intersects a box
  78999. * @param minimum bound of the box
  79000. * @param maximum bound of the box
  79001. * @param intersectionTreshold extra extend to be added to the box in all direction
  79002. * @returns if the box was hit
  79003. */
  79004. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  79005. /**
  79006. * Checks if the ray intersects a box
  79007. * @param box the bounding box to check
  79008. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  79009. * @returns if the box was hit
  79010. */
  79011. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  79012. /**
  79013. * If the ray hits a sphere
  79014. * @param sphere the bounding sphere to check
  79015. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  79016. * @returns true if it hits the sphere
  79017. */
  79018. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  79019. /**
  79020. * If the ray hits a triange
  79021. * @param vertex0 triangle vertex
  79022. * @param vertex1 triangle vertex
  79023. * @param vertex2 triangle vertex
  79024. * @returns intersection information if hit
  79025. */
  79026. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  79027. /**
  79028. * Checks if ray intersects a plane
  79029. * @param plane the plane to check
  79030. * @returns the distance away it was hit
  79031. */
  79032. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  79033. /**
  79034. * Calculate the intercept of a ray on a given axis
  79035. * @param axis to check 'x' | 'y' | 'z'
  79036. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  79037. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  79038. */
  79039. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  79040. /**
  79041. * Checks if ray intersects a mesh
  79042. * @param mesh the mesh to check
  79043. * @param fastCheck if only the bounding box should checked
  79044. * @returns picking info of the intersecton
  79045. */
  79046. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  79047. /**
  79048. * Checks if ray intersects a mesh
  79049. * @param meshes the meshes to check
  79050. * @param fastCheck if only the bounding box should checked
  79051. * @param results array to store result in
  79052. * @returns Array of picking infos
  79053. */
  79054. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  79055. private _comparePickingInfo;
  79056. private static smallnum;
  79057. private static rayl;
  79058. /**
  79059. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  79060. * @param sega the first point of the segment to test the intersection against
  79061. * @param segb the second point of the segment to test the intersection against
  79062. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  79063. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  79064. */
  79065. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  79066. /**
  79067. * Update the ray from viewport position
  79068. * @param x position
  79069. * @param y y position
  79070. * @param viewportWidth viewport width
  79071. * @param viewportHeight viewport height
  79072. * @param world world matrix
  79073. * @param view view matrix
  79074. * @param projection projection matrix
  79075. * @returns this ray updated
  79076. */
  79077. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79078. /**
  79079. * Creates a ray with origin and direction of 0,0,0
  79080. * @returns the new ray
  79081. */
  79082. static Zero(): Ray;
  79083. /**
  79084. * Creates a new ray from screen space and viewport
  79085. * @param x position
  79086. * @param y y position
  79087. * @param viewportWidth viewport width
  79088. * @param viewportHeight viewport height
  79089. * @param world world matrix
  79090. * @param view view matrix
  79091. * @param projection projection matrix
  79092. * @returns new ray
  79093. */
  79094. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79095. /**
  79096. * 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
  79097. * transformed to the given world matrix.
  79098. * @param origin The origin point
  79099. * @param end The end point
  79100. * @param world a matrix to transform the ray to. Default is the identity matrix.
  79101. * @returns the new ray
  79102. */
  79103. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  79104. /**
  79105. * Transforms a ray by a matrix
  79106. * @param ray ray to transform
  79107. * @param matrix matrix to apply
  79108. * @returns the resulting new ray
  79109. */
  79110. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  79111. /**
  79112. * Transforms a ray by a matrix
  79113. * @param ray ray to transform
  79114. * @param matrix matrix to apply
  79115. * @param result ray to store result in
  79116. */
  79117. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  79118. /**
  79119. * Unproject a ray from screen space to object space
  79120. * @param sourceX defines the screen space x coordinate to use
  79121. * @param sourceY defines the screen space y coordinate to use
  79122. * @param viewportWidth defines the current width of the viewport
  79123. * @param viewportHeight defines the current height of the viewport
  79124. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79125. * @param view defines the view matrix to use
  79126. * @param projection defines the projection matrix to use
  79127. */
  79128. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  79129. }
  79130. /**
  79131. * Type used to define predicate used to select faces when a mesh intersection is detected
  79132. */
  79133. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  79134. interface Scene {
  79135. /** @hidden */
  79136. _tempPickingRay: Nullable<Ray>;
  79137. /** @hidden */
  79138. _cachedRayForTransform: Ray;
  79139. /** @hidden */
  79140. _pickWithRayInverseMatrix: Matrix;
  79141. /** @hidden */
  79142. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  79143. /** @hidden */
  79144. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  79145. }
  79146. }
  79147. declare module BABYLON {
  79148. /**
  79149. * Groups all the scene component constants in one place to ease maintenance.
  79150. * @hidden
  79151. */
  79152. export class SceneComponentConstants {
  79153. static readonly NAME_EFFECTLAYER: string;
  79154. static readonly NAME_LAYER: string;
  79155. static readonly NAME_LENSFLARESYSTEM: string;
  79156. static readonly NAME_BOUNDINGBOXRENDERER: string;
  79157. static readonly NAME_PARTICLESYSTEM: string;
  79158. static readonly NAME_GAMEPAD: string;
  79159. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  79160. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  79161. static readonly NAME_DEPTHRENDERER: string;
  79162. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  79163. static readonly NAME_SPRITE: string;
  79164. static readonly NAME_OUTLINERENDERER: string;
  79165. static readonly NAME_PROCEDURALTEXTURE: string;
  79166. static readonly NAME_SHADOWGENERATOR: string;
  79167. static readonly NAME_OCTREE: string;
  79168. static readonly NAME_PHYSICSENGINE: string;
  79169. static readonly NAME_AUDIO: string;
  79170. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  79171. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79172. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  79173. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79174. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  79175. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  79176. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  79177. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  79178. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  79179. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  79180. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  79181. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  79182. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  79183. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  79184. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  79185. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  79186. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  79187. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  79188. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  79189. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  79190. static readonly STEP_AFTERRENDER_AUDIO: number;
  79191. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  79192. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  79193. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  79194. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  79195. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  79196. static readonly STEP_POINTERMOVE_SPRITE: number;
  79197. static readonly STEP_POINTERDOWN_SPRITE: number;
  79198. static readonly STEP_POINTERUP_SPRITE: number;
  79199. }
  79200. /**
  79201. * This represents a scene component.
  79202. *
  79203. * This is used to decouple the dependency the scene is having on the different workloads like
  79204. * layers, post processes...
  79205. */
  79206. export interface ISceneComponent {
  79207. /**
  79208. * The name of the component. Each component must have a unique name.
  79209. */
  79210. name: string;
  79211. /**
  79212. * The scene the component belongs to.
  79213. */
  79214. scene: Scene;
  79215. /**
  79216. * Register the component to one instance of a scene.
  79217. */
  79218. register(): void;
  79219. /**
  79220. * Rebuilds the elements related to this component in case of
  79221. * context lost for instance.
  79222. */
  79223. rebuild(): void;
  79224. /**
  79225. * Disposes the component and the associated ressources.
  79226. */
  79227. dispose(): void;
  79228. }
  79229. /**
  79230. * This represents a SERIALIZABLE scene component.
  79231. *
  79232. * This extends Scene Component to add Serialization methods on top.
  79233. */
  79234. export interface ISceneSerializableComponent extends ISceneComponent {
  79235. /**
  79236. * Adds all the elements from the container to the scene
  79237. * @param container the container holding the elements
  79238. */
  79239. addFromContainer(container: AbstractScene): void;
  79240. /**
  79241. * Removes all the elements in the container from the scene
  79242. * @param container contains the elements to remove
  79243. * @param dispose if the removed element should be disposed (default: false)
  79244. */
  79245. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  79246. /**
  79247. * Serializes the component data to the specified json object
  79248. * @param serializationObject The object to serialize to
  79249. */
  79250. serialize(serializationObject: any): void;
  79251. }
  79252. /**
  79253. * Strong typing of a Mesh related stage step action
  79254. */
  79255. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  79256. /**
  79257. * Strong typing of a Evaluate Sub Mesh related stage step action
  79258. */
  79259. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  79260. /**
  79261. * Strong typing of a Active Mesh related stage step action
  79262. */
  79263. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  79264. /**
  79265. * Strong typing of a Camera related stage step action
  79266. */
  79267. export type CameraStageAction = (camera: Camera) => void;
  79268. /**
  79269. * Strong typing of a Camera Frame buffer related stage step action
  79270. */
  79271. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  79272. /**
  79273. * Strong typing of a Render Target related stage step action
  79274. */
  79275. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  79276. /**
  79277. * Strong typing of a RenderingGroup related stage step action
  79278. */
  79279. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  79280. /**
  79281. * Strong typing of a Mesh Render related stage step action
  79282. */
  79283. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  79284. /**
  79285. * Strong typing of a simple stage step action
  79286. */
  79287. export type SimpleStageAction = () => void;
  79288. /**
  79289. * Strong typing of a render target action.
  79290. */
  79291. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  79292. /**
  79293. * Strong typing of a pointer move action.
  79294. */
  79295. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  79296. /**
  79297. * Strong typing of a pointer up/down action.
  79298. */
  79299. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  79300. /**
  79301. * Representation of a stage in the scene (Basically a list of ordered steps)
  79302. * @hidden
  79303. */
  79304. export class Stage<T extends Function> extends Array<{
  79305. index: number;
  79306. component: ISceneComponent;
  79307. action: T;
  79308. }> {
  79309. /**
  79310. * Hide ctor from the rest of the world.
  79311. * @param items The items to add.
  79312. */
  79313. private constructor();
  79314. /**
  79315. * Creates a new Stage.
  79316. * @returns A new instance of a Stage
  79317. */
  79318. static Create<T extends Function>(): Stage<T>;
  79319. /**
  79320. * Registers a step in an ordered way in the targeted stage.
  79321. * @param index Defines the position to register the step in
  79322. * @param component Defines the component attached to the step
  79323. * @param action Defines the action to launch during the step
  79324. */
  79325. registerStep(index: number, component: ISceneComponent, action: T): void;
  79326. /**
  79327. * Clears all the steps from the stage.
  79328. */
  79329. clear(): void;
  79330. }
  79331. }
  79332. declare module BABYLON {
  79333. interface Scene {
  79334. /** @hidden */
  79335. _pointerOverSprite: Nullable<Sprite>;
  79336. /** @hidden */
  79337. _pickedDownSprite: Nullable<Sprite>;
  79338. /** @hidden */
  79339. _tempSpritePickingRay: Nullable<Ray>;
  79340. /**
  79341. * All of the sprite managers added to this scene
  79342. * @see http://doc.babylonjs.com/babylon101/sprites
  79343. */
  79344. spriteManagers: Array<ISpriteManager>;
  79345. /**
  79346. * An event triggered when sprites rendering is about to start
  79347. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79348. */
  79349. onBeforeSpritesRenderingObservable: Observable<Scene>;
  79350. /**
  79351. * An event triggered when sprites rendering is done
  79352. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79353. */
  79354. onAfterSpritesRenderingObservable: Observable<Scene>;
  79355. /** @hidden */
  79356. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79357. /** Launch a ray to try to pick a sprite in the scene
  79358. * @param x position on screen
  79359. * @param y position on screen
  79360. * @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
  79361. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79362. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79363. * @returns a PickingInfo
  79364. */
  79365. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79366. /** Use the given ray to pick a sprite in the scene
  79367. * @param ray The ray (in world space) to use to pick meshes
  79368. * @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
  79369. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79370. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79371. * @returns a PickingInfo
  79372. */
  79373. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79374. /** @hidden */
  79375. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79376. /** Launch a ray to try to pick sprites in the scene
  79377. * @param x position on screen
  79378. * @param y position on screen
  79379. * @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
  79380. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79381. * @returns a PickingInfo array
  79382. */
  79383. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79384. /** Use the given ray to pick sprites in the scene
  79385. * @param ray The ray (in world space) to use to pick meshes
  79386. * @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
  79387. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79388. * @returns a PickingInfo array
  79389. */
  79390. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79391. /**
  79392. * Force the sprite under the pointer
  79393. * @param sprite defines the sprite to use
  79394. */
  79395. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  79396. /**
  79397. * Gets the sprite under the pointer
  79398. * @returns a Sprite or null if no sprite is under the pointer
  79399. */
  79400. getPointerOverSprite(): Nullable<Sprite>;
  79401. }
  79402. /**
  79403. * Defines the sprite scene component responsible to manage sprites
  79404. * in a given scene.
  79405. */
  79406. export class SpriteSceneComponent implements ISceneComponent {
  79407. /**
  79408. * The component name helpfull to identify the component in the list of scene components.
  79409. */
  79410. readonly name: string;
  79411. /**
  79412. * The scene the component belongs to.
  79413. */
  79414. scene: Scene;
  79415. /** @hidden */
  79416. private _spritePredicate;
  79417. /**
  79418. * Creates a new instance of the component for the given scene
  79419. * @param scene Defines the scene to register the component in
  79420. */
  79421. constructor(scene: Scene);
  79422. /**
  79423. * Registers the component in a given scene
  79424. */
  79425. register(): void;
  79426. /**
  79427. * Rebuilds the elements related to this component in case of
  79428. * context lost for instance.
  79429. */
  79430. rebuild(): void;
  79431. /**
  79432. * Disposes the component and the associated ressources.
  79433. */
  79434. dispose(): void;
  79435. private _pickSpriteButKeepRay;
  79436. private _pointerMove;
  79437. private _pointerDown;
  79438. private _pointerUp;
  79439. }
  79440. }
  79441. declare module BABYLON {
  79442. /** @hidden */
  79443. export var fogFragmentDeclaration: {
  79444. name: string;
  79445. shader: string;
  79446. };
  79447. }
  79448. declare module BABYLON {
  79449. /** @hidden */
  79450. export var fogFragment: {
  79451. name: string;
  79452. shader: string;
  79453. };
  79454. }
  79455. declare module BABYLON {
  79456. /** @hidden */
  79457. export var spritesPixelShader: {
  79458. name: string;
  79459. shader: string;
  79460. };
  79461. }
  79462. declare module BABYLON {
  79463. /** @hidden */
  79464. export var fogVertexDeclaration: {
  79465. name: string;
  79466. shader: string;
  79467. };
  79468. }
  79469. declare module BABYLON {
  79470. /** @hidden */
  79471. export var spritesVertexShader: {
  79472. name: string;
  79473. shader: string;
  79474. };
  79475. }
  79476. declare module BABYLON {
  79477. /**
  79478. * Defines the minimum interface to fullfil in order to be a sprite manager.
  79479. */
  79480. export interface ISpriteManager extends IDisposable {
  79481. /**
  79482. * Restricts the camera to viewing objects with the same layerMask.
  79483. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  79484. */
  79485. layerMask: number;
  79486. /**
  79487. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79488. */
  79489. isPickable: boolean;
  79490. /**
  79491. * Specifies the rendering group id for this mesh (0 by default)
  79492. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79493. */
  79494. renderingGroupId: number;
  79495. /**
  79496. * Defines the list of sprites managed by the manager.
  79497. */
  79498. sprites: Array<Sprite>;
  79499. /**
  79500. * Tests the intersection of a sprite with a specific ray.
  79501. * @param ray The ray we are sending to test the collision
  79502. * @param camera The camera space we are sending rays in
  79503. * @param predicate A predicate allowing excluding sprites from the list of object to test
  79504. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  79505. * @returns picking info or null.
  79506. */
  79507. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79508. /**
  79509. * Intersects the sprites with a ray
  79510. * @param ray defines the ray to intersect with
  79511. * @param camera defines the current active camera
  79512. * @param predicate defines a predicate used to select candidate sprites
  79513. * @returns null if no hit or a PickingInfo array
  79514. */
  79515. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79516. /**
  79517. * Renders the list of sprites on screen.
  79518. */
  79519. render(): void;
  79520. }
  79521. /**
  79522. * Class used to manage multiple sprites on the same spritesheet
  79523. * @see http://doc.babylonjs.com/babylon101/sprites
  79524. */
  79525. export class SpriteManager implements ISpriteManager {
  79526. /** defines the manager's name */
  79527. name: string;
  79528. /** Gets the list of sprites */
  79529. sprites: Sprite[];
  79530. /** Gets or sets the rendering group id (0 by default) */
  79531. renderingGroupId: number;
  79532. /** Gets or sets camera layer mask */
  79533. layerMask: number;
  79534. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  79535. fogEnabled: boolean;
  79536. /** Gets or sets a boolean indicating if the sprites are pickable */
  79537. isPickable: boolean;
  79538. /** Defines the default width of a cell in the spritesheet */
  79539. cellWidth: number;
  79540. /** Defines the default height of a cell in the spritesheet */
  79541. cellHeight: number;
  79542. /** Associative array from JSON sprite data file */
  79543. private _cellData;
  79544. /** Array of sprite names from JSON sprite data file */
  79545. private _spriteMap;
  79546. /** True when packed cell data from JSON file is ready*/
  79547. private _packedAndReady;
  79548. /**
  79549. * An event triggered when the manager is disposed.
  79550. */
  79551. onDisposeObservable: Observable<SpriteManager>;
  79552. private _onDisposeObserver;
  79553. /**
  79554. * Callback called when the manager is disposed
  79555. */
  79556. onDispose: () => void;
  79557. private _capacity;
  79558. private _fromPacked;
  79559. private _spriteTexture;
  79560. private _epsilon;
  79561. private _scene;
  79562. private _vertexData;
  79563. private _buffer;
  79564. private _vertexBuffers;
  79565. private _indexBuffer;
  79566. private _effectBase;
  79567. private _effectFog;
  79568. /**
  79569. * Gets or sets the spritesheet texture
  79570. */
  79571. texture: Texture;
  79572. /**
  79573. * Creates a new sprite manager
  79574. * @param name defines the manager's name
  79575. * @param imgUrl defines the sprite sheet url
  79576. * @param capacity defines the maximum allowed number of sprites
  79577. * @param cellSize defines the size of a sprite cell
  79578. * @param scene defines the hosting scene
  79579. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  79580. * @param samplingMode defines the smapling mode to use with spritesheet
  79581. * @param fromPacked set to false; do not alter
  79582. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  79583. */
  79584. constructor(
  79585. /** defines the manager's name */
  79586. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  79587. private _makePacked;
  79588. private _appendSpriteVertex;
  79589. /**
  79590. * Intersects the sprites with a ray
  79591. * @param ray defines the ray to intersect with
  79592. * @param camera defines the current active camera
  79593. * @param predicate defines a predicate used to select candidate sprites
  79594. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  79595. * @returns null if no hit or a PickingInfo
  79596. */
  79597. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79598. /**
  79599. * Intersects the sprites with a ray
  79600. * @param ray defines the ray to intersect with
  79601. * @param camera defines the current active camera
  79602. * @param predicate defines a predicate used to select candidate sprites
  79603. * @returns null if no hit or a PickingInfo array
  79604. */
  79605. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79606. /**
  79607. * Render all child sprites
  79608. */
  79609. render(): void;
  79610. /**
  79611. * Release associated resources
  79612. */
  79613. dispose(): void;
  79614. }
  79615. }
  79616. declare module BABYLON {
  79617. /**
  79618. * Class used to represent a sprite
  79619. * @see http://doc.babylonjs.com/babylon101/sprites
  79620. */
  79621. export class Sprite {
  79622. /** defines the name */
  79623. name: string;
  79624. /** Gets or sets the current world position */
  79625. position: Vector3;
  79626. /** Gets or sets the main color */
  79627. color: Color4;
  79628. /** Gets or sets the width */
  79629. width: number;
  79630. /** Gets or sets the height */
  79631. height: number;
  79632. /** Gets or sets rotation angle */
  79633. angle: number;
  79634. /** Gets or sets the cell index in the sprite sheet */
  79635. cellIndex: number;
  79636. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  79637. cellRef: string;
  79638. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  79639. invertU: number;
  79640. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  79641. invertV: number;
  79642. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  79643. disposeWhenFinishedAnimating: boolean;
  79644. /** Gets the list of attached animations */
  79645. animations: Animation[];
  79646. /** Gets or sets a boolean indicating if the sprite can be picked */
  79647. isPickable: boolean;
  79648. /**
  79649. * Gets or sets the associated action manager
  79650. */
  79651. actionManager: Nullable<ActionManager>;
  79652. private _animationStarted;
  79653. private _loopAnimation;
  79654. private _fromIndex;
  79655. private _toIndex;
  79656. private _delay;
  79657. private _direction;
  79658. private _manager;
  79659. private _time;
  79660. private _onAnimationEnd;
  79661. /**
  79662. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79663. */
  79664. isVisible: boolean;
  79665. /**
  79666. * Gets or sets the sprite size
  79667. */
  79668. size: number;
  79669. /**
  79670. * Creates a new Sprite
  79671. * @param name defines the name
  79672. * @param manager defines the manager
  79673. */
  79674. constructor(
  79675. /** defines the name */
  79676. name: string, manager: ISpriteManager);
  79677. /**
  79678. * Starts an animation
  79679. * @param from defines the initial key
  79680. * @param to defines the end key
  79681. * @param loop defines if the animation must loop
  79682. * @param delay defines the start delay (in ms)
  79683. * @param onAnimationEnd defines a callback to call when animation ends
  79684. */
  79685. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79686. /** Stops current animation (if any) */
  79687. stopAnimation(): void;
  79688. /** @hidden */
  79689. _animate(deltaTime: number): void;
  79690. /** Release associated resources */
  79691. dispose(): void;
  79692. }
  79693. }
  79694. declare module BABYLON {
  79695. /**
  79696. * Information about the result of picking within a scene
  79697. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79698. */
  79699. export class PickingInfo {
  79700. /** @hidden */
  79701. _pickingUnavailable: boolean;
  79702. /**
  79703. * If the pick collided with an object
  79704. */
  79705. hit: boolean;
  79706. /**
  79707. * Distance away where the pick collided
  79708. */
  79709. distance: number;
  79710. /**
  79711. * The location of pick collision
  79712. */
  79713. pickedPoint: Nullable<Vector3>;
  79714. /**
  79715. * The mesh corresponding the the pick collision
  79716. */
  79717. pickedMesh: Nullable<AbstractMesh>;
  79718. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79719. bu: number;
  79720. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79721. bv: number;
  79722. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79723. faceId: number;
  79724. /** Id of the the submesh that was picked */
  79725. subMeshId: number;
  79726. /** If a sprite was picked, this will be the sprite the pick collided with */
  79727. pickedSprite: Nullable<Sprite>;
  79728. /**
  79729. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79730. */
  79731. originMesh: Nullable<AbstractMesh>;
  79732. /**
  79733. * The ray that was used to perform the picking.
  79734. */
  79735. ray: Nullable<Ray>;
  79736. /**
  79737. * Gets the normal correspodning to the face the pick collided with
  79738. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79739. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79740. * @returns The normal correspodning to the face the pick collided with
  79741. */
  79742. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79743. /**
  79744. * Gets the texture coordinates of where the pick occured
  79745. * @returns the vector containing the coordnates of the texture
  79746. */
  79747. getTextureCoordinates(): Nullable<Vector2>;
  79748. }
  79749. }
  79750. declare module BABYLON {
  79751. /**
  79752. * Gather the list of pointer event types as constants.
  79753. */
  79754. export class PointerEventTypes {
  79755. /**
  79756. * 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.
  79757. */
  79758. static readonly POINTERDOWN: number;
  79759. /**
  79760. * The pointerup event is fired when a pointer is no longer active.
  79761. */
  79762. static readonly POINTERUP: number;
  79763. /**
  79764. * The pointermove event is fired when a pointer changes coordinates.
  79765. */
  79766. static readonly POINTERMOVE: number;
  79767. /**
  79768. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79769. */
  79770. static readonly POINTERWHEEL: number;
  79771. /**
  79772. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79773. */
  79774. static readonly POINTERPICK: number;
  79775. /**
  79776. * The pointertap event is fired when a the object has been touched and released without drag.
  79777. */
  79778. static readonly POINTERTAP: number;
  79779. /**
  79780. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79781. */
  79782. static readonly POINTERDOUBLETAP: number;
  79783. }
  79784. /**
  79785. * Base class of pointer info types.
  79786. */
  79787. export class PointerInfoBase {
  79788. /**
  79789. * Defines the type of event (PointerEventTypes)
  79790. */
  79791. type: number;
  79792. /**
  79793. * Defines the related dom event
  79794. */
  79795. event: PointerEvent | MouseWheelEvent;
  79796. /**
  79797. * Instantiates the base class of pointers info.
  79798. * @param type Defines the type of event (PointerEventTypes)
  79799. * @param event Defines the related dom event
  79800. */
  79801. constructor(
  79802. /**
  79803. * Defines the type of event (PointerEventTypes)
  79804. */
  79805. type: number,
  79806. /**
  79807. * Defines the related dom event
  79808. */
  79809. event: PointerEvent | MouseWheelEvent);
  79810. }
  79811. /**
  79812. * This class is used to store pointer related info for the onPrePointerObservable event.
  79813. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79814. */
  79815. export class PointerInfoPre extends PointerInfoBase {
  79816. /**
  79817. * Ray from a pointer if availible (eg. 6dof controller)
  79818. */
  79819. ray: Nullable<Ray>;
  79820. /**
  79821. * Defines the local position of the pointer on the canvas.
  79822. */
  79823. localPosition: Vector2;
  79824. /**
  79825. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79826. */
  79827. skipOnPointerObservable: boolean;
  79828. /**
  79829. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79830. * @param type Defines the type of event (PointerEventTypes)
  79831. * @param event Defines the related dom event
  79832. * @param localX Defines the local x coordinates of the pointer when the event occured
  79833. * @param localY Defines the local y coordinates of the pointer when the event occured
  79834. */
  79835. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79836. }
  79837. /**
  79838. * This type contains all the data related to a pointer event in Babylon.js.
  79839. * 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.
  79840. */
  79841. export class PointerInfo extends PointerInfoBase {
  79842. /**
  79843. * Defines the picking info associated to the info (if any)\
  79844. */
  79845. pickInfo: Nullable<PickingInfo>;
  79846. /**
  79847. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79848. * @param type Defines the type of event (PointerEventTypes)
  79849. * @param event Defines the related dom event
  79850. * @param pickInfo Defines the picking info associated to the info (if any)\
  79851. */
  79852. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79853. /**
  79854. * Defines the picking info associated to the info (if any)\
  79855. */
  79856. pickInfo: Nullable<PickingInfo>);
  79857. }
  79858. /**
  79859. * Data relating to a touch event on the screen.
  79860. */
  79861. export interface PointerTouch {
  79862. /**
  79863. * X coordinate of touch.
  79864. */
  79865. x: number;
  79866. /**
  79867. * Y coordinate of touch.
  79868. */
  79869. y: number;
  79870. /**
  79871. * Id of touch. Unique for each finger.
  79872. */
  79873. pointerId: number;
  79874. /**
  79875. * Event type passed from DOM.
  79876. */
  79877. type: any;
  79878. }
  79879. }
  79880. declare module BABYLON {
  79881. /**
  79882. * Manage the mouse inputs to control the movement of a free camera.
  79883. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79884. */
  79885. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79886. /**
  79887. * Define if touch is enabled in the mouse input
  79888. */
  79889. touchEnabled: boolean;
  79890. /**
  79891. * Defines the camera the input is attached to.
  79892. */
  79893. camera: FreeCamera;
  79894. /**
  79895. * Defines the buttons associated with the input to handle camera move.
  79896. */
  79897. buttons: number[];
  79898. /**
  79899. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79900. */
  79901. angularSensibility: number;
  79902. private _pointerInput;
  79903. private _onMouseMove;
  79904. private _observer;
  79905. private previousPosition;
  79906. /**
  79907. * Observable for when a pointer move event occurs containing the move offset
  79908. */
  79909. onPointerMovedObservable: Observable<{
  79910. offsetX: number;
  79911. offsetY: number;
  79912. }>;
  79913. /**
  79914. * @hidden
  79915. * If the camera should be rotated automatically based on pointer movement
  79916. */
  79917. _allowCameraRotation: boolean;
  79918. /**
  79919. * Manage the mouse inputs to control the movement of a free camera.
  79920. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79921. * @param touchEnabled Defines if touch is enabled or not
  79922. */
  79923. constructor(
  79924. /**
  79925. * Define if touch is enabled in the mouse input
  79926. */
  79927. touchEnabled?: boolean);
  79928. /**
  79929. * Attach the input controls to a specific dom element to get the input from.
  79930. * @param element Defines the element the controls should be listened from
  79931. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79932. */
  79933. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79934. /**
  79935. * Called on JS contextmenu event.
  79936. * Override this method to provide functionality.
  79937. */
  79938. protected onContextMenu(evt: PointerEvent): void;
  79939. /**
  79940. * Detach the current controls from the specified dom element.
  79941. * @param element Defines the element to stop listening the inputs from
  79942. */
  79943. detachControl(element: Nullable<HTMLElement>): void;
  79944. /**
  79945. * Gets the class name of the current intput.
  79946. * @returns the class name
  79947. */
  79948. getClassName(): string;
  79949. /**
  79950. * Get the friendly name associated with the input class.
  79951. * @returns the input friendly name
  79952. */
  79953. getSimpleName(): string;
  79954. }
  79955. }
  79956. declare module BABYLON {
  79957. /**
  79958. * Manage the touch inputs to control the movement of a free camera.
  79959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79960. */
  79961. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79962. /**
  79963. * Defines the camera the input is attached to.
  79964. */
  79965. camera: FreeCamera;
  79966. /**
  79967. * Defines the touch sensibility for rotation.
  79968. * The higher the faster.
  79969. */
  79970. touchAngularSensibility: number;
  79971. /**
  79972. * Defines the touch sensibility for move.
  79973. * The higher the faster.
  79974. */
  79975. touchMoveSensibility: number;
  79976. private _offsetX;
  79977. private _offsetY;
  79978. private _pointerPressed;
  79979. private _pointerInput;
  79980. private _observer;
  79981. private _onLostFocus;
  79982. /**
  79983. * Attach the input controls to a specific dom element to get the input from.
  79984. * @param element Defines the element the controls should be listened from
  79985. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79986. */
  79987. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79988. /**
  79989. * Detach the current controls from the specified dom element.
  79990. * @param element Defines the element to stop listening the inputs from
  79991. */
  79992. detachControl(element: Nullable<HTMLElement>): void;
  79993. /**
  79994. * Update the current camera state depending on the inputs that have been used this frame.
  79995. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79996. */
  79997. checkInputs(): void;
  79998. /**
  79999. * Gets the class name of the current intput.
  80000. * @returns the class name
  80001. */
  80002. getClassName(): string;
  80003. /**
  80004. * Get the friendly name associated with the input class.
  80005. * @returns the input friendly name
  80006. */
  80007. getSimpleName(): string;
  80008. }
  80009. }
  80010. declare module BABYLON {
  80011. /**
  80012. * Default Inputs manager for the FreeCamera.
  80013. * It groups all the default supported inputs for ease of use.
  80014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80015. */
  80016. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  80017. /**
  80018. * @hidden
  80019. */
  80020. _mouseInput: Nullable<FreeCameraMouseInput>;
  80021. /**
  80022. * Instantiates a new FreeCameraInputsManager.
  80023. * @param camera Defines the camera the inputs belong to
  80024. */
  80025. constructor(camera: FreeCamera);
  80026. /**
  80027. * Add keyboard input support to the input manager.
  80028. * @returns the current input manager
  80029. */
  80030. addKeyboard(): FreeCameraInputsManager;
  80031. /**
  80032. * Add mouse input support to the input manager.
  80033. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  80034. * @returns the current input manager
  80035. */
  80036. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  80037. /**
  80038. * Removes the mouse input support from the manager
  80039. * @returns the current input manager
  80040. */
  80041. removeMouse(): FreeCameraInputsManager;
  80042. /**
  80043. * Add touch input support to the input manager.
  80044. * @returns the current input manager
  80045. */
  80046. addTouch(): FreeCameraInputsManager;
  80047. /**
  80048. * Remove all attached input methods from a camera
  80049. */
  80050. clear(): void;
  80051. }
  80052. }
  80053. declare module BABYLON {
  80054. /**
  80055. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80056. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  80057. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80058. */
  80059. export class FreeCamera extends TargetCamera {
  80060. /**
  80061. * Define the collision ellipsoid of the camera.
  80062. * This is helpful to simulate a camera body like the player body around the camera
  80063. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  80064. */
  80065. ellipsoid: Vector3;
  80066. /**
  80067. * Define an offset for the position of the ellipsoid around the camera.
  80068. * This can be helpful to determine the center of the body near the gravity center of the body
  80069. * instead of its head.
  80070. */
  80071. ellipsoidOffset: Vector3;
  80072. /**
  80073. * Enable or disable collisions of the camera with the rest of the scene objects.
  80074. */
  80075. checkCollisions: boolean;
  80076. /**
  80077. * Enable or disable gravity on the camera.
  80078. */
  80079. applyGravity: boolean;
  80080. /**
  80081. * Define the input manager associated to the camera.
  80082. */
  80083. inputs: FreeCameraInputsManager;
  80084. /**
  80085. * Gets the input sensibility for a mouse input. (default is 2000.0)
  80086. * Higher values reduce sensitivity.
  80087. */
  80088. /**
  80089. * Sets the input sensibility for a mouse input. (default is 2000.0)
  80090. * Higher values reduce sensitivity.
  80091. */
  80092. angularSensibility: number;
  80093. /**
  80094. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  80095. */
  80096. keysUp: number[];
  80097. /**
  80098. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  80099. */
  80100. keysDown: number[];
  80101. /**
  80102. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  80103. */
  80104. keysLeft: number[];
  80105. /**
  80106. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  80107. */
  80108. keysRight: number[];
  80109. /**
  80110. * Event raised when the camera collide with a mesh in the scene.
  80111. */
  80112. onCollide: (collidedMesh: AbstractMesh) => void;
  80113. private _collider;
  80114. private _needMoveForGravity;
  80115. private _oldPosition;
  80116. private _diffPosition;
  80117. private _newPosition;
  80118. /** @hidden */
  80119. _localDirection: Vector3;
  80120. /** @hidden */
  80121. _transformedDirection: Vector3;
  80122. /**
  80123. * Instantiates a Free Camera.
  80124. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80125. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  80126. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80127. * @param name Define the name of the camera in the scene
  80128. * @param position Define the start position of the camera in the scene
  80129. * @param scene Define the scene the camera belongs to
  80130. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  80131. */
  80132. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  80133. /**
  80134. * Attached controls to the current camera.
  80135. * @param element Defines the element the controls should be listened from
  80136. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80137. */
  80138. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80139. /**
  80140. * Detach the current controls from the camera.
  80141. * The camera will stop reacting to inputs.
  80142. * @param element Defines the element to stop listening the inputs from
  80143. */
  80144. detachControl(element: HTMLElement): void;
  80145. private _collisionMask;
  80146. /**
  80147. * Define a collision mask to limit the list of object the camera can collide with
  80148. */
  80149. collisionMask: number;
  80150. /** @hidden */
  80151. _collideWithWorld(displacement: Vector3): void;
  80152. private _onCollisionPositionChange;
  80153. /** @hidden */
  80154. _checkInputs(): void;
  80155. /** @hidden */
  80156. _decideIfNeedsToMove(): boolean;
  80157. /** @hidden */
  80158. _updatePosition(): void;
  80159. /**
  80160. * Destroy the camera and release the current resources hold by it.
  80161. */
  80162. dispose(): void;
  80163. /**
  80164. * Gets the current object class name.
  80165. * @return the class name
  80166. */
  80167. getClassName(): string;
  80168. }
  80169. }
  80170. declare module BABYLON {
  80171. /**
  80172. * Represents a gamepad control stick position
  80173. */
  80174. export class StickValues {
  80175. /**
  80176. * The x component of the control stick
  80177. */
  80178. x: number;
  80179. /**
  80180. * The y component of the control stick
  80181. */
  80182. y: number;
  80183. /**
  80184. * Initializes the gamepad x and y control stick values
  80185. * @param x The x component of the gamepad control stick value
  80186. * @param y The y component of the gamepad control stick value
  80187. */
  80188. constructor(
  80189. /**
  80190. * The x component of the control stick
  80191. */
  80192. x: number,
  80193. /**
  80194. * The y component of the control stick
  80195. */
  80196. y: number);
  80197. }
  80198. /**
  80199. * An interface which manages callbacks for gamepad button changes
  80200. */
  80201. export interface GamepadButtonChanges {
  80202. /**
  80203. * Called when a gamepad has been changed
  80204. */
  80205. changed: boolean;
  80206. /**
  80207. * Called when a gamepad press event has been triggered
  80208. */
  80209. pressChanged: boolean;
  80210. /**
  80211. * Called when a touch event has been triggered
  80212. */
  80213. touchChanged: boolean;
  80214. /**
  80215. * Called when a value has changed
  80216. */
  80217. valueChanged: boolean;
  80218. }
  80219. /**
  80220. * Represents a gamepad
  80221. */
  80222. export class Gamepad {
  80223. /**
  80224. * The id of the gamepad
  80225. */
  80226. id: string;
  80227. /**
  80228. * The index of the gamepad
  80229. */
  80230. index: number;
  80231. /**
  80232. * The browser gamepad
  80233. */
  80234. browserGamepad: any;
  80235. /**
  80236. * Specifies what type of gamepad this represents
  80237. */
  80238. type: number;
  80239. private _leftStick;
  80240. private _rightStick;
  80241. /** @hidden */
  80242. _isConnected: boolean;
  80243. private _leftStickAxisX;
  80244. private _leftStickAxisY;
  80245. private _rightStickAxisX;
  80246. private _rightStickAxisY;
  80247. /**
  80248. * Triggered when the left control stick has been changed
  80249. */
  80250. private _onleftstickchanged;
  80251. /**
  80252. * Triggered when the right control stick has been changed
  80253. */
  80254. private _onrightstickchanged;
  80255. /**
  80256. * Represents a gamepad controller
  80257. */
  80258. static GAMEPAD: number;
  80259. /**
  80260. * Represents a generic controller
  80261. */
  80262. static GENERIC: number;
  80263. /**
  80264. * Represents an XBox controller
  80265. */
  80266. static XBOX: number;
  80267. /**
  80268. * Represents a pose-enabled controller
  80269. */
  80270. static POSE_ENABLED: number;
  80271. /**
  80272. * Represents an Dual Shock controller
  80273. */
  80274. static DUALSHOCK: number;
  80275. /**
  80276. * Specifies whether the left control stick should be Y-inverted
  80277. */
  80278. protected _invertLeftStickY: boolean;
  80279. /**
  80280. * Specifies if the gamepad has been connected
  80281. */
  80282. readonly isConnected: boolean;
  80283. /**
  80284. * Initializes the gamepad
  80285. * @param id The id of the gamepad
  80286. * @param index The index of the gamepad
  80287. * @param browserGamepad The browser gamepad
  80288. * @param leftStickX The x component of the left joystick
  80289. * @param leftStickY The y component of the left joystick
  80290. * @param rightStickX The x component of the right joystick
  80291. * @param rightStickY The y component of the right joystick
  80292. */
  80293. constructor(
  80294. /**
  80295. * The id of the gamepad
  80296. */
  80297. id: string,
  80298. /**
  80299. * The index of the gamepad
  80300. */
  80301. index: number,
  80302. /**
  80303. * The browser gamepad
  80304. */
  80305. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  80306. /**
  80307. * Callback triggered when the left joystick has changed
  80308. * @param callback
  80309. */
  80310. onleftstickchanged(callback: (values: StickValues) => void): void;
  80311. /**
  80312. * Callback triggered when the right joystick has changed
  80313. * @param callback
  80314. */
  80315. onrightstickchanged(callback: (values: StickValues) => void): void;
  80316. /**
  80317. * Gets the left joystick
  80318. */
  80319. /**
  80320. * Sets the left joystick values
  80321. */
  80322. leftStick: StickValues;
  80323. /**
  80324. * Gets the right joystick
  80325. */
  80326. /**
  80327. * Sets the right joystick value
  80328. */
  80329. rightStick: StickValues;
  80330. /**
  80331. * Updates the gamepad joystick positions
  80332. */
  80333. update(): void;
  80334. /**
  80335. * Disposes the gamepad
  80336. */
  80337. dispose(): void;
  80338. }
  80339. /**
  80340. * Represents a generic gamepad
  80341. */
  80342. export class GenericPad extends Gamepad {
  80343. private _buttons;
  80344. private _onbuttondown;
  80345. private _onbuttonup;
  80346. /**
  80347. * Observable triggered when a button has been pressed
  80348. */
  80349. onButtonDownObservable: Observable<number>;
  80350. /**
  80351. * Observable triggered when a button has been released
  80352. */
  80353. onButtonUpObservable: Observable<number>;
  80354. /**
  80355. * Callback triggered when a button has been pressed
  80356. * @param callback Called when a button has been pressed
  80357. */
  80358. onbuttondown(callback: (buttonPressed: number) => void): void;
  80359. /**
  80360. * Callback triggered when a button has been released
  80361. * @param callback Called when a button has been released
  80362. */
  80363. onbuttonup(callback: (buttonReleased: number) => void): void;
  80364. /**
  80365. * Initializes the generic gamepad
  80366. * @param id The id of the generic gamepad
  80367. * @param index The index of the generic gamepad
  80368. * @param browserGamepad The browser gamepad
  80369. */
  80370. constructor(id: string, index: number, browserGamepad: any);
  80371. private _setButtonValue;
  80372. /**
  80373. * Updates the generic gamepad
  80374. */
  80375. update(): void;
  80376. /**
  80377. * Disposes the generic gamepad
  80378. */
  80379. dispose(): void;
  80380. }
  80381. }
  80382. declare module BABYLON {
  80383. interface Engine {
  80384. /**
  80385. * Creates a raw texture
  80386. * @param data defines the data to store in the texture
  80387. * @param width defines the width of the texture
  80388. * @param height defines the height of the texture
  80389. * @param format defines the format of the data
  80390. * @param generateMipMaps defines if the engine should generate the mip levels
  80391. * @param invertY defines if data must be stored with Y axis inverted
  80392. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  80393. * @param compression defines the compression used (null by default)
  80394. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80395. * @returns the raw texture inside an InternalTexture
  80396. */
  80397. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  80398. /**
  80399. * Update a raw texture
  80400. * @param texture defines the texture to update
  80401. * @param data defines the data to store in the texture
  80402. * @param format defines the format of the data
  80403. * @param invertY defines if data must be stored with Y axis inverted
  80404. */
  80405. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80406. /**
  80407. * Update a raw texture
  80408. * @param texture defines the texture to update
  80409. * @param data defines the data to store in the texture
  80410. * @param format defines the format of the data
  80411. * @param invertY defines if data must be stored with Y axis inverted
  80412. * @param compression defines the compression used (null by default)
  80413. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80414. */
  80415. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  80416. /**
  80417. * Creates a new raw cube texture
  80418. * @param data defines the array of data to use to create each face
  80419. * @param size defines the size of the textures
  80420. * @param format defines the format of the data
  80421. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80422. * @param generateMipMaps defines if the engine should generate the mip levels
  80423. * @param invertY defines if data must be stored with Y axis inverted
  80424. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80425. * @param compression defines the compression used (null by default)
  80426. * @returns the cube texture as an InternalTexture
  80427. */
  80428. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  80429. /**
  80430. * Update a raw cube texture
  80431. * @param texture defines the texture to udpdate
  80432. * @param data defines the data to store
  80433. * @param format defines the data format
  80434. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80435. * @param invertY defines if data must be stored with Y axis inverted
  80436. */
  80437. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  80438. /**
  80439. * Update a raw cube texture
  80440. * @param texture defines the texture to udpdate
  80441. * @param data defines the data to store
  80442. * @param format defines the data format
  80443. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80444. * @param invertY defines if data must be stored with Y axis inverted
  80445. * @param compression defines the compression used (null by default)
  80446. */
  80447. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  80448. /**
  80449. * Update a raw cube texture
  80450. * @param texture defines the texture to udpdate
  80451. * @param data defines the data to store
  80452. * @param format defines the data format
  80453. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80454. * @param invertY defines if data must be stored with Y axis inverted
  80455. * @param compression defines the compression used (null by default)
  80456. * @param level defines which level of the texture to update
  80457. */
  80458. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  80459. /**
  80460. * Creates a new raw cube texture from a specified url
  80461. * @param url defines the url where the data is located
  80462. * @param scene defines the current scene
  80463. * @param size defines the size of the textures
  80464. * @param format defines the format of the data
  80465. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80466. * @param noMipmap defines if the engine should avoid generating the mip levels
  80467. * @param callback defines a callback used to extract texture data from loaded data
  80468. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80469. * @param onLoad defines a callback called when texture is loaded
  80470. * @param onError defines a callback called if there is an error
  80471. * @returns the cube texture as an InternalTexture
  80472. */
  80473. 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;
  80474. /**
  80475. * Creates a new raw cube texture from a specified url
  80476. * @param url defines the url where the data is located
  80477. * @param scene defines the current scene
  80478. * @param size defines the size of the textures
  80479. * @param format defines the format of the data
  80480. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80481. * @param noMipmap defines if the engine should avoid generating the mip levels
  80482. * @param callback defines a callback used to extract texture data from loaded data
  80483. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80484. * @param onLoad defines a callback called when texture is loaded
  80485. * @param onError defines a callback called if there is an error
  80486. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80487. * @param invertY defines if data must be stored with Y axis inverted
  80488. * @returns the cube texture as an InternalTexture
  80489. */
  80490. 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;
  80491. /**
  80492. * Creates a new raw 3D texture
  80493. * @param data defines the data used to create the texture
  80494. * @param width defines the width of the texture
  80495. * @param height defines the height of the texture
  80496. * @param depth defines the depth of the texture
  80497. * @param format defines the format of the texture
  80498. * @param generateMipMaps defines if the engine must generate mip levels
  80499. * @param invertY defines if data must be stored with Y axis inverted
  80500. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80501. * @param compression defines the compressed used (can be null)
  80502. * @param textureType defines the compressed used (can be null)
  80503. * @returns a new raw 3D texture (stored in an InternalTexture)
  80504. */
  80505. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80506. /**
  80507. * Update a raw 3D texture
  80508. * @param texture defines the texture to update
  80509. * @param data defines the data to store
  80510. * @param format defines the data format
  80511. * @param invertY defines if data must be stored with Y axis inverted
  80512. */
  80513. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80514. /**
  80515. * Update a raw 3D texture
  80516. * @param texture defines the texture to update
  80517. * @param data defines the data to store
  80518. * @param format defines the data format
  80519. * @param invertY defines if data must be stored with Y axis inverted
  80520. * @param compression defines the used compression (can be null)
  80521. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80522. */
  80523. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80524. /**
  80525. * Creates a new raw 2D array texture
  80526. * @param data defines the data used to create the texture
  80527. * @param width defines the width of the texture
  80528. * @param height defines the height of the texture
  80529. * @param depth defines the number of layers of the texture
  80530. * @param format defines the format of the texture
  80531. * @param generateMipMaps defines if the engine must generate mip levels
  80532. * @param invertY defines if data must be stored with Y axis inverted
  80533. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80534. * @param compression defines the compressed used (can be null)
  80535. * @param textureType defines the compressed used (can be null)
  80536. * @returns a new raw 2D array texture (stored in an InternalTexture)
  80537. */
  80538. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80539. /**
  80540. * Update a raw 2D array texture
  80541. * @param texture defines the texture to update
  80542. * @param data defines the data to store
  80543. * @param format defines the data format
  80544. * @param invertY defines if data must be stored with Y axis inverted
  80545. */
  80546. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80547. /**
  80548. * Update a raw 2D array texture
  80549. * @param texture defines the texture to update
  80550. * @param data defines the data to store
  80551. * @param format defines the data format
  80552. * @param invertY defines if data must be stored with Y axis inverted
  80553. * @param compression defines the used compression (can be null)
  80554. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80555. */
  80556. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80557. }
  80558. }
  80559. declare module BABYLON {
  80560. /**
  80561. * Raw texture can help creating a texture directly from an array of data.
  80562. * This can be super useful if you either get the data from an uncompressed source or
  80563. * if you wish to create your texture pixel by pixel.
  80564. */
  80565. export class RawTexture extends Texture {
  80566. /**
  80567. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80568. */
  80569. format: number;
  80570. private _engine;
  80571. /**
  80572. * Instantiates a new RawTexture.
  80573. * Raw texture can help creating a texture directly from an array of data.
  80574. * This can be super useful if you either get the data from an uncompressed source or
  80575. * if you wish to create your texture pixel by pixel.
  80576. * @param data define the array of data to use to create the texture
  80577. * @param width define the width of the texture
  80578. * @param height define the height of the texture
  80579. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80580. * @param scene define the scene the texture belongs to
  80581. * @param generateMipMaps define whether mip maps should be generated or not
  80582. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80583. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80584. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80585. */
  80586. constructor(data: ArrayBufferView, width: number, height: number,
  80587. /**
  80588. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80589. */
  80590. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  80591. /**
  80592. * Updates the texture underlying data.
  80593. * @param data Define the new data of the texture
  80594. */
  80595. update(data: ArrayBufferView): void;
  80596. /**
  80597. * Creates a luminance texture from some data.
  80598. * @param data Define the texture data
  80599. * @param width Define the width of the texture
  80600. * @param height Define the height of the texture
  80601. * @param scene Define the scene the texture belongs to
  80602. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80603. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80604. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80605. * @returns the luminance texture
  80606. */
  80607. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80608. /**
  80609. * Creates a luminance alpha texture from some data.
  80610. * @param data Define the texture data
  80611. * @param width Define the width of the texture
  80612. * @param height Define the height of the texture
  80613. * @param scene Define the scene the texture belongs to
  80614. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80615. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80616. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80617. * @returns the luminance alpha texture
  80618. */
  80619. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80620. /**
  80621. * Creates an alpha texture from some data.
  80622. * @param data Define the texture data
  80623. * @param width Define the width of the texture
  80624. * @param height Define the height of the texture
  80625. * @param scene Define the scene the texture belongs to
  80626. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80627. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80628. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80629. * @returns the alpha texture
  80630. */
  80631. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80632. /**
  80633. * Creates a RGB texture from some data.
  80634. * @param data Define the texture data
  80635. * @param width Define the width of the texture
  80636. * @param height Define the height of the texture
  80637. * @param scene Define the scene the texture belongs to
  80638. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80639. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80640. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80641. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80642. * @returns the RGB alpha texture
  80643. */
  80644. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80645. /**
  80646. * Creates a RGBA texture from some data.
  80647. * @param data Define the texture data
  80648. * @param width Define the width of the texture
  80649. * @param height Define the height of the texture
  80650. * @param scene Define the scene the texture belongs to
  80651. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80652. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80653. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80654. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80655. * @returns the RGBA texture
  80656. */
  80657. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80658. /**
  80659. * Creates a R texture from some data.
  80660. * @param data Define the texture data
  80661. * @param width Define the width of the texture
  80662. * @param height Define the height of the texture
  80663. * @param scene Define the scene the texture belongs to
  80664. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80665. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80666. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80667. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80668. * @returns the R texture
  80669. */
  80670. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80671. }
  80672. }
  80673. declare module BABYLON {
  80674. /**
  80675. * Interface for the size containing width and height
  80676. */
  80677. export interface ISize {
  80678. /**
  80679. * Width
  80680. */
  80681. width: number;
  80682. /**
  80683. * Heighht
  80684. */
  80685. height: number;
  80686. }
  80687. /**
  80688. * Size containing widht and height
  80689. */
  80690. export class Size implements ISize {
  80691. /**
  80692. * Width
  80693. */
  80694. width: number;
  80695. /**
  80696. * Height
  80697. */
  80698. height: number;
  80699. /**
  80700. * Creates a Size object from the given width and height (floats).
  80701. * @param width width of the new size
  80702. * @param height height of the new size
  80703. */
  80704. constructor(width: number, height: number);
  80705. /**
  80706. * Returns a string with the Size width and height
  80707. * @returns a string with the Size width and height
  80708. */
  80709. toString(): string;
  80710. /**
  80711. * "Size"
  80712. * @returns the string "Size"
  80713. */
  80714. getClassName(): string;
  80715. /**
  80716. * Returns the Size hash code.
  80717. * @returns a hash code for a unique width and height
  80718. */
  80719. getHashCode(): number;
  80720. /**
  80721. * Updates the current size from the given one.
  80722. * @param src the given size
  80723. */
  80724. copyFrom(src: Size): void;
  80725. /**
  80726. * Updates in place the current Size from the given floats.
  80727. * @param width width of the new size
  80728. * @param height height of the new size
  80729. * @returns the updated Size.
  80730. */
  80731. copyFromFloats(width: number, height: number): Size;
  80732. /**
  80733. * Updates in place the current Size from the given floats.
  80734. * @param width width to set
  80735. * @param height height to set
  80736. * @returns the updated Size.
  80737. */
  80738. set(width: number, height: number): Size;
  80739. /**
  80740. * Multiplies the width and height by numbers
  80741. * @param w factor to multiple the width by
  80742. * @param h factor to multiple the height by
  80743. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  80744. */
  80745. multiplyByFloats(w: number, h: number): Size;
  80746. /**
  80747. * Clones the size
  80748. * @returns a new Size copied from the given one.
  80749. */
  80750. clone(): Size;
  80751. /**
  80752. * True if the current Size and the given one width and height are strictly equal.
  80753. * @param other the other size to compare against
  80754. * @returns True if the current Size and the given one width and height are strictly equal.
  80755. */
  80756. equals(other: Size): boolean;
  80757. /**
  80758. * The surface of the Size : width * height (float).
  80759. */
  80760. readonly surface: number;
  80761. /**
  80762. * Create a new size of zero
  80763. * @returns a new Size set to (0.0, 0.0)
  80764. */
  80765. static Zero(): Size;
  80766. /**
  80767. * Sums the width and height of two sizes
  80768. * @param otherSize size to add to this size
  80769. * @returns a new Size set as the addition result of the current Size and the given one.
  80770. */
  80771. add(otherSize: Size): Size;
  80772. /**
  80773. * Subtracts the width and height of two
  80774. * @param otherSize size to subtract to this size
  80775. * @returns a new Size set as the subtraction result of the given one from the current Size.
  80776. */
  80777. subtract(otherSize: Size): Size;
  80778. /**
  80779. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  80780. * @param start starting size to lerp between
  80781. * @param end end size to lerp between
  80782. * @param amount amount to lerp between the start and end values
  80783. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  80784. */
  80785. static Lerp(start: Size, end: Size, amount: number): Size;
  80786. }
  80787. }
  80788. declare module BABYLON {
  80789. /**
  80790. * Defines a runtime animation
  80791. */
  80792. export class RuntimeAnimation {
  80793. private _events;
  80794. /**
  80795. * The current frame of the runtime animation
  80796. */
  80797. private _currentFrame;
  80798. /**
  80799. * The animation used by the runtime animation
  80800. */
  80801. private _animation;
  80802. /**
  80803. * The target of the runtime animation
  80804. */
  80805. private _target;
  80806. /**
  80807. * The initiating animatable
  80808. */
  80809. private _host;
  80810. /**
  80811. * The original value of the runtime animation
  80812. */
  80813. private _originalValue;
  80814. /**
  80815. * The original blend value of the runtime animation
  80816. */
  80817. private _originalBlendValue;
  80818. /**
  80819. * The offsets cache of the runtime animation
  80820. */
  80821. private _offsetsCache;
  80822. /**
  80823. * The high limits cache of the runtime animation
  80824. */
  80825. private _highLimitsCache;
  80826. /**
  80827. * Specifies if the runtime animation has been stopped
  80828. */
  80829. private _stopped;
  80830. /**
  80831. * The blending factor of the runtime animation
  80832. */
  80833. private _blendingFactor;
  80834. /**
  80835. * The BabylonJS scene
  80836. */
  80837. private _scene;
  80838. /**
  80839. * The current value of the runtime animation
  80840. */
  80841. private _currentValue;
  80842. /** @hidden */
  80843. _animationState: _IAnimationState;
  80844. /**
  80845. * The active target of the runtime animation
  80846. */
  80847. private _activeTargets;
  80848. private _currentActiveTarget;
  80849. private _directTarget;
  80850. /**
  80851. * The target path of the runtime animation
  80852. */
  80853. private _targetPath;
  80854. /**
  80855. * The weight of the runtime animation
  80856. */
  80857. private _weight;
  80858. /**
  80859. * The ratio offset of the runtime animation
  80860. */
  80861. private _ratioOffset;
  80862. /**
  80863. * The previous delay of the runtime animation
  80864. */
  80865. private _previousDelay;
  80866. /**
  80867. * The previous ratio of the runtime animation
  80868. */
  80869. private _previousRatio;
  80870. private _enableBlending;
  80871. private _keys;
  80872. private _minFrame;
  80873. private _maxFrame;
  80874. private _minValue;
  80875. private _maxValue;
  80876. private _targetIsArray;
  80877. /**
  80878. * Gets the current frame of the runtime animation
  80879. */
  80880. readonly currentFrame: number;
  80881. /**
  80882. * Gets the weight of the runtime animation
  80883. */
  80884. readonly weight: number;
  80885. /**
  80886. * Gets the current value of the runtime animation
  80887. */
  80888. readonly currentValue: any;
  80889. /**
  80890. * Gets the target path of the runtime animation
  80891. */
  80892. readonly targetPath: string;
  80893. /**
  80894. * Gets the actual target of the runtime animation
  80895. */
  80896. readonly target: any;
  80897. /** @hidden */
  80898. _onLoop: () => void;
  80899. /**
  80900. * Create a new RuntimeAnimation object
  80901. * @param target defines the target of the animation
  80902. * @param animation defines the source animation object
  80903. * @param scene defines the hosting scene
  80904. * @param host defines the initiating Animatable
  80905. */
  80906. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  80907. private _preparePath;
  80908. /**
  80909. * Gets the animation from the runtime animation
  80910. */
  80911. readonly animation: Animation;
  80912. /**
  80913. * Resets the runtime animation to the beginning
  80914. * @param restoreOriginal defines whether to restore the target property to the original value
  80915. */
  80916. reset(restoreOriginal?: boolean): void;
  80917. /**
  80918. * Specifies if the runtime animation is stopped
  80919. * @returns Boolean specifying if the runtime animation is stopped
  80920. */
  80921. isStopped(): boolean;
  80922. /**
  80923. * Disposes of the runtime animation
  80924. */
  80925. dispose(): void;
  80926. /**
  80927. * Apply the interpolated value to the target
  80928. * @param currentValue defines the value computed by the animation
  80929. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  80930. */
  80931. setValue(currentValue: any, weight: number): void;
  80932. private _getOriginalValues;
  80933. private _setValue;
  80934. /**
  80935. * Gets the loop pmode of the runtime animation
  80936. * @returns Loop Mode
  80937. */
  80938. private _getCorrectLoopMode;
  80939. /**
  80940. * Move the current animation to a given frame
  80941. * @param frame defines the frame to move to
  80942. */
  80943. goToFrame(frame: number): void;
  80944. /**
  80945. * @hidden Internal use only
  80946. */
  80947. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  80948. /**
  80949. * Execute the current animation
  80950. * @param delay defines the delay to add to the current frame
  80951. * @param from defines the lower bound of the animation range
  80952. * @param to defines the upper bound of the animation range
  80953. * @param loop defines if the current animation must loop
  80954. * @param speedRatio defines the current speed ratio
  80955. * @param weight defines the weight of the animation (default is -1 so no weight)
  80956. * @param onLoop optional callback called when animation loops
  80957. * @returns a boolean indicating if the animation is running
  80958. */
  80959. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  80960. }
  80961. }
  80962. declare module BABYLON {
  80963. /**
  80964. * Class used to store an actual running animation
  80965. */
  80966. export class Animatable {
  80967. /** defines the target object */
  80968. target: any;
  80969. /** defines the starting frame number (default is 0) */
  80970. fromFrame: number;
  80971. /** defines the ending frame number (default is 100) */
  80972. toFrame: number;
  80973. /** defines if the animation must loop (default is false) */
  80974. loopAnimation: boolean;
  80975. /** defines a callback to call when animation ends if it is not looping */
  80976. onAnimationEnd?: (() => void) | null | undefined;
  80977. /** defines a callback to call when animation loops */
  80978. onAnimationLoop?: (() => void) | null | undefined;
  80979. private _localDelayOffset;
  80980. private _pausedDelay;
  80981. private _runtimeAnimations;
  80982. private _paused;
  80983. private _scene;
  80984. private _speedRatio;
  80985. private _weight;
  80986. private _syncRoot;
  80987. /**
  80988. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  80989. * This will only apply for non looping animation (default is true)
  80990. */
  80991. disposeOnEnd: boolean;
  80992. /**
  80993. * Gets a boolean indicating if the animation has started
  80994. */
  80995. animationStarted: boolean;
  80996. /**
  80997. * Observer raised when the animation ends
  80998. */
  80999. onAnimationEndObservable: Observable<Animatable>;
  81000. /**
  81001. * Observer raised when the animation loops
  81002. */
  81003. onAnimationLoopObservable: Observable<Animatable>;
  81004. /**
  81005. * Gets the root Animatable used to synchronize and normalize animations
  81006. */
  81007. readonly syncRoot: Nullable<Animatable>;
  81008. /**
  81009. * Gets the current frame of the first RuntimeAnimation
  81010. * Used to synchronize Animatables
  81011. */
  81012. readonly masterFrame: number;
  81013. /**
  81014. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  81015. */
  81016. weight: number;
  81017. /**
  81018. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  81019. */
  81020. speedRatio: number;
  81021. /**
  81022. * Creates a new Animatable
  81023. * @param scene defines the hosting scene
  81024. * @param target defines the target object
  81025. * @param fromFrame defines the starting frame number (default is 0)
  81026. * @param toFrame defines the ending frame number (default is 100)
  81027. * @param loopAnimation defines if the animation must loop (default is false)
  81028. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  81029. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  81030. * @param animations defines a group of animation to add to the new Animatable
  81031. * @param onAnimationLoop defines a callback to call when animation loops
  81032. */
  81033. constructor(scene: Scene,
  81034. /** defines the target object */
  81035. target: any,
  81036. /** defines the starting frame number (default is 0) */
  81037. fromFrame?: number,
  81038. /** defines the ending frame number (default is 100) */
  81039. toFrame?: number,
  81040. /** defines if the animation must loop (default is false) */
  81041. loopAnimation?: boolean, speedRatio?: number,
  81042. /** defines a callback to call when animation ends if it is not looping */
  81043. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  81044. /** defines a callback to call when animation loops */
  81045. onAnimationLoop?: (() => void) | null | undefined);
  81046. /**
  81047. * Synchronize and normalize current Animatable with a source Animatable
  81048. * This is useful when using animation weights and when animations are not of the same length
  81049. * @param root defines the root Animatable to synchronize with
  81050. * @returns the current Animatable
  81051. */
  81052. syncWith(root: Animatable): Animatable;
  81053. /**
  81054. * Gets the list of runtime animations
  81055. * @returns an array of RuntimeAnimation
  81056. */
  81057. getAnimations(): RuntimeAnimation[];
  81058. /**
  81059. * Adds more animations to the current animatable
  81060. * @param target defines the target of the animations
  81061. * @param animations defines the new animations to add
  81062. */
  81063. appendAnimations(target: any, animations: Animation[]): void;
  81064. /**
  81065. * Gets the source animation for a specific property
  81066. * @param property defines the propertyu to look for
  81067. * @returns null or the source animation for the given property
  81068. */
  81069. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  81070. /**
  81071. * Gets the runtime animation for a specific property
  81072. * @param property defines the propertyu to look for
  81073. * @returns null or the runtime animation for the given property
  81074. */
  81075. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  81076. /**
  81077. * Resets the animatable to its original state
  81078. */
  81079. reset(): void;
  81080. /**
  81081. * Allows the animatable to blend with current running animations
  81082. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81083. * @param blendingSpeed defines the blending speed to use
  81084. */
  81085. enableBlending(blendingSpeed: number): void;
  81086. /**
  81087. * Disable animation blending
  81088. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81089. */
  81090. disableBlending(): void;
  81091. /**
  81092. * Jump directly to a given frame
  81093. * @param frame defines the frame to jump to
  81094. */
  81095. goToFrame(frame: number): void;
  81096. /**
  81097. * Pause the animation
  81098. */
  81099. pause(): void;
  81100. /**
  81101. * Restart the animation
  81102. */
  81103. restart(): void;
  81104. private _raiseOnAnimationEnd;
  81105. /**
  81106. * Stop and delete the current animation
  81107. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  81108. * @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)
  81109. */
  81110. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  81111. /**
  81112. * Wait asynchronously for the animation to end
  81113. * @returns a promise which will be fullfilled when the animation ends
  81114. */
  81115. waitAsync(): Promise<Animatable>;
  81116. /** @hidden */
  81117. _animate(delay: number): boolean;
  81118. }
  81119. interface Scene {
  81120. /** @hidden */
  81121. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  81122. /** @hidden */
  81123. _processLateAnimationBindingsForMatrices(holder: {
  81124. totalWeight: number;
  81125. animations: RuntimeAnimation[];
  81126. originalValue: Matrix;
  81127. }): any;
  81128. /** @hidden */
  81129. _processLateAnimationBindingsForQuaternions(holder: {
  81130. totalWeight: number;
  81131. animations: RuntimeAnimation[];
  81132. originalValue: Quaternion;
  81133. }, refQuaternion: Quaternion): Quaternion;
  81134. /** @hidden */
  81135. _processLateAnimationBindings(): void;
  81136. /**
  81137. * Will start the animation sequence of a given target
  81138. * @param target defines the target
  81139. * @param from defines from which frame should animation start
  81140. * @param to defines until which frame should animation run.
  81141. * @param weight defines the weight to apply to the animation (1.0 by default)
  81142. * @param loop defines if the animation loops
  81143. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81144. * @param onAnimationEnd defines the function to be executed when the animation ends
  81145. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81146. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81147. * @param onAnimationLoop defines the callback to call when an animation loops
  81148. * @returns the animatable object created for this animation
  81149. */
  81150. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81151. /**
  81152. * Will start the animation sequence of a given target
  81153. * @param target defines the target
  81154. * @param from defines from which frame should animation start
  81155. * @param to defines until which frame should animation run.
  81156. * @param loop defines if the animation loops
  81157. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81158. * @param onAnimationEnd defines the function to be executed when the animation ends
  81159. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81160. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81161. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  81162. * @param onAnimationLoop defines the callback to call when an animation loops
  81163. * @returns the animatable object created for this animation
  81164. */
  81165. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81166. /**
  81167. * Will start the animation sequence of a given target and its hierarchy
  81168. * @param target defines the target
  81169. * @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.
  81170. * @param from defines from which frame should animation start
  81171. * @param to defines until which frame should animation run.
  81172. * @param loop defines if the animation loops
  81173. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81174. * @param onAnimationEnd defines the function to be executed when the animation ends
  81175. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81176. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81177. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81178. * @param onAnimationLoop defines the callback to call when an animation loops
  81179. * @returns the list of created animatables
  81180. */
  81181. 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[];
  81182. /**
  81183. * Begin a new animation on a given node
  81184. * @param target defines the target where the animation will take place
  81185. * @param animations defines the list of animations to start
  81186. * @param from defines the initial value
  81187. * @param to defines the final value
  81188. * @param loop defines if you want animation to loop (off by default)
  81189. * @param speedRatio defines the speed ratio to apply to all animations
  81190. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81191. * @param onAnimationLoop defines the callback to call when an animation loops
  81192. * @returns the list of created animatables
  81193. */
  81194. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  81195. /**
  81196. * Begin a new animation on a given node and its hierarchy
  81197. * @param target defines the root node where the animation will take place
  81198. * @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.
  81199. * @param animations defines the list of animations to start
  81200. * @param from defines the initial value
  81201. * @param to defines the final value
  81202. * @param loop defines if you want animation to loop (off by default)
  81203. * @param speedRatio defines the speed ratio to apply to all animations
  81204. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81205. * @param onAnimationLoop defines the callback to call when an animation loops
  81206. * @returns the list of animatables created for all nodes
  81207. */
  81208. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  81209. /**
  81210. * Gets the animatable associated with a specific target
  81211. * @param target defines the target of the animatable
  81212. * @returns the required animatable if found
  81213. */
  81214. getAnimatableByTarget(target: any): Nullable<Animatable>;
  81215. /**
  81216. * Gets all animatables associated with a given target
  81217. * @param target defines the target to look animatables for
  81218. * @returns an array of Animatables
  81219. */
  81220. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  81221. /**
  81222. * Stops and removes all animations that have been applied to the scene
  81223. */
  81224. stopAllAnimations(): void;
  81225. /**
  81226. * Gets the current delta time used by animation engine
  81227. */
  81228. deltaTime: number;
  81229. }
  81230. interface Bone {
  81231. /**
  81232. * Copy an animation range from another bone
  81233. * @param source defines the source bone
  81234. * @param rangeName defines the range name to copy
  81235. * @param frameOffset defines the frame offset
  81236. * @param rescaleAsRequired defines if rescaling must be applied if required
  81237. * @param skelDimensionsRatio defines the scaling ratio
  81238. * @returns true if operation was successful
  81239. */
  81240. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  81241. }
  81242. }
  81243. declare module BABYLON {
  81244. /**
  81245. * Class used to override all child animations of a given target
  81246. */
  81247. export class AnimationPropertiesOverride {
  81248. /**
  81249. * Gets or sets a value indicating if animation blending must be used
  81250. */
  81251. enableBlending: boolean;
  81252. /**
  81253. * Gets or sets the blending speed to use when enableBlending is true
  81254. */
  81255. blendingSpeed: number;
  81256. /**
  81257. * Gets or sets the default loop mode to use
  81258. */
  81259. loopMode: number;
  81260. }
  81261. }
  81262. declare module BABYLON {
  81263. /**
  81264. * Class used to handle skinning animations
  81265. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81266. */
  81267. export class Skeleton implements IAnimatable {
  81268. /** defines the skeleton name */
  81269. name: string;
  81270. /** defines the skeleton Id */
  81271. id: string;
  81272. /**
  81273. * Defines the list of child bones
  81274. */
  81275. bones: Bone[];
  81276. /**
  81277. * Defines an estimate of the dimension of the skeleton at rest
  81278. */
  81279. dimensionsAtRest: Vector3;
  81280. /**
  81281. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  81282. */
  81283. needInitialSkinMatrix: boolean;
  81284. /**
  81285. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  81286. */
  81287. overrideMesh: Nullable<AbstractMesh>;
  81288. /**
  81289. * Gets the list of animations attached to this skeleton
  81290. */
  81291. animations: Array<Animation>;
  81292. private _scene;
  81293. private _isDirty;
  81294. private _transformMatrices;
  81295. private _transformMatrixTexture;
  81296. private _meshesWithPoseMatrix;
  81297. private _animatables;
  81298. private _identity;
  81299. private _synchronizedWithMesh;
  81300. private _ranges;
  81301. private _lastAbsoluteTransformsUpdateId;
  81302. private _canUseTextureForBones;
  81303. private _uniqueId;
  81304. /** @hidden */
  81305. _numBonesWithLinkedTransformNode: number;
  81306. /** @hidden */
  81307. _hasWaitingData: Nullable<boolean>;
  81308. /**
  81309. * Specifies if the skeleton should be serialized
  81310. */
  81311. doNotSerialize: boolean;
  81312. private _useTextureToStoreBoneMatrices;
  81313. /**
  81314. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  81315. * Please note that this option is not available if the hardware does not support it
  81316. */
  81317. useTextureToStoreBoneMatrices: boolean;
  81318. private _animationPropertiesOverride;
  81319. /**
  81320. * Gets or sets the animation properties override
  81321. */
  81322. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81323. /**
  81324. * List of inspectable custom properties (used by the Inspector)
  81325. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81326. */
  81327. inspectableCustomProperties: IInspectable[];
  81328. /**
  81329. * An observable triggered before computing the skeleton's matrices
  81330. */
  81331. onBeforeComputeObservable: Observable<Skeleton>;
  81332. /**
  81333. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  81334. */
  81335. readonly isUsingTextureForMatrices: boolean;
  81336. /**
  81337. * Gets the unique ID of this skeleton
  81338. */
  81339. readonly uniqueId: number;
  81340. /**
  81341. * Creates a new skeleton
  81342. * @param name defines the skeleton name
  81343. * @param id defines the skeleton Id
  81344. * @param scene defines the hosting scene
  81345. */
  81346. constructor(
  81347. /** defines the skeleton name */
  81348. name: string,
  81349. /** defines the skeleton Id */
  81350. id: string, scene: Scene);
  81351. /**
  81352. * Gets the current object class name.
  81353. * @return the class name
  81354. */
  81355. getClassName(): string;
  81356. /**
  81357. * Returns an array containing the root bones
  81358. * @returns an array containing the root bones
  81359. */
  81360. getChildren(): Array<Bone>;
  81361. /**
  81362. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  81363. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81364. * @returns a Float32Array containing matrices data
  81365. */
  81366. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  81367. /**
  81368. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  81369. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81370. * @returns a raw texture containing the data
  81371. */
  81372. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  81373. /**
  81374. * Gets the current hosting scene
  81375. * @returns a scene object
  81376. */
  81377. getScene(): Scene;
  81378. /**
  81379. * Gets a string representing the current skeleton data
  81380. * @param fullDetails defines a boolean indicating if we want a verbose version
  81381. * @returns a string representing the current skeleton data
  81382. */
  81383. toString(fullDetails?: boolean): string;
  81384. /**
  81385. * Get bone's index searching by name
  81386. * @param name defines bone's name to search for
  81387. * @return the indice of the bone. Returns -1 if not found
  81388. */
  81389. getBoneIndexByName(name: string): number;
  81390. /**
  81391. * Creater a new animation range
  81392. * @param name defines the name of the range
  81393. * @param from defines the start key
  81394. * @param to defines the end key
  81395. */
  81396. createAnimationRange(name: string, from: number, to: number): void;
  81397. /**
  81398. * Delete a specific animation range
  81399. * @param name defines the name of the range
  81400. * @param deleteFrames defines if frames must be removed as well
  81401. */
  81402. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81403. /**
  81404. * Gets a specific animation range
  81405. * @param name defines the name of the range to look for
  81406. * @returns the requested animation range or null if not found
  81407. */
  81408. getAnimationRange(name: string): Nullable<AnimationRange>;
  81409. /**
  81410. * Gets the list of all animation ranges defined on this skeleton
  81411. * @returns an array
  81412. */
  81413. getAnimationRanges(): Nullable<AnimationRange>[];
  81414. /**
  81415. * Copy animation range from a source skeleton.
  81416. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  81417. * @param source defines the source skeleton
  81418. * @param name defines the name of the range to copy
  81419. * @param rescaleAsRequired defines if rescaling must be applied if required
  81420. * @returns true if operation was successful
  81421. */
  81422. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  81423. /**
  81424. * Forces the skeleton to go to rest pose
  81425. */
  81426. returnToRest(): void;
  81427. private _getHighestAnimationFrame;
  81428. /**
  81429. * Begin a specific animation range
  81430. * @param name defines the name of the range to start
  81431. * @param loop defines if looping must be turned on (false by default)
  81432. * @param speedRatio defines the speed ratio to apply (1 by default)
  81433. * @param onAnimationEnd defines a callback which will be called when animation will end
  81434. * @returns a new animatable
  81435. */
  81436. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81437. /** @hidden */
  81438. _markAsDirty(): void;
  81439. /** @hidden */
  81440. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81441. /** @hidden */
  81442. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81443. private _computeTransformMatrices;
  81444. /**
  81445. * Build all resources required to render a skeleton
  81446. */
  81447. prepare(): void;
  81448. /**
  81449. * Gets the list of animatables currently running for this skeleton
  81450. * @returns an array of animatables
  81451. */
  81452. getAnimatables(): IAnimatable[];
  81453. /**
  81454. * Clone the current skeleton
  81455. * @param name defines the name of the new skeleton
  81456. * @param id defines the id of the new skeleton
  81457. * @returns the new skeleton
  81458. */
  81459. clone(name: string, id?: string): Skeleton;
  81460. /**
  81461. * Enable animation blending for this skeleton
  81462. * @param blendingSpeed defines the blending speed to apply
  81463. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81464. */
  81465. enableBlending(blendingSpeed?: number): void;
  81466. /**
  81467. * Releases all resources associated with the current skeleton
  81468. */
  81469. dispose(): void;
  81470. /**
  81471. * Serialize the skeleton in a JSON object
  81472. * @returns a JSON object
  81473. */
  81474. serialize(): any;
  81475. /**
  81476. * Creates a new skeleton from serialized data
  81477. * @param parsedSkeleton defines the serialized data
  81478. * @param scene defines the hosting scene
  81479. * @returns a new skeleton
  81480. */
  81481. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  81482. /**
  81483. * Compute all node absolute transforms
  81484. * @param forceUpdate defines if computation must be done even if cache is up to date
  81485. */
  81486. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  81487. /**
  81488. * Gets the root pose matrix
  81489. * @returns a matrix
  81490. */
  81491. getPoseMatrix(): Nullable<Matrix>;
  81492. /**
  81493. * Sorts bones per internal index
  81494. */
  81495. sortBones(): void;
  81496. private _sortBones;
  81497. }
  81498. }
  81499. declare module BABYLON {
  81500. /**
  81501. * Class used to store bone information
  81502. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81503. */
  81504. export class Bone extends Node {
  81505. /**
  81506. * defines the bone name
  81507. */
  81508. name: string;
  81509. private static _tmpVecs;
  81510. private static _tmpQuat;
  81511. private static _tmpMats;
  81512. /**
  81513. * Gets the list of child bones
  81514. */
  81515. children: Bone[];
  81516. /** Gets the animations associated with this bone */
  81517. animations: Animation[];
  81518. /**
  81519. * Gets or sets bone length
  81520. */
  81521. length: number;
  81522. /**
  81523. * @hidden Internal only
  81524. * Set this value to map this bone to a different index in the transform matrices
  81525. * Set this value to -1 to exclude the bone from the transform matrices
  81526. */
  81527. _index: Nullable<number>;
  81528. private _skeleton;
  81529. private _localMatrix;
  81530. private _restPose;
  81531. private _baseMatrix;
  81532. private _absoluteTransform;
  81533. private _invertedAbsoluteTransform;
  81534. private _parent;
  81535. private _scalingDeterminant;
  81536. private _worldTransform;
  81537. private _localScaling;
  81538. private _localRotation;
  81539. private _localPosition;
  81540. private _needToDecompose;
  81541. private _needToCompose;
  81542. /** @hidden */
  81543. _linkedTransformNode: Nullable<TransformNode>;
  81544. /** @hidden */
  81545. _waitingTransformNodeId: Nullable<string>;
  81546. /** @hidden */
  81547. /** @hidden */
  81548. _matrix: Matrix;
  81549. /**
  81550. * Create a new bone
  81551. * @param name defines the bone name
  81552. * @param skeleton defines the parent skeleton
  81553. * @param parentBone defines the parent (can be null if the bone is the root)
  81554. * @param localMatrix defines the local matrix
  81555. * @param restPose defines the rest pose matrix
  81556. * @param baseMatrix defines the base matrix
  81557. * @param index defines index of the bone in the hiearchy
  81558. */
  81559. constructor(
  81560. /**
  81561. * defines the bone name
  81562. */
  81563. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  81564. /**
  81565. * Gets the current object class name.
  81566. * @return the class name
  81567. */
  81568. getClassName(): string;
  81569. /**
  81570. * Gets the parent skeleton
  81571. * @returns a skeleton
  81572. */
  81573. getSkeleton(): Skeleton;
  81574. /**
  81575. * Gets parent bone
  81576. * @returns a bone or null if the bone is the root of the bone hierarchy
  81577. */
  81578. getParent(): Nullable<Bone>;
  81579. /**
  81580. * Returns an array containing the root bones
  81581. * @returns an array containing the root bones
  81582. */
  81583. getChildren(): Array<Bone>;
  81584. /**
  81585. * Gets the node index in matrix array generated for rendering
  81586. * @returns the node index
  81587. */
  81588. getIndex(): number;
  81589. /**
  81590. * Sets the parent bone
  81591. * @param parent defines the parent (can be null if the bone is the root)
  81592. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81593. */
  81594. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  81595. /**
  81596. * Gets the local matrix
  81597. * @returns a matrix
  81598. */
  81599. getLocalMatrix(): Matrix;
  81600. /**
  81601. * Gets the base matrix (initial matrix which remains unchanged)
  81602. * @returns a matrix
  81603. */
  81604. getBaseMatrix(): Matrix;
  81605. /**
  81606. * Gets the rest pose matrix
  81607. * @returns a matrix
  81608. */
  81609. getRestPose(): Matrix;
  81610. /**
  81611. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  81612. */
  81613. getWorldMatrix(): Matrix;
  81614. /**
  81615. * Sets the local matrix to rest pose matrix
  81616. */
  81617. returnToRest(): void;
  81618. /**
  81619. * Gets the inverse of the absolute transform matrix.
  81620. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  81621. * @returns a matrix
  81622. */
  81623. getInvertedAbsoluteTransform(): Matrix;
  81624. /**
  81625. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  81626. * @returns a matrix
  81627. */
  81628. getAbsoluteTransform(): Matrix;
  81629. /**
  81630. * Links with the given transform node.
  81631. * The local matrix of this bone is copied from the transform node every frame.
  81632. * @param transformNode defines the transform node to link to
  81633. */
  81634. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  81635. /**
  81636. * Gets the node used to drive the bone's transformation
  81637. * @returns a transform node or null
  81638. */
  81639. getTransformNode(): Nullable<TransformNode>;
  81640. /** Gets or sets current position (in local space) */
  81641. position: Vector3;
  81642. /** Gets or sets current rotation (in local space) */
  81643. rotation: Vector3;
  81644. /** Gets or sets current rotation quaternion (in local space) */
  81645. rotationQuaternion: Quaternion;
  81646. /** Gets or sets current scaling (in local space) */
  81647. scaling: Vector3;
  81648. /**
  81649. * Gets the animation properties override
  81650. */
  81651. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81652. private _decompose;
  81653. private _compose;
  81654. /**
  81655. * Update the base and local matrices
  81656. * @param matrix defines the new base or local matrix
  81657. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81658. * @param updateLocalMatrix defines if the local matrix should be updated
  81659. */
  81660. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  81661. /** @hidden */
  81662. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  81663. /**
  81664. * Flag the bone as dirty (Forcing it to update everything)
  81665. */
  81666. markAsDirty(): void;
  81667. /** @hidden */
  81668. _markAsDirtyAndCompose(): void;
  81669. private _markAsDirtyAndDecompose;
  81670. /**
  81671. * Translate the bone in local or world space
  81672. * @param vec The amount to translate the bone
  81673. * @param space The space that the translation is in
  81674. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81675. */
  81676. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81677. /**
  81678. * Set the postion of the bone in local or world space
  81679. * @param position The position to set the bone
  81680. * @param space The space that the position is in
  81681. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81682. */
  81683. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81684. /**
  81685. * Set the absolute position of the bone (world space)
  81686. * @param position The position to set the bone
  81687. * @param mesh The mesh that this bone is attached to
  81688. */
  81689. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  81690. /**
  81691. * Scale the bone on the x, y and z axes (in local space)
  81692. * @param x The amount to scale the bone on the x axis
  81693. * @param y The amount to scale the bone on the y axis
  81694. * @param z The amount to scale the bone on the z axis
  81695. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  81696. */
  81697. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  81698. /**
  81699. * Set the bone scaling in local space
  81700. * @param scale defines the scaling vector
  81701. */
  81702. setScale(scale: Vector3): void;
  81703. /**
  81704. * Gets the current scaling in local space
  81705. * @returns the current scaling vector
  81706. */
  81707. getScale(): Vector3;
  81708. /**
  81709. * Gets the current scaling in local space and stores it in a target vector
  81710. * @param result defines the target vector
  81711. */
  81712. getScaleToRef(result: Vector3): void;
  81713. /**
  81714. * Set the yaw, pitch, and roll of the bone in local or world space
  81715. * @param yaw The rotation of the bone on the y axis
  81716. * @param pitch The rotation of the bone on the x axis
  81717. * @param roll The rotation of the bone on the z axis
  81718. * @param space The space that the axes of rotation are in
  81719. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81720. */
  81721. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  81722. /**
  81723. * Add a rotation to the bone on an axis in local or world space
  81724. * @param axis The axis to rotate the bone on
  81725. * @param amount The amount to rotate the bone
  81726. * @param space The space that the axis is in
  81727. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81728. */
  81729. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  81730. /**
  81731. * Set the rotation of the bone to a particular axis angle in local or world space
  81732. * @param axis The axis to rotate the bone on
  81733. * @param angle The angle that the bone should be rotated to
  81734. * @param space The space that the axis is in
  81735. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81736. */
  81737. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  81738. /**
  81739. * Set the euler rotation of the bone in local of world space
  81740. * @param rotation The euler rotation that the bone should be set to
  81741. * @param space The space that the rotation is in
  81742. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81743. */
  81744. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81745. /**
  81746. * Set the quaternion rotation of the bone in local of world space
  81747. * @param quat The quaternion rotation that the bone should be set to
  81748. * @param space The space that the rotation is in
  81749. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81750. */
  81751. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  81752. /**
  81753. * Set the rotation matrix of the bone in local of world space
  81754. * @param rotMat The rotation matrix that the bone should be set to
  81755. * @param space The space that the rotation is in
  81756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81757. */
  81758. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  81759. private _rotateWithMatrix;
  81760. private _getNegativeRotationToRef;
  81761. /**
  81762. * Get the position of the bone in local or world space
  81763. * @param space The space that the returned position is in
  81764. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81765. * @returns The position of the bone
  81766. */
  81767. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81768. /**
  81769. * Copy the position of the bone to a vector3 in local or world space
  81770. * @param space The space that the returned position is in
  81771. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81772. * @param result The vector3 to copy the position to
  81773. */
  81774. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  81775. /**
  81776. * Get the absolute position of the bone (world space)
  81777. * @param mesh The mesh that this bone is attached to
  81778. * @returns The absolute position of the bone
  81779. */
  81780. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  81781. /**
  81782. * Copy the absolute position of the bone (world space) to the result param
  81783. * @param mesh The mesh that this bone is attached to
  81784. * @param result The vector3 to copy the absolute position to
  81785. */
  81786. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  81787. /**
  81788. * Compute the absolute transforms of this bone and its children
  81789. */
  81790. computeAbsoluteTransforms(): void;
  81791. /**
  81792. * Get the world direction from an axis that is in the local space of the bone
  81793. * @param localAxis The local direction that is used to compute the world direction
  81794. * @param mesh The mesh that this bone is attached to
  81795. * @returns The world direction
  81796. */
  81797. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81798. /**
  81799. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  81800. * @param localAxis The local direction that is used to compute the world direction
  81801. * @param mesh The mesh that this bone is attached to
  81802. * @param result The vector3 that the world direction will be copied to
  81803. */
  81804. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81805. /**
  81806. * Get the euler rotation of the bone in local or world space
  81807. * @param space The space that the rotation should be in
  81808. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81809. * @returns The euler rotation
  81810. */
  81811. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81812. /**
  81813. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  81814. * @param space The space that the rotation should be in
  81815. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81816. * @param result The vector3 that the rotation should be copied to
  81817. */
  81818. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81819. /**
  81820. * Get the quaternion rotation of the bone in either local or world space
  81821. * @param space The space that the rotation should be in
  81822. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81823. * @returns The quaternion rotation
  81824. */
  81825. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  81826. /**
  81827. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  81828. * @param space The space that the rotation should be in
  81829. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81830. * @param result The quaternion that the rotation should be copied to
  81831. */
  81832. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  81833. /**
  81834. * Get the rotation matrix of the bone in local or world space
  81835. * @param space The space that the rotation should be in
  81836. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81837. * @returns The rotation matrix
  81838. */
  81839. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  81840. /**
  81841. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  81842. * @param space The space that the rotation should be in
  81843. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81844. * @param result The quaternion that the rotation should be copied to
  81845. */
  81846. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  81847. /**
  81848. * Get the world position of a point that is in the local space of the bone
  81849. * @param position The local position
  81850. * @param mesh The mesh that this bone is attached to
  81851. * @returns The world position
  81852. */
  81853. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81854. /**
  81855. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  81856. * @param position The local position
  81857. * @param mesh The mesh that this bone is attached to
  81858. * @param result The vector3 that the world position should be copied to
  81859. */
  81860. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81861. /**
  81862. * Get the local position of a point that is in world space
  81863. * @param position The world position
  81864. * @param mesh The mesh that this bone is attached to
  81865. * @returns The local position
  81866. */
  81867. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81868. /**
  81869. * Get the local position of a point that is in world space and copy it to the result param
  81870. * @param position The world position
  81871. * @param mesh The mesh that this bone is attached to
  81872. * @param result The vector3 that the local position should be copied to
  81873. */
  81874. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81875. }
  81876. }
  81877. declare module BABYLON {
  81878. /**
  81879. * 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.
  81880. * @see https://doc.babylonjs.com/how_to/transformnode
  81881. */
  81882. export class TransformNode extends Node {
  81883. /**
  81884. * Object will not rotate to face the camera
  81885. */
  81886. static BILLBOARDMODE_NONE: number;
  81887. /**
  81888. * Object will rotate to face the camera but only on the x axis
  81889. */
  81890. static BILLBOARDMODE_X: number;
  81891. /**
  81892. * Object will rotate to face the camera but only on the y axis
  81893. */
  81894. static BILLBOARDMODE_Y: number;
  81895. /**
  81896. * Object will rotate to face the camera but only on the z axis
  81897. */
  81898. static BILLBOARDMODE_Z: number;
  81899. /**
  81900. * Object will rotate to face the camera
  81901. */
  81902. static BILLBOARDMODE_ALL: number;
  81903. /**
  81904. * Object will rotate to face the camera's position instead of orientation
  81905. */
  81906. static BILLBOARDMODE_USE_POSITION: number;
  81907. private _forward;
  81908. private _forwardInverted;
  81909. private _up;
  81910. private _right;
  81911. private _rightInverted;
  81912. private _position;
  81913. private _rotation;
  81914. private _rotationQuaternion;
  81915. protected _scaling: Vector3;
  81916. protected _isDirty: boolean;
  81917. private _transformToBoneReferal;
  81918. private _isAbsoluteSynced;
  81919. private _billboardMode;
  81920. /**
  81921. * Gets or sets the billboard mode. Default is 0.
  81922. *
  81923. * | Value | Type | Description |
  81924. * | --- | --- | --- |
  81925. * | 0 | BILLBOARDMODE_NONE | |
  81926. * | 1 | BILLBOARDMODE_X | |
  81927. * | 2 | BILLBOARDMODE_Y | |
  81928. * | 4 | BILLBOARDMODE_Z | |
  81929. * | 7 | BILLBOARDMODE_ALL | |
  81930. *
  81931. */
  81932. billboardMode: number;
  81933. private _preserveParentRotationForBillboard;
  81934. /**
  81935. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  81936. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  81937. */
  81938. preserveParentRotationForBillboard: boolean;
  81939. /**
  81940. * 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
  81941. */
  81942. scalingDeterminant: number;
  81943. private _infiniteDistance;
  81944. /**
  81945. * Gets or sets the distance of the object to max, often used by skybox
  81946. */
  81947. infiniteDistance: boolean;
  81948. /**
  81949. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  81950. * By default the system will update normals to compensate
  81951. */
  81952. ignoreNonUniformScaling: boolean;
  81953. /**
  81954. * 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
  81955. */
  81956. reIntegrateRotationIntoRotationQuaternion: boolean;
  81957. /** @hidden */
  81958. _poseMatrix: Nullable<Matrix>;
  81959. /** @hidden */
  81960. _localMatrix: Matrix;
  81961. private _usePivotMatrix;
  81962. private _absolutePosition;
  81963. private _absoluteScaling;
  81964. private _absoluteRotationQuaternion;
  81965. private _pivotMatrix;
  81966. private _pivotMatrixInverse;
  81967. protected _postMultiplyPivotMatrix: boolean;
  81968. protected _isWorldMatrixFrozen: boolean;
  81969. /** @hidden */
  81970. _indexInSceneTransformNodesArray: number;
  81971. /**
  81972. * An event triggered after the world matrix is updated
  81973. */
  81974. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  81975. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  81976. /**
  81977. * Gets a string identifying the name of the class
  81978. * @returns "TransformNode" string
  81979. */
  81980. getClassName(): string;
  81981. /**
  81982. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  81983. */
  81984. position: Vector3;
  81985. /**
  81986. * 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)).
  81987. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  81988. */
  81989. rotation: Vector3;
  81990. /**
  81991. * 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)).
  81992. */
  81993. scaling: Vector3;
  81994. /**
  81995. * 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).
  81996. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  81997. */
  81998. rotationQuaternion: Nullable<Quaternion>;
  81999. /**
  82000. * The forward direction of that transform in world space.
  82001. */
  82002. readonly forward: Vector3;
  82003. /**
  82004. * The up direction of that transform in world space.
  82005. */
  82006. readonly up: Vector3;
  82007. /**
  82008. * The right direction of that transform in world space.
  82009. */
  82010. readonly right: Vector3;
  82011. /**
  82012. * Copies the parameter passed Matrix into the mesh Pose matrix.
  82013. * @param matrix the matrix to copy the pose from
  82014. * @returns this TransformNode.
  82015. */
  82016. updatePoseMatrix(matrix: Matrix): TransformNode;
  82017. /**
  82018. * Returns the mesh Pose matrix.
  82019. * @returns the pose matrix
  82020. */
  82021. getPoseMatrix(): Matrix;
  82022. /** @hidden */
  82023. _isSynchronized(): boolean;
  82024. /** @hidden */
  82025. _initCache(): void;
  82026. /**
  82027. * Flag the transform node as dirty (Forcing it to update everything)
  82028. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  82029. * @returns this transform node
  82030. */
  82031. markAsDirty(property: string): TransformNode;
  82032. /**
  82033. * Returns the current mesh absolute position.
  82034. * Returns a Vector3.
  82035. */
  82036. readonly absolutePosition: Vector3;
  82037. /**
  82038. * Returns the current mesh absolute scaling.
  82039. * Returns a Vector3.
  82040. */
  82041. readonly absoluteScaling: Vector3;
  82042. /**
  82043. * Returns the current mesh absolute rotation.
  82044. * Returns a Quaternion.
  82045. */
  82046. readonly absoluteRotationQuaternion: Quaternion;
  82047. /**
  82048. * Sets a new matrix to apply before all other transformation
  82049. * @param matrix defines the transform matrix
  82050. * @returns the current TransformNode
  82051. */
  82052. setPreTransformMatrix(matrix: Matrix): TransformNode;
  82053. /**
  82054. * Sets a new pivot matrix to the current node
  82055. * @param matrix defines the new pivot matrix to use
  82056. * @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
  82057. * @returns the current TransformNode
  82058. */
  82059. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  82060. /**
  82061. * Returns the mesh pivot matrix.
  82062. * Default : Identity.
  82063. * @returns the matrix
  82064. */
  82065. getPivotMatrix(): Matrix;
  82066. /**
  82067. * Instantiate (when possible) or clone that node with its hierarchy
  82068. * @param newParent defines the new parent to use for the instance (or clone)
  82069. * @param options defines options to configure how copy is done
  82070. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  82071. * @returns an instance (or a clone) of the current node with its hiearchy
  82072. */
  82073. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  82074. doNotInstantiate: boolean;
  82075. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  82076. /**
  82077. * Prevents the World matrix to be computed any longer
  82078. * @param newWorldMatrix defines an optional matrix to use as world matrix
  82079. * @returns the TransformNode.
  82080. */
  82081. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  82082. /**
  82083. * Allows back the World matrix computation.
  82084. * @returns the TransformNode.
  82085. */
  82086. unfreezeWorldMatrix(): this;
  82087. /**
  82088. * True if the World matrix has been frozen.
  82089. */
  82090. readonly isWorldMatrixFrozen: boolean;
  82091. /**
  82092. * Retuns the mesh absolute position in the World.
  82093. * @returns a Vector3.
  82094. */
  82095. getAbsolutePosition(): Vector3;
  82096. /**
  82097. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  82098. * @param absolutePosition the absolute position to set
  82099. * @returns the TransformNode.
  82100. */
  82101. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  82102. /**
  82103. * Sets the mesh position in its local space.
  82104. * @param vector3 the position to set in localspace
  82105. * @returns the TransformNode.
  82106. */
  82107. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  82108. /**
  82109. * Returns the mesh position in the local space from the current World matrix values.
  82110. * @returns a new Vector3.
  82111. */
  82112. getPositionExpressedInLocalSpace(): Vector3;
  82113. /**
  82114. * Translates the mesh along the passed Vector3 in its local space.
  82115. * @param vector3 the distance to translate in localspace
  82116. * @returns the TransformNode.
  82117. */
  82118. locallyTranslate(vector3: Vector3): TransformNode;
  82119. private static _lookAtVectorCache;
  82120. /**
  82121. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  82122. * @param targetPoint the position (must be in same space as current mesh) to look at
  82123. * @param yawCor optional yaw (y-axis) correction in radians
  82124. * @param pitchCor optional pitch (x-axis) correction in radians
  82125. * @param rollCor optional roll (z-axis) correction in radians
  82126. * @param space the choosen space of the target
  82127. * @returns the TransformNode.
  82128. */
  82129. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  82130. /**
  82131. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82132. * This Vector3 is expressed in the World space.
  82133. * @param localAxis axis to rotate
  82134. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82135. */
  82136. getDirection(localAxis: Vector3): Vector3;
  82137. /**
  82138. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  82139. * localAxis is expressed in the mesh local space.
  82140. * result is computed in the Wordl space from the mesh World matrix.
  82141. * @param localAxis axis to rotate
  82142. * @param result the resulting transformnode
  82143. * @returns this TransformNode.
  82144. */
  82145. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  82146. /**
  82147. * Sets this transform node rotation to the given local axis.
  82148. * @param localAxis the axis in local space
  82149. * @param yawCor optional yaw (y-axis) correction in radians
  82150. * @param pitchCor optional pitch (x-axis) correction in radians
  82151. * @param rollCor optional roll (z-axis) correction in radians
  82152. * @returns this TransformNode
  82153. */
  82154. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  82155. /**
  82156. * Sets a new pivot point to the current node
  82157. * @param point defines the new pivot point to use
  82158. * @param space defines if the point is in world or local space (local by default)
  82159. * @returns the current TransformNode
  82160. */
  82161. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  82162. /**
  82163. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  82164. * @returns the pivot point
  82165. */
  82166. getPivotPoint(): Vector3;
  82167. /**
  82168. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  82169. * @param result the vector3 to store the result
  82170. * @returns this TransformNode.
  82171. */
  82172. getPivotPointToRef(result: Vector3): TransformNode;
  82173. /**
  82174. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  82175. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  82176. */
  82177. getAbsolutePivotPoint(): Vector3;
  82178. /**
  82179. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  82180. * @param result vector3 to store the result
  82181. * @returns this TransformNode.
  82182. */
  82183. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  82184. /**
  82185. * Defines the passed node as the parent of the current node.
  82186. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  82187. * @see https://doc.babylonjs.com/how_to/parenting
  82188. * @param node the node ot set as the parent
  82189. * @returns this TransformNode.
  82190. */
  82191. setParent(node: Nullable<Node>): TransformNode;
  82192. private _nonUniformScaling;
  82193. /**
  82194. * True if the scaling property of this object is non uniform eg. (1,2,1)
  82195. */
  82196. readonly nonUniformScaling: boolean;
  82197. /** @hidden */
  82198. _updateNonUniformScalingState(value: boolean): boolean;
  82199. /**
  82200. * Attach the current TransformNode to another TransformNode associated with a bone
  82201. * @param bone Bone affecting the TransformNode
  82202. * @param affectedTransformNode TransformNode associated with the bone
  82203. * @returns this object
  82204. */
  82205. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  82206. /**
  82207. * Detach the transform node if its associated with a bone
  82208. * @returns this object
  82209. */
  82210. detachFromBone(): TransformNode;
  82211. private static _rotationAxisCache;
  82212. /**
  82213. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  82214. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82215. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82216. * The passed axis is also normalized.
  82217. * @param axis the axis to rotate around
  82218. * @param amount the amount to rotate in radians
  82219. * @param space Space to rotate in (Default: local)
  82220. * @returns the TransformNode.
  82221. */
  82222. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  82223. /**
  82224. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  82225. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82226. * The passed axis is also normalized. .
  82227. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  82228. * @param point the point to rotate around
  82229. * @param axis the axis to rotate around
  82230. * @param amount the amount to rotate in radians
  82231. * @returns the TransformNode
  82232. */
  82233. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  82234. /**
  82235. * Translates the mesh along the axis vector for the passed distance in the given space.
  82236. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82237. * @param axis the axis to translate in
  82238. * @param distance the distance to translate
  82239. * @param space Space to rotate in (Default: local)
  82240. * @returns the TransformNode.
  82241. */
  82242. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  82243. /**
  82244. * Adds a rotation step to the mesh current rotation.
  82245. * x, y, z are Euler angles expressed in radians.
  82246. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  82247. * This means this rotation is made in the mesh local space only.
  82248. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  82249. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  82250. * ```javascript
  82251. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  82252. * ```
  82253. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  82254. * 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.
  82255. * @param x Rotation to add
  82256. * @param y Rotation to add
  82257. * @param z Rotation to add
  82258. * @returns the TransformNode.
  82259. */
  82260. addRotation(x: number, y: number, z: number): TransformNode;
  82261. /**
  82262. * @hidden
  82263. */
  82264. protected _getEffectiveParent(): Nullable<Node>;
  82265. /**
  82266. * Computes the world matrix of the node
  82267. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82268. * @returns the world matrix
  82269. */
  82270. computeWorldMatrix(force?: boolean): Matrix;
  82271. protected _afterComputeWorldMatrix(): void;
  82272. /**
  82273. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  82274. * @param func callback function to add
  82275. *
  82276. * @returns the TransformNode.
  82277. */
  82278. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82279. /**
  82280. * Removes a registered callback function.
  82281. * @param func callback function to remove
  82282. * @returns the TransformNode.
  82283. */
  82284. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82285. /**
  82286. * Gets the position of the current mesh in camera space
  82287. * @param camera defines the camera to use
  82288. * @returns a position
  82289. */
  82290. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  82291. /**
  82292. * Returns the distance from the mesh to the active camera
  82293. * @param camera defines the camera to use
  82294. * @returns the distance
  82295. */
  82296. getDistanceToCamera(camera?: Nullable<Camera>): number;
  82297. /**
  82298. * Clone the current transform node
  82299. * @param name Name of the new clone
  82300. * @param newParent New parent for the clone
  82301. * @param doNotCloneChildren Do not clone children hierarchy
  82302. * @returns the new transform node
  82303. */
  82304. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  82305. /**
  82306. * Serializes the objects information.
  82307. * @param currentSerializationObject defines the object to serialize in
  82308. * @returns the serialized object
  82309. */
  82310. serialize(currentSerializationObject?: any): any;
  82311. /**
  82312. * Returns a new TransformNode object parsed from the source provided.
  82313. * @param parsedTransformNode is the source.
  82314. * @param scene the scne the object belongs to
  82315. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  82316. * @returns a new TransformNode object parsed from the source provided.
  82317. */
  82318. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  82319. /**
  82320. * Get all child-transformNodes of this node
  82321. * @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
  82322. * @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
  82323. * @returns an array of TransformNode
  82324. */
  82325. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  82326. /**
  82327. * Releases resources associated with this transform node.
  82328. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82329. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82330. */
  82331. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82332. /**
  82333. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82334. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  82335. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  82336. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  82337. * @returns the current mesh
  82338. */
  82339. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  82340. private _syncAbsoluteScalingAndRotation;
  82341. }
  82342. }
  82343. declare module BABYLON {
  82344. /**
  82345. * Defines the types of pose enabled controllers that are supported
  82346. */
  82347. export enum PoseEnabledControllerType {
  82348. /**
  82349. * HTC Vive
  82350. */
  82351. VIVE = 0,
  82352. /**
  82353. * Oculus Rift
  82354. */
  82355. OCULUS = 1,
  82356. /**
  82357. * Windows mixed reality
  82358. */
  82359. WINDOWS = 2,
  82360. /**
  82361. * Samsung gear VR
  82362. */
  82363. GEAR_VR = 3,
  82364. /**
  82365. * Google Daydream
  82366. */
  82367. DAYDREAM = 4,
  82368. /**
  82369. * Generic
  82370. */
  82371. GENERIC = 5
  82372. }
  82373. /**
  82374. * Defines the MutableGamepadButton interface for the state of a gamepad button
  82375. */
  82376. export interface MutableGamepadButton {
  82377. /**
  82378. * Value of the button/trigger
  82379. */
  82380. value: number;
  82381. /**
  82382. * If the button/trigger is currently touched
  82383. */
  82384. touched: boolean;
  82385. /**
  82386. * If the button/trigger is currently pressed
  82387. */
  82388. pressed: boolean;
  82389. }
  82390. /**
  82391. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  82392. * @hidden
  82393. */
  82394. export interface ExtendedGamepadButton extends GamepadButton {
  82395. /**
  82396. * If the button/trigger is currently pressed
  82397. */
  82398. readonly pressed: boolean;
  82399. /**
  82400. * If the button/trigger is currently touched
  82401. */
  82402. readonly touched: boolean;
  82403. /**
  82404. * Value of the button/trigger
  82405. */
  82406. readonly value: number;
  82407. }
  82408. /** @hidden */
  82409. export interface _GamePadFactory {
  82410. /**
  82411. * Returns wether or not the current gamepad can be created for this type of controller.
  82412. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82413. * @returns true if it can be created, otherwise false
  82414. */
  82415. canCreate(gamepadInfo: any): boolean;
  82416. /**
  82417. * Creates a new instance of the Gamepad.
  82418. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82419. * @returns the new gamepad instance
  82420. */
  82421. create(gamepadInfo: any): Gamepad;
  82422. }
  82423. /**
  82424. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82425. */
  82426. export class PoseEnabledControllerHelper {
  82427. /** @hidden */
  82428. static _ControllerFactories: _GamePadFactory[];
  82429. /** @hidden */
  82430. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  82431. /**
  82432. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82433. * @param vrGamepad the gamepad to initialized
  82434. * @returns a vr controller of the type the gamepad identified as
  82435. */
  82436. static InitiateController(vrGamepad: any): Gamepad;
  82437. }
  82438. /**
  82439. * Defines the PoseEnabledController object that contains state of a vr capable controller
  82440. */
  82441. export class PoseEnabledController extends Gamepad implements PoseControlled {
  82442. /**
  82443. * If the controller is used in a webXR session
  82444. */
  82445. isXR: boolean;
  82446. private _deviceRoomPosition;
  82447. private _deviceRoomRotationQuaternion;
  82448. /**
  82449. * The device position in babylon space
  82450. */
  82451. devicePosition: Vector3;
  82452. /**
  82453. * The device rotation in babylon space
  82454. */
  82455. deviceRotationQuaternion: Quaternion;
  82456. /**
  82457. * The scale factor of the device in babylon space
  82458. */
  82459. deviceScaleFactor: number;
  82460. /**
  82461. * (Likely devicePosition should be used instead) The device position in its room space
  82462. */
  82463. position: Vector3;
  82464. /**
  82465. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  82466. */
  82467. rotationQuaternion: Quaternion;
  82468. /**
  82469. * The type of controller (Eg. Windows mixed reality)
  82470. */
  82471. controllerType: PoseEnabledControllerType;
  82472. protected _calculatedPosition: Vector3;
  82473. private _calculatedRotation;
  82474. /**
  82475. * The raw pose from the device
  82476. */
  82477. rawPose: DevicePose;
  82478. private _trackPosition;
  82479. private _maxRotationDistFromHeadset;
  82480. private _draggedRoomRotation;
  82481. /**
  82482. * @hidden
  82483. */
  82484. _disableTrackPosition(fixedPosition: Vector3): void;
  82485. /**
  82486. * Internal, the mesh attached to the controller
  82487. * @hidden
  82488. */
  82489. _mesh: Nullable<AbstractMesh>;
  82490. private _poseControlledCamera;
  82491. private _leftHandSystemQuaternion;
  82492. /**
  82493. * Internal, matrix used to convert room space to babylon space
  82494. * @hidden
  82495. */
  82496. _deviceToWorld: Matrix;
  82497. /**
  82498. * Node to be used when casting a ray from the controller
  82499. * @hidden
  82500. */
  82501. _pointingPoseNode: Nullable<TransformNode>;
  82502. /**
  82503. * Name of the child mesh that can be used to cast a ray from the controller
  82504. */
  82505. static readonly POINTING_POSE: string;
  82506. /**
  82507. * Creates a new PoseEnabledController from a gamepad
  82508. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  82509. */
  82510. constructor(browserGamepad: any);
  82511. private _workingMatrix;
  82512. /**
  82513. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  82514. */
  82515. update(): void;
  82516. /**
  82517. * Updates only the pose device and mesh without doing any button event checking
  82518. */
  82519. protected _updatePoseAndMesh(): void;
  82520. /**
  82521. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  82522. * @param poseData raw pose fromthe device
  82523. */
  82524. updateFromDevice(poseData: DevicePose): void;
  82525. /**
  82526. * @hidden
  82527. */
  82528. _meshAttachedObservable: Observable<AbstractMesh>;
  82529. /**
  82530. * Attaches a mesh to the controller
  82531. * @param mesh the mesh to be attached
  82532. */
  82533. attachToMesh(mesh: AbstractMesh): void;
  82534. /**
  82535. * Attaches the controllers mesh to a camera
  82536. * @param camera the camera the mesh should be attached to
  82537. */
  82538. attachToPoseControlledCamera(camera: TargetCamera): void;
  82539. /**
  82540. * Disposes of the controller
  82541. */
  82542. dispose(): void;
  82543. /**
  82544. * The mesh that is attached to the controller
  82545. */
  82546. readonly mesh: Nullable<AbstractMesh>;
  82547. /**
  82548. * Gets the ray of the controller in the direction the controller is pointing
  82549. * @param length the length the resulting ray should be
  82550. * @returns a ray in the direction the controller is pointing
  82551. */
  82552. getForwardRay(length?: number): Ray;
  82553. }
  82554. }
  82555. declare module BABYLON {
  82556. /**
  82557. * Defines the WebVRController object that represents controllers tracked in 3D space
  82558. */
  82559. export abstract class WebVRController extends PoseEnabledController {
  82560. /**
  82561. * Internal, the default controller model for the controller
  82562. */
  82563. protected _defaultModel: Nullable<AbstractMesh>;
  82564. /**
  82565. * Fired when the trigger state has changed
  82566. */
  82567. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  82568. /**
  82569. * Fired when the main button state has changed
  82570. */
  82571. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82572. /**
  82573. * Fired when the secondary button state has changed
  82574. */
  82575. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82576. /**
  82577. * Fired when the pad state has changed
  82578. */
  82579. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  82580. /**
  82581. * Fired when controllers stick values have changed
  82582. */
  82583. onPadValuesChangedObservable: Observable<StickValues>;
  82584. /**
  82585. * Array of button availible on the controller
  82586. */
  82587. protected _buttons: Array<MutableGamepadButton>;
  82588. private _onButtonStateChange;
  82589. /**
  82590. * Fired when a controller button's state has changed
  82591. * @param callback the callback containing the button that was modified
  82592. */
  82593. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  82594. /**
  82595. * X and Y axis corresponding to the controllers joystick
  82596. */
  82597. pad: StickValues;
  82598. /**
  82599. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  82600. */
  82601. hand: string;
  82602. /**
  82603. * The default controller model for the controller
  82604. */
  82605. readonly defaultModel: Nullable<AbstractMesh>;
  82606. /**
  82607. * Creates a new WebVRController from a gamepad
  82608. * @param vrGamepad the gamepad that the WebVRController should be created from
  82609. */
  82610. constructor(vrGamepad: any);
  82611. /**
  82612. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  82613. */
  82614. update(): void;
  82615. /**
  82616. * Function to be called when a button is modified
  82617. */
  82618. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  82619. /**
  82620. * Loads a mesh and attaches it to the controller
  82621. * @param scene the scene the mesh should be added to
  82622. * @param meshLoaded callback for when the mesh has been loaded
  82623. */
  82624. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  82625. private _setButtonValue;
  82626. private _changes;
  82627. private _checkChanges;
  82628. /**
  82629. * Disposes of th webVRCOntroller
  82630. */
  82631. dispose(): void;
  82632. }
  82633. }
  82634. declare module BABYLON {
  82635. /**
  82636. * The HemisphericLight simulates the ambient environment light,
  82637. * so the passed direction is the light reflection direction, not the incoming direction.
  82638. */
  82639. export class HemisphericLight extends Light {
  82640. /**
  82641. * The groundColor is the light in the opposite direction to the one specified during creation.
  82642. * 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.
  82643. */
  82644. groundColor: Color3;
  82645. /**
  82646. * The light reflection direction, not the incoming direction.
  82647. */
  82648. direction: Vector3;
  82649. /**
  82650. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  82651. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  82652. * The HemisphericLight can't cast shadows.
  82653. * Documentation : https://doc.babylonjs.com/babylon101/lights
  82654. * @param name The friendly name of the light
  82655. * @param direction The direction of the light reflection
  82656. * @param scene The scene the light belongs to
  82657. */
  82658. constructor(name: string, direction: Vector3, scene: Scene);
  82659. protected _buildUniformLayout(): void;
  82660. /**
  82661. * Returns the string "HemisphericLight".
  82662. * @return The class name
  82663. */
  82664. getClassName(): string;
  82665. /**
  82666. * Sets the HemisphericLight direction towards the passed target (Vector3).
  82667. * Returns the updated direction.
  82668. * @param target The target the direction should point to
  82669. * @return The computed direction
  82670. */
  82671. setDirectionToTarget(target: Vector3): Vector3;
  82672. /**
  82673. * Returns the shadow generator associated to the light.
  82674. * @returns Always null for hemispheric lights because it does not support shadows.
  82675. */
  82676. getShadowGenerator(): Nullable<IShadowGenerator>;
  82677. /**
  82678. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  82679. * @param effect The effect to update
  82680. * @param lightIndex The index of the light in the effect to update
  82681. * @returns The hemispheric light
  82682. */
  82683. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  82684. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  82685. /**
  82686. * Computes the world matrix of the node
  82687. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82688. * @param useWasUpdatedFlag defines a reserved property
  82689. * @returns the world matrix
  82690. */
  82691. computeWorldMatrix(): Matrix;
  82692. /**
  82693. * Returns the integer 3.
  82694. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  82695. */
  82696. getTypeID(): number;
  82697. /**
  82698. * Prepares the list of defines specific to the light type.
  82699. * @param defines the list of defines
  82700. * @param lightIndex defines the index of the light for the effect
  82701. */
  82702. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  82703. }
  82704. }
  82705. declare module BABYLON {
  82706. /** @hidden */
  82707. export var vrMultiviewToSingleviewPixelShader: {
  82708. name: string;
  82709. shader: string;
  82710. };
  82711. }
  82712. declare module BABYLON {
  82713. /**
  82714. * Renders to multiple views with a single draw call
  82715. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  82716. */
  82717. export class MultiviewRenderTarget extends RenderTargetTexture {
  82718. /**
  82719. * Creates a multiview render target
  82720. * @param scene scene used with the render target
  82721. * @param size the size of the render target (used for each view)
  82722. */
  82723. constructor(scene: Scene, size?: number | {
  82724. width: number;
  82725. height: number;
  82726. } | {
  82727. ratio: number;
  82728. });
  82729. /**
  82730. * @hidden
  82731. * @param faceIndex the face index, if its a cube texture
  82732. */
  82733. _bindFrameBuffer(faceIndex?: number): void;
  82734. /**
  82735. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  82736. * @returns the view count
  82737. */
  82738. getViewCount(): number;
  82739. }
  82740. }
  82741. declare module BABYLON {
  82742. /**
  82743. * Represents a camera frustum
  82744. */
  82745. export class Frustum {
  82746. /**
  82747. * Gets the planes representing the frustum
  82748. * @param transform matrix to be applied to the returned planes
  82749. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  82750. */
  82751. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  82752. /**
  82753. * Gets the near frustum plane transformed by the transform matrix
  82754. * @param transform transformation matrix to be applied to the resulting frustum plane
  82755. * @param frustumPlane the resuling frustum plane
  82756. */
  82757. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82758. /**
  82759. * Gets the far frustum plane transformed by the transform matrix
  82760. * @param transform transformation matrix to be applied to the resulting frustum plane
  82761. * @param frustumPlane the resuling frustum plane
  82762. */
  82763. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82764. /**
  82765. * Gets the left frustum plane transformed by the transform matrix
  82766. * @param transform transformation matrix to be applied to the resulting frustum plane
  82767. * @param frustumPlane the resuling frustum plane
  82768. */
  82769. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82770. /**
  82771. * Gets the right frustum plane transformed by the transform matrix
  82772. * @param transform transformation matrix to be applied to the resulting frustum plane
  82773. * @param frustumPlane the resuling frustum plane
  82774. */
  82775. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82776. /**
  82777. * Gets the top frustum plane transformed by the transform matrix
  82778. * @param transform transformation matrix to be applied to the resulting frustum plane
  82779. * @param frustumPlane the resuling frustum plane
  82780. */
  82781. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82782. /**
  82783. * Gets the bottom frustum plane transformed by the transform matrix
  82784. * @param transform transformation matrix to be applied to the resulting frustum plane
  82785. * @param frustumPlane the resuling frustum plane
  82786. */
  82787. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82788. /**
  82789. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  82790. * @param transform transformation matrix to be applied to the resulting frustum planes
  82791. * @param frustumPlanes the resuling frustum planes
  82792. */
  82793. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  82794. }
  82795. }
  82796. declare module BABYLON {
  82797. interface Engine {
  82798. /**
  82799. * Creates a new multiview render target
  82800. * @param width defines the width of the texture
  82801. * @param height defines the height of the texture
  82802. * @returns the created multiview texture
  82803. */
  82804. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  82805. /**
  82806. * Binds a multiview framebuffer to be drawn to
  82807. * @param multiviewTexture texture to bind
  82808. */
  82809. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  82810. }
  82811. interface Camera {
  82812. /**
  82813. * @hidden
  82814. * 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)
  82815. */
  82816. _useMultiviewToSingleView: boolean;
  82817. /**
  82818. * @hidden
  82819. * 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)
  82820. */
  82821. _multiviewTexture: Nullable<RenderTargetTexture>;
  82822. /**
  82823. * @hidden
  82824. * ensures the multiview texture of the camera exists and has the specified width/height
  82825. * @param width height to set on the multiview texture
  82826. * @param height width to set on the multiview texture
  82827. */
  82828. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  82829. }
  82830. interface Scene {
  82831. /** @hidden */
  82832. _transformMatrixR: Matrix;
  82833. /** @hidden */
  82834. _multiviewSceneUbo: Nullable<UniformBuffer>;
  82835. /** @hidden */
  82836. _createMultiviewUbo(): void;
  82837. /** @hidden */
  82838. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  82839. /** @hidden */
  82840. _renderMultiviewToSingleView(camera: Camera): void;
  82841. }
  82842. }
  82843. declare module BABYLON {
  82844. /**
  82845. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  82846. * This will not be used for webXR as it supports displaying texture arrays directly
  82847. */
  82848. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  82849. /**
  82850. * Initializes a VRMultiviewToSingleview
  82851. * @param name name of the post process
  82852. * @param camera camera to be applied to
  82853. * @param scaleFactor scaling factor to the size of the output texture
  82854. */
  82855. constructor(name: string, camera: Camera, scaleFactor: number);
  82856. }
  82857. }
  82858. declare module BABYLON {
  82859. /**
  82860. * Interface used to define additional presentation attributes
  82861. */
  82862. export interface IVRPresentationAttributes {
  82863. /**
  82864. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  82865. */
  82866. highRefreshRate: boolean;
  82867. /**
  82868. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  82869. */
  82870. foveationLevel: number;
  82871. }
  82872. interface Engine {
  82873. /** @hidden */
  82874. _vrDisplay: any;
  82875. /** @hidden */
  82876. _vrSupported: boolean;
  82877. /** @hidden */
  82878. _oldSize: Size;
  82879. /** @hidden */
  82880. _oldHardwareScaleFactor: number;
  82881. /** @hidden */
  82882. _vrExclusivePointerMode: boolean;
  82883. /** @hidden */
  82884. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  82885. /** @hidden */
  82886. _onVRDisplayPointerRestricted: () => void;
  82887. /** @hidden */
  82888. _onVRDisplayPointerUnrestricted: () => void;
  82889. /** @hidden */
  82890. _onVrDisplayConnect: Nullable<(display: any) => void>;
  82891. /** @hidden */
  82892. _onVrDisplayDisconnect: Nullable<() => void>;
  82893. /** @hidden */
  82894. _onVrDisplayPresentChange: Nullable<() => void>;
  82895. /**
  82896. * Observable signaled when VR display mode changes
  82897. */
  82898. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  82899. /**
  82900. * Observable signaled when VR request present is complete
  82901. */
  82902. onVRRequestPresentComplete: Observable<boolean>;
  82903. /**
  82904. * Observable signaled when VR request present starts
  82905. */
  82906. onVRRequestPresentStart: Observable<Engine>;
  82907. /**
  82908. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  82909. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  82910. */
  82911. isInVRExclusivePointerMode: boolean;
  82912. /**
  82913. * Gets a boolean indicating if a webVR device was detected
  82914. * @returns true if a webVR device was detected
  82915. */
  82916. isVRDevicePresent(): boolean;
  82917. /**
  82918. * Gets the current webVR device
  82919. * @returns the current webVR device (or null)
  82920. */
  82921. getVRDevice(): any;
  82922. /**
  82923. * Initializes a webVR display and starts listening to display change events
  82924. * The onVRDisplayChangedObservable will be notified upon these changes
  82925. * @returns A promise containing a VRDisplay and if vr is supported
  82926. */
  82927. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  82928. /** @hidden */
  82929. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  82930. /**
  82931. * Gets or sets the presentation attributes used to configure VR rendering
  82932. */
  82933. vrPresentationAttributes?: IVRPresentationAttributes;
  82934. /**
  82935. * Call this function to switch to webVR mode
  82936. * Will do nothing if webVR is not supported or if there is no webVR device
  82937. * @see http://doc.babylonjs.com/how_to/webvr_camera
  82938. */
  82939. enableVR(): void;
  82940. /** @hidden */
  82941. _onVRFullScreenTriggered(): void;
  82942. }
  82943. }
  82944. declare module BABYLON {
  82945. /**
  82946. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  82947. * IMPORTANT!! The data is right-hand data.
  82948. * @export
  82949. * @interface DevicePose
  82950. */
  82951. export interface DevicePose {
  82952. /**
  82953. * The position of the device, values in array are [x,y,z].
  82954. */
  82955. readonly position: Nullable<Float32Array>;
  82956. /**
  82957. * The linearVelocity of the device, values in array are [x,y,z].
  82958. */
  82959. readonly linearVelocity: Nullable<Float32Array>;
  82960. /**
  82961. * The linearAcceleration of the device, values in array are [x,y,z].
  82962. */
  82963. readonly linearAcceleration: Nullable<Float32Array>;
  82964. /**
  82965. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  82966. */
  82967. readonly orientation: Nullable<Float32Array>;
  82968. /**
  82969. * The angularVelocity of the device, values in array are [x,y,z].
  82970. */
  82971. readonly angularVelocity: Nullable<Float32Array>;
  82972. /**
  82973. * The angularAcceleration of the device, values in array are [x,y,z].
  82974. */
  82975. readonly angularAcceleration: Nullable<Float32Array>;
  82976. }
  82977. /**
  82978. * Interface representing a pose controlled object in Babylon.
  82979. * A pose controlled object has both regular pose values as well as pose values
  82980. * from an external device such as a VR head mounted display
  82981. */
  82982. export interface PoseControlled {
  82983. /**
  82984. * The position of the object in babylon space.
  82985. */
  82986. position: Vector3;
  82987. /**
  82988. * The rotation quaternion of the object in babylon space.
  82989. */
  82990. rotationQuaternion: Quaternion;
  82991. /**
  82992. * The position of the device in babylon space.
  82993. */
  82994. devicePosition?: Vector3;
  82995. /**
  82996. * The rotation quaternion of the device in babylon space.
  82997. */
  82998. deviceRotationQuaternion: Quaternion;
  82999. /**
  83000. * The raw pose coming from the device.
  83001. */
  83002. rawPose: Nullable<DevicePose>;
  83003. /**
  83004. * The scale of the device to be used when translating from device space to babylon space.
  83005. */
  83006. deviceScaleFactor: number;
  83007. /**
  83008. * Updates the poseControlled values based on the input device pose.
  83009. * @param poseData the pose data to update the object with
  83010. */
  83011. updateFromDevice(poseData: DevicePose): void;
  83012. }
  83013. /**
  83014. * Set of options to customize the webVRCamera
  83015. */
  83016. export interface WebVROptions {
  83017. /**
  83018. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  83019. */
  83020. trackPosition?: boolean;
  83021. /**
  83022. * Sets the scale of the vrDevice in babylon space. (default: 1)
  83023. */
  83024. positionScale?: number;
  83025. /**
  83026. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  83027. */
  83028. displayName?: string;
  83029. /**
  83030. * Should the native controller meshes be initialized. (default: true)
  83031. */
  83032. controllerMeshes?: boolean;
  83033. /**
  83034. * Creating a default HemiLight only on controllers. (default: true)
  83035. */
  83036. defaultLightingOnControllers?: boolean;
  83037. /**
  83038. * If you don't want to use the default VR button of the helper. (default: false)
  83039. */
  83040. useCustomVRButton?: boolean;
  83041. /**
  83042. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  83043. */
  83044. customVRButton?: HTMLButtonElement;
  83045. /**
  83046. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  83047. */
  83048. rayLength?: number;
  83049. /**
  83050. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  83051. */
  83052. defaultHeight?: number;
  83053. /**
  83054. * If multiview should be used if availible (default: false)
  83055. */
  83056. useMultiview?: boolean;
  83057. }
  83058. /**
  83059. * This represents a WebVR camera.
  83060. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  83061. * @example http://doc.babylonjs.com/how_to/webvr_camera
  83062. */
  83063. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  83064. private webVROptions;
  83065. /**
  83066. * @hidden
  83067. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  83068. */
  83069. _vrDevice: any;
  83070. /**
  83071. * The rawPose of the vrDevice.
  83072. */
  83073. rawPose: Nullable<DevicePose>;
  83074. private _onVREnabled;
  83075. private _specsVersion;
  83076. private _attached;
  83077. private _frameData;
  83078. protected _descendants: Array<Node>;
  83079. private _deviceRoomPosition;
  83080. /** @hidden */
  83081. _deviceRoomRotationQuaternion: Quaternion;
  83082. private _standingMatrix;
  83083. /**
  83084. * Represents device position in babylon space.
  83085. */
  83086. devicePosition: Vector3;
  83087. /**
  83088. * Represents device rotation in babylon space.
  83089. */
  83090. deviceRotationQuaternion: Quaternion;
  83091. /**
  83092. * The scale of the device to be used when translating from device space to babylon space.
  83093. */
  83094. deviceScaleFactor: number;
  83095. private _deviceToWorld;
  83096. private _worldToDevice;
  83097. /**
  83098. * References to the webVR controllers for the vrDevice.
  83099. */
  83100. controllers: Array<WebVRController>;
  83101. /**
  83102. * Emits an event when a controller is attached.
  83103. */
  83104. onControllersAttachedObservable: Observable<WebVRController[]>;
  83105. /**
  83106. * Emits an event when a controller's mesh has been loaded;
  83107. */
  83108. onControllerMeshLoadedObservable: Observable<WebVRController>;
  83109. /**
  83110. * Emits an event when the HMD's pose has been updated.
  83111. */
  83112. onPoseUpdatedFromDeviceObservable: Observable<any>;
  83113. private _poseSet;
  83114. /**
  83115. * If the rig cameras be used as parent instead of this camera.
  83116. */
  83117. rigParenting: boolean;
  83118. private _lightOnControllers;
  83119. private _defaultHeight?;
  83120. /**
  83121. * Instantiates a WebVRFreeCamera.
  83122. * @param name The name of the WebVRFreeCamera
  83123. * @param position The starting anchor position for the camera
  83124. * @param scene The scene the camera belongs to
  83125. * @param webVROptions a set of customizable options for the webVRCamera
  83126. */
  83127. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  83128. /**
  83129. * Gets the device distance from the ground in meters.
  83130. * @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.
  83131. */
  83132. deviceDistanceToRoomGround(): number;
  83133. /**
  83134. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83135. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  83136. */
  83137. useStandingMatrix(callback?: (bool: boolean) => void): void;
  83138. /**
  83139. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83140. * @returns A promise with a boolean set to if the standing matrix is supported.
  83141. */
  83142. useStandingMatrixAsync(): Promise<boolean>;
  83143. /**
  83144. * Disposes the camera
  83145. */
  83146. dispose(): void;
  83147. /**
  83148. * Gets a vrController by name.
  83149. * @param name The name of the controller to retreive
  83150. * @returns the controller matching the name specified or null if not found
  83151. */
  83152. getControllerByName(name: string): Nullable<WebVRController>;
  83153. private _leftController;
  83154. /**
  83155. * The controller corresponding to the users left hand.
  83156. */
  83157. readonly leftController: Nullable<WebVRController>;
  83158. private _rightController;
  83159. /**
  83160. * The controller corresponding to the users right hand.
  83161. */
  83162. readonly rightController: Nullable<WebVRController>;
  83163. /**
  83164. * Casts a ray forward from the vrCamera's gaze.
  83165. * @param length Length of the ray (default: 100)
  83166. * @returns the ray corresponding to the gaze
  83167. */
  83168. getForwardRay(length?: number): Ray;
  83169. /**
  83170. * @hidden
  83171. * Updates the camera based on device's frame data
  83172. */
  83173. _checkInputs(): void;
  83174. /**
  83175. * Updates the poseControlled values based on the input device pose.
  83176. * @param poseData Pose coming from the device
  83177. */
  83178. updateFromDevice(poseData: DevicePose): void;
  83179. private _htmlElementAttached;
  83180. private _detachIfAttached;
  83181. /**
  83182. * WebVR's attach control will start broadcasting frames to the device.
  83183. * Note that in certain browsers (chrome for example) this function must be called
  83184. * within a user-interaction callback. Example:
  83185. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  83186. *
  83187. * @param element html element to attach the vrDevice to
  83188. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  83189. */
  83190. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83191. /**
  83192. * Detaches the camera from the html element and disables VR
  83193. *
  83194. * @param element html element to detach from
  83195. */
  83196. detachControl(element: HTMLElement): void;
  83197. /**
  83198. * @returns the name of this class
  83199. */
  83200. getClassName(): string;
  83201. /**
  83202. * Calls resetPose on the vrDisplay
  83203. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  83204. */
  83205. resetToCurrentRotation(): void;
  83206. /**
  83207. * @hidden
  83208. * Updates the rig cameras (left and right eye)
  83209. */
  83210. _updateRigCameras(): void;
  83211. private _workingVector;
  83212. private _oneVector;
  83213. private _workingMatrix;
  83214. private updateCacheCalled;
  83215. private _correctPositionIfNotTrackPosition;
  83216. /**
  83217. * @hidden
  83218. * Updates the cached values of the camera
  83219. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  83220. */
  83221. _updateCache(ignoreParentClass?: boolean): void;
  83222. /**
  83223. * @hidden
  83224. * Get current device position in babylon world
  83225. */
  83226. _computeDevicePosition(): void;
  83227. /**
  83228. * Updates the current device position and rotation in the babylon world
  83229. */
  83230. update(): void;
  83231. /**
  83232. * @hidden
  83233. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  83234. * @returns an identity matrix
  83235. */
  83236. _getViewMatrix(): Matrix;
  83237. private _tmpMatrix;
  83238. /**
  83239. * This function is called by the two RIG cameras.
  83240. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  83241. * @hidden
  83242. */
  83243. _getWebVRViewMatrix(): Matrix;
  83244. /** @hidden */
  83245. _getWebVRProjectionMatrix(): Matrix;
  83246. private _onGamepadConnectedObserver;
  83247. private _onGamepadDisconnectedObserver;
  83248. private _updateCacheWhenTrackingDisabledObserver;
  83249. /**
  83250. * Initializes the controllers and their meshes
  83251. */
  83252. initControllers(): void;
  83253. }
  83254. }
  83255. declare module BABYLON {
  83256. /**
  83257. * Size options for a post process
  83258. */
  83259. export type PostProcessOptions = {
  83260. width: number;
  83261. height: number;
  83262. };
  83263. /**
  83264. * PostProcess can be used to apply a shader to a texture after it has been rendered
  83265. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83266. */
  83267. export class PostProcess {
  83268. /** Name of the PostProcess. */
  83269. name: string;
  83270. /**
  83271. * Gets or sets the unique id of the post process
  83272. */
  83273. uniqueId: number;
  83274. /**
  83275. * Width of the texture to apply the post process on
  83276. */
  83277. width: number;
  83278. /**
  83279. * Height of the texture to apply the post process on
  83280. */
  83281. height: number;
  83282. /**
  83283. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  83284. * @hidden
  83285. */
  83286. _outputTexture: Nullable<InternalTexture>;
  83287. /**
  83288. * Sampling mode used by the shader
  83289. * See https://doc.babylonjs.com/classes/3.1/texture
  83290. */
  83291. renderTargetSamplingMode: number;
  83292. /**
  83293. * Clear color to use when screen clearing
  83294. */
  83295. clearColor: Color4;
  83296. /**
  83297. * If the buffer needs to be cleared before applying the post process. (default: true)
  83298. * Should be set to false if shader will overwrite all previous pixels.
  83299. */
  83300. autoClear: boolean;
  83301. /**
  83302. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  83303. */
  83304. alphaMode: number;
  83305. /**
  83306. * Sets the setAlphaBlendConstants of the babylon engine
  83307. */
  83308. alphaConstants: Color4;
  83309. /**
  83310. * Animations to be used for the post processing
  83311. */
  83312. animations: Animation[];
  83313. /**
  83314. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  83315. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  83316. */
  83317. enablePixelPerfectMode: boolean;
  83318. /**
  83319. * Force the postprocess to be applied without taking in account viewport
  83320. */
  83321. forceFullscreenViewport: boolean;
  83322. /**
  83323. * List of inspectable custom properties (used by the Inspector)
  83324. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83325. */
  83326. inspectableCustomProperties: IInspectable[];
  83327. /**
  83328. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  83329. *
  83330. * | Value | Type | Description |
  83331. * | ----- | ----------------------------------- | ----------- |
  83332. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  83333. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  83334. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  83335. *
  83336. */
  83337. scaleMode: number;
  83338. /**
  83339. * Force textures to be a power of two (default: false)
  83340. */
  83341. alwaysForcePOT: boolean;
  83342. private _samples;
  83343. /**
  83344. * Number of sample textures (default: 1)
  83345. */
  83346. samples: number;
  83347. /**
  83348. * Modify the scale of the post process to be the same as the viewport (default: false)
  83349. */
  83350. adaptScaleToCurrentViewport: boolean;
  83351. private _camera;
  83352. private _scene;
  83353. private _engine;
  83354. private _options;
  83355. private _reusable;
  83356. private _textureType;
  83357. /**
  83358. * Smart array of input and output textures for the post process.
  83359. * @hidden
  83360. */
  83361. _textures: SmartArray<InternalTexture>;
  83362. /**
  83363. * The index in _textures that corresponds to the output texture.
  83364. * @hidden
  83365. */
  83366. _currentRenderTextureInd: number;
  83367. private _effect;
  83368. private _samplers;
  83369. private _fragmentUrl;
  83370. private _vertexUrl;
  83371. private _parameters;
  83372. private _scaleRatio;
  83373. protected _indexParameters: any;
  83374. private _shareOutputWithPostProcess;
  83375. private _texelSize;
  83376. private _forcedOutputTexture;
  83377. /**
  83378. * Returns the fragment url or shader name used in the post process.
  83379. * @returns the fragment url or name in the shader store.
  83380. */
  83381. getEffectName(): string;
  83382. /**
  83383. * An event triggered when the postprocess is activated.
  83384. */
  83385. onActivateObservable: Observable<Camera>;
  83386. private _onActivateObserver;
  83387. /**
  83388. * A function that is added to the onActivateObservable
  83389. */
  83390. onActivate: Nullable<(camera: Camera) => void>;
  83391. /**
  83392. * An event triggered when the postprocess changes its size.
  83393. */
  83394. onSizeChangedObservable: Observable<PostProcess>;
  83395. private _onSizeChangedObserver;
  83396. /**
  83397. * A function that is added to the onSizeChangedObservable
  83398. */
  83399. onSizeChanged: (postProcess: PostProcess) => void;
  83400. /**
  83401. * An event triggered when the postprocess applies its effect.
  83402. */
  83403. onApplyObservable: Observable<Effect>;
  83404. private _onApplyObserver;
  83405. /**
  83406. * A function that is added to the onApplyObservable
  83407. */
  83408. onApply: (effect: Effect) => void;
  83409. /**
  83410. * An event triggered before rendering the postprocess
  83411. */
  83412. onBeforeRenderObservable: Observable<Effect>;
  83413. private _onBeforeRenderObserver;
  83414. /**
  83415. * A function that is added to the onBeforeRenderObservable
  83416. */
  83417. onBeforeRender: (effect: Effect) => void;
  83418. /**
  83419. * An event triggered after rendering the postprocess
  83420. */
  83421. onAfterRenderObservable: Observable<Effect>;
  83422. private _onAfterRenderObserver;
  83423. /**
  83424. * A function that is added to the onAfterRenderObservable
  83425. */
  83426. onAfterRender: (efect: Effect) => void;
  83427. /**
  83428. * 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
  83429. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  83430. */
  83431. inputTexture: InternalTexture;
  83432. /**
  83433. * Gets the camera which post process is applied to.
  83434. * @returns The camera the post process is applied to.
  83435. */
  83436. getCamera(): Camera;
  83437. /**
  83438. * Gets the texel size of the postprocess.
  83439. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  83440. */
  83441. readonly texelSize: Vector2;
  83442. /**
  83443. * Creates a new instance PostProcess
  83444. * @param name The name of the PostProcess.
  83445. * @param fragmentUrl The url of the fragment shader to be used.
  83446. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  83447. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  83448. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83449. * @param camera The camera to apply the render pass to.
  83450. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83451. * @param engine The engine which the post process will be applied. (default: current engine)
  83452. * @param reusable If the post process can be reused on the same frame. (default: false)
  83453. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  83454. * @param textureType Type of textures used when performing the post process. (default: 0)
  83455. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  83456. * @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
  83457. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  83458. */
  83459. constructor(
  83460. /** Name of the PostProcess. */
  83461. 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);
  83462. /**
  83463. * Gets a string idenfifying the name of the class
  83464. * @returns "PostProcess" string
  83465. */
  83466. getClassName(): string;
  83467. /**
  83468. * Gets the engine which this post process belongs to.
  83469. * @returns The engine the post process was enabled with.
  83470. */
  83471. getEngine(): Engine;
  83472. /**
  83473. * The effect that is created when initializing the post process.
  83474. * @returns The created effect corresponding the the postprocess.
  83475. */
  83476. getEffect(): Effect;
  83477. /**
  83478. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  83479. * @param postProcess The post process to share the output with.
  83480. * @returns This post process.
  83481. */
  83482. shareOutputWith(postProcess: PostProcess): PostProcess;
  83483. /**
  83484. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  83485. * This should be called if the post process that shares output with this post process is disabled/disposed.
  83486. */
  83487. useOwnOutput(): void;
  83488. /**
  83489. * Updates the effect with the current post process compile time values and recompiles the shader.
  83490. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83491. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83492. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83493. * @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
  83494. * @param onCompiled Called when the shader has been compiled.
  83495. * @param onError Called if there is an error when compiling a shader.
  83496. */
  83497. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83498. /**
  83499. * The post process is reusable if it can be used multiple times within one frame.
  83500. * @returns If the post process is reusable
  83501. */
  83502. isReusable(): boolean;
  83503. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  83504. markTextureDirty(): void;
  83505. /**
  83506. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  83507. * 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.
  83508. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  83509. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  83510. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  83511. * @returns The target texture that was bound to be written to.
  83512. */
  83513. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  83514. /**
  83515. * If the post process is supported.
  83516. */
  83517. readonly isSupported: boolean;
  83518. /**
  83519. * The aspect ratio of the output texture.
  83520. */
  83521. readonly aspectRatio: number;
  83522. /**
  83523. * Get a value indicating if the post-process is ready to be used
  83524. * @returns true if the post-process is ready (shader is compiled)
  83525. */
  83526. isReady(): boolean;
  83527. /**
  83528. * Binds all textures and uniforms to the shader, this will be run on every pass.
  83529. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  83530. */
  83531. apply(): Nullable<Effect>;
  83532. private _disposeTextures;
  83533. /**
  83534. * Disposes the post process.
  83535. * @param camera The camera to dispose the post process on.
  83536. */
  83537. dispose(camera?: Camera): void;
  83538. }
  83539. }
  83540. declare module BABYLON {
  83541. /** @hidden */
  83542. export var kernelBlurVaryingDeclaration: {
  83543. name: string;
  83544. shader: string;
  83545. };
  83546. }
  83547. declare module BABYLON {
  83548. /** @hidden */
  83549. export var kernelBlurFragment: {
  83550. name: string;
  83551. shader: string;
  83552. };
  83553. }
  83554. declare module BABYLON {
  83555. /** @hidden */
  83556. export var kernelBlurFragment2: {
  83557. name: string;
  83558. shader: string;
  83559. };
  83560. }
  83561. declare module BABYLON {
  83562. /** @hidden */
  83563. export var kernelBlurPixelShader: {
  83564. name: string;
  83565. shader: string;
  83566. };
  83567. }
  83568. declare module BABYLON {
  83569. /** @hidden */
  83570. export var kernelBlurVertex: {
  83571. name: string;
  83572. shader: string;
  83573. };
  83574. }
  83575. declare module BABYLON {
  83576. /** @hidden */
  83577. export var kernelBlurVertexShader: {
  83578. name: string;
  83579. shader: string;
  83580. };
  83581. }
  83582. declare module BABYLON {
  83583. /**
  83584. * The Blur Post Process which blurs an image based on a kernel and direction.
  83585. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  83586. */
  83587. export class BlurPostProcess extends PostProcess {
  83588. /** The direction in which to blur the image. */
  83589. direction: Vector2;
  83590. private blockCompilation;
  83591. protected _kernel: number;
  83592. protected _idealKernel: number;
  83593. protected _packedFloat: boolean;
  83594. private _staticDefines;
  83595. /**
  83596. * Sets the length in pixels of the blur sample region
  83597. */
  83598. /**
  83599. * Gets the length in pixels of the blur sample region
  83600. */
  83601. kernel: number;
  83602. /**
  83603. * Sets wether or not the blur needs to unpack/repack floats
  83604. */
  83605. /**
  83606. * Gets wether or not the blur is unpacking/repacking floats
  83607. */
  83608. packedFloat: boolean;
  83609. /**
  83610. * Creates a new instance BlurPostProcess
  83611. * @param name The name of the effect.
  83612. * @param direction The direction in which to blur the image.
  83613. * @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.
  83614. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83615. * @param camera The camera to apply the render pass to.
  83616. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83617. * @param engine The engine which the post process will be applied. (default: current engine)
  83618. * @param reusable If the post process can be reused on the same frame. (default: false)
  83619. * @param textureType Type of textures used when performing the post process. (default: 0)
  83620. * @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)
  83621. */
  83622. constructor(name: string,
  83623. /** The direction in which to blur the image. */
  83624. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  83625. /**
  83626. * Updates the effect with the current post process compile time values and recompiles the shader.
  83627. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83628. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83629. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83630. * @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
  83631. * @param onCompiled Called when the shader has been compiled.
  83632. * @param onError Called if there is an error when compiling a shader.
  83633. */
  83634. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83635. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83636. /**
  83637. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  83638. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  83639. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  83640. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  83641. * The gaps between physical kernels are compensated for in the weighting of the samples
  83642. * @param idealKernel Ideal blur kernel.
  83643. * @return Nearest best kernel.
  83644. */
  83645. protected _nearestBestKernel(idealKernel: number): number;
  83646. /**
  83647. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  83648. * @param x The point on the Gaussian distribution to sample.
  83649. * @return the value of the Gaussian function at x.
  83650. */
  83651. protected _gaussianWeight(x: number): number;
  83652. /**
  83653. * Generates a string that can be used as a floating point number in GLSL.
  83654. * @param x Value to print.
  83655. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  83656. * @return GLSL float string.
  83657. */
  83658. protected _glslFloat(x: number, decimalFigures?: number): string;
  83659. }
  83660. }
  83661. declare module BABYLON {
  83662. /**
  83663. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83664. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83665. * You can then easily use it as a reflectionTexture on a flat surface.
  83666. * In case the surface is not a plane, please consider relying on reflection probes.
  83667. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83668. */
  83669. export class MirrorTexture extends RenderTargetTexture {
  83670. private scene;
  83671. /**
  83672. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  83673. * 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.
  83674. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83675. */
  83676. mirrorPlane: Plane;
  83677. /**
  83678. * Define the blur ratio used to blur the reflection if needed.
  83679. */
  83680. blurRatio: number;
  83681. /**
  83682. * Define the adaptive blur kernel used to blur the reflection if needed.
  83683. * This will autocompute the closest best match for the `blurKernel`
  83684. */
  83685. adaptiveBlurKernel: number;
  83686. /**
  83687. * Define the blur kernel used to blur the reflection if needed.
  83688. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83689. */
  83690. blurKernel: number;
  83691. /**
  83692. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  83693. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83694. */
  83695. blurKernelX: number;
  83696. /**
  83697. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  83698. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83699. */
  83700. blurKernelY: number;
  83701. private _autoComputeBlurKernel;
  83702. protected _onRatioRescale(): void;
  83703. private _updateGammaSpace;
  83704. private _imageProcessingConfigChangeObserver;
  83705. private _transformMatrix;
  83706. private _mirrorMatrix;
  83707. private _savedViewMatrix;
  83708. private _blurX;
  83709. private _blurY;
  83710. private _adaptiveBlurKernel;
  83711. private _blurKernelX;
  83712. private _blurKernelY;
  83713. private _blurRatio;
  83714. /**
  83715. * Instantiates a Mirror Texture.
  83716. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83717. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83718. * You can then easily use it as a reflectionTexture on a flat surface.
  83719. * In case the surface is not a plane, please consider relying on reflection probes.
  83720. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83721. * @param name
  83722. * @param size
  83723. * @param scene
  83724. * @param generateMipMaps
  83725. * @param type
  83726. * @param samplingMode
  83727. * @param generateDepthBuffer
  83728. */
  83729. constructor(name: string, size: number | {
  83730. width: number;
  83731. height: number;
  83732. } | {
  83733. ratio: number;
  83734. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  83735. private _preparePostProcesses;
  83736. /**
  83737. * Clone the mirror texture.
  83738. * @returns the cloned texture
  83739. */
  83740. clone(): MirrorTexture;
  83741. /**
  83742. * Serialize the texture to a JSON representation you could use in Parse later on
  83743. * @returns the serialized JSON representation
  83744. */
  83745. serialize(): any;
  83746. /**
  83747. * Dispose the texture and release its associated resources.
  83748. */
  83749. dispose(): void;
  83750. }
  83751. }
  83752. declare module BABYLON {
  83753. /**
  83754. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83755. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83756. */
  83757. export class Texture extends BaseTexture {
  83758. /**
  83759. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  83760. */
  83761. static SerializeBuffers: boolean;
  83762. /** @hidden */
  83763. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  83764. /** @hidden */
  83765. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  83766. /** @hidden */
  83767. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  83768. /** nearest is mag = nearest and min = nearest and mip = linear */
  83769. static readonly NEAREST_SAMPLINGMODE: number;
  83770. /** nearest is mag = nearest and min = nearest and mip = linear */
  83771. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  83772. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83773. static readonly BILINEAR_SAMPLINGMODE: number;
  83774. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83775. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  83776. /** Trilinear is mag = linear and min = linear and mip = linear */
  83777. static readonly TRILINEAR_SAMPLINGMODE: number;
  83778. /** Trilinear is mag = linear and min = linear and mip = linear */
  83779. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  83780. /** mag = nearest and min = nearest and mip = nearest */
  83781. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  83782. /** mag = nearest and min = linear and mip = nearest */
  83783. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  83784. /** mag = nearest and min = linear and mip = linear */
  83785. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  83786. /** mag = nearest and min = linear and mip = none */
  83787. static readonly NEAREST_LINEAR: number;
  83788. /** mag = nearest and min = nearest and mip = none */
  83789. static readonly NEAREST_NEAREST: number;
  83790. /** mag = linear and min = nearest and mip = nearest */
  83791. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  83792. /** mag = linear and min = nearest and mip = linear */
  83793. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  83794. /** mag = linear and min = linear and mip = none */
  83795. static readonly LINEAR_LINEAR: number;
  83796. /** mag = linear and min = nearest and mip = none */
  83797. static readonly LINEAR_NEAREST: number;
  83798. /** Explicit coordinates mode */
  83799. static readonly EXPLICIT_MODE: number;
  83800. /** Spherical coordinates mode */
  83801. static readonly SPHERICAL_MODE: number;
  83802. /** Planar coordinates mode */
  83803. static readonly PLANAR_MODE: number;
  83804. /** Cubic coordinates mode */
  83805. static readonly CUBIC_MODE: number;
  83806. /** Projection coordinates mode */
  83807. static readonly PROJECTION_MODE: number;
  83808. /** Inverse Cubic coordinates mode */
  83809. static readonly SKYBOX_MODE: number;
  83810. /** Inverse Cubic coordinates mode */
  83811. static readonly INVCUBIC_MODE: number;
  83812. /** Equirectangular coordinates mode */
  83813. static readonly EQUIRECTANGULAR_MODE: number;
  83814. /** Equirectangular Fixed coordinates mode */
  83815. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  83816. /** Equirectangular Fixed Mirrored coordinates mode */
  83817. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  83818. /** Texture is not repeating outside of 0..1 UVs */
  83819. static readonly CLAMP_ADDRESSMODE: number;
  83820. /** Texture is repeating outside of 0..1 UVs */
  83821. static readonly WRAP_ADDRESSMODE: number;
  83822. /** Texture is repeating and mirrored */
  83823. static readonly MIRROR_ADDRESSMODE: number;
  83824. /**
  83825. * 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
  83826. */
  83827. static UseSerializedUrlIfAny: boolean;
  83828. /**
  83829. * Define the url of the texture.
  83830. */
  83831. url: Nullable<string>;
  83832. /**
  83833. * Define an offset on the texture to offset the u coordinates of the UVs
  83834. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83835. */
  83836. uOffset: number;
  83837. /**
  83838. * Define an offset on the texture to offset the v coordinates of the UVs
  83839. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83840. */
  83841. vOffset: number;
  83842. /**
  83843. * Define an offset on the texture to scale the u coordinates of the UVs
  83844. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83845. */
  83846. uScale: number;
  83847. /**
  83848. * Define an offset on the texture to scale the v coordinates of the UVs
  83849. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83850. */
  83851. vScale: number;
  83852. /**
  83853. * Define an offset on the texture to rotate around the u coordinates of the UVs
  83854. * @see http://doc.babylonjs.com/how_to/more_materials
  83855. */
  83856. uAng: number;
  83857. /**
  83858. * Define an offset on the texture to rotate around the v coordinates of the UVs
  83859. * @see http://doc.babylonjs.com/how_to/more_materials
  83860. */
  83861. vAng: number;
  83862. /**
  83863. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  83864. * @see http://doc.babylonjs.com/how_to/more_materials
  83865. */
  83866. wAng: number;
  83867. /**
  83868. * Defines the center of rotation (U)
  83869. */
  83870. uRotationCenter: number;
  83871. /**
  83872. * Defines the center of rotation (V)
  83873. */
  83874. vRotationCenter: number;
  83875. /**
  83876. * Defines the center of rotation (W)
  83877. */
  83878. wRotationCenter: number;
  83879. /**
  83880. * Are mip maps generated for this texture or not.
  83881. */
  83882. readonly noMipmap: boolean;
  83883. /**
  83884. * List of inspectable custom properties (used by the Inspector)
  83885. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83886. */
  83887. inspectableCustomProperties: Nullable<IInspectable[]>;
  83888. private _noMipmap;
  83889. /** @hidden */
  83890. _invertY: boolean;
  83891. private _rowGenerationMatrix;
  83892. private _cachedTextureMatrix;
  83893. private _projectionModeMatrix;
  83894. private _t0;
  83895. private _t1;
  83896. private _t2;
  83897. private _cachedUOffset;
  83898. private _cachedVOffset;
  83899. private _cachedUScale;
  83900. private _cachedVScale;
  83901. private _cachedUAng;
  83902. private _cachedVAng;
  83903. private _cachedWAng;
  83904. private _cachedProjectionMatrixId;
  83905. private _cachedCoordinatesMode;
  83906. /** @hidden */
  83907. protected _initialSamplingMode: number;
  83908. /** @hidden */
  83909. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  83910. private _deleteBuffer;
  83911. protected _format: Nullable<number>;
  83912. private _delayedOnLoad;
  83913. private _delayedOnError;
  83914. private _mimeType?;
  83915. /**
  83916. * Observable triggered once the texture has been loaded.
  83917. */
  83918. onLoadObservable: Observable<Texture>;
  83919. protected _isBlocking: boolean;
  83920. /**
  83921. * Is the texture preventing material to render while loading.
  83922. * If false, a default texture will be used instead of the loading one during the preparation step.
  83923. */
  83924. isBlocking: boolean;
  83925. /**
  83926. * Get the current sampling mode associated with the texture.
  83927. */
  83928. readonly samplingMode: number;
  83929. /**
  83930. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  83931. */
  83932. readonly invertY: boolean;
  83933. /**
  83934. * Instantiates a new texture.
  83935. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83936. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83937. * @param url defines the url of the picture to load as a texture
  83938. * @param scene defines the scene or engine the texture will belong to
  83939. * @param noMipmap defines if the texture will require mip maps or not
  83940. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  83941. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83942. * @param onLoad defines a callback triggered when the texture has been loaded
  83943. * @param onError defines a callback triggered when an error occurred during the loading session
  83944. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  83945. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  83946. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83947. * @param mimeType defines an optional mime type information
  83948. */
  83949. 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);
  83950. /**
  83951. * Update the url (and optional buffer) of this texture if url was null during construction.
  83952. * @param url the url of the texture
  83953. * @param buffer the buffer of the texture (defaults to null)
  83954. * @param onLoad callback called when the texture is loaded (defaults to null)
  83955. */
  83956. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  83957. /**
  83958. * Finish the loading sequence of a texture flagged as delayed load.
  83959. * @hidden
  83960. */
  83961. delayLoad(): void;
  83962. private _prepareRowForTextureGeneration;
  83963. /**
  83964. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  83965. * @returns the transform matrix of the texture.
  83966. */
  83967. getTextureMatrix(): Matrix;
  83968. /**
  83969. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  83970. * @returns The reflection texture transform
  83971. */
  83972. getReflectionTextureMatrix(): Matrix;
  83973. /**
  83974. * Clones the texture.
  83975. * @returns the cloned texture
  83976. */
  83977. clone(): Texture;
  83978. /**
  83979. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  83980. * @returns The JSON representation of the texture
  83981. */
  83982. serialize(): any;
  83983. /**
  83984. * Get the current class name of the texture useful for serialization or dynamic coding.
  83985. * @returns "Texture"
  83986. */
  83987. getClassName(): string;
  83988. /**
  83989. * Dispose the texture and release its associated resources.
  83990. */
  83991. dispose(): void;
  83992. /**
  83993. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  83994. * @param parsedTexture Define the JSON representation of the texture
  83995. * @param scene Define the scene the parsed texture should be instantiated in
  83996. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  83997. * @returns The parsed texture if successful
  83998. */
  83999. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  84000. /**
  84001. * Creates a texture from its base 64 representation.
  84002. * @param data Define the base64 payload without the data: prefix
  84003. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  84004. * @param scene Define the scene the texture should belong to
  84005. * @param noMipmap Forces the texture to not create mip map information if true
  84006. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84007. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84008. * @param onLoad define a callback triggered when the texture has been loaded
  84009. * @param onError define a callback triggered when an error occurred during the loading session
  84010. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84011. * @returns the created texture
  84012. */
  84013. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  84014. /**
  84015. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  84016. * @param data Define the base64 payload without the data: prefix
  84017. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  84018. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  84019. * @param scene Define the scene the texture should belong to
  84020. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  84021. * @param noMipmap Forces the texture to not create mip map information if true
  84022. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84023. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84024. * @param onLoad define a callback triggered when the texture has been loaded
  84025. * @param onError define a callback triggered when an error occurred during the loading session
  84026. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84027. * @returns the created texture
  84028. */
  84029. 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;
  84030. }
  84031. }
  84032. declare module BABYLON {
  84033. /**
  84034. * PostProcessManager is used to manage one or more post processes or post process pipelines
  84035. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  84036. */
  84037. export class PostProcessManager {
  84038. private _scene;
  84039. private _indexBuffer;
  84040. private _vertexBuffers;
  84041. /**
  84042. * Creates a new instance PostProcess
  84043. * @param scene The scene that the post process is associated with.
  84044. */
  84045. constructor(scene: Scene);
  84046. private _prepareBuffers;
  84047. private _buildIndexBuffer;
  84048. /**
  84049. * Rebuilds the vertex buffers of the manager.
  84050. * @hidden
  84051. */
  84052. _rebuild(): void;
  84053. /**
  84054. * Prepares a frame to be run through a post process.
  84055. * @param sourceTexture The input texture to the post procesess. (default: null)
  84056. * @param postProcesses An array of post processes to be run. (default: null)
  84057. * @returns True if the post processes were able to be run.
  84058. * @hidden
  84059. */
  84060. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  84061. /**
  84062. * Manually render a set of post processes to a texture.
  84063. * @param postProcesses An array of post processes to be run.
  84064. * @param targetTexture The target texture to render to.
  84065. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  84066. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  84067. * @param lodLevel defines which lod of the texture to render to
  84068. */
  84069. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  84070. /**
  84071. * Finalize the result of the output of the postprocesses.
  84072. * @param doNotPresent If true the result will not be displayed to the screen.
  84073. * @param targetTexture The target texture to render to.
  84074. * @param faceIndex The index of the face to bind the target texture to.
  84075. * @param postProcesses The array of post processes to render.
  84076. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  84077. * @hidden
  84078. */
  84079. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  84080. /**
  84081. * Disposes of the post process manager.
  84082. */
  84083. dispose(): void;
  84084. }
  84085. }
  84086. declare module BABYLON {
  84087. /** Interface used by value gradients (color, factor, ...) */
  84088. export interface IValueGradient {
  84089. /**
  84090. * Gets or sets the gradient value (between 0 and 1)
  84091. */
  84092. gradient: number;
  84093. }
  84094. /** Class used to store color4 gradient */
  84095. export class ColorGradient implements IValueGradient {
  84096. /**
  84097. * Gets or sets the gradient value (between 0 and 1)
  84098. */
  84099. gradient: number;
  84100. /**
  84101. * Gets or sets first associated color
  84102. */
  84103. color1: Color4;
  84104. /**
  84105. * Gets or sets second associated color
  84106. */
  84107. color2?: Color4;
  84108. /**
  84109. * Will get a color picked randomly between color1 and color2.
  84110. * If color2 is undefined then color1 will be used
  84111. * @param result defines the target Color4 to store the result in
  84112. */
  84113. getColorToRef(result: Color4): void;
  84114. }
  84115. /** Class used to store color 3 gradient */
  84116. export class Color3Gradient implements IValueGradient {
  84117. /**
  84118. * Gets or sets the gradient value (between 0 and 1)
  84119. */
  84120. gradient: number;
  84121. /**
  84122. * Gets or sets the associated color
  84123. */
  84124. color: Color3;
  84125. }
  84126. /** Class used to store factor gradient */
  84127. export class FactorGradient implements IValueGradient {
  84128. /**
  84129. * Gets or sets the gradient value (between 0 and 1)
  84130. */
  84131. gradient: number;
  84132. /**
  84133. * Gets or sets first associated factor
  84134. */
  84135. factor1: number;
  84136. /**
  84137. * Gets or sets second associated factor
  84138. */
  84139. factor2?: number;
  84140. /**
  84141. * Will get a number picked randomly between factor1 and factor2.
  84142. * If factor2 is undefined then factor1 will be used
  84143. * @returns the picked number
  84144. */
  84145. getFactor(): number;
  84146. }
  84147. /**
  84148. * Helper used to simplify some generic gradient tasks
  84149. */
  84150. export class GradientHelper {
  84151. /**
  84152. * Gets the current gradient from an array of IValueGradient
  84153. * @param ratio defines the current ratio to get
  84154. * @param gradients defines the array of IValueGradient
  84155. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  84156. */
  84157. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  84158. }
  84159. }
  84160. declare module BABYLON {
  84161. interface ThinEngine {
  84162. /**
  84163. * Creates a dynamic texture
  84164. * @param width defines the width of the texture
  84165. * @param height defines the height of the texture
  84166. * @param generateMipMaps defines if the engine should generate the mip levels
  84167. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84168. * @returns the dynamic texture inside an InternalTexture
  84169. */
  84170. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84171. /**
  84172. * Update the content of a dynamic texture
  84173. * @param texture defines the texture to update
  84174. * @param canvas defines the canvas containing the source
  84175. * @param invertY defines if data must be stored with Y axis inverted
  84176. * @param premulAlpha defines if alpha is stored as premultiplied
  84177. * @param format defines the format of the data
  84178. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84179. */
  84180. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84181. }
  84182. }
  84183. declare module BABYLON {
  84184. /**
  84185. * Helper class used to generate a canvas to manipulate images
  84186. */
  84187. export class CanvasGenerator {
  84188. /**
  84189. * Create a new canvas (or offscreen canvas depending on the context)
  84190. * @param width defines the expected width
  84191. * @param height defines the expected height
  84192. * @return a new canvas or offscreen canvas
  84193. */
  84194. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  84195. }
  84196. }
  84197. declare module BABYLON {
  84198. /**
  84199. * A class extending Texture allowing drawing on a texture
  84200. * @see http://doc.babylonjs.com/how_to/dynamictexture
  84201. */
  84202. export class DynamicTexture extends Texture {
  84203. private _generateMipMaps;
  84204. private _canvas;
  84205. private _context;
  84206. private _engine;
  84207. /**
  84208. * Creates a DynamicTexture
  84209. * @param name defines the name of the texture
  84210. * @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
  84211. * @param scene defines the scene where you want the texture
  84212. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  84213. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  84214. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  84215. */
  84216. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  84217. /**
  84218. * Get the current class name of the texture useful for serialization or dynamic coding.
  84219. * @returns "DynamicTexture"
  84220. */
  84221. getClassName(): string;
  84222. /**
  84223. * Gets the current state of canRescale
  84224. */
  84225. readonly canRescale: boolean;
  84226. private _recreate;
  84227. /**
  84228. * Scales the texture
  84229. * @param ratio the scale factor to apply to both width and height
  84230. */
  84231. scale(ratio: number): void;
  84232. /**
  84233. * Resizes the texture
  84234. * @param width the new width
  84235. * @param height the new height
  84236. */
  84237. scaleTo(width: number, height: number): void;
  84238. /**
  84239. * Gets the context of the canvas used by the texture
  84240. * @returns the canvas context of the dynamic texture
  84241. */
  84242. getContext(): CanvasRenderingContext2D;
  84243. /**
  84244. * Clears the texture
  84245. */
  84246. clear(): void;
  84247. /**
  84248. * Updates the texture
  84249. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84250. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  84251. */
  84252. update(invertY?: boolean, premulAlpha?: boolean): void;
  84253. /**
  84254. * Draws text onto the texture
  84255. * @param text defines the text to be drawn
  84256. * @param x defines the placement of the text from the left
  84257. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  84258. * @param font defines the font to be used with font-style, font-size, font-name
  84259. * @param color defines the color used for the text
  84260. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  84261. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84262. * @param update defines whether texture is immediately update (default is true)
  84263. */
  84264. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  84265. /**
  84266. * Clones the texture
  84267. * @returns the clone of the texture.
  84268. */
  84269. clone(): DynamicTexture;
  84270. /**
  84271. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  84272. * @returns a serialized dynamic texture object
  84273. */
  84274. serialize(): any;
  84275. /** @hidden */
  84276. _rebuild(): void;
  84277. }
  84278. }
  84279. declare module BABYLON {
  84280. interface AbstractScene {
  84281. /**
  84282. * The list of procedural textures added to the scene
  84283. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84284. */
  84285. proceduralTextures: Array<ProceduralTexture>;
  84286. }
  84287. /**
  84288. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84289. * in a given scene.
  84290. */
  84291. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84292. /**
  84293. * The component name helpfull to identify the component in the list of scene components.
  84294. */
  84295. readonly name: string;
  84296. /**
  84297. * The scene the component belongs to.
  84298. */
  84299. scene: Scene;
  84300. /**
  84301. * Creates a new instance of the component for the given scene
  84302. * @param scene Defines the scene to register the component in
  84303. */
  84304. constructor(scene: Scene);
  84305. /**
  84306. * Registers the component in a given scene
  84307. */
  84308. register(): void;
  84309. /**
  84310. * Rebuilds the elements related to this component in case of
  84311. * context lost for instance.
  84312. */
  84313. rebuild(): void;
  84314. /**
  84315. * Disposes the component and the associated ressources.
  84316. */
  84317. dispose(): void;
  84318. private _beforeClear;
  84319. }
  84320. }
  84321. declare module BABYLON {
  84322. interface ThinEngine {
  84323. /**
  84324. * Creates a new render target cube texture
  84325. * @param size defines the size of the texture
  84326. * @param options defines the options used to create the texture
  84327. * @returns a new render target cube texture stored in an InternalTexture
  84328. */
  84329. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84330. }
  84331. }
  84332. declare module BABYLON {
  84333. /** @hidden */
  84334. export var proceduralVertexShader: {
  84335. name: string;
  84336. shader: string;
  84337. };
  84338. }
  84339. declare module BABYLON {
  84340. /**
  84341. * 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.
  84342. * This is the base class of any Procedural texture and contains most of the shareable code.
  84343. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84344. */
  84345. export class ProceduralTexture extends Texture {
  84346. isCube: boolean;
  84347. /**
  84348. * Define if the texture is enabled or not (disabled texture will not render)
  84349. */
  84350. isEnabled: boolean;
  84351. /**
  84352. * Define if the texture must be cleared before rendering (default is true)
  84353. */
  84354. autoClear: boolean;
  84355. /**
  84356. * Callback called when the texture is generated
  84357. */
  84358. onGenerated: () => void;
  84359. /**
  84360. * Event raised when the texture is generated
  84361. */
  84362. onGeneratedObservable: Observable<ProceduralTexture>;
  84363. /** @hidden */
  84364. _generateMipMaps: boolean;
  84365. /** @hidden **/
  84366. _effect: Effect;
  84367. /** @hidden */
  84368. _textures: {
  84369. [key: string]: Texture;
  84370. };
  84371. private _size;
  84372. private _currentRefreshId;
  84373. private _refreshRate;
  84374. private _vertexBuffers;
  84375. private _indexBuffer;
  84376. private _uniforms;
  84377. private _samplers;
  84378. private _fragment;
  84379. private _floats;
  84380. private _ints;
  84381. private _floatsArrays;
  84382. private _colors3;
  84383. private _colors4;
  84384. private _vectors2;
  84385. private _vectors3;
  84386. private _matrices;
  84387. private _fallbackTexture;
  84388. private _fallbackTextureUsed;
  84389. private _engine;
  84390. private _cachedDefines;
  84391. private _contentUpdateId;
  84392. private _contentData;
  84393. /**
  84394. * Instantiates a new procedural texture.
  84395. * 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.
  84396. * This is the base class of any Procedural texture and contains most of the shareable code.
  84397. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84398. * @param name Define the name of the texture
  84399. * @param size Define the size of the texture to create
  84400. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84401. * @param scene Define the scene the texture belongs to
  84402. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84403. * @param generateMipMaps Define if the texture should creates mip maps or not
  84404. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84405. */
  84406. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84407. /**
  84408. * The effect that is created when initializing the post process.
  84409. * @returns The created effect corresponding the the postprocess.
  84410. */
  84411. getEffect(): Effect;
  84412. /**
  84413. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84414. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84415. */
  84416. getContent(): Nullable<ArrayBufferView>;
  84417. private _createIndexBuffer;
  84418. /** @hidden */
  84419. _rebuild(): void;
  84420. /**
  84421. * Resets the texture in order to recreate its associated resources.
  84422. * This can be called in case of context loss
  84423. */
  84424. reset(): void;
  84425. protected _getDefines(): string;
  84426. /**
  84427. * Is the texture ready to be used ? (rendered at least once)
  84428. * @returns true if ready, otherwise, false.
  84429. */
  84430. isReady(): boolean;
  84431. /**
  84432. * Resets the refresh counter of the texture and start bak from scratch.
  84433. * Could be useful to regenerate the texture if it is setup to render only once.
  84434. */
  84435. resetRefreshCounter(): void;
  84436. /**
  84437. * Set the fragment shader to use in order to render the texture.
  84438. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84439. */
  84440. setFragment(fragment: any): void;
  84441. /**
  84442. * Define the refresh rate of the texture or the rendering frequency.
  84443. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84444. */
  84445. refreshRate: number;
  84446. /** @hidden */
  84447. _shouldRender(): boolean;
  84448. /**
  84449. * Get the size the texture is rendering at.
  84450. * @returns the size (texture is always squared)
  84451. */
  84452. getRenderSize(): number;
  84453. /**
  84454. * Resize the texture to new value.
  84455. * @param size Define the new size the texture should have
  84456. * @param generateMipMaps Define whether the new texture should create mip maps
  84457. */
  84458. resize(size: number, generateMipMaps: boolean): void;
  84459. private _checkUniform;
  84460. /**
  84461. * Set a texture in the shader program used to render.
  84462. * @param name Define the name of the uniform samplers as defined in the shader
  84463. * @param texture Define the texture to bind to this sampler
  84464. * @return the texture itself allowing "fluent" like uniform updates
  84465. */
  84466. setTexture(name: string, texture: Texture): ProceduralTexture;
  84467. /**
  84468. * Set a float in the shader.
  84469. * @param name Define the name of the uniform as defined in the shader
  84470. * @param value Define the value to give to the uniform
  84471. * @return the texture itself allowing "fluent" like uniform updates
  84472. */
  84473. setFloat(name: string, value: number): ProceduralTexture;
  84474. /**
  84475. * Set a int in the shader.
  84476. * @param name Define the name of the uniform as defined in the shader
  84477. * @param value Define the value to give to the uniform
  84478. * @return the texture itself allowing "fluent" like uniform updates
  84479. */
  84480. setInt(name: string, value: number): ProceduralTexture;
  84481. /**
  84482. * Set an array of floats in the shader.
  84483. * @param name Define the name of the uniform as defined in the shader
  84484. * @param value Define the value to give to the uniform
  84485. * @return the texture itself allowing "fluent" like uniform updates
  84486. */
  84487. setFloats(name: string, value: number[]): ProceduralTexture;
  84488. /**
  84489. * Set a vec3 in the shader from a Color3.
  84490. * @param name Define the name of the uniform as defined in the shader
  84491. * @param value Define the value to give to the uniform
  84492. * @return the texture itself allowing "fluent" like uniform updates
  84493. */
  84494. setColor3(name: string, value: Color3): ProceduralTexture;
  84495. /**
  84496. * Set a vec4 in the shader from a Color4.
  84497. * @param name Define the name of the uniform as defined in the shader
  84498. * @param value Define the value to give to the uniform
  84499. * @return the texture itself allowing "fluent" like uniform updates
  84500. */
  84501. setColor4(name: string, value: Color4): ProceduralTexture;
  84502. /**
  84503. * Set a vec2 in the shader from a Vector2.
  84504. * @param name Define the name of the uniform as defined in the shader
  84505. * @param value Define the value to give to the uniform
  84506. * @return the texture itself allowing "fluent" like uniform updates
  84507. */
  84508. setVector2(name: string, value: Vector2): ProceduralTexture;
  84509. /**
  84510. * Set a vec3 in the shader from a Vector3.
  84511. * @param name Define the name of the uniform as defined in the shader
  84512. * @param value Define the value to give to the uniform
  84513. * @return the texture itself allowing "fluent" like uniform updates
  84514. */
  84515. setVector3(name: string, value: Vector3): ProceduralTexture;
  84516. /**
  84517. * Set a mat4 in the shader from a MAtrix.
  84518. * @param name Define the name of the uniform as defined in the shader
  84519. * @param value Define the value to give to the uniform
  84520. * @return the texture itself allowing "fluent" like uniform updates
  84521. */
  84522. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84523. /**
  84524. * Render the texture to its associated render target.
  84525. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84526. */
  84527. render(useCameraPostProcess?: boolean): void;
  84528. /**
  84529. * Clone the texture.
  84530. * @returns the cloned texture
  84531. */
  84532. clone(): ProceduralTexture;
  84533. /**
  84534. * Dispose the texture and release its asoociated resources.
  84535. */
  84536. dispose(): void;
  84537. }
  84538. }
  84539. declare module BABYLON {
  84540. /**
  84541. * This represents the base class for particle system in Babylon.
  84542. * 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.
  84543. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84544. * @example https://doc.babylonjs.com/babylon101/particles
  84545. */
  84546. export class BaseParticleSystem {
  84547. /**
  84548. * Source color is added to the destination color without alpha affecting the result
  84549. */
  84550. static BLENDMODE_ONEONE: number;
  84551. /**
  84552. * Blend current color and particle color using particle’s alpha
  84553. */
  84554. static BLENDMODE_STANDARD: number;
  84555. /**
  84556. * Add current color and particle color multiplied by particle’s alpha
  84557. */
  84558. static BLENDMODE_ADD: number;
  84559. /**
  84560. * Multiply current color with particle color
  84561. */
  84562. static BLENDMODE_MULTIPLY: number;
  84563. /**
  84564. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84565. */
  84566. static BLENDMODE_MULTIPLYADD: number;
  84567. /**
  84568. * List of animations used by the particle system.
  84569. */
  84570. animations: Animation[];
  84571. /**
  84572. * The id of the Particle system.
  84573. */
  84574. id: string;
  84575. /**
  84576. * The friendly name of the Particle system.
  84577. */
  84578. name: string;
  84579. /**
  84580. * The rendering group used by the Particle system to chose when to render.
  84581. */
  84582. renderingGroupId: number;
  84583. /**
  84584. * The emitter represents the Mesh or position we are attaching the particle system to.
  84585. */
  84586. emitter: Nullable<AbstractMesh | Vector3>;
  84587. /**
  84588. * The maximum number of particles to emit per frame
  84589. */
  84590. emitRate: number;
  84591. /**
  84592. * If you want to launch only a few particles at once, that can be done, as well.
  84593. */
  84594. manualEmitCount: number;
  84595. /**
  84596. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84597. */
  84598. updateSpeed: number;
  84599. /**
  84600. * The amount of time the particle system is running (depends of the overall update speed).
  84601. */
  84602. targetStopDuration: number;
  84603. /**
  84604. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84605. */
  84606. disposeOnStop: boolean;
  84607. /**
  84608. * Minimum power of emitting particles.
  84609. */
  84610. minEmitPower: number;
  84611. /**
  84612. * Maximum power of emitting particles.
  84613. */
  84614. maxEmitPower: number;
  84615. /**
  84616. * Minimum life time of emitting particles.
  84617. */
  84618. minLifeTime: number;
  84619. /**
  84620. * Maximum life time of emitting particles.
  84621. */
  84622. maxLifeTime: number;
  84623. /**
  84624. * Minimum Size of emitting particles.
  84625. */
  84626. minSize: number;
  84627. /**
  84628. * Maximum Size of emitting particles.
  84629. */
  84630. maxSize: number;
  84631. /**
  84632. * Minimum scale of emitting particles on X axis.
  84633. */
  84634. minScaleX: number;
  84635. /**
  84636. * Maximum scale of emitting particles on X axis.
  84637. */
  84638. maxScaleX: number;
  84639. /**
  84640. * Minimum scale of emitting particles on Y axis.
  84641. */
  84642. minScaleY: number;
  84643. /**
  84644. * Maximum scale of emitting particles on Y axis.
  84645. */
  84646. maxScaleY: number;
  84647. /**
  84648. * Gets or sets the minimal initial rotation in radians.
  84649. */
  84650. minInitialRotation: number;
  84651. /**
  84652. * Gets or sets the maximal initial rotation in radians.
  84653. */
  84654. maxInitialRotation: number;
  84655. /**
  84656. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84657. */
  84658. minAngularSpeed: number;
  84659. /**
  84660. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84661. */
  84662. maxAngularSpeed: number;
  84663. /**
  84664. * The texture used to render each particle. (this can be a spritesheet)
  84665. */
  84666. particleTexture: Nullable<Texture>;
  84667. /**
  84668. * The layer mask we are rendering the particles through.
  84669. */
  84670. layerMask: number;
  84671. /**
  84672. * This can help using your own shader to render the particle system.
  84673. * The according effect will be created
  84674. */
  84675. customShader: any;
  84676. /**
  84677. * By default particle system starts as soon as they are created. This prevents the
  84678. * automatic start to happen and let you decide when to start emitting particles.
  84679. */
  84680. preventAutoStart: boolean;
  84681. private _noiseTexture;
  84682. /**
  84683. * Gets or sets a texture used to add random noise to particle positions
  84684. */
  84685. noiseTexture: Nullable<ProceduralTexture>;
  84686. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84687. noiseStrength: Vector3;
  84688. /**
  84689. * Callback triggered when the particle animation is ending.
  84690. */
  84691. onAnimationEnd: Nullable<() => void>;
  84692. /**
  84693. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84694. */
  84695. blendMode: number;
  84696. /**
  84697. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84698. * to override the particles.
  84699. */
  84700. forceDepthWrite: boolean;
  84701. /** 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 */
  84702. preWarmCycles: number;
  84703. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84704. preWarmStepOffset: number;
  84705. /**
  84706. * 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)
  84707. */
  84708. spriteCellChangeSpeed: number;
  84709. /**
  84710. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84711. */
  84712. startSpriteCellID: number;
  84713. /**
  84714. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84715. */
  84716. endSpriteCellID: number;
  84717. /**
  84718. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84719. */
  84720. spriteCellWidth: number;
  84721. /**
  84722. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84723. */
  84724. spriteCellHeight: number;
  84725. /**
  84726. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84727. */
  84728. spriteRandomStartCell: boolean;
  84729. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84730. translationPivot: Vector2;
  84731. /** @hidden */
  84732. protected _isAnimationSheetEnabled: boolean;
  84733. /**
  84734. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84735. */
  84736. beginAnimationOnStart: boolean;
  84737. /**
  84738. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84739. */
  84740. beginAnimationFrom: number;
  84741. /**
  84742. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84743. */
  84744. beginAnimationTo: number;
  84745. /**
  84746. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84747. */
  84748. beginAnimationLoop: boolean;
  84749. /**
  84750. * Gets or sets a world offset applied to all particles
  84751. */
  84752. worldOffset: Vector3;
  84753. /**
  84754. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84755. */
  84756. isAnimationSheetEnabled: boolean;
  84757. /**
  84758. * Get hosting scene
  84759. * @returns the scene
  84760. */
  84761. getScene(): Scene;
  84762. /**
  84763. * You can use gravity if you want to give an orientation to your particles.
  84764. */
  84765. gravity: Vector3;
  84766. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84767. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84768. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84769. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84770. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84771. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84772. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84773. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84774. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84775. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84776. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84777. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84778. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84779. /**
  84780. * Defines the delay in milliseconds before starting the system (0 by default)
  84781. */
  84782. startDelay: number;
  84783. /**
  84784. * Gets the current list of drag gradients.
  84785. * You must use addDragGradient and removeDragGradient to udpate this list
  84786. * @returns the list of drag gradients
  84787. */
  84788. getDragGradients(): Nullable<Array<FactorGradient>>;
  84789. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84790. limitVelocityDamping: number;
  84791. /**
  84792. * Gets the current list of limit velocity gradients.
  84793. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84794. * @returns the list of limit velocity gradients
  84795. */
  84796. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84797. /**
  84798. * Gets the current list of color gradients.
  84799. * You must use addColorGradient and removeColorGradient to udpate this list
  84800. * @returns the list of color gradients
  84801. */
  84802. getColorGradients(): Nullable<Array<ColorGradient>>;
  84803. /**
  84804. * Gets the current list of size gradients.
  84805. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84806. * @returns the list of size gradients
  84807. */
  84808. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84809. /**
  84810. * Gets the current list of color remap gradients.
  84811. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84812. * @returns the list of color remap gradients
  84813. */
  84814. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84815. /**
  84816. * Gets the current list of alpha remap gradients.
  84817. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84818. * @returns the list of alpha remap gradients
  84819. */
  84820. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84821. /**
  84822. * Gets the current list of life time gradients.
  84823. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84824. * @returns the list of life time gradients
  84825. */
  84826. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84827. /**
  84828. * Gets the current list of angular speed gradients.
  84829. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84830. * @returns the list of angular speed gradients
  84831. */
  84832. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84833. /**
  84834. * Gets the current list of velocity gradients.
  84835. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84836. * @returns the list of velocity gradients
  84837. */
  84838. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84839. /**
  84840. * Gets the current list of start size gradients.
  84841. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84842. * @returns the list of start size gradients
  84843. */
  84844. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84845. /**
  84846. * Gets the current list of emit rate gradients.
  84847. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84848. * @returns the list of emit rate gradients
  84849. */
  84850. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84851. /**
  84852. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84853. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84854. */
  84855. direction1: Vector3;
  84856. /**
  84857. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84858. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84859. */
  84860. direction2: Vector3;
  84861. /**
  84862. * 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.
  84863. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84864. */
  84865. minEmitBox: Vector3;
  84866. /**
  84867. * 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.
  84868. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84869. */
  84870. maxEmitBox: Vector3;
  84871. /**
  84872. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84873. */
  84874. color1: Color4;
  84875. /**
  84876. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84877. */
  84878. color2: Color4;
  84879. /**
  84880. * Color the particle will have at the end of its lifetime
  84881. */
  84882. colorDead: Color4;
  84883. /**
  84884. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84885. */
  84886. textureMask: Color4;
  84887. /**
  84888. * The particle emitter type defines the emitter used by the particle system.
  84889. * It can be for example box, sphere, or cone...
  84890. */
  84891. particleEmitterType: IParticleEmitterType;
  84892. /** @hidden */
  84893. _isSubEmitter: boolean;
  84894. /**
  84895. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84896. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84897. */
  84898. billboardMode: number;
  84899. protected _isBillboardBased: boolean;
  84900. /**
  84901. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84902. */
  84903. isBillboardBased: boolean;
  84904. /**
  84905. * The scene the particle system belongs to.
  84906. */
  84907. protected _scene: Scene;
  84908. /**
  84909. * Local cache of defines for image processing.
  84910. */
  84911. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84912. /**
  84913. * Default configuration related to image processing available in the standard Material.
  84914. */
  84915. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84916. /**
  84917. * Gets the image processing configuration used either in this material.
  84918. */
  84919. /**
  84920. * Sets the Default image processing configuration used either in the this material.
  84921. *
  84922. * If sets to null, the scene one is in use.
  84923. */
  84924. imageProcessingConfiguration: ImageProcessingConfiguration;
  84925. /**
  84926. * Attaches a new image processing configuration to the Standard Material.
  84927. * @param configuration
  84928. */
  84929. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84930. /** @hidden */
  84931. protected _reset(): void;
  84932. /** @hidden */
  84933. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84934. /**
  84935. * Instantiates a particle system.
  84936. * 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.
  84937. * @param name The name of the particle system
  84938. */
  84939. constructor(name: string);
  84940. /**
  84941. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84942. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84943. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84944. * @returns the emitter
  84945. */
  84946. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84947. /**
  84948. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84949. * @param radius The radius of the hemisphere to emit from
  84950. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84951. * @returns the emitter
  84952. */
  84953. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84954. /**
  84955. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84956. * @param radius The radius of the sphere to emit from
  84957. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84958. * @returns the emitter
  84959. */
  84960. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84961. /**
  84962. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84963. * @param radius The radius of the sphere to emit from
  84964. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84965. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84966. * @returns the emitter
  84967. */
  84968. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84969. /**
  84970. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84971. * @param radius The radius of the emission cylinder
  84972. * @param height The height of the emission cylinder
  84973. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84974. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84975. * @returns the emitter
  84976. */
  84977. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84978. /**
  84979. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84980. * @param radius The radius of the cylinder to emit from
  84981. * @param height The height of the emission cylinder
  84982. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84983. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84984. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84985. * @returns the emitter
  84986. */
  84987. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84988. /**
  84989. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84990. * @param radius The radius of the cone to emit from
  84991. * @param angle The base angle of the cone
  84992. * @returns the emitter
  84993. */
  84994. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84995. /**
  84996. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84997. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84998. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84999. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85000. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85001. * @returns the emitter
  85002. */
  85003. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85004. }
  85005. }
  85006. declare module BABYLON {
  85007. /**
  85008. * Type of sub emitter
  85009. */
  85010. export enum SubEmitterType {
  85011. /**
  85012. * Attached to the particle over it's lifetime
  85013. */
  85014. ATTACHED = 0,
  85015. /**
  85016. * Created when the particle dies
  85017. */
  85018. END = 1
  85019. }
  85020. /**
  85021. * Sub emitter class used to emit particles from an existing particle
  85022. */
  85023. export class SubEmitter {
  85024. /**
  85025. * the particle system to be used by the sub emitter
  85026. */
  85027. particleSystem: ParticleSystem;
  85028. /**
  85029. * Type of the submitter (Default: END)
  85030. */
  85031. type: SubEmitterType;
  85032. /**
  85033. * 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)
  85034. * Note: This only is supported when using an emitter of type Mesh
  85035. */
  85036. inheritDirection: boolean;
  85037. /**
  85038. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85039. */
  85040. inheritedVelocityAmount: number;
  85041. /**
  85042. * Creates a sub emitter
  85043. * @param particleSystem the particle system to be used by the sub emitter
  85044. */
  85045. constructor(
  85046. /**
  85047. * the particle system to be used by the sub emitter
  85048. */
  85049. particleSystem: ParticleSystem);
  85050. /**
  85051. * Clones the sub emitter
  85052. * @returns the cloned sub emitter
  85053. */
  85054. clone(): SubEmitter;
  85055. /**
  85056. * Serialize current object to a JSON object
  85057. * @returns the serialized object
  85058. */
  85059. serialize(): any;
  85060. /** @hidden */
  85061. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85062. /**
  85063. * Creates a new SubEmitter from a serialized JSON version
  85064. * @param serializationObject defines the JSON object to read from
  85065. * @param scene defines the hosting scene
  85066. * @param rootUrl defines the rootUrl for data loading
  85067. * @returns a new SubEmitter
  85068. */
  85069. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  85070. /** Release associated resources */
  85071. dispose(): void;
  85072. }
  85073. }
  85074. declare module BABYLON {
  85075. /** @hidden */
  85076. export var clipPlaneFragmentDeclaration: {
  85077. name: string;
  85078. shader: string;
  85079. };
  85080. }
  85081. declare module BABYLON {
  85082. /** @hidden */
  85083. export var imageProcessingDeclaration: {
  85084. name: string;
  85085. shader: string;
  85086. };
  85087. }
  85088. declare module BABYLON {
  85089. /** @hidden */
  85090. export var imageProcessingFunctions: {
  85091. name: string;
  85092. shader: string;
  85093. };
  85094. }
  85095. declare module BABYLON {
  85096. /** @hidden */
  85097. export var clipPlaneFragment: {
  85098. name: string;
  85099. shader: string;
  85100. };
  85101. }
  85102. declare module BABYLON {
  85103. /** @hidden */
  85104. export var particlesPixelShader: {
  85105. name: string;
  85106. shader: string;
  85107. };
  85108. }
  85109. declare module BABYLON {
  85110. /** @hidden */
  85111. export var clipPlaneVertexDeclaration: {
  85112. name: string;
  85113. shader: string;
  85114. };
  85115. }
  85116. declare module BABYLON {
  85117. /** @hidden */
  85118. export var clipPlaneVertex: {
  85119. name: string;
  85120. shader: string;
  85121. };
  85122. }
  85123. declare module BABYLON {
  85124. /** @hidden */
  85125. export var particlesVertexShader: {
  85126. name: string;
  85127. shader: string;
  85128. };
  85129. }
  85130. declare module BABYLON {
  85131. /**
  85132. * This represents a particle system in Babylon.
  85133. * 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.
  85134. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85135. * @example https://doc.babylonjs.com/babylon101/particles
  85136. */
  85137. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  85138. /**
  85139. * Billboard mode will only apply to Y axis
  85140. */
  85141. static readonly BILLBOARDMODE_Y: number;
  85142. /**
  85143. * Billboard mode will apply to all axes
  85144. */
  85145. static readonly BILLBOARDMODE_ALL: number;
  85146. /**
  85147. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85148. */
  85149. static readonly BILLBOARDMODE_STRETCHED: number;
  85150. /**
  85151. * This function can be defined to provide custom update for active particles.
  85152. * This function will be called instead of regular update (age, position, color, etc.).
  85153. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  85154. */
  85155. updateFunction: (particles: Particle[]) => void;
  85156. private _emitterWorldMatrix;
  85157. /**
  85158. * This function can be defined to specify initial direction for every new particle.
  85159. * It by default use the emitterType defined function
  85160. */
  85161. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  85162. /**
  85163. * This function can be defined to specify initial position for every new particle.
  85164. * It by default use the emitterType defined function
  85165. */
  85166. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  85167. /**
  85168. * @hidden
  85169. */
  85170. _inheritedVelocityOffset: Vector3;
  85171. /**
  85172. * An event triggered when the system is disposed
  85173. */
  85174. onDisposeObservable: Observable<ParticleSystem>;
  85175. private _onDisposeObserver;
  85176. /**
  85177. * Sets a callback that will be triggered when the system is disposed
  85178. */
  85179. onDispose: () => void;
  85180. private _particles;
  85181. private _epsilon;
  85182. private _capacity;
  85183. private _stockParticles;
  85184. private _newPartsExcess;
  85185. private _vertexData;
  85186. private _vertexBuffer;
  85187. private _vertexBuffers;
  85188. private _spriteBuffer;
  85189. private _indexBuffer;
  85190. private _effect;
  85191. private _customEffect;
  85192. private _cachedDefines;
  85193. private _scaledColorStep;
  85194. private _colorDiff;
  85195. private _scaledDirection;
  85196. private _scaledGravity;
  85197. private _currentRenderId;
  85198. private _alive;
  85199. private _useInstancing;
  85200. private _started;
  85201. private _stopped;
  85202. private _actualFrame;
  85203. private _scaledUpdateSpeed;
  85204. private _vertexBufferSize;
  85205. /** @hidden */
  85206. _currentEmitRateGradient: Nullable<FactorGradient>;
  85207. /** @hidden */
  85208. _currentEmitRate1: number;
  85209. /** @hidden */
  85210. _currentEmitRate2: number;
  85211. /** @hidden */
  85212. _currentStartSizeGradient: Nullable<FactorGradient>;
  85213. /** @hidden */
  85214. _currentStartSize1: number;
  85215. /** @hidden */
  85216. _currentStartSize2: number;
  85217. private readonly _rawTextureWidth;
  85218. private _rampGradientsTexture;
  85219. private _useRampGradients;
  85220. /** Gets or sets a boolean indicating that ramp gradients must be used
  85221. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85222. */
  85223. useRampGradients: boolean;
  85224. /**
  85225. * 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.
  85226. * 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: [])
  85227. */
  85228. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85229. private _subEmitters;
  85230. /**
  85231. * @hidden
  85232. * If the particle systems emitter should be disposed when the particle system is disposed
  85233. */
  85234. _disposeEmitterOnDispose: boolean;
  85235. /**
  85236. * The current active Sub-systems, this property is used by the root particle system only.
  85237. */
  85238. activeSubSystems: Array<ParticleSystem>;
  85239. private _rootParticleSystem;
  85240. /**
  85241. * Gets the current list of active particles
  85242. */
  85243. readonly particles: Particle[];
  85244. /**
  85245. * Returns the string "ParticleSystem"
  85246. * @returns a string containing the class name
  85247. */
  85248. getClassName(): string;
  85249. /**
  85250. * Instantiates a particle system.
  85251. * 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.
  85252. * @param name The name of the particle system
  85253. * @param capacity The max number of particles alive at the same time
  85254. * @param scene The scene the particle system belongs to
  85255. * @param customEffect a custom effect used to change the way particles are rendered by default
  85256. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  85257. * @param epsilon Offset used to render the particles
  85258. */
  85259. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  85260. private _addFactorGradient;
  85261. private _removeFactorGradient;
  85262. /**
  85263. * Adds a new life time gradient
  85264. * @param gradient defines the gradient to use (between 0 and 1)
  85265. * @param factor defines the life time factor to affect to the specified gradient
  85266. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85267. * @returns the current particle system
  85268. */
  85269. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85270. /**
  85271. * Remove a specific life time gradient
  85272. * @param gradient defines the gradient to remove
  85273. * @returns the current particle system
  85274. */
  85275. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85276. /**
  85277. * Adds a new size gradient
  85278. * @param gradient defines the gradient to use (between 0 and 1)
  85279. * @param factor defines the size factor to affect to the specified gradient
  85280. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85281. * @returns the current particle system
  85282. */
  85283. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85284. /**
  85285. * Remove a specific size gradient
  85286. * @param gradient defines the gradient to remove
  85287. * @returns the current particle system
  85288. */
  85289. removeSizeGradient(gradient: number): IParticleSystem;
  85290. /**
  85291. * Adds a new color remap gradient
  85292. * @param gradient defines the gradient to use (between 0 and 1)
  85293. * @param min defines the color remap minimal range
  85294. * @param max defines the color remap maximal range
  85295. * @returns the current particle system
  85296. */
  85297. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85298. /**
  85299. * Remove a specific color remap gradient
  85300. * @param gradient defines the gradient to remove
  85301. * @returns the current particle system
  85302. */
  85303. removeColorRemapGradient(gradient: number): IParticleSystem;
  85304. /**
  85305. * Adds a new alpha remap gradient
  85306. * @param gradient defines the gradient to use (between 0 and 1)
  85307. * @param min defines the alpha remap minimal range
  85308. * @param max defines the alpha remap maximal range
  85309. * @returns the current particle system
  85310. */
  85311. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85312. /**
  85313. * Remove a specific alpha remap gradient
  85314. * @param gradient defines the gradient to remove
  85315. * @returns the current particle system
  85316. */
  85317. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85318. /**
  85319. * Adds a new angular speed gradient
  85320. * @param gradient defines the gradient to use (between 0 and 1)
  85321. * @param factor defines the angular speed to affect to the specified gradient
  85322. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85323. * @returns the current particle system
  85324. */
  85325. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85326. /**
  85327. * Remove a specific angular speed gradient
  85328. * @param gradient defines the gradient to remove
  85329. * @returns the current particle system
  85330. */
  85331. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85332. /**
  85333. * Adds a new velocity gradient
  85334. * @param gradient defines the gradient to use (between 0 and 1)
  85335. * @param factor defines the velocity to affect to the specified gradient
  85336. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85337. * @returns the current particle system
  85338. */
  85339. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85340. /**
  85341. * Remove a specific velocity gradient
  85342. * @param gradient defines the gradient to remove
  85343. * @returns the current particle system
  85344. */
  85345. removeVelocityGradient(gradient: number): IParticleSystem;
  85346. /**
  85347. * Adds a new limit velocity gradient
  85348. * @param gradient defines the gradient to use (between 0 and 1)
  85349. * @param factor defines the limit velocity value to affect to the specified gradient
  85350. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85351. * @returns the current particle system
  85352. */
  85353. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85354. /**
  85355. * Remove a specific limit velocity gradient
  85356. * @param gradient defines the gradient to remove
  85357. * @returns the current particle system
  85358. */
  85359. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85360. /**
  85361. * Adds a new drag gradient
  85362. * @param gradient defines the gradient to use (between 0 and 1)
  85363. * @param factor defines the drag value to affect to the specified gradient
  85364. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85365. * @returns the current particle system
  85366. */
  85367. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85368. /**
  85369. * Remove a specific drag gradient
  85370. * @param gradient defines the gradient to remove
  85371. * @returns the current particle system
  85372. */
  85373. removeDragGradient(gradient: number): IParticleSystem;
  85374. /**
  85375. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85376. * @param gradient defines the gradient to use (between 0 and 1)
  85377. * @param factor defines the emit rate value to affect to the specified gradient
  85378. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85379. * @returns the current particle system
  85380. */
  85381. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85382. /**
  85383. * Remove a specific emit rate gradient
  85384. * @param gradient defines the gradient to remove
  85385. * @returns the current particle system
  85386. */
  85387. removeEmitRateGradient(gradient: number): IParticleSystem;
  85388. /**
  85389. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85390. * @param gradient defines the gradient to use (between 0 and 1)
  85391. * @param factor defines the start size value to affect to the specified gradient
  85392. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85393. * @returns the current particle system
  85394. */
  85395. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85396. /**
  85397. * Remove a specific start size gradient
  85398. * @param gradient defines the gradient to remove
  85399. * @returns the current particle system
  85400. */
  85401. removeStartSizeGradient(gradient: number): IParticleSystem;
  85402. private _createRampGradientTexture;
  85403. /**
  85404. * Gets the current list of ramp gradients.
  85405. * You must use addRampGradient and removeRampGradient to udpate this list
  85406. * @returns the list of ramp gradients
  85407. */
  85408. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85409. /**
  85410. * Adds a new ramp gradient used to remap particle colors
  85411. * @param gradient defines the gradient to use (between 0 and 1)
  85412. * @param color defines the color to affect to the specified gradient
  85413. * @returns the current particle system
  85414. */
  85415. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85416. /**
  85417. * Remove a specific ramp gradient
  85418. * @param gradient defines the gradient to remove
  85419. * @returns the current particle system
  85420. */
  85421. removeRampGradient(gradient: number): ParticleSystem;
  85422. /**
  85423. * Adds a new color gradient
  85424. * @param gradient defines the gradient to use (between 0 and 1)
  85425. * @param color1 defines the color to affect to the specified gradient
  85426. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85427. * @returns this particle system
  85428. */
  85429. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85430. /**
  85431. * Remove a specific color gradient
  85432. * @param gradient defines the gradient to remove
  85433. * @returns this particle system
  85434. */
  85435. removeColorGradient(gradient: number): IParticleSystem;
  85436. private _fetchR;
  85437. protected _reset(): void;
  85438. private _resetEffect;
  85439. private _createVertexBuffers;
  85440. private _createIndexBuffer;
  85441. /**
  85442. * Gets the maximum number of particles active at the same time.
  85443. * @returns The max number of active particles.
  85444. */
  85445. getCapacity(): number;
  85446. /**
  85447. * Gets whether there are still active particles in the system.
  85448. * @returns True if it is alive, otherwise false.
  85449. */
  85450. isAlive(): boolean;
  85451. /**
  85452. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85453. * @returns True if it has been started, otherwise false.
  85454. */
  85455. isStarted(): boolean;
  85456. private _prepareSubEmitterInternalArray;
  85457. /**
  85458. * Starts the particle system and begins to emit
  85459. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85460. */
  85461. start(delay?: number): void;
  85462. /**
  85463. * Stops the particle system.
  85464. * @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.
  85465. */
  85466. stop(stopSubEmitters?: boolean): void;
  85467. /**
  85468. * Remove all active particles
  85469. */
  85470. reset(): void;
  85471. /**
  85472. * @hidden (for internal use only)
  85473. */
  85474. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85475. /**
  85476. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85477. * Its lifetime will start back at 0.
  85478. */
  85479. recycleParticle: (particle: Particle) => void;
  85480. private _stopSubEmitters;
  85481. private _createParticle;
  85482. private _removeFromRoot;
  85483. private _emitFromParticle;
  85484. private _update;
  85485. /** @hidden */
  85486. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85487. /** @hidden */
  85488. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85489. /** @hidden */
  85490. private _getEffect;
  85491. /**
  85492. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85493. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85494. */
  85495. animate(preWarmOnly?: boolean): void;
  85496. private _appendParticleVertices;
  85497. /**
  85498. * Rebuilds the particle system.
  85499. */
  85500. rebuild(): void;
  85501. /**
  85502. * Is this system ready to be used/rendered
  85503. * @return true if the system is ready
  85504. */
  85505. isReady(): boolean;
  85506. private _render;
  85507. /**
  85508. * Renders the particle system in its current state.
  85509. * @returns the current number of particles
  85510. */
  85511. render(): number;
  85512. /**
  85513. * Disposes the particle system and free the associated resources
  85514. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85515. */
  85516. dispose(disposeTexture?: boolean): void;
  85517. /**
  85518. * Clones the particle system.
  85519. * @param name The name of the cloned object
  85520. * @param newEmitter The new emitter to use
  85521. * @returns the cloned particle system
  85522. */
  85523. clone(name: string, newEmitter: any): ParticleSystem;
  85524. /**
  85525. * Serializes the particle system to a JSON object.
  85526. * @returns the JSON object
  85527. */
  85528. serialize(): any;
  85529. /** @hidden */
  85530. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85531. /** @hidden */
  85532. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85533. /**
  85534. * Parses a JSON object to create a particle system.
  85535. * @param parsedParticleSystem The JSON object to parse
  85536. * @param scene The scene to create the particle system in
  85537. * @param rootUrl The root url to use to load external dependencies like texture
  85538. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85539. * @returns the Parsed particle system
  85540. */
  85541. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85542. }
  85543. }
  85544. declare module BABYLON {
  85545. /**
  85546. * A particle represents one of the element emitted by a particle system.
  85547. * This is mainly define by its coordinates, direction, velocity and age.
  85548. */
  85549. export class Particle {
  85550. /**
  85551. * The particle system the particle belongs to.
  85552. */
  85553. particleSystem: ParticleSystem;
  85554. private static _Count;
  85555. /**
  85556. * Unique ID of the particle
  85557. */
  85558. id: number;
  85559. /**
  85560. * The world position of the particle in the scene.
  85561. */
  85562. position: Vector3;
  85563. /**
  85564. * The world direction of the particle in the scene.
  85565. */
  85566. direction: Vector3;
  85567. /**
  85568. * The color of the particle.
  85569. */
  85570. color: Color4;
  85571. /**
  85572. * The color change of the particle per step.
  85573. */
  85574. colorStep: Color4;
  85575. /**
  85576. * Defines how long will the life of the particle be.
  85577. */
  85578. lifeTime: number;
  85579. /**
  85580. * The current age of the particle.
  85581. */
  85582. age: number;
  85583. /**
  85584. * The current size of the particle.
  85585. */
  85586. size: number;
  85587. /**
  85588. * The current scale of the particle.
  85589. */
  85590. scale: Vector2;
  85591. /**
  85592. * The current angle of the particle.
  85593. */
  85594. angle: number;
  85595. /**
  85596. * Defines how fast is the angle changing.
  85597. */
  85598. angularSpeed: number;
  85599. /**
  85600. * Defines the cell index used by the particle to be rendered from a sprite.
  85601. */
  85602. cellIndex: number;
  85603. /**
  85604. * The information required to support color remapping
  85605. */
  85606. remapData: Vector4;
  85607. /** @hidden */
  85608. _randomCellOffset?: number;
  85609. /** @hidden */
  85610. _initialDirection: Nullable<Vector3>;
  85611. /** @hidden */
  85612. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85613. /** @hidden */
  85614. _initialStartSpriteCellID: number;
  85615. /** @hidden */
  85616. _initialEndSpriteCellID: number;
  85617. /** @hidden */
  85618. _currentColorGradient: Nullable<ColorGradient>;
  85619. /** @hidden */
  85620. _currentColor1: Color4;
  85621. /** @hidden */
  85622. _currentColor2: Color4;
  85623. /** @hidden */
  85624. _currentSizeGradient: Nullable<FactorGradient>;
  85625. /** @hidden */
  85626. _currentSize1: number;
  85627. /** @hidden */
  85628. _currentSize2: number;
  85629. /** @hidden */
  85630. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85631. /** @hidden */
  85632. _currentAngularSpeed1: number;
  85633. /** @hidden */
  85634. _currentAngularSpeed2: number;
  85635. /** @hidden */
  85636. _currentVelocityGradient: Nullable<FactorGradient>;
  85637. /** @hidden */
  85638. _currentVelocity1: number;
  85639. /** @hidden */
  85640. _currentVelocity2: number;
  85641. /** @hidden */
  85642. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85643. /** @hidden */
  85644. _currentLimitVelocity1: number;
  85645. /** @hidden */
  85646. _currentLimitVelocity2: number;
  85647. /** @hidden */
  85648. _currentDragGradient: Nullable<FactorGradient>;
  85649. /** @hidden */
  85650. _currentDrag1: number;
  85651. /** @hidden */
  85652. _currentDrag2: number;
  85653. /** @hidden */
  85654. _randomNoiseCoordinates1: Vector3;
  85655. /** @hidden */
  85656. _randomNoiseCoordinates2: Vector3;
  85657. /**
  85658. * Creates a new instance Particle
  85659. * @param particleSystem the particle system the particle belongs to
  85660. */
  85661. constructor(
  85662. /**
  85663. * The particle system the particle belongs to.
  85664. */
  85665. particleSystem: ParticleSystem);
  85666. private updateCellInfoFromSystem;
  85667. /**
  85668. * Defines how the sprite cell index is updated for the particle
  85669. */
  85670. updateCellIndex(): void;
  85671. /** @hidden */
  85672. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85673. /** @hidden */
  85674. _inheritParticleInfoToSubEmitters(): void;
  85675. /** @hidden */
  85676. _reset(): void;
  85677. /**
  85678. * Copy the properties of particle to another one.
  85679. * @param other the particle to copy the information to.
  85680. */
  85681. copyTo(other: Particle): void;
  85682. }
  85683. }
  85684. declare module BABYLON {
  85685. /**
  85686. * Particle emitter represents a volume emitting particles.
  85687. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85688. */
  85689. export interface IParticleEmitterType {
  85690. /**
  85691. * Called by the particle System when the direction is computed for the created particle.
  85692. * @param worldMatrix is the world matrix of the particle system
  85693. * @param directionToUpdate is the direction vector to update with the result
  85694. * @param particle is the particle we are computed the direction for
  85695. */
  85696. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85697. /**
  85698. * Called by the particle System when the position is computed for the created particle.
  85699. * @param worldMatrix is the world matrix of the particle system
  85700. * @param positionToUpdate is the position vector to update with the result
  85701. * @param particle is the particle we are computed the position for
  85702. */
  85703. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85704. /**
  85705. * Clones the current emitter and returns a copy of it
  85706. * @returns the new emitter
  85707. */
  85708. clone(): IParticleEmitterType;
  85709. /**
  85710. * Called by the GPUParticleSystem to setup the update shader
  85711. * @param effect defines the update shader
  85712. */
  85713. applyToShader(effect: Effect): void;
  85714. /**
  85715. * Returns a string to use to update the GPU particles update shader
  85716. * @returns the effect defines string
  85717. */
  85718. getEffectDefines(): string;
  85719. /**
  85720. * Returns a string representing the class name
  85721. * @returns a string containing the class name
  85722. */
  85723. getClassName(): string;
  85724. /**
  85725. * Serializes the particle system to a JSON object.
  85726. * @returns the JSON object
  85727. */
  85728. serialize(): any;
  85729. /**
  85730. * Parse properties from a JSON object
  85731. * @param serializationObject defines the JSON object
  85732. */
  85733. parse(serializationObject: any): void;
  85734. }
  85735. }
  85736. declare module BABYLON {
  85737. /**
  85738. * Particle emitter emitting particles from the inside of a box.
  85739. * It emits the particles randomly between 2 given directions.
  85740. */
  85741. export class BoxParticleEmitter implements IParticleEmitterType {
  85742. /**
  85743. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85744. */
  85745. direction1: Vector3;
  85746. /**
  85747. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85748. */
  85749. direction2: Vector3;
  85750. /**
  85751. * 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.
  85752. */
  85753. minEmitBox: Vector3;
  85754. /**
  85755. * 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.
  85756. */
  85757. maxEmitBox: Vector3;
  85758. /**
  85759. * Creates a new instance BoxParticleEmitter
  85760. */
  85761. constructor();
  85762. /**
  85763. * Called by the particle System when the direction is computed for the created particle.
  85764. * @param worldMatrix is the world matrix of the particle system
  85765. * @param directionToUpdate is the direction vector to update with the result
  85766. * @param particle is the particle we are computed the direction for
  85767. */
  85768. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85769. /**
  85770. * Called by the particle System when the position is computed for the created particle.
  85771. * @param worldMatrix is the world matrix of the particle system
  85772. * @param positionToUpdate is the position vector to update with the result
  85773. * @param particle is the particle we are computed the position for
  85774. */
  85775. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85776. /**
  85777. * Clones the current emitter and returns a copy of it
  85778. * @returns the new emitter
  85779. */
  85780. clone(): BoxParticleEmitter;
  85781. /**
  85782. * Called by the GPUParticleSystem to setup the update shader
  85783. * @param effect defines the update shader
  85784. */
  85785. applyToShader(effect: Effect): void;
  85786. /**
  85787. * Returns a string to use to update the GPU particles update shader
  85788. * @returns a string containng the defines string
  85789. */
  85790. getEffectDefines(): string;
  85791. /**
  85792. * Returns the string "BoxParticleEmitter"
  85793. * @returns a string containing the class name
  85794. */
  85795. getClassName(): string;
  85796. /**
  85797. * Serializes the particle system to a JSON object.
  85798. * @returns the JSON object
  85799. */
  85800. serialize(): any;
  85801. /**
  85802. * Parse properties from a JSON object
  85803. * @param serializationObject defines the JSON object
  85804. */
  85805. parse(serializationObject: any): void;
  85806. }
  85807. }
  85808. declare module BABYLON {
  85809. /**
  85810. * Particle emitter emitting particles from the inside of a cone.
  85811. * It emits the particles alongside the cone volume from the base to the particle.
  85812. * The emission direction might be randomized.
  85813. */
  85814. export class ConeParticleEmitter implements IParticleEmitterType {
  85815. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85816. directionRandomizer: number;
  85817. private _radius;
  85818. private _angle;
  85819. private _height;
  85820. /**
  85821. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85822. */
  85823. radiusRange: number;
  85824. /**
  85825. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85826. */
  85827. heightRange: number;
  85828. /**
  85829. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85830. */
  85831. emitFromSpawnPointOnly: boolean;
  85832. /**
  85833. * Gets or sets the radius of the emission cone
  85834. */
  85835. radius: number;
  85836. /**
  85837. * Gets or sets the angle of the emission cone
  85838. */
  85839. angle: number;
  85840. private _buildHeight;
  85841. /**
  85842. * Creates a new instance ConeParticleEmitter
  85843. * @param radius the radius of the emission cone (1 by default)
  85844. * @param angle the cone base angle (PI by default)
  85845. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85846. */
  85847. constructor(radius?: number, angle?: number,
  85848. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85849. directionRandomizer?: number);
  85850. /**
  85851. * Called by the particle System when the direction is computed for the created particle.
  85852. * @param worldMatrix is the world matrix of the particle system
  85853. * @param directionToUpdate is the direction vector to update with the result
  85854. * @param particle is the particle we are computed the direction for
  85855. */
  85856. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85857. /**
  85858. * Called by the particle System when the position is computed for the created particle.
  85859. * @param worldMatrix is the world matrix of the particle system
  85860. * @param positionToUpdate is the position vector to update with the result
  85861. * @param particle is the particle we are computed the position for
  85862. */
  85863. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85864. /**
  85865. * Clones the current emitter and returns a copy of it
  85866. * @returns the new emitter
  85867. */
  85868. clone(): ConeParticleEmitter;
  85869. /**
  85870. * Called by the GPUParticleSystem to setup the update shader
  85871. * @param effect defines the update shader
  85872. */
  85873. applyToShader(effect: Effect): void;
  85874. /**
  85875. * Returns a string to use to update the GPU particles update shader
  85876. * @returns a string containng the defines string
  85877. */
  85878. getEffectDefines(): string;
  85879. /**
  85880. * Returns the string "ConeParticleEmitter"
  85881. * @returns a string containing the class name
  85882. */
  85883. getClassName(): string;
  85884. /**
  85885. * Serializes the particle system to a JSON object.
  85886. * @returns the JSON object
  85887. */
  85888. serialize(): any;
  85889. /**
  85890. * Parse properties from a JSON object
  85891. * @param serializationObject defines the JSON object
  85892. */
  85893. parse(serializationObject: any): void;
  85894. }
  85895. }
  85896. declare module BABYLON {
  85897. /**
  85898. * Particle emitter emitting particles from the inside of a cylinder.
  85899. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85900. */
  85901. export class CylinderParticleEmitter implements IParticleEmitterType {
  85902. /**
  85903. * The radius of the emission cylinder.
  85904. */
  85905. radius: number;
  85906. /**
  85907. * The height of the emission cylinder.
  85908. */
  85909. height: number;
  85910. /**
  85911. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85912. */
  85913. radiusRange: number;
  85914. /**
  85915. * How much to randomize the particle direction [0-1].
  85916. */
  85917. directionRandomizer: number;
  85918. /**
  85919. * Creates a new instance CylinderParticleEmitter
  85920. * @param radius the radius of the emission cylinder (1 by default)
  85921. * @param height the height of the emission cylinder (1 by default)
  85922. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85923. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85924. */
  85925. constructor(
  85926. /**
  85927. * The radius of the emission cylinder.
  85928. */
  85929. radius?: number,
  85930. /**
  85931. * The height of the emission cylinder.
  85932. */
  85933. height?: number,
  85934. /**
  85935. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85936. */
  85937. radiusRange?: number,
  85938. /**
  85939. * How much to randomize the particle direction [0-1].
  85940. */
  85941. directionRandomizer?: number);
  85942. /**
  85943. * Called by the particle System when the direction is computed for the created particle.
  85944. * @param worldMatrix is the world matrix of the particle system
  85945. * @param directionToUpdate is the direction vector to update with the result
  85946. * @param particle is the particle we are computed the direction for
  85947. */
  85948. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85949. /**
  85950. * Called by the particle System when the position is computed for the created particle.
  85951. * @param worldMatrix is the world matrix of the particle system
  85952. * @param positionToUpdate is the position vector to update with the result
  85953. * @param particle is the particle we are computed the position for
  85954. */
  85955. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85956. /**
  85957. * Clones the current emitter and returns a copy of it
  85958. * @returns the new emitter
  85959. */
  85960. clone(): CylinderParticleEmitter;
  85961. /**
  85962. * Called by the GPUParticleSystem to setup the update shader
  85963. * @param effect defines the update shader
  85964. */
  85965. applyToShader(effect: Effect): void;
  85966. /**
  85967. * Returns a string to use to update the GPU particles update shader
  85968. * @returns a string containng the defines string
  85969. */
  85970. getEffectDefines(): string;
  85971. /**
  85972. * Returns the string "CylinderParticleEmitter"
  85973. * @returns a string containing the class name
  85974. */
  85975. getClassName(): string;
  85976. /**
  85977. * Serializes the particle system to a JSON object.
  85978. * @returns the JSON object
  85979. */
  85980. serialize(): any;
  85981. /**
  85982. * Parse properties from a JSON object
  85983. * @param serializationObject defines the JSON object
  85984. */
  85985. parse(serializationObject: any): void;
  85986. }
  85987. /**
  85988. * Particle emitter emitting particles from the inside of a cylinder.
  85989. * It emits the particles randomly between two vectors.
  85990. */
  85991. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85992. /**
  85993. * The min limit of the emission direction.
  85994. */
  85995. direction1: Vector3;
  85996. /**
  85997. * The max limit of the emission direction.
  85998. */
  85999. direction2: Vector3;
  86000. /**
  86001. * Creates a new instance CylinderDirectedParticleEmitter
  86002. * @param radius the radius of the emission cylinder (1 by default)
  86003. * @param height the height of the emission cylinder (1 by default)
  86004. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86005. * @param direction1 the min limit of the emission direction (up vector by default)
  86006. * @param direction2 the max limit of the emission direction (up vector by default)
  86007. */
  86008. constructor(radius?: number, height?: number, radiusRange?: number,
  86009. /**
  86010. * The min limit of the emission direction.
  86011. */
  86012. direction1?: Vector3,
  86013. /**
  86014. * The max limit of the emission direction.
  86015. */
  86016. direction2?: Vector3);
  86017. /**
  86018. * Called by the particle System when the direction is computed for the created particle.
  86019. * @param worldMatrix is the world matrix of the particle system
  86020. * @param directionToUpdate is the direction vector to update with the result
  86021. * @param particle is the particle we are computed the direction for
  86022. */
  86023. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86024. /**
  86025. * Clones the current emitter and returns a copy of it
  86026. * @returns the new emitter
  86027. */
  86028. clone(): CylinderDirectedParticleEmitter;
  86029. /**
  86030. * Called by the GPUParticleSystem to setup the update shader
  86031. * @param effect defines the update shader
  86032. */
  86033. applyToShader(effect: Effect): void;
  86034. /**
  86035. * Returns a string to use to update the GPU particles update shader
  86036. * @returns a string containng the defines string
  86037. */
  86038. getEffectDefines(): string;
  86039. /**
  86040. * Returns the string "CylinderDirectedParticleEmitter"
  86041. * @returns a string containing the class name
  86042. */
  86043. getClassName(): string;
  86044. /**
  86045. * Serializes the particle system to a JSON object.
  86046. * @returns the JSON object
  86047. */
  86048. serialize(): any;
  86049. /**
  86050. * Parse properties from a JSON object
  86051. * @param serializationObject defines the JSON object
  86052. */
  86053. parse(serializationObject: any): void;
  86054. }
  86055. }
  86056. declare module BABYLON {
  86057. /**
  86058. * Particle emitter emitting particles from the inside of a hemisphere.
  86059. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86060. */
  86061. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86062. /**
  86063. * The radius of the emission hemisphere.
  86064. */
  86065. radius: number;
  86066. /**
  86067. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86068. */
  86069. radiusRange: number;
  86070. /**
  86071. * How much to randomize the particle direction [0-1].
  86072. */
  86073. directionRandomizer: number;
  86074. /**
  86075. * Creates a new instance HemisphericParticleEmitter
  86076. * @param radius the radius of the emission hemisphere (1 by default)
  86077. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86078. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86079. */
  86080. constructor(
  86081. /**
  86082. * The radius of the emission hemisphere.
  86083. */
  86084. radius?: number,
  86085. /**
  86086. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86087. */
  86088. radiusRange?: number,
  86089. /**
  86090. * How much to randomize the particle direction [0-1].
  86091. */
  86092. directionRandomizer?: number);
  86093. /**
  86094. * Called by the particle System when the direction is computed for the created particle.
  86095. * @param worldMatrix is the world matrix of the particle system
  86096. * @param directionToUpdate is the direction vector to update with the result
  86097. * @param particle is the particle we are computed the direction for
  86098. */
  86099. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86100. /**
  86101. * Called by the particle System when the position is computed for the created particle.
  86102. * @param worldMatrix is the world matrix of the particle system
  86103. * @param positionToUpdate is the position vector to update with the result
  86104. * @param particle is the particle we are computed the position for
  86105. */
  86106. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86107. /**
  86108. * Clones the current emitter and returns a copy of it
  86109. * @returns the new emitter
  86110. */
  86111. clone(): HemisphericParticleEmitter;
  86112. /**
  86113. * Called by the GPUParticleSystem to setup the update shader
  86114. * @param effect defines the update shader
  86115. */
  86116. applyToShader(effect: Effect): void;
  86117. /**
  86118. * Returns a string to use to update the GPU particles update shader
  86119. * @returns a string containng the defines string
  86120. */
  86121. getEffectDefines(): string;
  86122. /**
  86123. * Returns the string "HemisphericParticleEmitter"
  86124. * @returns a string containing the class name
  86125. */
  86126. getClassName(): string;
  86127. /**
  86128. * Serializes the particle system to a JSON object.
  86129. * @returns the JSON object
  86130. */
  86131. serialize(): any;
  86132. /**
  86133. * Parse properties from a JSON object
  86134. * @param serializationObject defines the JSON object
  86135. */
  86136. parse(serializationObject: any): void;
  86137. }
  86138. }
  86139. declare module BABYLON {
  86140. /**
  86141. * Particle emitter emitting particles from a point.
  86142. * It emits the particles randomly between 2 given directions.
  86143. */
  86144. export class PointParticleEmitter implements IParticleEmitterType {
  86145. /**
  86146. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86147. */
  86148. direction1: Vector3;
  86149. /**
  86150. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86151. */
  86152. direction2: Vector3;
  86153. /**
  86154. * Creates a new instance PointParticleEmitter
  86155. */
  86156. constructor();
  86157. /**
  86158. * Called by the particle System when the direction is computed for the created particle.
  86159. * @param worldMatrix is the world matrix of the particle system
  86160. * @param directionToUpdate is the direction vector to update with the result
  86161. * @param particle is the particle we are computed the direction for
  86162. */
  86163. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86164. /**
  86165. * Called by the particle System when the position is computed for the created particle.
  86166. * @param worldMatrix is the world matrix of the particle system
  86167. * @param positionToUpdate is the position vector to update with the result
  86168. * @param particle is the particle we are computed the position for
  86169. */
  86170. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86171. /**
  86172. * Clones the current emitter and returns a copy of it
  86173. * @returns the new emitter
  86174. */
  86175. clone(): PointParticleEmitter;
  86176. /**
  86177. * Called by the GPUParticleSystem to setup the update shader
  86178. * @param effect defines the update shader
  86179. */
  86180. applyToShader(effect: Effect): void;
  86181. /**
  86182. * Returns a string to use to update the GPU particles update shader
  86183. * @returns a string containng the defines string
  86184. */
  86185. getEffectDefines(): string;
  86186. /**
  86187. * Returns the string "PointParticleEmitter"
  86188. * @returns a string containing the class name
  86189. */
  86190. getClassName(): string;
  86191. /**
  86192. * Serializes the particle system to a JSON object.
  86193. * @returns the JSON object
  86194. */
  86195. serialize(): any;
  86196. /**
  86197. * Parse properties from a JSON object
  86198. * @param serializationObject defines the JSON object
  86199. */
  86200. parse(serializationObject: any): void;
  86201. }
  86202. }
  86203. declare module BABYLON {
  86204. /**
  86205. * Particle emitter emitting particles from the inside of a sphere.
  86206. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86207. */
  86208. export class SphereParticleEmitter implements IParticleEmitterType {
  86209. /**
  86210. * The radius of the emission sphere.
  86211. */
  86212. radius: number;
  86213. /**
  86214. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86215. */
  86216. radiusRange: number;
  86217. /**
  86218. * How much to randomize the particle direction [0-1].
  86219. */
  86220. directionRandomizer: number;
  86221. /**
  86222. * Creates a new instance SphereParticleEmitter
  86223. * @param radius the radius of the emission sphere (1 by default)
  86224. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86225. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86226. */
  86227. constructor(
  86228. /**
  86229. * The radius of the emission sphere.
  86230. */
  86231. radius?: number,
  86232. /**
  86233. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86234. */
  86235. radiusRange?: number,
  86236. /**
  86237. * How much to randomize the particle direction [0-1].
  86238. */
  86239. directionRandomizer?: number);
  86240. /**
  86241. * Called by the particle System when the direction is computed for the created particle.
  86242. * @param worldMatrix is the world matrix of the particle system
  86243. * @param directionToUpdate is the direction vector to update with the result
  86244. * @param particle is the particle we are computed the direction for
  86245. */
  86246. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86247. /**
  86248. * Called by the particle System when the position is computed for the created particle.
  86249. * @param worldMatrix is the world matrix of the particle system
  86250. * @param positionToUpdate is the position vector to update with the result
  86251. * @param particle is the particle we are computed the position for
  86252. */
  86253. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86254. /**
  86255. * Clones the current emitter and returns a copy of it
  86256. * @returns the new emitter
  86257. */
  86258. clone(): SphereParticleEmitter;
  86259. /**
  86260. * Called by the GPUParticleSystem to setup the update shader
  86261. * @param effect defines the update shader
  86262. */
  86263. applyToShader(effect: Effect): void;
  86264. /**
  86265. * Returns a string to use to update the GPU particles update shader
  86266. * @returns a string containng the defines string
  86267. */
  86268. getEffectDefines(): string;
  86269. /**
  86270. * Returns the string "SphereParticleEmitter"
  86271. * @returns a string containing the class name
  86272. */
  86273. getClassName(): string;
  86274. /**
  86275. * Serializes the particle system to a JSON object.
  86276. * @returns the JSON object
  86277. */
  86278. serialize(): any;
  86279. /**
  86280. * Parse properties from a JSON object
  86281. * @param serializationObject defines the JSON object
  86282. */
  86283. parse(serializationObject: any): void;
  86284. }
  86285. /**
  86286. * Particle emitter emitting particles from the inside of a sphere.
  86287. * It emits the particles randomly between two vectors.
  86288. */
  86289. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  86290. /**
  86291. * The min limit of the emission direction.
  86292. */
  86293. direction1: Vector3;
  86294. /**
  86295. * The max limit of the emission direction.
  86296. */
  86297. direction2: Vector3;
  86298. /**
  86299. * Creates a new instance SphereDirectedParticleEmitter
  86300. * @param radius the radius of the emission sphere (1 by default)
  86301. * @param direction1 the min limit of the emission direction (up vector by default)
  86302. * @param direction2 the max limit of the emission direction (up vector by default)
  86303. */
  86304. constructor(radius?: number,
  86305. /**
  86306. * The min limit of the emission direction.
  86307. */
  86308. direction1?: Vector3,
  86309. /**
  86310. * The max limit of the emission direction.
  86311. */
  86312. direction2?: Vector3);
  86313. /**
  86314. * Called by the particle System when the direction is computed for the created particle.
  86315. * @param worldMatrix is the world matrix of the particle system
  86316. * @param directionToUpdate is the direction vector to update with the result
  86317. * @param particle is the particle we are computed the direction for
  86318. */
  86319. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86320. /**
  86321. * Clones the current emitter and returns a copy of it
  86322. * @returns the new emitter
  86323. */
  86324. clone(): SphereDirectedParticleEmitter;
  86325. /**
  86326. * Called by the GPUParticleSystem to setup the update shader
  86327. * @param effect defines the update shader
  86328. */
  86329. applyToShader(effect: Effect): void;
  86330. /**
  86331. * Returns a string to use to update the GPU particles update shader
  86332. * @returns a string containng the defines string
  86333. */
  86334. getEffectDefines(): string;
  86335. /**
  86336. * Returns the string "SphereDirectedParticleEmitter"
  86337. * @returns a string containing the class name
  86338. */
  86339. getClassName(): string;
  86340. /**
  86341. * Serializes the particle system to a JSON object.
  86342. * @returns the JSON object
  86343. */
  86344. serialize(): any;
  86345. /**
  86346. * Parse properties from a JSON object
  86347. * @param serializationObject defines the JSON object
  86348. */
  86349. parse(serializationObject: any): void;
  86350. }
  86351. }
  86352. declare module BABYLON {
  86353. /**
  86354. * Interface representing a particle system in Babylon.js.
  86355. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86356. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86357. */
  86358. export interface IParticleSystem {
  86359. /**
  86360. * List of animations used by the particle system.
  86361. */
  86362. animations: Animation[];
  86363. /**
  86364. * The id of the Particle system.
  86365. */
  86366. id: string;
  86367. /**
  86368. * The name of the Particle system.
  86369. */
  86370. name: string;
  86371. /**
  86372. * The emitter represents the Mesh or position we are attaching the particle system to.
  86373. */
  86374. emitter: Nullable<AbstractMesh | Vector3>;
  86375. /**
  86376. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86377. */
  86378. isBillboardBased: boolean;
  86379. /**
  86380. * The rendering group used by the Particle system to chose when to render.
  86381. */
  86382. renderingGroupId: number;
  86383. /**
  86384. * The layer mask we are rendering the particles through.
  86385. */
  86386. layerMask: number;
  86387. /**
  86388. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86389. */
  86390. updateSpeed: number;
  86391. /**
  86392. * The amount of time the particle system is running (depends of the overall update speed).
  86393. */
  86394. targetStopDuration: number;
  86395. /**
  86396. * The texture used to render each particle. (this can be a spritesheet)
  86397. */
  86398. particleTexture: Nullable<Texture>;
  86399. /**
  86400. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86401. */
  86402. blendMode: number;
  86403. /**
  86404. * Minimum life time of emitting particles.
  86405. */
  86406. minLifeTime: number;
  86407. /**
  86408. * Maximum life time of emitting particles.
  86409. */
  86410. maxLifeTime: number;
  86411. /**
  86412. * Minimum Size of emitting particles.
  86413. */
  86414. minSize: number;
  86415. /**
  86416. * Maximum Size of emitting particles.
  86417. */
  86418. maxSize: number;
  86419. /**
  86420. * Minimum scale of emitting particles on X axis.
  86421. */
  86422. minScaleX: number;
  86423. /**
  86424. * Maximum scale of emitting particles on X axis.
  86425. */
  86426. maxScaleX: number;
  86427. /**
  86428. * Minimum scale of emitting particles on Y axis.
  86429. */
  86430. minScaleY: number;
  86431. /**
  86432. * Maximum scale of emitting particles on Y axis.
  86433. */
  86434. maxScaleY: number;
  86435. /**
  86436. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86437. */
  86438. color1: Color4;
  86439. /**
  86440. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86441. */
  86442. color2: Color4;
  86443. /**
  86444. * Color the particle will have at the end of its lifetime.
  86445. */
  86446. colorDead: Color4;
  86447. /**
  86448. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86449. */
  86450. emitRate: number;
  86451. /**
  86452. * You can use gravity if you want to give an orientation to your particles.
  86453. */
  86454. gravity: Vector3;
  86455. /**
  86456. * Minimum power of emitting particles.
  86457. */
  86458. minEmitPower: number;
  86459. /**
  86460. * Maximum power of emitting particles.
  86461. */
  86462. maxEmitPower: number;
  86463. /**
  86464. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86465. */
  86466. minAngularSpeed: number;
  86467. /**
  86468. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86469. */
  86470. maxAngularSpeed: number;
  86471. /**
  86472. * Gets or sets the minimal initial rotation in radians.
  86473. */
  86474. minInitialRotation: number;
  86475. /**
  86476. * Gets or sets the maximal initial rotation in radians.
  86477. */
  86478. maxInitialRotation: number;
  86479. /**
  86480. * The particle emitter type defines the emitter used by the particle system.
  86481. * It can be for example box, sphere, or cone...
  86482. */
  86483. particleEmitterType: Nullable<IParticleEmitterType>;
  86484. /**
  86485. * Defines the delay in milliseconds before starting the system (0 by default)
  86486. */
  86487. startDelay: number;
  86488. /**
  86489. * 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
  86490. */
  86491. preWarmCycles: number;
  86492. /**
  86493. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86494. */
  86495. preWarmStepOffset: number;
  86496. /**
  86497. * 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)
  86498. */
  86499. spriteCellChangeSpeed: number;
  86500. /**
  86501. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86502. */
  86503. startSpriteCellID: number;
  86504. /**
  86505. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86506. */
  86507. endSpriteCellID: number;
  86508. /**
  86509. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86510. */
  86511. spriteCellWidth: number;
  86512. /**
  86513. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86514. */
  86515. spriteCellHeight: number;
  86516. /**
  86517. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86518. */
  86519. spriteRandomStartCell: boolean;
  86520. /**
  86521. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86522. */
  86523. isAnimationSheetEnabled: boolean;
  86524. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86525. translationPivot: Vector2;
  86526. /**
  86527. * Gets or sets a texture used to add random noise to particle positions
  86528. */
  86529. noiseTexture: Nullable<BaseTexture>;
  86530. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86531. noiseStrength: Vector3;
  86532. /**
  86533. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86534. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86535. */
  86536. billboardMode: number;
  86537. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86538. limitVelocityDamping: number;
  86539. /**
  86540. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86541. */
  86542. beginAnimationOnStart: boolean;
  86543. /**
  86544. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86545. */
  86546. beginAnimationFrom: number;
  86547. /**
  86548. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86549. */
  86550. beginAnimationTo: number;
  86551. /**
  86552. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86553. */
  86554. beginAnimationLoop: boolean;
  86555. /**
  86556. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86557. */
  86558. disposeOnStop: boolean;
  86559. /**
  86560. * Gets the maximum number of particles active at the same time.
  86561. * @returns The max number of active particles.
  86562. */
  86563. getCapacity(): number;
  86564. /**
  86565. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86566. * @returns True if it has been started, otherwise false.
  86567. */
  86568. isStarted(): boolean;
  86569. /**
  86570. * Animates the particle system for this frame.
  86571. */
  86572. animate(): void;
  86573. /**
  86574. * Renders the particle system in its current state.
  86575. * @returns the current number of particles
  86576. */
  86577. render(): number;
  86578. /**
  86579. * Dispose the particle system and frees its associated resources.
  86580. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86581. */
  86582. dispose(disposeTexture?: boolean): void;
  86583. /**
  86584. * Clones the particle system.
  86585. * @param name The name of the cloned object
  86586. * @param newEmitter The new emitter to use
  86587. * @returns the cloned particle system
  86588. */
  86589. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86590. /**
  86591. * Serializes the particle system to a JSON object.
  86592. * @returns the JSON object
  86593. */
  86594. serialize(): any;
  86595. /**
  86596. * Rebuild the particle system
  86597. */
  86598. rebuild(): void;
  86599. /**
  86600. * Starts the particle system and begins to emit
  86601. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86602. */
  86603. start(delay?: number): void;
  86604. /**
  86605. * Stops the particle system.
  86606. */
  86607. stop(): void;
  86608. /**
  86609. * Remove all active particles
  86610. */
  86611. reset(): void;
  86612. /**
  86613. * Is this system ready to be used/rendered
  86614. * @return true if the system is ready
  86615. */
  86616. isReady(): boolean;
  86617. /**
  86618. * Adds a new color gradient
  86619. * @param gradient defines the gradient to use (between 0 and 1)
  86620. * @param color1 defines the color to affect to the specified gradient
  86621. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86622. * @returns the current particle system
  86623. */
  86624. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86625. /**
  86626. * Remove a specific color gradient
  86627. * @param gradient defines the gradient to remove
  86628. * @returns the current particle system
  86629. */
  86630. removeColorGradient(gradient: number): IParticleSystem;
  86631. /**
  86632. * Adds a new size gradient
  86633. * @param gradient defines the gradient to use (between 0 and 1)
  86634. * @param factor defines the size factor to affect to the specified gradient
  86635. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86636. * @returns the current particle system
  86637. */
  86638. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86639. /**
  86640. * Remove a specific size gradient
  86641. * @param gradient defines the gradient to remove
  86642. * @returns the current particle system
  86643. */
  86644. removeSizeGradient(gradient: number): IParticleSystem;
  86645. /**
  86646. * Gets the current list of color gradients.
  86647. * You must use addColorGradient and removeColorGradient to udpate this list
  86648. * @returns the list of color gradients
  86649. */
  86650. getColorGradients(): Nullable<Array<ColorGradient>>;
  86651. /**
  86652. * Gets the current list of size gradients.
  86653. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86654. * @returns the list of size gradients
  86655. */
  86656. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86657. /**
  86658. * Gets the current list of angular speed gradients.
  86659. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86660. * @returns the list of angular speed gradients
  86661. */
  86662. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86663. /**
  86664. * Adds a new angular speed gradient
  86665. * @param gradient defines the gradient to use (between 0 and 1)
  86666. * @param factor defines the angular speed to affect to the specified gradient
  86667. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86668. * @returns the current particle system
  86669. */
  86670. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86671. /**
  86672. * Remove a specific angular speed gradient
  86673. * @param gradient defines the gradient to remove
  86674. * @returns the current particle system
  86675. */
  86676. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86677. /**
  86678. * Gets the current list of velocity gradients.
  86679. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86680. * @returns the list of velocity gradients
  86681. */
  86682. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86683. /**
  86684. * Adds a new velocity gradient
  86685. * @param gradient defines the gradient to use (between 0 and 1)
  86686. * @param factor defines the velocity to affect to the specified gradient
  86687. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86688. * @returns the current particle system
  86689. */
  86690. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86691. /**
  86692. * Remove a specific velocity gradient
  86693. * @param gradient defines the gradient to remove
  86694. * @returns the current particle system
  86695. */
  86696. removeVelocityGradient(gradient: number): IParticleSystem;
  86697. /**
  86698. * Gets the current list of limit velocity gradients.
  86699. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86700. * @returns the list of limit velocity gradients
  86701. */
  86702. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86703. /**
  86704. * Adds a new limit velocity gradient
  86705. * @param gradient defines the gradient to use (between 0 and 1)
  86706. * @param factor defines the limit velocity to affect to the specified gradient
  86707. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86708. * @returns the current particle system
  86709. */
  86710. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86711. /**
  86712. * Remove a specific limit velocity gradient
  86713. * @param gradient defines the gradient to remove
  86714. * @returns the current particle system
  86715. */
  86716. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86717. /**
  86718. * Adds a new drag gradient
  86719. * @param gradient defines the gradient to use (between 0 and 1)
  86720. * @param factor defines the drag to affect to the specified gradient
  86721. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86722. * @returns the current particle system
  86723. */
  86724. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86725. /**
  86726. * Remove a specific drag gradient
  86727. * @param gradient defines the gradient to remove
  86728. * @returns the current particle system
  86729. */
  86730. removeDragGradient(gradient: number): IParticleSystem;
  86731. /**
  86732. * Gets the current list of drag gradients.
  86733. * You must use addDragGradient and removeDragGradient to udpate this list
  86734. * @returns the list of drag gradients
  86735. */
  86736. getDragGradients(): Nullable<Array<FactorGradient>>;
  86737. /**
  86738. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86739. * @param gradient defines the gradient to use (between 0 and 1)
  86740. * @param factor defines the emit rate to affect to the specified gradient
  86741. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86742. * @returns the current particle system
  86743. */
  86744. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86745. /**
  86746. * Remove a specific emit rate gradient
  86747. * @param gradient defines the gradient to remove
  86748. * @returns the current particle system
  86749. */
  86750. removeEmitRateGradient(gradient: number): IParticleSystem;
  86751. /**
  86752. * Gets the current list of emit rate gradients.
  86753. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86754. * @returns the list of emit rate gradients
  86755. */
  86756. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86757. /**
  86758. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86759. * @param gradient defines the gradient to use (between 0 and 1)
  86760. * @param factor defines the start size to affect to the specified gradient
  86761. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86762. * @returns the current particle system
  86763. */
  86764. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86765. /**
  86766. * Remove a specific start size gradient
  86767. * @param gradient defines the gradient to remove
  86768. * @returns the current particle system
  86769. */
  86770. removeStartSizeGradient(gradient: number): IParticleSystem;
  86771. /**
  86772. * Gets the current list of start size gradients.
  86773. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86774. * @returns the list of start size gradients
  86775. */
  86776. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86777. /**
  86778. * Adds a new life time gradient
  86779. * @param gradient defines the gradient to use (between 0 and 1)
  86780. * @param factor defines the life time factor to affect to the specified gradient
  86781. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86782. * @returns the current particle system
  86783. */
  86784. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86785. /**
  86786. * Remove a specific life time gradient
  86787. * @param gradient defines the gradient to remove
  86788. * @returns the current particle system
  86789. */
  86790. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86791. /**
  86792. * Gets the current list of life time gradients.
  86793. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86794. * @returns the list of life time gradients
  86795. */
  86796. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86797. /**
  86798. * Gets the current list of color gradients.
  86799. * You must use addColorGradient and removeColorGradient to udpate this list
  86800. * @returns the list of color gradients
  86801. */
  86802. getColorGradients(): Nullable<Array<ColorGradient>>;
  86803. /**
  86804. * Adds a new ramp gradient used to remap particle colors
  86805. * @param gradient defines the gradient to use (between 0 and 1)
  86806. * @param color defines the color to affect to the specified gradient
  86807. * @returns the current particle system
  86808. */
  86809. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86810. /**
  86811. * Gets the current list of ramp gradients.
  86812. * You must use addRampGradient and removeRampGradient to udpate this list
  86813. * @returns the list of ramp gradients
  86814. */
  86815. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86816. /** Gets or sets a boolean indicating that ramp gradients must be used
  86817. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86818. */
  86819. useRampGradients: boolean;
  86820. /**
  86821. * Adds a new color remap gradient
  86822. * @param gradient defines the gradient to use (between 0 and 1)
  86823. * @param min defines the color remap minimal range
  86824. * @param max defines the color remap maximal range
  86825. * @returns the current particle system
  86826. */
  86827. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86828. /**
  86829. * Gets the current list of color remap gradients.
  86830. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86831. * @returns the list of color remap gradients
  86832. */
  86833. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86834. /**
  86835. * Adds a new alpha remap gradient
  86836. * @param gradient defines the gradient to use (between 0 and 1)
  86837. * @param min defines the alpha remap minimal range
  86838. * @param max defines the alpha remap maximal range
  86839. * @returns the current particle system
  86840. */
  86841. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86842. /**
  86843. * Gets the current list of alpha remap gradients.
  86844. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86845. * @returns the list of alpha remap gradients
  86846. */
  86847. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86848. /**
  86849. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86850. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86851. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86852. * @returns the emitter
  86853. */
  86854. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86855. /**
  86856. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86857. * @param radius The radius of the hemisphere to emit from
  86858. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86859. * @returns the emitter
  86860. */
  86861. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86862. /**
  86863. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86864. * @param radius The radius of the sphere to emit from
  86865. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86866. * @returns the emitter
  86867. */
  86868. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86869. /**
  86870. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86871. * @param radius The radius of the sphere to emit from
  86872. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86873. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86874. * @returns the emitter
  86875. */
  86876. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86877. /**
  86878. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86879. * @param radius The radius of the emission cylinder
  86880. * @param height The height of the emission cylinder
  86881. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86882. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86883. * @returns the emitter
  86884. */
  86885. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86886. /**
  86887. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86888. * @param radius The radius of the cylinder to emit from
  86889. * @param height The height of the emission cylinder
  86890. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86891. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86892. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86893. * @returns the emitter
  86894. */
  86895. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86896. /**
  86897. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86898. * @param radius The radius of the cone to emit from
  86899. * @param angle The base angle of the cone
  86900. * @returns the emitter
  86901. */
  86902. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86903. /**
  86904. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86905. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86906. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86907. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86908. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86909. * @returns the emitter
  86910. */
  86911. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86912. /**
  86913. * Get hosting scene
  86914. * @returns the scene
  86915. */
  86916. getScene(): Scene;
  86917. }
  86918. }
  86919. declare module BABYLON {
  86920. /**
  86921. * Creates an instance based on a source mesh.
  86922. */
  86923. export class InstancedMesh extends AbstractMesh {
  86924. private _sourceMesh;
  86925. private _currentLOD;
  86926. /** @hidden */
  86927. _indexInSourceMeshInstanceArray: number;
  86928. constructor(name: string, source: Mesh);
  86929. /**
  86930. * Returns the string "InstancedMesh".
  86931. */
  86932. getClassName(): string;
  86933. /** Gets the list of lights affecting that mesh */
  86934. readonly lightSources: Light[];
  86935. _resyncLightSources(): void;
  86936. _resyncLighSource(light: Light): void;
  86937. _removeLightSource(light: Light, dispose: boolean): void;
  86938. /**
  86939. * If the source mesh receives shadows
  86940. */
  86941. readonly receiveShadows: boolean;
  86942. /**
  86943. * The material of the source mesh
  86944. */
  86945. readonly material: Nullable<Material>;
  86946. /**
  86947. * Visibility of the source mesh
  86948. */
  86949. readonly visibility: number;
  86950. /**
  86951. * Skeleton of the source mesh
  86952. */
  86953. readonly skeleton: Nullable<Skeleton>;
  86954. /**
  86955. * Rendering ground id of the source mesh
  86956. */
  86957. renderingGroupId: number;
  86958. /**
  86959. * Returns the total number of vertices (integer).
  86960. */
  86961. getTotalVertices(): number;
  86962. /**
  86963. * Returns a positive integer : the total number of indices in this mesh geometry.
  86964. * @returns the numner of indices or zero if the mesh has no geometry.
  86965. */
  86966. getTotalIndices(): number;
  86967. /**
  86968. * The source mesh of the instance
  86969. */
  86970. readonly sourceMesh: Mesh;
  86971. /**
  86972. * Is this node ready to be used/rendered
  86973. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  86974. * @return {boolean} is it ready
  86975. */
  86976. isReady(completeCheck?: boolean): boolean;
  86977. /**
  86978. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86979. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  86980. * @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.
  86981. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  86982. */
  86983. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  86984. /**
  86985. * Sets the vertex data of the mesh geometry for the requested `kind`.
  86986. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  86987. * The `data` are either a numeric array either a Float32Array.
  86988. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  86989. * 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).
  86990. * Note that a new underlying VertexBuffer object is created each call.
  86991. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  86992. *
  86993. * Possible `kind` values :
  86994. * - VertexBuffer.PositionKind
  86995. * - VertexBuffer.UVKind
  86996. * - VertexBuffer.UV2Kind
  86997. * - VertexBuffer.UV3Kind
  86998. * - VertexBuffer.UV4Kind
  86999. * - VertexBuffer.UV5Kind
  87000. * - VertexBuffer.UV6Kind
  87001. * - VertexBuffer.ColorKind
  87002. * - VertexBuffer.MatricesIndicesKind
  87003. * - VertexBuffer.MatricesIndicesExtraKind
  87004. * - VertexBuffer.MatricesWeightsKind
  87005. * - VertexBuffer.MatricesWeightsExtraKind
  87006. *
  87007. * Returns the Mesh.
  87008. */
  87009. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87010. /**
  87011. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87012. * If the mesh has no geometry, it is simply returned as it is.
  87013. * The `data` are either a numeric array either a Float32Array.
  87014. * No new underlying VertexBuffer object is created.
  87015. * 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.
  87016. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  87017. *
  87018. * Possible `kind` values :
  87019. * - VertexBuffer.PositionKind
  87020. * - VertexBuffer.UVKind
  87021. * - VertexBuffer.UV2Kind
  87022. * - VertexBuffer.UV3Kind
  87023. * - VertexBuffer.UV4Kind
  87024. * - VertexBuffer.UV5Kind
  87025. * - VertexBuffer.UV6Kind
  87026. * - VertexBuffer.ColorKind
  87027. * - VertexBuffer.MatricesIndicesKind
  87028. * - VertexBuffer.MatricesIndicesExtraKind
  87029. * - VertexBuffer.MatricesWeightsKind
  87030. * - VertexBuffer.MatricesWeightsExtraKind
  87031. *
  87032. * Returns the Mesh.
  87033. */
  87034. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  87035. /**
  87036. * Sets the mesh indices.
  87037. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  87038. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87039. * This method creates a new index buffer each call.
  87040. * Returns the Mesh.
  87041. */
  87042. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  87043. /**
  87044. * Boolean : True if the mesh owns the requested kind of data.
  87045. */
  87046. isVerticesDataPresent(kind: string): boolean;
  87047. /**
  87048. * Returns an array of indices (IndicesArray).
  87049. */
  87050. getIndices(): Nullable<IndicesArray>;
  87051. readonly _positions: Nullable<Vector3[]>;
  87052. /**
  87053. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87054. * This means the mesh underlying bounding box and sphere are recomputed.
  87055. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87056. * @returns the current mesh
  87057. */
  87058. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  87059. /** @hidden */
  87060. _preActivate(): InstancedMesh;
  87061. /** @hidden */
  87062. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87063. /** @hidden */
  87064. _postActivate(): void;
  87065. getWorldMatrix(): Matrix;
  87066. readonly isAnInstance: boolean;
  87067. /**
  87068. * Returns the current associated LOD AbstractMesh.
  87069. */
  87070. getLOD(camera: Camera): AbstractMesh;
  87071. /** @hidden */
  87072. _syncSubMeshes(): InstancedMesh;
  87073. /** @hidden */
  87074. _generatePointsArray(): boolean;
  87075. /**
  87076. * Creates a new InstancedMesh from the current mesh.
  87077. * - name (string) : the cloned mesh name
  87078. * - newParent (optional Node) : the optional Node to parent the clone to.
  87079. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  87080. *
  87081. * Returns the clone.
  87082. */
  87083. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87084. /**
  87085. * Disposes the InstancedMesh.
  87086. * Returns nothing.
  87087. */
  87088. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87089. }
  87090. interface Mesh {
  87091. /**
  87092. * Register a custom buffer that will be instanced
  87093. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87094. * @param kind defines the buffer kind
  87095. * @param stride defines the stride in floats
  87096. */
  87097. registerInstancedBuffer(kind: string, stride: number): void;
  87098. /** @hidden */
  87099. _userInstancedBuffersStorage: {
  87100. data: {
  87101. [key: string]: Float32Array;
  87102. };
  87103. sizes: {
  87104. [key: string]: number;
  87105. };
  87106. vertexBuffers: {
  87107. [key: string]: Nullable<VertexBuffer>;
  87108. };
  87109. strides: {
  87110. [key: string]: number;
  87111. };
  87112. };
  87113. }
  87114. interface AbstractMesh {
  87115. /**
  87116. * Object used to store instanced buffers defined by user
  87117. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87118. */
  87119. instancedBuffers: {
  87120. [key: string]: any;
  87121. };
  87122. }
  87123. }
  87124. declare module BABYLON {
  87125. /**
  87126. * Defines the options associated with the creation of a shader material.
  87127. */
  87128. export interface IShaderMaterialOptions {
  87129. /**
  87130. * Does the material work in alpha blend mode
  87131. */
  87132. needAlphaBlending: boolean;
  87133. /**
  87134. * Does the material work in alpha test mode
  87135. */
  87136. needAlphaTesting: boolean;
  87137. /**
  87138. * The list of attribute names used in the shader
  87139. */
  87140. attributes: string[];
  87141. /**
  87142. * The list of unifrom names used in the shader
  87143. */
  87144. uniforms: string[];
  87145. /**
  87146. * The list of UBO names used in the shader
  87147. */
  87148. uniformBuffers: string[];
  87149. /**
  87150. * The list of sampler names used in the shader
  87151. */
  87152. samplers: string[];
  87153. /**
  87154. * The list of defines used in the shader
  87155. */
  87156. defines: string[];
  87157. }
  87158. /**
  87159. * 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.
  87160. *
  87161. * This returned material effects how the mesh will look based on the code in the shaders.
  87162. *
  87163. * @see http://doc.babylonjs.com/how_to/shader_material
  87164. */
  87165. export class ShaderMaterial extends Material {
  87166. private _shaderPath;
  87167. private _options;
  87168. private _textures;
  87169. private _textureArrays;
  87170. private _floats;
  87171. private _ints;
  87172. private _floatsArrays;
  87173. private _colors3;
  87174. private _colors3Arrays;
  87175. private _colors4;
  87176. private _colors4Arrays;
  87177. private _vectors2;
  87178. private _vectors3;
  87179. private _vectors4;
  87180. private _matrices;
  87181. private _matrixArrays;
  87182. private _matrices3x3;
  87183. private _matrices2x2;
  87184. private _vectors2Arrays;
  87185. private _vectors3Arrays;
  87186. private _vectors4Arrays;
  87187. private _cachedWorldViewMatrix;
  87188. private _cachedWorldViewProjectionMatrix;
  87189. private _renderId;
  87190. /**
  87191. * Instantiate a new shader material.
  87192. * 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.
  87193. * This returned material effects how the mesh will look based on the code in the shaders.
  87194. * @see http://doc.babylonjs.com/how_to/shader_material
  87195. * @param name Define the name of the material in the scene
  87196. * @param scene Define the scene the material belongs to
  87197. * @param shaderPath Defines the route to the shader code in one of three ways:
  87198. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  87199. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  87200. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  87201. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  87202. * @param options Define the options used to create the shader
  87203. */
  87204. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  87205. /**
  87206. * Gets the shader path used to define the shader code
  87207. * It can be modified to trigger a new compilation
  87208. */
  87209. /**
  87210. * Sets the shader path used to define the shader code
  87211. * It can be modified to trigger a new compilation
  87212. */
  87213. shaderPath: any;
  87214. /**
  87215. * Gets the options used to compile the shader.
  87216. * They can be modified to trigger a new compilation
  87217. */
  87218. readonly options: IShaderMaterialOptions;
  87219. /**
  87220. * Gets the current class name of the material e.g. "ShaderMaterial"
  87221. * Mainly use in serialization.
  87222. * @returns the class name
  87223. */
  87224. getClassName(): string;
  87225. /**
  87226. * Specifies if the material will require alpha blending
  87227. * @returns a boolean specifying if alpha blending is needed
  87228. */
  87229. needAlphaBlending(): boolean;
  87230. /**
  87231. * Specifies if this material should be rendered in alpha test mode
  87232. * @returns a boolean specifying if an alpha test is needed.
  87233. */
  87234. needAlphaTesting(): boolean;
  87235. private _checkUniform;
  87236. /**
  87237. * Set a texture in the shader.
  87238. * @param name Define the name of the uniform samplers as defined in the shader
  87239. * @param texture Define the texture to bind to this sampler
  87240. * @return the material itself allowing "fluent" like uniform updates
  87241. */
  87242. setTexture(name: string, texture: Texture): ShaderMaterial;
  87243. /**
  87244. * Set a texture array in the shader.
  87245. * @param name Define the name of the uniform sampler array as defined in the shader
  87246. * @param textures Define the list of textures to bind to this sampler
  87247. * @return the material itself allowing "fluent" like uniform updates
  87248. */
  87249. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  87250. /**
  87251. * Set a float in the shader.
  87252. * @param name Define the name of the uniform as defined in the shader
  87253. * @param value Define the value to give to the uniform
  87254. * @return the material itself allowing "fluent" like uniform updates
  87255. */
  87256. setFloat(name: string, value: number): ShaderMaterial;
  87257. /**
  87258. * Set a int in the shader.
  87259. * @param name Define the name of the uniform as defined in the shader
  87260. * @param value Define the value to give to the uniform
  87261. * @return the material itself allowing "fluent" like uniform updates
  87262. */
  87263. setInt(name: string, value: number): ShaderMaterial;
  87264. /**
  87265. * Set an array of floats in the shader.
  87266. * @param name Define the name of the uniform as defined in the shader
  87267. * @param value Define the value to give to the uniform
  87268. * @return the material itself allowing "fluent" like uniform updates
  87269. */
  87270. setFloats(name: string, value: number[]): ShaderMaterial;
  87271. /**
  87272. * Set a vec3 in the shader from a Color3.
  87273. * @param name Define the name of the uniform as defined in the shader
  87274. * @param value Define the value to give to the uniform
  87275. * @return the material itself allowing "fluent" like uniform updates
  87276. */
  87277. setColor3(name: string, value: Color3): ShaderMaterial;
  87278. /**
  87279. * Set a vec3 array in the shader from a Color3 array.
  87280. * @param name Define the name of the uniform as defined in the shader
  87281. * @param value Define the value to give to the uniform
  87282. * @return the material itself allowing "fluent" like uniform updates
  87283. */
  87284. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  87285. /**
  87286. * Set a vec4 in the shader from a Color4.
  87287. * @param name Define the name of the uniform as defined in the shader
  87288. * @param value Define the value to give to the uniform
  87289. * @return the material itself allowing "fluent" like uniform updates
  87290. */
  87291. setColor4(name: string, value: Color4): ShaderMaterial;
  87292. /**
  87293. * Set a vec4 array in the shader from a Color4 array.
  87294. * @param name Define the name of the uniform as defined in the shader
  87295. * @param value Define the value to give to the uniform
  87296. * @return the material itself allowing "fluent" like uniform updates
  87297. */
  87298. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  87299. /**
  87300. * Set a vec2 in the shader from a Vector2.
  87301. * @param name Define the name of the uniform as defined in the shader
  87302. * @param value Define the value to give to the uniform
  87303. * @return the material itself allowing "fluent" like uniform updates
  87304. */
  87305. setVector2(name: string, value: Vector2): ShaderMaterial;
  87306. /**
  87307. * Set a vec3 in the shader from a Vector3.
  87308. * @param name Define the name of the uniform as defined in the shader
  87309. * @param value Define the value to give to the uniform
  87310. * @return the material itself allowing "fluent" like uniform updates
  87311. */
  87312. setVector3(name: string, value: Vector3): ShaderMaterial;
  87313. /**
  87314. * Set a vec4 in the shader from a Vector4.
  87315. * @param name Define the name of the uniform as defined in the shader
  87316. * @param value Define the value to give to the uniform
  87317. * @return the material itself allowing "fluent" like uniform updates
  87318. */
  87319. setVector4(name: string, value: Vector4): ShaderMaterial;
  87320. /**
  87321. * Set a mat4 in the shader from a Matrix.
  87322. * @param name Define the name of the uniform as defined in the shader
  87323. * @param value Define the value to give to the uniform
  87324. * @return the material itself allowing "fluent" like uniform updates
  87325. */
  87326. setMatrix(name: string, value: Matrix): ShaderMaterial;
  87327. /**
  87328. * Set a float32Array in the shader from a matrix array.
  87329. * @param name Define the name of the uniform as defined in the shader
  87330. * @param value Define the value to give to the uniform
  87331. * @return the material itself allowing "fluent" like uniform updates
  87332. */
  87333. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  87334. /**
  87335. * Set a mat3 in the shader from a Float32Array.
  87336. * @param name Define the name of the uniform as defined in the shader
  87337. * @param value Define the value to give to the uniform
  87338. * @return the material itself allowing "fluent" like uniform updates
  87339. */
  87340. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  87341. /**
  87342. * Set a mat2 in the shader from a Float32Array.
  87343. * @param name Define the name of the uniform as defined in the shader
  87344. * @param value Define the value to give to the uniform
  87345. * @return the material itself allowing "fluent" like uniform updates
  87346. */
  87347. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  87348. /**
  87349. * Set a vec2 array in the shader from a number array.
  87350. * @param name Define the name of the uniform as defined in the shader
  87351. * @param value Define the value to give to the uniform
  87352. * @return the material itself allowing "fluent" like uniform updates
  87353. */
  87354. setArray2(name: string, value: number[]): ShaderMaterial;
  87355. /**
  87356. * Set a vec3 array in the shader from a number array.
  87357. * @param name Define the name of the uniform as defined in the shader
  87358. * @param value Define the value to give to the uniform
  87359. * @return the material itself allowing "fluent" like uniform updates
  87360. */
  87361. setArray3(name: string, value: number[]): ShaderMaterial;
  87362. /**
  87363. * Set a vec4 array in the shader from a number array.
  87364. * @param name Define the name of the uniform as defined in the shader
  87365. * @param value Define the value to give to the uniform
  87366. * @return the material itself allowing "fluent" like uniform updates
  87367. */
  87368. setArray4(name: string, value: number[]): ShaderMaterial;
  87369. private _checkCache;
  87370. /**
  87371. * Specifies that the submesh is ready to be used
  87372. * @param mesh defines the mesh to check
  87373. * @param subMesh defines which submesh to check
  87374. * @param useInstances specifies that instances should be used
  87375. * @returns a boolean indicating that the submesh is ready or not
  87376. */
  87377. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87378. /**
  87379. * Checks if the material is ready to render the requested mesh
  87380. * @param mesh Define the mesh to render
  87381. * @param useInstances Define whether or not the material is used with instances
  87382. * @returns true if ready, otherwise false
  87383. */
  87384. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87385. /**
  87386. * Binds the world matrix to the material
  87387. * @param world defines the world transformation matrix
  87388. */
  87389. bindOnlyWorldMatrix(world: Matrix): void;
  87390. /**
  87391. * Binds the material to the mesh
  87392. * @param world defines the world transformation matrix
  87393. * @param mesh defines the mesh to bind the material to
  87394. */
  87395. bind(world: Matrix, mesh?: Mesh): void;
  87396. /**
  87397. * Gets the active textures from the material
  87398. * @returns an array of textures
  87399. */
  87400. getActiveTextures(): BaseTexture[];
  87401. /**
  87402. * Specifies if the material uses a texture
  87403. * @param texture defines the texture to check against the material
  87404. * @returns a boolean specifying if the material uses the texture
  87405. */
  87406. hasTexture(texture: BaseTexture): boolean;
  87407. /**
  87408. * Makes a duplicate of the material, and gives it a new name
  87409. * @param name defines the new name for the duplicated material
  87410. * @returns the cloned material
  87411. */
  87412. clone(name: string): ShaderMaterial;
  87413. /**
  87414. * Disposes the material
  87415. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87416. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87417. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87418. */
  87419. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87420. /**
  87421. * Serializes this material in a JSON representation
  87422. * @returns the serialized material object
  87423. */
  87424. serialize(): any;
  87425. /**
  87426. * Creates a shader material from parsed shader material data
  87427. * @param source defines the JSON represnetation of the material
  87428. * @param scene defines the hosting scene
  87429. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87430. * @returns a new material
  87431. */
  87432. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  87433. }
  87434. }
  87435. declare module BABYLON {
  87436. /** @hidden */
  87437. export var colorPixelShader: {
  87438. name: string;
  87439. shader: string;
  87440. };
  87441. }
  87442. declare module BABYLON {
  87443. /** @hidden */
  87444. export var colorVertexShader: {
  87445. name: string;
  87446. shader: string;
  87447. };
  87448. }
  87449. declare module BABYLON {
  87450. /**
  87451. * Line mesh
  87452. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  87453. */
  87454. export class LinesMesh extends Mesh {
  87455. /**
  87456. * If vertex color should be applied to the mesh
  87457. */
  87458. readonly useVertexColor?: boolean | undefined;
  87459. /**
  87460. * If vertex alpha should be applied to the mesh
  87461. */
  87462. readonly useVertexAlpha?: boolean | undefined;
  87463. /**
  87464. * Color of the line (Default: White)
  87465. */
  87466. color: Color3;
  87467. /**
  87468. * Alpha of the line (Default: 1)
  87469. */
  87470. alpha: number;
  87471. /**
  87472. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87473. * This margin is expressed in world space coordinates, so its value may vary.
  87474. * Default value is 0.1
  87475. */
  87476. intersectionThreshold: number;
  87477. private _colorShader;
  87478. private color4;
  87479. /**
  87480. * Creates a new LinesMesh
  87481. * @param name defines the name
  87482. * @param scene defines the hosting scene
  87483. * @param parent defines the parent mesh if any
  87484. * @param source defines the optional source LinesMesh used to clone data from
  87485. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87486. * When false, achieved by calling a clone(), also passing False.
  87487. * This will make creation of children, recursive.
  87488. * @param useVertexColor defines if this LinesMesh supports vertex color
  87489. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  87490. */
  87491. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  87492. /**
  87493. * If vertex color should be applied to the mesh
  87494. */
  87495. useVertexColor?: boolean | undefined,
  87496. /**
  87497. * If vertex alpha should be applied to the mesh
  87498. */
  87499. useVertexAlpha?: boolean | undefined);
  87500. private _addClipPlaneDefine;
  87501. private _removeClipPlaneDefine;
  87502. isReady(): boolean;
  87503. /**
  87504. * Returns the string "LineMesh"
  87505. */
  87506. getClassName(): string;
  87507. /**
  87508. * @hidden
  87509. */
  87510. /**
  87511. * @hidden
  87512. */
  87513. material: Material;
  87514. /**
  87515. * @hidden
  87516. */
  87517. readonly checkCollisions: boolean;
  87518. /** @hidden */
  87519. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  87520. /** @hidden */
  87521. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  87522. /**
  87523. * Disposes of the line mesh
  87524. * @param doNotRecurse If children should be disposed
  87525. */
  87526. dispose(doNotRecurse?: boolean): void;
  87527. /**
  87528. * Returns a new LineMesh object cloned from the current one.
  87529. */
  87530. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87531. /**
  87532. * Creates a new InstancedLinesMesh object from the mesh model.
  87533. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87534. * @param name defines the name of the new instance
  87535. * @returns a new InstancedLinesMesh
  87536. */
  87537. createInstance(name: string): InstancedLinesMesh;
  87538. }
  87539. /**
  87540. * Creates an instance based on a source LinesMesh
  87541. */
  87542. export class InstancedLinesMesh extends InstancedMesh {
  87543. /**
  87544. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87545. * This margin is expressed in world space coordinates, so its value may vary.
  87546. * Initilized with the intersectionThreshold value of the source LinesMesh
  87547. */
  87548. intersectionThreshold: number;
  87549. constructor(name: string, source: LinesMesh);
  87550. /**
  87551. * Returns the string "InstancedLinesMesh".
  87552. */
  87553. getClassName(): string;
  87554. }
  87555. }
  87556. declare module BABYLON {
  87557. /** @hidden */
  87558. export var linePixelShader: {
  87559. name: string;
  87560. shader: string;
  87561. };
  87562. }
  87563. declare module BABYLON {
  87564. /** @hidden */
  87565. export var lineVertexShader: {
  87566. name: string;
  87567. shader: string;
  87568. };
  87569. }
  87570. declare module BABYLON {
  87571. interface AbstractMesh {
  87572. /**
  87573. * Gets the edgesRenderer associated with the mesh
  87574. */
  87575. edgesRenderer: Nullable<EdgesRenderer>;
  87576. }
  87577. interface LinesMesh {
  87578. /**
  87579. * Enables the edge rendering mode on the mesh.
  87580. * This mode makes the mesh edges visible
  87581. * @param epsilon defines the maximal distance between two angles to detect a face
  87582. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87583. * @returns the currentAbstractMesh
  87584. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87585. */
  87586. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87587. }
  87588. interface InstancedLinesMesh {
  87589. /**
  87590. * Enables the edge rendering mode on the mesh.
  87591. * This mode makes the mesh edges visible
  87592. * @param epsilon defines the maximal distance between two angles to detect a face
  87593. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87594. * @returns the current InstancedLinesMesh
  87595. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87596. */
  87597. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  87598. }
  87599. /**
  87600. * Defines the minimum contract an Edges renderer should follow.
  87601. */
  87602. export interface IEdgesRenderer extends IDisposable {
  87603. /**
  87604. * Gets or sets a boolean indicating if the edgesRenderer is active
  87605. */
  87606. isEnabled: boolean;
  87607. /**
  87608. * Renders the edges of the attached mesh,
  87609. */
  87610. render(): void;
  87611. /**
  87612. * Checks wether or not the edges renderer is ready to render.
  87613. * @return true if ready, otherwise false.
  87614. */
  87615. isReady(): boolean;
  87616. }
  87617. /**
  87618. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  87619. */
  87620. export class EdgesRenderer implements IEdgesRenderer {
  87621. /**
  87622. * Define the size of the edges with an orthographic camera
  87623. */
  87624. edgesWidthScalerForOrthographic: number;
  87625. /**
  87626. * Define the size of the edges with a perspective camera
  87627. */
  87628. edgesWidthScalerForPerspective: number;
  87629. protected _source: AbstractMesh;
  87630. protected _linesPositions: number[];
  87631. protected _linesNormals: number[];
  87632. protected _linesIndices: number[];
  87633. protected _epsilon: number;
  87634. protected _indicesCount: number;
  87635. protected _lineShader: ShaderMaterial;
  87636. protected _ib: DataBuffer;
  87637. protected _buffers: {
  87638. [key: string]: Nullable<VertexBuffer>;
  87639. };
  87640. protected _checkVerticesInsteadOfIndices: boolean;
  87641. private _meshRebuildObserver;
  87642. private _meshDisposeObserver;
  87643. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  87644. isEnabled: boolean;
  87645. /**
  87646. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  87647. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  87648. * @param source Mesh used to create edges
  87649. * @param epsilon sum of angles in adjacency to check for edge
  87650. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  87651. * @param generateEdgesLines - should generate Lines or only prepare resources.
  87652. */
  87653. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  87654. protected _prepareRessources(): void;
  87655. /** @hidden */
  87656. _rebuild(): void;
  87657. /**
  87658. * Releases the required resources for the edges renderer
  87659. */
  87660. dispose(): void;
  87661. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  87662. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  87663. /**
  87664. * Checks if the pair of p0 and p1 is en edge
  87665. * @param faceIndex
  87666. * @param edge
  87667. * @param faceNormals
  87668. * @param p0
  87669. * @param p1
  87670. * @private
  87671. */
  87672. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  87673. /**
  87674. * push line into the position, normal and index buffer
  87675. * @protected
  87676. */
  87677. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  87678. /**
  87679. * Generates lines edges from adjacencjes
  87680. * @private
  87681. */
  87682. _generateEdgesLines(): void;
  87683. /**
  87684. * Checks wether or not the edges renderer is ready to render.
  87685. * @return true if ready, otherwise false.
  87686. */
  87687. isReady(): boolean;
  87688. /**
  87689. * Renders the edges of the attached mesh,
  87690. */
  87691. render(): void;
  87692. }
  87693. /**
  87694. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  87695. */
  87696. export class LineEdgesRenderer extends EdgesRenderer {
  87697. /**
  87698. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  87699. * @param source LineMesh used to generate edges
  87700. * @param epsilon not important (specified angle for edge detection)
  87701. * @param checkVerticesInsteadOfIndices not important for LineMesh
  87702. */
  87703. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  87704. /**
  87705. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  87706. */
  87707. _generateEdgesLines(): void;
  87708. }
  87709. }
  87710. declare module BABYLON {
  87711. /**
  87712. * This represents the object necessary to create a rendering group.
  87713. * This is exclusively used and created by the rendering manager.
  87714. * To modify the behavior, you use the available helpers in your scene or meshes.
  87715. * @hidden
  87716. */
  87717. export class RenderingGroup {
  87718. index: number;
  87719. private static _zeroVector;
  87720. private _scene;
  87721. private _opaqueSubMeshes;
  87722. private _transparentSubMeshes;
  87723. private _alphaTestSubMeshes;
  87724. private _depthOnlySubMeshes;
  87725. private _particleSystems;
  87726. private _spriteManagers;
  87727. private _opaqueSortCompareFn;
  87728. private _alphaTestSortCompareFn;
  87729. private _transparentSortCompareFn;
  87730. private _renderOpaque;
  87731. private _renderAlphaTest;
  87732. private _renderTransparent;
  87733. /** @hidden */
  87734. _edgesRenderers: SmartArray<IEdgesRenderer>;
  87735. onBeforeTransparentRendering: () => void;
  87736. /**
  87737. * Set the opaque sort comparison function.
  87738. * If null the sub meshes will be render in the order they were created
  87739. */
  87740. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87741. /**
  87742. * Set the alpha test sort comparison function.
  87743. * If null the sub meshes will be render in the order they were created
  87744. */
  87745. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87746. /**
  87747. * Set the transparent sort comparison function.
  87748. * If null the sub meshes will be render in the order they were created
  87749. */
  87750. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87751. /**
  87752. * Creates a new rendering group.
  87753. * @param index The rendering group index
  87754. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  87755. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  87756. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  87757. */
  87758. 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>);
  87759. /**
  87760. * Render all the sub meshes contained in the group.
  87761. * @param customRenderFunction Used to override the default render behaviour of the group.
  87762. * @returns true if rendered some submeshes.
  87763. */
  87764. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  87765. /**
  87766. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  87767. * @param subMeshes The submeshes to render
  87768. */
  87769. private renderOpaqueSorted;
  87770. /**
  87771. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  87772. * @param subMeshes The submeshes to render
  87773. */
  87774. private renderAlphaTestSorted;
  87775. /**
  87776. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  87777. * @param subMeshes The submeshes to render
  87778. */
  87779. private renderTransparentSorted;
  87780. /**
  87781. * Renders the submeshes in a specified order.
  87782. * @param subMeshes The submeshes to sort before render
  87783. * @param sortCompareFn The comparison function use to sort
  87784. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  87785. * @param transparent Specifies to activate blending if true
  87786. */
  87787. private static renderSorted;
  87788. /**
  87789. * Renders the submeshes in the order they were dispatched (no sort applied).
  87790. * @param subMeshes The submeshes to render
  87791. */
  87792. private static renderUnsorted;
  87793. /**
  87794. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87795. * are rendered back to front if in the same alpha index.
  87796. *
  87797. * @param a The first submesh
  87798. * @param b The second submesh
  87799. * @returns The result of the comparison
  87800. */
  87801. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  87802. /**
  87803. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87804. * are rendered back to front.
  87805. *
  87806. * @param a The first submesh
  87807. * @param b The second submesh
  87808. * @returns The result of the comparison
  87809. */
  87810. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  87811. /**
  87812. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87813. * are rendered front to back (prevent overdraw).
  87814. *
  87815. * @param a The first submesh
  87816. * @param b The second submesh
  87817. * @returns The result of the comparison
  87818. */
  87819. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  87820. /**
  87821. * Resets the different lists of submeshes to prepare a new frame.
  87822. */
  87823. prepare(): void;
  87824. dispose(): void;
  87825. /**
  87826. * Inserts the submesh in its correct queue depending on its material.
  87827. * @param subMesh The submesh to dispatch
  87828. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87829. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87830. */
  87831. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87832. dispatchSprites(spriteManager: ISpriteManager): void;
  87833. dispatchParticles(particleSystem: IParticleSystem): void;
  87834. private _renderParticles;
  87835. private _renderSprites;
  87836. }
  87837. }
  87838. declare module BABYLON {
  87839. /**
  87840. * Interface describing the different options available in the rendering manager
  87841. * regarding Auto Clear between groups.
  87842. */
  87843. export interface IRenderingManagerAutoClearSetup {
  87844. /**
  87845. * Defines whether or not autoclear is enable.
  87846. */
  87847. autoClear: boolean;
  87848. /**
  87849. * Defines whether or not to autoclear the depth buffer.
  87850. */
  87851. depth: boolean;
  87852. /**
  87853. * Defines whether or not to autoclear the stencil buffer.
  87854. */
  87855. stencil: boolean;
  87856. }
  87857. /**
  87858. * This class is used by the onRenderingGroupObservable
  87859. */
  87860. export class RenderingGroupInfo {
  87861. /**
  87862. * The Scene that being rendered
  87863. */
  87864. scene: Scene;
  87865. /**
  87866. * The camera currently used for the rendering pass
  87867. */
  87868. camera: Nullable<Camera>;
  87869. /**
  87870. * The ID of the renderingGroup being processed
  87871. */
  87872. renderingGroupId: number;
  87873. }
  87874. /**
  87875. * This is the manager responsible of all the rendering for meshes sprites and particles.
  87876. * It is enable to manage the different groups as well as the different necessary sort functions.
  87877. * This should not be used directly aside of the few static configurations
  87878. */
  87879. export class RenderingManager {
  87880. /**
  87881. * The max id used for rendering groups (not included)
  87882. */
  87883. static MAX_RENDERINGGROUPS: number;
  87884. /**
  87885. * The min id used for rendering groups (included)
  87886. */
  87887. static MIN_RENDERINGGROUPS: number;
  87888. /**
  87889. * Used to globally prevent autoclearing scenes.
  87890. */
  87891. static AUTOCLEAR: boolean;
  87892. /**
  87893. * @hidden
  87894. */
  87895. _useSceneAutoClearSetup: boolean;
  87896. private _scene;
  87897. private _renderingGroups;
  87898. private _depthStencilBufferAlreadyCleaned;
  87899. private _autoClearDepthStencil;
  87900. private _customOpaqueSortCompareFn;
  87901. private _customAlphaTestSortCompareFn;
  87902. private _customTransparentSortCompareFn;
  87903. private _renderingGroupInfo;
  87904. /**
  87905. * Instantiates a new rendering group for a particular scene
  87906. * @param scene Defines the scene the groups belongs to
  87907. */
  87908. constructor(scene: Scene);
  87909. private _clearDepthStencilBuffer;
  87910. /**
  87911. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  87912. * @hidden
  87913. */
  87914. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  87915. /**
  87916. * Resets the different information of the group to prepare a new frame
  87917. * @hidden
  87918. */
  87919. reset(): void;
  87920. /**
  87921. * Dispose and release the group and its associated resources.
  87922. * @hidden
  87923. */
  87924. dispose(): void;
  87925. /**
  87926. * Clear the info related to rendering groups preventing retention points during dispose.
  87927. */
  87928. freeRenderingGroups(): void;
  87929. private _prepareRenderingGroup;
  87930. /**
  87931. * Add a sprite manager to the rendering manager in order to render it this frame.
  87932. * @param spriteManager Define the sprite manager to render
  87933. */
  87934. dispatchSprites(spriteManager: ISpriteManager): void;
  87935. /**
  87936. * Add a particle system to the rendering manager in order to render it this frame.
  87937. * @param particleSystem Define the particle system to render
  87938. */
  87939. dispatchParticles(particleSystem: IParticleSystem): void;
  87940. /**
  87941. * Add a submesh to the manager in order to render it this frame
  87942. * @param subMesh The submesh to dispatch
  87943. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87944. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87945. */
  87946. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87947. /**
  87948. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  87949. * This allowed control for front to back rendering or reversly depending of the special needs.
  87950. *
  87951. * @param renderingGroupId The rendering group id corresponding to its index
  87952. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  87953. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  87954. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  87955. */
  87956. 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;
  87957. /**
  87958. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  87959. *
  87960. * @param renderingGroupId The rendering group id corresponding to its index
  87961. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  87962. * @param depth Automatically clears depth between groups if true and autoClear is true.
  87963. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  87964. */
  87965. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  87966. /**
  87967. * Gets the current auto clear configuration for one rendering group of the rendering
  87968. * manager.
  87969. * @param index the rendering group index to get the information for
  87970. * @returns The auto clear setup for the requested rendering group
  87971. */
  87972. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  87973. }
  87974. }
  87975. declare module BABYLON {
  87976. /**
  87977. * This Helps creating a texture that will be created from a camera in your scene.
  87978. * It is basically a dynamic texture that could be used to create special effects for instance.
  87979. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  87980. */
  87981. export class RenderTargetTexture extends Texture {
  87982. isCube: boolean;
  87983. /**
  87984. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  87985. */
  87986. static readonly REFRESHRATE_RENDER_ONCE: number;
  87987. /**
  87988. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  87989. */
  87990. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  87991. /**
  87992. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  87993. * the central point of your effect and can save a lot of performances.
  87994. */
  87995. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  87996. /**
  87997. * Use this predicate to dynamically define the list of mesh you want to render.
  87998. * If set, the renderList property will be overwritten.
  87999. */
  88000. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  88001. private _renderList;
  88002. /**
  88003. * Use this list to define the list of mesh you want to render.
  88004. */
  88005. renderList: Nullable<Array<AbstractMesh>>;
  88006. private _hookArray;
  88007. /**
  88008. * Define if particles should be rendered in your texture.
  88009. */
  88010. renderParticles: boolean;
  88011. /**
  88012. * Define if sprites should be rendered in your texture.
  88013. */
  88014. renderSprites: boolean;
  88015. /**
  88016. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  88017. */
  88018. coordinatesMode: number;
  88019. /**
  88020. * Define the camera used to render the texture.
  88021. */
  88022. activeCamera: Nullable<Camera>;
  88023. /**
  88024. * Override the render function of the texture with your own one.
  88025. */
  88026. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  88027. /**
  88028. * Define if camera post processes should be use while rendering the texture.
  88029. */
  88030. useCameraPostProcesses: boolean;
  88031. /**
  88032. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  88033. */
  88034. ignoreCameraViewport: boolean;
  88035. private _postProcessManager;
  88036. private _postProcesses;
  88037. private _resizeObserver;
  88038. /**
  88039. * An event triggered when the texture is unbind.
  88040. */
  88041. onBeforeBindObservable: Observable<RenderTargetTexture>;
  88042. /**
  88043. * An event triggered when the texture is unbind.
  88044. */
  88045. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  88046. private _onAfterUnbindObserver;
  88047. /**
  88048. * Set a after unbind callback in the texture.
  88049. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  88050. */
  88051. onAfterUnbind: () => void;
  88052. /**
  88053. * An event triggered before rendering the texture
  88054. */
  88055. onBeforeRenderObservable: Observable<number>;
  88056. private _onBeforeRenderObserver;
  88057. /**
  88058. * Set a before render callback in the texture.
  88059. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  88060. */
  88061. onBeforeRender: (faceIndex: number) => void;
  88062. /**
  88063. * An event triggered after rendering the texture
  88064. */
  88065. onAfterRenderObservable: Observable<number>;
  88066. private _onAfterRenderObserver;
  88067. /**
  88068. * Set a after render callback in the texture.
  88069. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  88070. */
  88071. onAfterRender: (faceIndex: number) => void;
  88072. /**
  88073. * An event triggered after the texture clear
  88074. */
  88075. onClearObservable: Observable<Engine>;
  88076. private _onClearObserver;
  88077. /**
  88078. * Set a clear callback in the texture.
  88079. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  88080. */
  88081. onClear: (Engine: Engine) => void;
  88082. /**
  88083. * An event triggered when the texture is resized.
  88084. */
  88085. onResizeObservable: Observable<RenderTargetTexture>;
  88086. /**
  88087. * Define the clear color of the Render Target if it should be different from the scene.
  88088. */
  88089. clearColor: Color4;
  88090. protected _size: number | {
  88091. width: number;
  88092. height: number;
  88093. };
  88094. protected _initialSizeParameter: number | {
  88095. width: number;
  88096. height: number;
  88097. } | {
  88098. ratio: number;
  88099. };
  88100. protected _sizeRatio: Nullable<number>;
  88101. /** @hidden */
  88102. _generateMipMaps: boolean;
  88103. protected _renderingManager: RenderingManager;
  88104. /** @hidden */
  88105. _waitingRenderList: string[];
  88106. protected _doNotChangeAspectRatio: boolean;
  88107. protected _currentRefreshId: number;
  88108. protected _refreshRate: number;
  88109. protected _textureMatrix: Matrix;
  88110. protected _samples: number;
  88111. protected _renderTargetOptions: RenderTargetCreationOptions;
  88112. /**
  88113. * Gets render target creation options that were used.
  88114. */
  88115. readonly renderTargetOptions: RenderTargetCreationOptions;
  88116. protected _engine: Engine;
  88117. protected _onRatioRescale(): void;
  88118. /**
  88119. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  88120. * It must define where the camera used to render the texture is set
  88121. */
  88122. boundingBoxPosition: Vector3;
  88123. private _boundingBoxSize;
  88124. /**
  88125. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  88126. * When defined, the cubemap will switch to local mode
  88127. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88128. * @example https://www.babylonjs-playground.com/#RNASML
  88129. */
  88130. boundingBoxSize: Vector3;
  88131. /**
  88132. * In case the RTT has been created with a depth texture, get the associated
  88133. * depth texture.
  88134. * Otherwise, return null.
  88135. */
  88136. depthStencilTexture: Nullable<InternalTexture>;
  88137. /**
  88138. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  88139. * or used a shadow, depth texture...
  88140. * @param name The friendly name of the texture
  88141. * @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)
  88142. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  88143. * @param generateMipMaps True if mip maps need to be generated after render.
  88144. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  88145. * @param type The type of the buffer in the RTT (int, half float, float...)
  88146. * @param isCube True if a cube texture needs to be created
  88147. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  88148. * @param generateDepthBuffer True to generate a depth buffer
  88149. * @param generateStencilBuffer True to generate a stencil buffer
  88150. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  88151. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  88152. * @param delayAllocation if the texture allocation should be delayed (default: false)
  88153. */
  88154. constructor(name: string, size: number | {
  88155. width: number;
  88156. height: number;
  88157. } | {
  88158. ratio: number;
  88159. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  88160. /**
  88161. * Creates a depth stencil texture.
  88162. * This is only available in WebGL 2 or with the depth texture extension available.
  88163. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  88164. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  88165. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  88166. */
  88167. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  88168. private _processSizeParameter;
  88169. /**
  88170. * Define the number of samples to use in case of MSAA.
  88171. * It defaults to one meaning no MSAA has been enabled.
  88172. */
  88173. samples: number;
  88174. /**
  88175. * Resets the refresh counter of the texture and start bak from scratch.
  88176. * Could be useful to regenerate the texture if it is setup to render only once.
  88177. */
  88178. resetRefreshCounter(): void;
  88179. /**
  88180. * Define the refresh rate of the texture or the rendering frequency.
  88181. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  88182. */
  88183. refreshRate: number;
  88184. /**
  88185. * Adds a post process to the render target rendering passes.
  88186. * @param postProcess define the post process to add
  88187. */
  88188. addPostProcess(postProcess: PostProcess): void;
  88189. /**
  88190. * Clear all the post processes attached to the render target
  88191. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  88192. */
  88193. clearPostProcesses(dispose?: boolean): void;
  88194. /**
  88195. * Remove one of the post process from the list of attached post processes to the texture
  88196. * @param postProcess define the post process to remove from the list
  88197. */
  88198. removePostProcess(postProcess: PostProcess): void;
  88199. /** @hidden */
  88200. _shouldRender(): boolean;
  88201. /**
  88202. * Gets the actual render size of the texture.
  88203. * @returns the width of the render size
  88204. */
  88205. getRenderSize(): number;
  88206. /**
  88207. * Gets the actual render width of the texture.
  88208. * @returns the width of the render size
  88209. */
  88210. getRenderWidth(): number;
  88211. /**
  88212. * Gets the actual render height of the texture.
  88213. * @returns the height of the render size
  88214. */
  88215. getRenderHeight(): number;
  88216. /**
  88217. * Get if the texture can be rescaled or not.
  88218. */
  88219. readonly canRescale: boolean;
  88220. /**
  88221. * Resize the texture using a ratio.
  88222. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  88223. */
  88224. scale(ratio: number): void;
  88225. /**
  88226. * Get the texture reflection matrix used to rotate/transform the reflection.
  88227. * @returns the reflection matrix
  88228. */
  88229. getReflectionTextureMatrix(): Matrix;
  88230. /**
  88231. * Resize the texture to a new desired size.
  88232. * Be carrefull as it will recreate all the data in the new texture.
  88233. * @param size Define the new size. It can be:
  88234. * - a number for squared texture,
  88235. * - an object containing { width: number, height: number }
  88236. * - or an object containing a ratio { ratio: number }
  88237. */
  88238. resize(size: number | {
  88239. width: number;
  88240. height: number;
  88241. } | {
  88242. ratio: number;
  88243. }): void;
  88244. /**
  88245. * Renders all the objects from the render list into the texture.
  88246. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  88247. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  88248. */
  88249. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  88250. private _bestReflectionRenderTargetDimension;
  88251. /**
  88252. * @hidden
  88253. * @param faceIndex face index to bind to if this is a cubetexture
  88254. */
  88255. _bindFrameBuffer(faceIndex?: number): void;
  88256. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  88257. private renderToTarget;
  88258. /**
  88259. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88260. * This allowed control for front to back rendering or reversly depending of the special needs.
  88261. *
  88262. * @param renderingGroupId The rendering group id corresponding to its index
  88263. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88264. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88265. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88266. */
  88267. 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;
  88268. /**
  88269. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88270. *
  88271. * @param renderingGroupId The rendering group id corresponding to its index
  88272. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88273. */
  88274. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  88275. /**
  88276. * Clones the texture.
  88277. * @returns the cloned texture
  88278. */
  88279. clone(): RenderTargetTexture;
  88280. /**
  88281. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  88282. * @returns The JSON representation of the texture
  88283. */
  88284. serialize(): any;
  88285. /**
  88286. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  88287. */
  88288. disposeFramebufferObjects(): void;
  88289. /**
  88290. * Dispose the texture and release its associated resources.
  88291. */
  88292. dispose(): void;
  88293. /** @hidden */
  88294. _rebuild(): void;
  88295. /**
  88296. * Clear the info related to rendering groups preventing retention point in material dispose.
  88297. */
  88298. freeRenderingGroups(): void;
  88299. /**
  88300. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  88301. * @returns the view count
  88302. */
  88303. getViewCount(): number;
  88304. }
  88305. }
  88306. declare module BABYLON {
  88307. /**
  88308. * Options for compiling materials.
  88309. */
  88310. export interface IMaterialCompilationOptions {
  88311. /**
  88312. * Defines whether clip planes are enabled.
  88313. */
  88314. clipPlane: boolean;
  88315. /**
  88316. * Defines whether instances are enabled.
  88317. */
  88318. useInstances: boolean;
  88319. }
  88320. /**
  88321. * Base class for the main features of a material in Babylon.js
  88322. */
  88323. export class Material implements IAnimatable {
  88324. /**
  88325. * Returns the triangle fill mode
  88326. */
  88327. static readonly TriangleFillMode: number;
  88328. /**
  88329. * Returns the wireframe mode
  88330. */
  88331. static readonly WireFrameFillMode: number;
  88332. /**
  88333. * Returns the point fill mode
  88334. */
  88335. static readonly PointFillMode: number;
  88336. /**
  88337. * Returns the point list draw mode
  88338. */
  88339. static readonly PointListDrawMode: number;
  88340. /**
  88341. * Returns the line list draw mode
  88342. */
  88343. static readonly LineListDrawMode: number;
  88344. /**
  88345. * Returns the line loop draw mode
  88346. */
  88347. static readonly LineLoopDrawMode: number;
  88348. /**
  88349. * Returns the line strip draw mode
  88350. */
  88351. static readonly LineStripDrawMode: number;
  88352. /**
  88353. * Returns the triangle strip draw mode
  88354. */
  88355. static readonly TriangleStripDrawMode: number;
  88356. /**
  88357. * Returns the triangle fan draw mode
  88358. */
  88359. static readonly TriangleFanDrawMode: number;
  88360. /**
  88361. * Stores the clock-wise side orientation
  88362. */
  88363. static readonly ClockWiseSideOrientation: number;
  88364. /**
  88365. * Stores the counter clock-wise side orientation
  88366. */
  88367. static readonly CounterClockWiseSideOrientation: number;
  88368. /**
  88369. * The dirty texture flag value
  88370. */
  88371. static readonly TextureDirtyFlag: number;
  88372. /**
  88373. * The dirty light flag value
  88374. */
  88375. static readonly LightDirtyFlag: number;
  88376. /**
  88377. * The dirty fresnel flag value
  88378. */
  88379. static readonly FresnelDirtyFlag: number;
  88380. /**
  88381. * The dirty attribute flag value
  88382. */
  88383. static readonly AttributesDirtyFlag: number;
  88384. /**
  88385. * The dirty misc flag value
  88386. */
  88387. static readonly MiscDirtyFlag: number;
  88388. /**
  88389. * The all dirty flag value
  88390. */
  88391. static readonly AllDirtyFlag: number;
  88392. /**
  88393. * The ID of the material
  88394. */
  88395. id: string;
  88396. /**
  88397. * Gets or sets the unique id of the material
  88398. */
  88399. uniqueId: number;
  88400. /**
  88401. * The name of the material
  88402. */
  88403. name: string;
  88404. /**
  88405. * Gets or sets user defined metadata
  88406. */
  88407. metadata: any;
  88408. /**
  88409. * For internal use only. Please do not use.
  88410. */
  88411. reservedDataStore: any;
  88412. /**
  88413. * Specifies if the ready state should be checked on each call
  88414. */
  88415. checkReadyOnEveryCall: boolean;
  88416. /**
  88417. * Specifies if the ready state should be checked once
  88418. */
  88419. checkReadyOnlyOnce: boolean;
  88420. /**
  88421. * The state of the material
  88422. */
  88423. state: string;
  88424. /**
  88425. * The alpha value of the material
  88426. */
  88427. protected _alpha: number;
  88428. /**
  88429. * List of inspectable custom properties (used by the Inspector)
  88430. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88431. */
  88432. inspectableCustomProperties: IInspectable[];
  88433. /**
  88434. * Sets the alpha value of the material
  88435. */
  88436. /**
  88437. * Gets the alpha value of the material
  88438. */
  88439. alpha: number;
  88440. /**
  88441. * Specifies if back face culling is enabled
  88442. */
  88443. protected _backFaceCulling: boolean;
  88444. /**
  88445. * Sets the back-face culling state
  88446. */
  88447. /**
  88448. * Gets the back-face culling state
  88449. */
  88450. backFaceCulling: boolean;
  88451. /**
  88452. * Stores the value for side orientation
  88453. */
  88454. sideOrientation: number;
  88455. /**
  88456. * Callback triggered when the material is compiled
  88457. */
  88458. onCompiled: Nullable<(effect: Effect) => void>;
  88459. /**
  88460. * Callback triggered when an error occurs
  88461. */
  88462. onError: Nullable<(effect: Effect, errors: string) => void>;
  88463. /**
  88464. * Callback triggered to get the render target textures
  88465. */
  88466. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  88467. /**
  88468. * Gets a boolean indicating that current material needs to register RTT
  88469. */
  88470. readonly hasRenderTargetTextures: boolean;
  88471. /**
  88472. * Specifies if the material should be serialized
  88473. */
  88474. doNotSerialize: boolean;
  88475. /**
  88476. * @hidden
  88477. */
  88478. _storeEffectOnSubMeshes: boolean;
  88479. /**
  88480. * Stores the animations for the material
  88481. */
  88482. animations: Nullable<Array<Animation>>;
  88483. /**
  88484. * An event triggered when the material is disposed
  88485. */
  88486. onDisposeObservable: Observable<Material>;
  88487. /**
  88488. * An observer which watches for dispose events
  88489. */
  88490. private _onDisposeObserver;
  88491. private _onUnBindObservable;
  88492. /**
  88493. * Called during a dispose event
  88494. */
  88495. onDispose: () => void;
  88496. private _onBindObservable;
  88497. /**
  88498. * An event triggered when the material is bound
  88499. */
  88500. readonly onBindObservable: Observable<AbstractMesh>;
  88501. /**
  88502. * An observer which watches for bind events
  88503. */
  88504. private _onBindObserver;
  88505. /**
  88506. * Called during a bind event
  88507. */
  88508. onBind: (Mesh: AbstractMesh) => void;
  88509. /**
  88510. * An event triggered when the material is unbound
  88511. */
  88512. readonly onUnBindObservable: Observable<Material>;
  88513. /**
  88514. * Stores the value of the alpha mode
  88515. */
  88516. private _alphaMode;
  88517. /**
  88518. * Sets the value of the alpha mode.
  88519. *
  88520. * | Value | Type | Description |
  88521. * | --- | --- | --- |
  88522. * | 0 | ALPHA_DISABLE | |
  88523. * | 1 | ALPHA_ADD | |
  88524. * | 2 | ALPHA_COMBINE | |
  88525. * | 3 | ALPHA_SUBTRACT | |
  88526. * | 4 | ALPHA_MULTIPLY | |
  88527. * | 5 | ALPHA_MAXIMIZED | |
  88528. * | 6 | ALPHA_ONEONE | |
  88529. * | 7 | ALPHA_PREMULTIPLIED | |
  88530. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  88531. * | 9 | ALPHA_INTERPOLATE | |
  88532. * | 10 | ALPHA_SCREENMODE | |
  88533. *
  88534. */
  88535. /**
  88536. * Gets the value of the alpha mode
  88537. */
  88538. alphaMode: number;
  88539. /**
  88540. * Stores the state of the need depth pre-pass value
  88541. */
  88542. private _needDepthPrePass;
  88543. /**
  88544. * Sets the need depth pre-pass value
  88545. */
  88546. /**
  88547. * Gets the depth pre-pass value
  88548. */
  88549. needDepthPrePass: boolean;
  88550. /**
  88551. * Specifies if depth writing should be disabled
  88552. */
  88553. disableDepthWrite: boolean;
  88554. /**
  88555. * Specifies if depth writing should be forced
  88556. */
  88557. forceDepthWrite: boolean;
  88558. /**
  88559. * Specifies if there should be a separate pass for culling
  88560. */
  88561. separateCullingPass: boolean;
  88562. /**
  88563. * Stores the state specifing if fog should be enabled
  88564. */
  88565. private _fogEnabled;
  88566. /**
  88567. * Sets the state for enabling fog
  88568. */
  88569. /**
  88570. * Gets the value of the fog enabled state
  88571. */
  88572. fogEnabled: boolean;
  88573. /**
  88574. * Stores the size of points
  88575. */
  88576. pointSize: number;
  88577. /**
  88578. * Stores the z offset value
  88579. */
  88580. zOffset: number;
  88581. /**
  88582. * Gets a value specifying if wireframe mode is enabled
  88583. */
  88584. /**
  88585. * Sets the state of wireframe mode
  88586. */
  88587. wireframe: boolean;
  88588. /**
  88589. * Gets the value specifying if point clouds are enabled
  88590. */
  88591. /**
  88592. * Sets the state of point cloud mode
  88593. */
  88594. pointsCloud: boolean;
  88595. /**
  88596. * Gets the material fill mode
  88597. */
  88598. /**
  88599. * Sets the material fill mode
  88600. */
  88601. fillMode: number;
  88602. /**
  88603. * @hidden
  88604. * Stores the effects for the material
  88605. */
  88606. _effect: Nullable<Effect>;
  88607. /**
  88608. * @hidden
  88609. * Specifies if the material was previously ready
  88610. */
  88611. _wasPreviouslyReady: boolean;
  88612. /**
  88613. * Specifies if uniform buffers should be used
  88614. */
  88615. private _useUBO;
  88616. /**
  88617. * Stores a reference to the scene
  88618. */
  88619. private _scene;
  88620. /**
  88621. * Stores the fill mode state
  88622. */
  88623. private _fillMode;
  88624. /**
  88625. * Specifies if the depth write state should be cached
  88626. */
  88627. private _cachedDepthWriteState;
  88628. /**
  88629. * Stores the uniform buffer
  88630. */
  88631. protected _uniformBuffer: UniformBuffer;
  88632. /** @hidden */
  88633. _indexInSceneMaterialArray: number;
  88634. /** @hidden */
  88635. meshMap: Nullable<{
  88636. [id: string]: AbstractMesh | undefined;
  88637. }>;
  88638. /**
  88639. * Creates a material instance
  88640. * @param name defines the name of the material
  88641. * @param scene defines the scene to reference
  88642. * @param doNotAdd specifies if the material should be added to the scene
  88643. */
  88644. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  88645. /**
  88646. * Returns a string representation of the current material
  88647. * @param fullDetails defines a boolean indicating which levels of logging is desired
  88648. * @returns a string with material information
  88649. */
  88650. toString(fullDetails?: boolean): string;
  88651. /**
  88652. * Gets the class name of the material
  88653. * @returns a string with the class name of the material
  88654. */
  88655. getClassName(): string;
  88656. /**
  88657. * Specifies if updates for the material been locked
  88658. */
  88659. readonly isFrozen: boolean;
  88660. /**
  88661. * Locks updates for the material
  88662. */
  88663. freeze(): void;
  88664. /**
  88665. * Unlocks updates for the material
  88666. */
  88667. unfreeze(): void;
  88668. /**
  88669. * Specifies if the material is ready to be used
  88670. * @param mesh defines the mesh to check
  88671. * @param useInstances specifies if instances should be used
  88672. * @returns a boolean indicating if the material is ready to be used
  88673. */
  88674. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88675. /**
  88676. * Specifies that the submesh is ready to be used
  88677. * @param mesh defines the mesh to check
  88678. * @param subMesh defines which submesh to check
  88679. * @param useInstances specifies that instances should be used
  88680. * @returns a boolean indicating that the submesh is ready or not
  88681. */
  88682. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88683. /**
  88684. * Returns the material effect
  88685. * @returns the effect associated with the material
  88686. */
  88687. getEffect(): Nullable<Effect>;
  88688. /**
  88689. * Returns the current scene
  88690. * @returns a Scene
  88691. */
  88692. getScene(): Scene;
  88693. /**
  88694. * Specifies if the material will require alpha blending
  88695. * @returns a boolean specifying if alpha blending is needed
  88696. */
  88697. needAlphaBlending(): boolean;
  88698. /**
  88699. * Specifies if the mesh will require alpha blending
  88700. * @param mesh defines the mesh to check
  88701. * @returns a boolean specifying if alpha blending is needed for the mesh
  88702. */
  88703. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  88704. /**
  88705. * Specifies if this material should be rendered in alpha test mode
  88706. * @returns a boolean specifying if an alpha test is needed.
  88707. */
  88708. needAlphaTesting(): boolean;
  88709. /**
  88710. * Gets the texture used for the alpha test
  88711. * @returns the texture to use for alpha testing
  88712. */
  88713. getAlphaTestTexture(): Nullable<BaseTexture>;
  88714. /**
  88715. * Marks the material to indicate that it needs to be re-calculated
  88716. */
  88717. markDirty(): void;
  88718. /** @hidden */
  88719. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  88720. /**
  88721. * Binds the material to the mesh
  88722. * @param world defines the world transformation matrix
  88723. * @param mesh defines the mesh to bind the material to
  88724. */
  88725. bind(world: Matrix, mesh?: Mesh): void;
  88726. /**
  88727. * Binds the submesh to the material
  88728. * @param world defines the world transformation matrix
  88729. * @param mesh defines the mesh containing the submesh
  88730. * @param subMesh defines the submesh to bind the material to
  88731. */
  88732. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  88733. /**
  88734. * Binds the world matrix to the material
  88735. * @param world defines the world transformation matrix
  88736. */
  88737. bindOnlyWorldMatrix(world: Matrix): void;
  88738. /**
  88739. * Binds the scene's uniform buffer to the effect.
  88740. * @param effect defines the effect to bind to the scene uniform buffer
  88741. * @param sceneUbo defines the uniform buffer storing scene data
  88742. */
  88743. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  88744. /**
  88745. * Binds the view matrix to the effect
  88746. * @param effect defines the effect to bind the view matrix to
  88747. */
  88748. bindView(effect: Effect): void;
  88749. /**
  88750. * Binds the view projection matrix to the effect
  88751. * @param effect defines the effect to bind the view projection matrix to
  88752. */
  88753. bindViewProjection(effect: Effect): void;
  88754. /**
  88755. * Specifies if material alpha testing should be turned on for the mesh
  88756. * @param mesh defines the mesh to check
  88757. */
  88758. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  88759. /**
  88760. * Processes to execute after binding the material to a mesh
  88761. * @param mesh defines the rendered mesh
  88762. */
  88763. protected _afterBind(mesh?: Mesh): void;
  88764. /**
  88765. * Unbinds the material from the mesh
  88766. */
  88767. unbind(): void;
  88768. /**
  88769. * Gets the active textures from the material
  88770. * @returns an array of textures
  88771. */
  88772. getActiveTextures(): BaseTexture[];
  88773. /**
  88774. * Specifies if the material uses a texture
  88775. * @param texture defines the texture to check against the material
  88776. * @returns a boolean specifying if the material uses the texture
  88777. */
  88778. hasTexture(texture: BaseTexture): boolean;
  88779. /**
  88780. * Makes a duplicate of the material, and gives it a new name
  88781. * @param name defines the new name for the duplicated material
  88782. * @returns the cloned material
  88783. */
  88784. clone(name: string): Nullable<Material>;
  88785. /**
  88786. * Gets the meshes bound to the material
  88787. * @returns an array of meshes bound to the material
  88788. */
  88789. getBindedMeshes(): AbstractMesh[];
  88790. /**
  88791. * Force shader compilation
  88792. * @param mesh defines the mesh associated with this material
  88793. * @param onCompiled defines a function to execute once the material is compiled
  88794. * @param options defines the options to configure the compilation
  88795. * @param onError defines a function to execute if the material fails compiling
  88796. */
  88797. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  88798. /**
  88799. * Force shader compilation
  88800. * @param mesh defines the mesh that will use this material
  88801. * @param options defines additional options for compiling the shaders
  88802. * @returns a promise that resolves when the compilation completes
  88803. */
  88804. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  88805. private static readonly _AllDirtyCallBack;
  88806. private static readonly _ImageProcessingDirtyCallBack;
  88807. private static readonly _TextureDirtyCallBack;
  88808. private static readonly _FresnelDirtyCallBack;
  88809. private static readonly _MiscDirtyCallBack;
  88810. private static readonly _LightsDirtyCallBack;
  88811. private static readonly _AttributeDirtyCallBack;
  88812. private static _FresnelAndMiscDirtyCallBack;
  88813. private static _TextureAndMiscDirtyCallBack;
  88814. private static readonly _DirtyCallbackArray;
  88815. private static readonly _RunDirtyCallBacks;
  88816. /**
  88817. * Marks a define in the material to indicate that it needs to be re-computed
  88818. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  88819. */
  88820. markAsDirty(flag: number): void;
  88821. /**
  88822. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  88823. * @param func defines a function which checks material defines against the submeshes
  88824. */
  88825. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  88826. /**
  88827. * Indicates that we need to re-calculated for all submeshes
  88828. */
  88829. protected _markAllSubMeshesAsAllDirty(): void;
  88830. /**
  88831. * Indicates that image processing needs to be re-calculated for all submeshes
  88832. */
  88833. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  88834. /**
  88835. * Indicates that textures need to be re-calculated for all submeshes
  88836. */
  88837. protected _markAllSubMeshesAsTexturesDirty(): void;
  88838. /**
  88839. * Indicates that fresnel needs to be re-calculated for all submeshes
  88840. */
  88841. protected _markAllSubMeshesAsFresnelDirty(): void;
  88842. /**
  88843. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  88844. */
  88845. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  88846. /**
  88847. * Indicates that lights need to be re-calculated for all submeshes
  88848. */
  88849. protected _markAllSubMeshesAsLightsDirty(): void;
  88850. /**
  88851. * Indicates that attributes need to be re-calculated for all submeshes
  88852. */
  88853. protected _markAllSubMeshesAsAttributesDirty(): void;
  88854. /**
  88855. * Indicates that misc needs to be re-calculated for all submeshes
  88856. */
  88857. protected _markAllSubMeshesAsMiscDirty(): void;
  88858. /**
  88859. * Indicates that textures and misc need to be re-calculated for all submeshes
  88860. */
  88861. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  88862. /**
  88863. * Disposes the material
  88864. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88865. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88866. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88867. */
  88868. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88869. /** @hidden */
  88870. private releaseVertexArrayObject;
  88871. /**
  88872. * Serializes this material
  88873. * @returns the serialized material object
  88874. */
  88875. serialize(): any;
  88876. /**
  88877. * Creates a material from parsed material data
  88878. * @param parsedMaterial defines parsed material data
  88879. * @param scene defines the hosting scene
  88880. * @param rootUrl defines the root URL to use to load textures
  88881. * @returns a new material
  88882. */
  88883. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  88884. }
  88885. }
  88886. declare module BABYLON {
  88887. /**
  88888. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88889. * separate meshes. This can be use to improve performances.
  88890. * @see http://doc.babylonjs.com/how_to/multi_materials
  88891. */
  88892. export class MultiMaterial extends Material {
  88893. private _subMaterials;
  88894. /**
  88895. * Gets or Sets the list of Materials used within the multi material.
  88896. * They need to be ordered according to the submeshes order in the associated mesh
  88897. */
  88898. subMaterials: Nullable<Material>[];
  88899. /**
  88900. * Function used to align with Node.getChildren()
  88901. * @returns the list of Materials used within the multi material
  88902. */
  88903. getChildren(): Nullable<Material>[];
  88904. /**
  88905. * Instantiates a new Multi Material
  88906. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88907. * separate meshes. This can be use to improve performances.
  88908. * @see http://doc.babylonjs.com/how_to/multi_materials
  88909. * @param name Define the name in the scene
  88910. * @param scene Define the scene the material belongs to
  88911. */
  88912. constructor(name: string, scene: Scene);
  88913. private _hookArray;
  88914. /**
  88915. * Get one of the submaterial by its index in the submaterials array
  88916. * @param index The index to look the sub material at
  88917. * @returns The Material if the index has been defined
  88918. */
  88919. getSubMaterial(index: number): Nullable<Material>;
  88920. /**
  88921. * Get the list of active textures for the whole sub materials list.
  88922. * @returns All the textures that will be used during the rendering
  88923. */
  88924. getActiveTextures(): BaseTexture[];
  88925. /**
  88926. * Gets the current class name of the material e.g. "MultiMaterial"
  88927. * Mainly use in serialization.
  88928. * @returns the class name
  88929. */
  88930. getClassName(): string;
  88931. /**
  88932. * Checks if the material is ready to render the requested sub mesh
  88933. * @param mesh Define the mesh the submesh belongs to
  88934. * @param subMesh Define the sub mesh to look readyness for
  88935. * @param useInstances Define whether or not the material is used with instances
  88936. * @returns true if ready, otherwise false
  88937. */
  88938. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88939. /**
  88940. * Clones the current material and its related sub materials
  88941. * @param name Define the name of the newly cloned material
  88942. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  88943. * @returns the cloned material
  88944. */
  88945. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  88946. /**
  88947. * Serializes the materials into a JSON representation.
  88948. * @returns the JSON representation
  88949. */
  88950. serialize(): any;
  88951. /**
  88952. * Dispose the material and release its associated resources
  88953. * @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)
  88954. * @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)
  88955. * @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)
  88956. */
  88957. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  88958. /**
  88959. * Creates a MultiMaterial from parsed MultiMaterial data.
  88960. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  88961. * @param scene defines the hosting scene
  88962. * @returns a new MultiMaterial
  88963. */
  88964. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  88965. }
  88966. }
  88967. declare module BABYLON {
  88968. /**
  88969. * Base class for submeshes
  88970. */
  88971. export class BaseSubMesh {
  88972. /** @hidden */
  88973. _materialDefines: Nullable<MaterialDefines>;
  88974. /** @hidden */
  88975. _materialEffect: Nullable<Effect>;
  88976. /**
  88977. * Gets associated effect
  88978. */
  88979. readonly effect: Nullable<Effect>;
  88980. /**
  88981. * Sets associated effect (effect used to render this submesh)
  88982. * @param effect defines the effect to associate with
  88983. * @param defines defines the set of defines used to compile this effect
  88984. */
  88985. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  88986. }
  88987. /**
  88988. * Defines a subdivision inside a mesh
  88989. */
  88990. export class SubMesh extends BaseSubMesh implements ICullable {
  88991. /** the material index to use */
  88992. materialIndex: number;
  88993. /** vertex index start */
  88994. verticesStart: number;
  88995. /** vertices count */
  88996. verticesCount: number;
  88997. /** index start */
  88998. indexStart: number;
  88999. /** indices count */
  89000. indexCount: number;
  89001. /** @hidden */
  89002. _linesIndexCount: number;
  89003. private _mesh;
  89004. private _renderingMesh;
  89005. private _boundingInfo;
  89006. private _linesIndexBuffer;
  89007. /** @hidden */
  89008. _lastColliderWorldVertices: Nullable<Vector3[]>;
  89009. /** @hidden */
  89010. _trianglePlanes: Plane[];
  89011. /** @hidden */
  89012. _lastColliderTransformMatrix: Nullable<Matrix>;
  89013. /** @hidden */
  89014. _renderId: number;
  89015. /** @hidden */
  89016. _alphaIndex: number;
  89017. /** @hidden */
  89018. _distanceToCamera: number;
  89019. /** @hidden */
  89020. _id: number;
  89021. private _currentMaterial;
  89022. /**
  89023. * Add a new submesh to a mesh
  89024. * @param materialIndex defines the material index to use
  89025. * @param verticesStart defines vertex index start
  89026. * @param verticesCount defines vertices count
  89027. * @param indexStart defines index start
  89028. * @param indexCount defines indices count
  89029. * @param mesh defines the parent mesh
  89030. * @param renderingMesh defines an optional rendering mesh
  89031. * @param createBoundingBox defines if bounding box should be created for this submesh
  89032. * @returns the new submesh
  89033. */
  89034. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  89035. /**
  89036. * Creates a new submesh
  89037. * @param materialIndex defines the material index to use
  89038. * @param verticesStart defines vertex index start
  89039. * @param verticesCount defines vertices count
  89040. * @param indexStart defines index start
  89041. * @param indexCount defines indices count
  89042. * @param mesh defines the parent mesh
  89043. * @param renderingMesh defines an optional rendering mesh
  89044. * @param createBoundingBox defines if bounding box should be created for this submesh
  89045. */
  89046. constructor(
  89047. /** the material index to use */
  89048. materialIndex: number,
  89049. /** vertex index start */
  89050. verticesStart: number,
  89051. /** vertices count */
  89052. verticesCount: number,
  89053. /** index start */
  89054. indexStart: number,
  89055. /** indices count */
  89056. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  89057. /**
  89058. * Returns true if this submesh covers the entire parent mesh
  89059. * @ignorenaming
  89060. */
  89061. readonly IsGlobal: boolean;
  89062. /**
  89063. * Returns the submesh BoudingInfo object
  89064. * @returns current bounding info (or mesh's one if the submesh is global)
  89065. */
  89066. getBoundingInfo(): BoundingInfo;
  89067. /**
  89068. * Sets the submesh BoundingInfo
  89069. * @param boundingInfo defines the new bounding info to use
  89070. * @returns the SubMesh
  89071. */
  89072. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  89073. /**
  89074. * Returns the mesh of the current submesh
  89075. * @return the parent mesh
  89076. */
  89077. getMesh(): AbstractMesh;
  89078. /**
  89079. * Returns the rendering mesh of the submesh
  89080. * @returns the rendering mesh (could be different from parent mesh)
  89081. */
  89082. getRenderingMesh(): Mesh;
  89083. /**
  89084. * Returns the submesh material
  89085. * @returns null or the current material
  89086. */
  89087. getMaterial(): Nullable<Material>;
  89088. /**
  89089. * Sets a new updated BoundingInfo object to the submesh
  89090. * @param data defines an optional position array to use to determine the bounding info
  89091. * @returns the SubMesh
  89092. */
  89093. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  89094. /** @hidden */
  89095. _checkCollision(collider: Collider): boolean;
  89096. /**
  89097. * Updates the submesh BoundingInfo
  89098. * @param world defines the world matrix to use to update the bounding info
  89099. * @returns the submesh
  89100. */
  89101. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  89102. /**
  89103. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  89104. * @param frustumPlanes defines the frustum planes
  89105. * @returns true if the submesh is intersecting with the frustum
  89106. */
  89107. isInFrustum(frustumPlanes: Plane[]): boolean;
  89108. /**
  89109. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  89110. * @param frustumPlanes defines the frustum planes
  89111. * @returns true if the submesh is inside the frustum
  89112. */
  89113. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  89114. /**
  89115. * Renders the submesh
  89116. * @param enableAlphaMode defines if alpha needs to be used
  89117. * @returns the submesh
  89118. */
  89119. render(enableAlphaMode: boolean): SubMesh;
  89120. /**
  89121. * @hidden
  89122. */
  89123. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  89124. /**
  89125. * Checks if the submesh intersects with a ray
  89126. * @param ray defines the ray to test
  89127. * @returns true is the passed ray intersects the submesh bounding box
  89128. */
  89129. canIntersects(ray: Ray): boolean;
  89130. /**
  89131. * Intersects current submesh with a ray
  89132. * @param ray defines the ray to test
  89133. * @param positions defines mesh's positions array
  89134. * @param indices defines mesh's indices array
  89135. * @param fastCheck defines if only bounding info should be used
  89136. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  89137. * @returns intersection info or null if no intersection
  89138. */
  89139. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  89140. /** @hidden */
  89141. private _intersectLines;
  89142. /** @hidden */
  89143. private _intersectUnIndexedLines;
  89144. /** @hidden */
  89145. private _intersectTriangles;
  89146. /** @hidden */
  89147. private _intersectUnIndexedTriangles;
  89148. /** @hidden */
  89149. _rebuild(): void;
  89150. /**
  89151. * Creates a new submesh from the passed mesh
  89152. * @param newMesh defines the new hosting mesh
  89153. * @param newRenderingMesh defines an optional rendering mesh
  89154. * @returns the new submesh
  89155. */
  89156. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  89157. /**
  89158. * Release associated resources
  89159. */
  89160. dispose(): void;
  89161. /**
  89162. * Gets the class name
  89163. * @returns the string "SubMesh".
  89164. */
  89165. getClassName(): string;
  89166. /**
  89167. * Creates a new submesh from indices data
  89168. * @param materialIndex the index of the main mesh material
  89169. * @param startIndex the index where to start the copy in the mesh indices array
  89170. * @param indexCount the number of indices to copy then from the startIndex
  89171. * @param mesh the main mesh to create the submesh from
  89172. * @param renderingMesh the optional rendering mesh
  89173. * @returns a new submesh
  89174. */
  89175. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  89176. }
  89177. }
  89178. declare module BABYLON {
  89179. /**
  89180. * Class used to represent data loading progression
  89181. */
  89182. export class SceneLoaderFlags {
  89183. private static _ForceFullSceneLoadingForIncremental;
  89184. private static _ShowLoadingScreen;
  89185. private static _CleanBoneMatrixWeights;
  89186. private static _loggingLevel;
  89187. /**
  89188. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  89189. */
  89190. static ForceFullSceneLoadingForIncremental: boolean;
  89191. /**
  89192. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  89193. */
  89194. static ShowLoadingScreen: boolean;
  89195. /**
  89196. * Defines the current logging level (while loading the scene)
  89197. * @ignorenaming
  89198. */
  89199. static loggingLevel: number;
  89200. /**
  89201. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  89202. */
  89203. static CleanBoneMatrixWeights: boolean;
  89204. }
  89205. }
  89206. declare module BABYLON {
  89207. /**
  89208. * Class used to store geometry data (vertex buffers + index buffer)
  89209. */
  89210. export class Geometry implements IGetSetVerticesData {
  89211. /**
  89212. * Gets or sets the ID of the geometry
  89213. */
  89214. id: string;
  89215. /**
  89216. * Gets or sets the unique ID of the geometry
  89217. */
  89218. uniqueId: number;
  89219. /**
  89220. * Gets the delay loading state of the geometry (none by default which means not delayed)
  89221. */
  89222. delayLoadState: number;
  89223. /**
  89224. * Gets the file containing the data to load when running in delay load state
  89225. */
  89226. delayLoadingFile: Nullable<string>;
  89227. /**
  89228. * Callback called when the geometry is updated
  89229. */
  89230. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  89231. private _scene;
  89232. private _engine;
  89233. private _meshes;
  89234. private _totalVertices;
  89235. /** @hidden */
  89236. _indices: IndicesArray;
  89237. /** @hidden */
  89238. _vertexBuffers: {
  89239. [key: string]: VertexBuffer;
  89240. };
  89241. private _isDisposed;
  89242. private _extend;
  89243. private _boundingBias;
  89244. /** @hidden */
  89245. _delayInfo: Array<string>;
  89246. private _indexBuffer;
  89247. private _indexBufferIsUpdatable;
  89248. /** @hidden */
  89249. _boundingInfo: Nullable<BoundingInfo>;
  89250. /** @hidden */
  89251. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  89252. /** @hidden */
  89253. _softwareSkinningFrameId: number;
  89254. private _vertexArrayObjects;
  89255. private _updatable;
  89256. /** @hidden */
  89257. _positions: Nullable<Vector3[]>;
  89258. /**
  89259. * 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
  89260. */
  89261. /**
  89262. * 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
  89263. */
  89264. boundingBias: Vector2;
  89265. /**
  89266. * Static function used to attach a new empty geometry to a mesh
  89267. * @param mesh defines the mesh to attach the geometry to
  89268. * @returns the new Geometry
  89269. */
  89270. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  89271. /**
  89272. * Creates a new geometry
  89273. * @param id defines the unique ID
  89274. * @param scene defines the hosting scene
  89275. * @param vertexData defines the VertexData used to get geometry data
  89276. * @param updatable defines if geometry must be updatable (false by default)
  89277. * @param mesh defines the mesh that will be associated with the geometry
  89278. */
  89279. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  89280. /**
  89281. * Gets the current extend of the geometry
  89282. */
  89283. readonly extend: {
  89284. minimum: Vector3;
  89285. maximum: Vector3;
  89286. };
  89287. /**
  89288. * Gets the hosting scene
  89289. * @returns the hosting Scene
  89290. */
  89291. getScene(): Scene;
  89292. /**
  89293. * Gets the hosting engine
  89294. * @returns the hosting Engine
  89295. */
  89296. getEngine(): Engine;
  89297. /**
  89298. * Defines if the geometry is ready to use
  89299. * @returns true if the geometry is ready to be used
  89300. */
  89301. isReady(): boolean;
  89302. /**
  89303. * Gets a value indicating that the geometry should not be serialized
  89304. */
  89305. readonly doNotSerialize: boolean;
  89306. /** @hidden */
  89307. _rebuild(): void;
  89308. /**
  89309. * Affects all geometry data in one call
  89310. * @param vertexData defines the geometry data
  89311. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  89312. */
  89313. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  89314. /**
  89315. * Set specific vertex data
  89316. * @param kind defines the data kind (Position, normal, etc...)
  89317. * @param data defines the vertex data to use
  89318. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89319. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89320. */
  89321. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  89322. /**
  89323. * Removes a specific vertex data
  89324. * @param kind defines the data kind (Position, normal, etc...)
  89325. */
  89326. removeVerticesData(kind: string): void;
  89327. /**
  89328. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  89329. * @param buffer defines the vertex buffer to use
  89330. * @param totalVertices defines the total number of vertices for position kind (could be null)
  89331. */
  89332. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  89333. /**
  89334. * Update a specific vertex buffer
  89335. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  89336. * It will do nothing if the buffer is not updatable
  89337. * @param kind defines the data kind (Position, normal, etc...)
  89338. * @param data defines the data to use
  89339. * @param offset defines the offset in the target buffer where to store the data
  89340. * @param useBytes set to true if the offset is in bytes
  89341. */
  89342. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  89343. /**
  89344. * Update a specific vertex buffer
  89345. * This function will create a new buffer if the current one is not updatable
  89346. * @param kind defines the data kind (Position, normal, etc...)
  89347. * @param data defines the data to use
  89348. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  89349. */
  89350. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  89351. private _updateBoundingInfo;
  89352. /** @hidden */
  89353. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  89354. /**
  89355. * Gets total number of vertices
  89356. * @returns the total number of vertices
  89357. */
  89358. getTotalVertices(): number;
  89359. /**
  89360. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89361. * @param kind defines the data kind (Position, normal, etc...)
  89362. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89363. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89364. * @returns a float array containing vertex data
  89365. */
  89366. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89367. /**
  89368. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  89369. * @param kind defines the data kind (Position, normal, etc...)
  89370. * @returns true if the vertex buffer with the specified kind is updatable
  89371. */
  89372. isVertexBufferUpdatable(kind: string): boolean;
  89373. /**
  89374. * Gets a specific vertex buffer
  89375. * @param kind defines the data kind (Position, normal, etc...)
  89376. * @returns a VertexBuffer
  89377. */
  89378. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89379. /**
  89380. * Returns all vertex buffers
  89381. * @return an object holding all vertex buffers indexed by kind
  89382. */
  89383. getVertexBuffers(): Nullable<{
  89384. [key: string]: VertexBuffer;
  89385. }>;
  89386. /**
  89387. * Gets a boolean indicating if specific vertex buffer is present
  89388. * @param kind defines the data kind (Position, normal, etc...)
  89389. * @returns true if data is present
  89390. */
  89391. isVerticesDataPresent(kind: string): boolean;
  89392. /**
  89393. * Gets a list of all attached data kinds (Position, normal, etc...)
  89394. * @returns a list of string containing all kinds
  89395. */
  89396. getVerticesDataKinds(): string[];
  89397. /**
  89398. * Update index buffer
  89399. * @param indices defines the indices to store in the index buffer
  89400. * @param offset defines the offset in the target buffer where to store the data
  89401. * @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)
  89402. */
  89403. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  89404. /**
  89405. * Creates a new index buffer
  89406. * @param indices defines the indices to store in the index buffer
  89407. * @param totalVertices defines the total number of vertices (could be null)
  89408. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89409. */
  89410. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  89411. /**
  89412. * Return the total number of indices
  89413. * @returns the total number of indices
  89414. */
  89415. getTotalIndices(): number;
  89416. /**
  89417. * Gets the index buffer array
  89418. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89419. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89420. * @returns the index buffer array
  89421. */
  89422. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89423. /**
  89424. * Gets the index buffer
  89425. * @return the index buffer
  89426. */
  89427. getIndexBuffer(): Nullable<DataBuffer>;
  89428. /** @hidden */
  89429. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  89430. /**
  89431. * Release the associated resources for a specific mesh
  89432. * @param mesh defines the source mesh
  89433. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  89434. */
  89435. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  89436. /**
  89437. * Apply current geometry to a given mesh
  89438. * @param mesh defines the mesh to apply geometry to
  89439. */
  89440. applyToMesh(mesh: Mesh): void;
  89441. private _updateExtend;
  89442. private _applyToMesh;
  89443. private notifyUpdate;
  89444. /**
  89445. * Load the geometry if it was flagged as delay loaded
  89446. * @param scene defines the hosting scene
  89447. * @param onLoaded defines a callback called when the geometry is loaded
  89448. */
  89449. load(scene: Scene, onLoaded?: () => void): void;
  89450. private _queueLoad;
  89451. /**
  89452. * Invert the geometry to move from a right handed system to a left handed one.
  89453. */
  89454. toLeftHanded(): void;
  89455. /** @hidden */
  89456. _resetPointsArrayCache(): void;
  89457. /** @hidden */
  89458. _generatePointsArray(): boolean;
  89459. /**
  89460. * Gets a value indicating if the geometry is disposed
  89461. * @returns true if the geometry was disposed
  89462. */
  89463. isDisposed(): boolean;
  89464. private _disposeVertexArrayObjects;
  89465. /**
  89466. * Free all associated resources
  89467. */
  89468. dispose(): void;
  89469. /**
  89470. * Clone the current geometry into a new geometry
  89471. * @param id defines the unique ID of the new geometry
  89472. * @returns a new geometry object
  89473. */
  89474. copy(id: string): Geometry;
  89475. /**
  89476. * Serialize the current geometry info (and not the vertices data) into a JSON object
  89477. * @return a JSON representation of the current geometry data (without the vertices data)
  89478. */
  89479. serialize(): any;
  89480. private toNumberArray;
  89481. /**
  89482. * Serialize all vertices data into a JSON oject
  89483. * @returns a JSON representation of the current geometry data
  89484. */
  89485. serializeVerticeData(): any;
  89486. /**
  89487. * Extracts a clone of a mesh geometry
  89488. * @param mesh defines the source mesh
  89489. * @param id defines the unique ID of the new geometry object
  89490. * @returns the new geometry object
  89491. */
  89492. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  89493. /**
  89494. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  89495. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89496. * Be aware Math.random() could cause collisions, but:
  89497. * "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"
  89498. * @returns a string containing a new GUID
  89499. */
  89500. static RandomId(): string;
  89501. /** @hidden */
  89502. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  89503. private static _CleanMatricesWeights;
  89504. /**
  89505. * Create a new geometry from persisted data (Using .babylon file format)
  89506. * @param parsedVertexData defines the persisted data
  89507. * @param scene defines the hosting scene
  89508. * @param rootUrl defines the root url to use to load assets (like delayed data)
  89509. * @returns the new geometry object
  89510. */
  89511. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  89512. }
  89513. }
  89514. declare module BABYLON {
  89515. /**
  89516. * Define an interface for all classes that will get and set the data on vertices
  89517. */
  89518. export interface IGetSetVerticesData {
  89519. /**
  89520. * Gets a boolean indicating if specific vertex data is present
  89521. * @param kind defines the vertex data kind to use
  89522. * @returns true is data kind is present
  89523. */
  89524. isVerticesDataPresent(kind: string): boolean;
  89525. /**
  89526. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89527. * @param kind defines the data kind (Position, normal, etc...)
  89528. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89529. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89530. * @returns a float array containing vertex data
  89531. */
  89532. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89533. /**
  89534. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89535. * @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.
  89536. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89537. * @returns the indices array or an empty array if the mesh has no geometry
  89538. */
  89539. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89540. /**
  89541. * Set specific vertex data
  89542. * @param kind defines the data kind (Position, normal, etc...)
  89543. * @param data defines the vertex data to use
  89544. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89545. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89546. */
  89547. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  89548. /**
  89549. * Update a specific associated vertex buffer
  89550. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89551. * - VertexBuffer.PositionKind
  89552. * - VertexBuffer.UVKind
  89553. * - VertexBuffer.UV2Kind
  89554. * - VertexBuffer.UV3Kind
  89555. * - VertexBuffer.UV4Kind
  89556. * - VertexBuffer.UV5Kind
  89557. * - VertexBuffer.UV6Kind
  89558. * - VertexBuffer.ColorKind
  89559. * - VertexBuffer.MatricesIndicesKind
  89560. * - VertexBuffer.MatricesIndicesExtraKind
  89561. * - VertexBuffer.MatricesWeightsKind
  89562. * - VertexBuffer.MatricesWeightsExtraKind
  89563. * @param data defines the data source
  89564. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89565. * @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)
  89566. */
  89567. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  89568. /**
  89569. * Creates a new index buffer
  89570. * @param indices defines the indices to store in the index buffer
  89571. * @param totalVertices defines the total number of vertices (could be null)
  89572. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89573. */
  89574. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  89575. }
  89576. /**
  89577. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  89578. */
  89579. export class VertexData {
  89580. /**
  89581. * Mesh side orientation : usually the external or front surface
  89582. */
  89583. static readonly FRONTSIDE: number;
  89584. /**
  89585. * Mesh side orientation : usually the internal or back surface
  89586. */
  89587. static readonly BACKSIDE: number;
  89588. /**
  89589. * Mesh side orientation : both internal and external or front and back surfaces
  89590. */
  89591. static readonly DOUBLESIDE: number;
  89592. /**
  89593. * Mesh side orientation : by default, `FRONTSIDE`
  89594. */
  89595. static readonly DEFAULTSIDE: number;
  89596. /**
  89597. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  89598. */
  89599. positions: Nullable<FloatArray>;
  89600. /**
  89601. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  89602. */
  89603. normals: Nullable<FloatArray>;
  89604. /**
  89605. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  89606. */
  89607. tangents: Nullable<FloatArray>;
  89608. /**
  89609. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89610. */
  89611. uvs: Nullable<FloatArray>;
  89612. /**
  89613. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89614. */
  89615. uvs2: Nullable<FloatArray>;
  89616. /**
  89617. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89618. */
  89619. uvs3: Nullable<FloatArray>;
  89620. /**
  89621. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89622. */
  89623. uvs4: Nullable<FloatArray>;
  89624. /**
  89625. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89626. */
  89627. uvs5: Nullable<FloatArray>;
  89628. /**
  89629. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89630. */
  89631. uvs6: Nullable<FloatArray>;
  89632. /**
  89633. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  89634. */
  89635. colors: Nullable<FloatArray>;
  89636. /**
  89637. * 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).
  89638. */
  89639. matricesIndices: Nullable<FloatArray>;
  89640. /**
  89641. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  89642. */
  89643. matricesWeights: Nullable<FloatArray>;
  89644. /**
  89645. * An array extending the number of possible indices
  89646. */
  89647. matricesIndicesExtra: Nullable<FloatArray>;
  89648. /**
  89649. * An array extending the number of possible weights when the number of indices is extended
  89650. */
  89651. matricesWeightsExtra: Nullable<FloatArray>;
  89652. /**
  89653. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  89654. */
  89655. indices: Nullable<IndicesArray>;
  89656. /**
  89657. * Uses the passed data array to set the set the values for the specified kind of data
  89658. * @param data a linear array of floating numbers
  89659. * @param kind the type of data that is being set, eg positions, colors etc
  89660. */
  89661. set(data: FloatArray, kind: string): void;
  89662. /**
  89663. * Associates the vertexData to the passed Mesh.
  89664. * Sets it as updatable or not (default `false`)
  89665. * @param mesh the mesh the vertexData is applied to
  89666. * @param updatable when used and having the value true allows new data to update the vertexData
  89667. * @returns the VertexData
  89668. */
  89669. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  89670. /**
  89671. * Associates the vertexData to the passed Geometry.
  89672. * Sets it as updatable or not (default `false`)
  89673. * @param geometry the geometry the vertexData is applied to
  89674. * @param updatable when used and having the value true allows new data to update the vertexData
  89675. * @returns VertexData
  89676. */
  89677. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  89678. /**
  89679. * Updates the associated mesh
  89680. * @param mesh the mesh to be updated
  89681. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89682. * @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
  89683. * @returns VertexData
  89684. */
  89685. updateMesh(mesh: Mesh): VertexData;
  89686. /**
  89687. * Updates the associated geometry
  89688. * @param geometry the geometry to be updated
  89689. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89690. * @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
  89691. * @returns VertexData.
  89692. */
  89693. updateGeometry(geometry: Geometry): VertexData;
  89694. private _applyTo;
  89695. private _update;
  89696. /**
  89697. * Transforms each position and each normal of the vertexData according to the passed Matrix
  89698. * @param matrix the transforming matrix
  89699. * @returns the VertexData
  89700. */
  89701. transform(matrix: Matrix): VertexData;
  89702. /**
  89703. * Merges the passed VertexData into the current one
  89704. * @param other the VertexData to be merged into the current one
  89705. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  89706. * @returns the modified VertexData
  89707. */
  89708. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  89709. private _mergeElement;
  89710. private _validate;
  89711. /**
  89712. * Serializes the VertexData
  89713. * @returns a serialized object
  89714. */
  89715. serialize(): any;
  89716. /**
  89717. * Extracts the vertexData from a mesh
  89718. * @param mesh the mesh from which to extract the VertexData
  89719. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  89720. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89721. * @returns the object VertexData associated to the passed mesh
  89722. */
  89723. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89724. /**
  89725. * Extracts the vertexData from the geometry
  89726. * @param geometry the geometry from which to extract the VertexData
  89727. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  89728. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89729. * @returns the object VertexData associated to the passed mesh
  89730. */
  89731. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89732. private static _ExtractFrom;
  89733. /**
  89734. * Creates the VertexData for a Ribbon
  89735. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  89736. * * pathArray array of paths, each of which an array of successive Vector3
  89737. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  89738. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  89739. * * 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
  89740. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89741. * * 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)
  89742. * * 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)
  89743. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  89744. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  89745. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  89746. * @returns the VertexData of the ribbon
  89747. */
  89748. static CreateRibbon(options: {
  89749. pathArray: Vector3[][];
  89750. closeArray?: boolean;
  89751. closePath?: boolean;
  89752. offset?: number;
  89753. sideOrientation?: number;
  89754. frontUVs?: Vector4;
  89755. backUVs?: Vector4;
  89756. invertUV?: boolean;
  89757. uvs?: Vector2[];
  89758. colors?: Color4[];
  89759. }): VertexData;
  89760. /**
  89761. * Creates the VertexData for a box
  89762. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89763. * * size sets the width, height and depth of the box to the value of size, optional default 1
  89764. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  89765. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  89766. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  89767. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89768. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89769. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89770. * * 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)
  89771. * * 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)
  89772. * @returns the VertexData of the box
  89773. */
  89774. static CreateBox(options: {
  89775. size?: number;
  89776. width?: number;
  89777. height?: number;
  89778. depth?: number;
  89779. faceUV?: Vector4[];
  89780. faceColors?: Color4[];
  89781. sideOrientation?: number;
  89782. frontUVs?: Vector4;
  89783. backUVs?: Vector4;
  89784. }): VertexData;
  89785. /**
  89786. * Creates the VertexData for a tiled box
  89787. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89788. * * faceTiles sets the pattern, tile size and number of tiles for a face
  89789. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89790. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89791. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89792. * @returns the VertexData of the box
  89793. */
  89794. static CreateTiledBox(options: {
  89795. pattern?: number;
  89796. width?: number;
  89797. height?: number;
  89798. depth?: number;
  89799. tileSize?: number;
  89800. tileWidth?: number;
  89801. tileHeight?: number;
  89802. alignHorizontal?: number;
  89803. alignVertical?: number;
  89804. faceUV?: Vector4[];
  89805. faceColors?: Color4[];
  89806. sideOrientation?: number;
  89807. }): VertexData;
  89808. /**
  89809. * Creates the VertexData for a tiled plane
  89810. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89811. * * pattern a limited pattern arrangement depending on the number
  89812. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  89813. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  89814. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  89815. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89816. * * 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)
  89817. * * 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)
  89818. * @returns the VertexData of the tiled plane
  89819. */
  89820. static CreateTiledPlane(options: {
  89821. pattern?: number;
  89822. tileSize?: number;
  89823. tileWidth?: number;
  89824. tileHeight?: number;
  89825. size?: number;
  89826. width?: number;
  89827. height?: number;
  89828. alignHorizontal?: number;
  89829. alignVertical?: number;
  89830. sideOrientation?: number;
  89831. frontUVs?: Vector4;
  89832. backUVs?: Vector4;
  89833. }): VertexData;
  89834. /**
  89835. * Creates the VertexData for an ellipsoid, defaults to a sphere
  89836. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89837. * * segments sets the number of horizontal strips optional, default 32
  89838. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  89839. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  89840. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  89841. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  89842. * * 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
  89843. * * 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
  89844. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89845. * * 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)
  89846. * * 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)
  89847. * @returns the VertexData of the ellipsoid
  89848. */
  89849. static CreateSphere(options: {
  89850. segments?: number;
  89851. diameter?: number;
  89852. diameterX?: number;
  89853. diameterY?: number;
  89854. diameterZ?: number;
  89855. arc?: number;
  89856. slice?: number;
  89857. sideOrientation?: number;
  89858. frontUVs?: Vector4;
  89859. backUVs?: Vector4;
  89860. }): VertexData;
  89861. /**
  89862. * Creates the VertexData for a cylinder, cone or prism
  89863. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89864. * * height sets the height (y direction) of the cylinder, optional, default 2
  89865. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  89866. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  89867. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  89868. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89869. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  89870. * * 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
  89871. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89872. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89873. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  89874. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  89875. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89876. * * 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)
  89877. * * 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)
  89878. * @returns the VertexData of the cylinder, cone or prism
  89879. */
  89880. static CreateCylinder(options: {
  89881. height?: number;
  89882. diameterTop?: number;
  89883. diameterBottom?: number;
  89884. diameter?: number;
  89885. tessellation?: number;
  89886. subdivisions?: number;
  89887. arc?: number;
  89888. faceColors?: Color4[];
  89889. faceUV?: Vector4[];
  89890. hasRings?: boolean;
  89891. enclose?: boolean;
  89892. sideOrientation?: number;
  89893. frontUVs?: Vector4;
  89894. backUVs?: Vector4;
  89895. }): VertexData;
  89896. /**
  89897. * Creates the VertexData for a torus
  89898. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89899. * * diameter the diameter of the torus, optional default 1
  89900. * * thickness the diameter of the tube forming the torus, optional default 0.5
  89901. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89902. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89903. * * 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)
  89904. * * 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)
  89905. * @returns the VertexData of the torus
  89906. */
  89907. static CreateTorus(options: {
  89908. diameter?: number;
  89909. thickness?: number;
  89910. tessellation?: number;
  89911. sideOrientation?: number;
  89912. frontUVs?: Vector4;
  89913. backUVs?: Vector4;
  89914. }): VertexData;
  89915. /**
  89916. * Creates the VertexData of the LineSystem
  89917. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  89918. * - lines an array of lines, each line being an array of successive Vector3
  89919. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  89920. * @returns the VertexData of the LineSystem
  89921. */
  89922. static CreateLineSystem(options: {
  89923. lines: Vector3[][];
  89924. colors?: Nullable<Color4[][]>;
  89925. }): VertexData;
  89926. /**
  89927. * Create the VertexData for a DashedLines
  89928. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  89929. * - points an array successive Vector3
  89930. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  89931. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  89932. * - dashNb the intended total number of dashes, optional, default 200
  89933. * @returns the VertexData for the DashedLines
  89934. */
  89935. static CreateDashedLines(options: {
  89936. points: Vector3[];
  89937. dashSize?: number;
  89938. gapSize?: number;
  89939. dashNb?: number;
  89940. }): VertexData;
  89941. /**
  89942. * Creates the VertexData for a Ground
  89943. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89944. * - width the width (x direction) of the ground, optional, default 1
  89945. * - height the height (z direction) of the ground, optional, default 1
  89946. * - subdivisions the number of subdivisions per side, optional, default 1
  89947. * @returns the VertexData of the Ground
  89948. */
  89949. static CreateGround(options: {
  89950. width?: number;
  89951. height?: number;
  89952. subdivisions?: number;
  89953. subdivisionsX?: number;
  89954. subdivisionsY?: number;
  89955. }): VertexData;
  89956. /**
  89957. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  89958. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89959. * * xmin the ground minimum X coordinate, optional, default -1
  89960. * * zmin the ground minimum Z coordinate, optional, default -1
  89961. * * xmax the ground maximum X coordinate, optional, default 1
  89962. * * zmax the ground maximum Z coordinate, optional, default 1
  89963. * * 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}
  89964. * * 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}
  89965. * @returns the VertexData of the TiledGround
  89966. */
  89967. static CreateTiledGround(options: {
  89968. xmin: number;
  89969. zmin: number;
  89970. xmax: number;
  89971. zmax: number;
  89972. subdivisions?: {
  89973. w: number;
  89974. h: number;
  89975. };
  89976. precision?: {
  89977. w: number;
  89978. h: number;
  89979. };
  89980. }): VertexData;
  89981. /**
  89982. * Creates the VertexData of the Ground designed from a heightmap
  89983. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  89984. * * width the width (x direction) of the ground
  89985. * * height the height (z direction) of the ground
  89986. * * subdivisions the number of subdivisions per side
  89987. * * minHeight the minimum altitude on the ground, optional, default 0
  89988. * * maxHeight the maximum altitude on the ground, optional default 1
  89989. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  89990. * * buffer the array holding the image color data
  89991. * * bufferWidth the width of image
  89992. * * bufferHeight the height of image
  89993. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  89994. * @returns the VertexData of the Ground designed from a heightmap
  89995. */
  89996. static CreateGroundFromHeightMap(options: {
  89997. width: number;
  89998. height: number;
  89999. subdivisions: number;
  90000. minHeight: number;
  90001. maxHeight: number;
  90002. colorFilter: Color3;
  90003. buffer: Uint8Array;
  90004. bufferWidth: number;
  90005. bufferHeight: number;
  90006. alphaFilter: number;
  90007. }): VertexData;
  90008. /**
  90009. * Creates the VertexData for a Plane
  90010. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  90011. * * size sets the width and height of the plane to the value of size, optional default 1
  90012. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  90013. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  90014. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90015. * * 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)
  90016. * * 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)
  90017. * @returns the VertexData of the box
  90018. */
  90019. static CreatePlane(options: {
  90020. size?: number;
  90021. width?: number;
  90022. height?: number;
  90023. sideOrientation?: number;
  90024. frontUVs?: Vector4;
  90025. backUVs?: Vector4;
  90026. }): VertexData;
  90027. /**
  90028. * Creates the VertexData of the Disc or regular Polygon
  90029. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  90030. * * radius the radius of the disc, optional default 0.5
  90031. * * tessellation the number of polygon sides, optional, default 64
  90032. * * 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
  90033. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90034. * * 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)
  90035. * * 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)
  90036. * @returns the VertexData of the box
  90037. */
  90038. static CreateDisc(options: {
  90039. radius?: number;
  90040. tessellation?: number;
  90041. arc?: number;
  90042. sideOrientation?: number;
  90043. frontUVs?: Vector4;
  90044. backUVs?: Vector4;
  90045. }): VertexData;
  90046. /**
  90047. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  90048. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  90049. * @param polygon a mesh built from polygonTriangulation.build()
  90050. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90051. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90052. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90053. * @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)
  90054. * @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)
  90055. * @returns the VertexData of the Polygon
  90056. */
  90057. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  90058. /**
  90059. * Creates the VertexData of the IcoSphere
  90060. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  90061. * * radius the radius of the IcoSphere, optional default 1
  90062. * * radiusX allows stretching in the x direction, optional, default radius
  90063. * * radiusY allows stretching in the y direction, optional, default radius
  90064. * * radiusZ allows stretching in the z direction, optional, default radius
  90065. * * flat when true creates a flat shaded mesh, optional, default true
  90066. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90067. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90068. * * 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)
  90069. * * 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)
  90070. * @returns the VertexData of the IcoSphere
  90071. */
  90072. static CreateIcoSphere(options: {
  90073. radius?: number;
  90074. radiusX?: number;
  90075. radiusY?: number;
  90076. radiusZ?: number;
  90077. flat?: boolean;
  90078. subdivisions?: number;
  90079. sideOrientation?: number;
  90080. frontUVs?: Vector4;
  90081. backUVs?: Vector4;
  90082. }): VertexData;
  90083. /**
  90084. * Creates the VertexData for a Polyhedron
  90085. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  90086. * * type provided types are:
  90087. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  90088. * * 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)
  90089. * * size the size of the IcoSphere, optional default 1
  90090. * * sizeX allows stretching in the x direction, optional, default size
  90091. * * sizeY allows stretching in the y direction, optional, default size
  90092. * * sizeZ allows stretching in the z direction, optional, default size
  90093. * * 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
  90094. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90095. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90096. * * flat when true creates a flat shaded mesh, optional, default true
  90097. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90098. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90099. * * 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)
  90100. * * 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)
  90101. * @returns the VertexData of the Polyhedron
  90102. */
  90103. static CreatePolyhedron(options: {
  90104. type?: number;
  90105. size?: number;
  90106. sizeX?: number;
  90107. sizeY?: number;
  90108. sizeZ?: number;
  90109. custom?: any;
  90110. faceUV?: Vector4[];
  90111. faceColors?: Color4[];
  90112. flat?: boolean;
  90113. sideOrientation?: number;
  90114. frontUVs?: Vector4;
  90115. backUVs?: Vector4;
  90116. }): VertexData;
  90117. /**
  90118. * Creates the VertexData for a TorusKnot
  90119. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  90120. * * radius the radius of the torus knot, optional, default 2
  90121. * * tube the thickness of the tube, optional, default 0.5
  90122. * * radialSegments the number of sides on each tube segments, optional, default 32
  90123. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  90124. * * p the number of windings around the z axis, optional, default 2
  90125. * * q the number of windings around the x axis, optional, default 3
  90126. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90127. * * 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)
  90128. * * 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)
  90129. * @returns the VertexData of the Torus Knot
  90130. */
  90131. static CreateTorusKnot(options: {
  90132. radius?: number;
  90133. tube?: number;
  90134. radialSegments?: number;
  90135. tubularSegments?: number;
  90136. p?: number;
  90137. q?: number;
  90138. sideOrientation?: number;
  90139. frontUVs?: Vector4;
  90140. backUVs?: Vector4;
  90141. }): VertexData;
  90142. /**
  90143. * Compute normals for given positions and indices
  90144. * @param positions an array of vertex positions, [...., x, y, z, ......]
  90145. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  90146. * @param normals an array of vertex normals, [...., x, y, z, ......]
  90147. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  90148. * * facetNormals : optional array of facet normals (vector3)
  90149. * * facetPositions : optional array of facet positions (vector3)
  90150. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  90151. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  90152. * * bInfo : optional bounding info, required for facetPartitioning computation
  90153. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  90154. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  90155. * * useRightHandedSystem: optional boolean to for right handed system computation
  90156. * * depthSort : optional boolean to enable the facet depth sort computation
  90157. * * distanceTo : optional Vector3 to compute the facet depth from this location
  90158. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  90159. */
  90160. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  90161. facetNormals?: any;
  90162. facetPositions?: any;
  90163. facetPartitioning?: any;
  90164. ratio?: number;
  90165. bInfo?: any;
  90166. bbSize?: Vector3;
  90167. subDiv?: any;
  90168. useRightHandedSystem?: boolean;
  90169. depthSort?: boolean;
  90170. distanceTo?: Vector3;
  90171. depthSortedFacets?: any;
  90172. }): void;
  90173. /** @hidden */
  90174. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  90175. /**
  90176. * Applies VertexData created from the imported parameters to the geometry
  90177. * @param parsedVertexData the parsed data from an imported file
  90178. * @param geometry the geometry to apply the VertexData to
  90179. */
  90180. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  90181. }
  90182. }
  90183. declare module BABYLON {
  90184. /**
  90185. * Defines a target to use with MorphTargetManager
  90186. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90187. */
  90188. export class MorphTarget implements IAnimatable {
  90189. /** defines the name of the target */
  90190. name: string;
  90191. /**
  90192. * Gets or sets the list of animations
  90193. */
  90194. animations: Animation[];
  90195. private _scene;
  90196. private _positions;
  90197. private _normals;
  90198. private _tangents;
  90199. private _uvs;
  90200. private _influence;
  90201. private _uniqueId;
  90202. /**
  90203. * Observable raised when the influence changes
  90204. */
  90205. onInfluenceChanged: Observable<boolean>;
  90206. /** @hidden */
  90207. _onDataLayoutChanged: Observable<void>;
  90208. /**
  90209. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  90210. */
  90211. influence: number;
  90212. /**
  90213. * Gets or sets the id of the morph Target
  90214. */
  90215. id: string;
  90216. private _animationPropertiesOverride;
  90217. /**
  90218. * Gets or sets the animation properties override
  90219. */
  90220. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90221. /**
  90222. * Creates a new MorphTarget
  90223. * @param name defines the name of the target
  90224. * @param influence defines the influence to use
  90225. * @param scene defines the scene the morphtarget belongs to
  90226. */
  90227. constructor(
  90228. /** defines the name of the target */
  90229. name: string, influence?: number, scene?: Nullable<Scene>);
  90230. /**
  90231. * Gets the unique ID of this manager
  90232. */
  90233. readonly uniqueId: number;
  90234. /**
  90235. * Gets a boolean defining if the target contains position data
  90236. */
  90237. readonly hasPositions: boolean;
  90238. /**
  90239. * Gets a boolean defining if the target contains normal data
  90240. */
  90241. readonly hasNormals: boolean;
  90242. /**
  90243. * Gets a boolean defining if the target contains tangent data
  90244. */
  90245. readonly hasTangents: boolean;
  90246. /**
  90247. * Gets a boolean defining if the target contains texture coordinates data
  90248. */
  90249. readonly hasUVs: boolean;
  90250. /**
  90251. * Affects position data to this target
  90252. * @param data defines the position data to use
  90253. */
  90254. setPositions(data: Nullable<FloatArray>): void;
  90255. /**
  90256. * Gets the position data stored in this target
  90257. * @returns a FloatArray containing the position data (or null if not present)
  90258. */
  90259. getPositions(): Nullable<FloatArray>;
  90260. /**
  90261. * Affects normal data to this target
  90262. * @param data defines the normal data to use
  90263. */
  90264. setNormals(data: Nullable<FloatArray>): void;
  90265. /**
  90266. * Gets the normal data stored in this target
  90267. * @returns a FloatArray containing the normal data (or null if not present)
  90268. */
  90269. getNormals(): Nullable<FloatArray>;
  90270. /**
  90271. * Affects tangent data to this target
  90272. * @param data defines the tangent data to use
  90273. */
  90274. setTangents(data: Nullable<FloatArray>): void;
  90275. /**
  90276. * Gets the tangent data stored in this target
  90277. * @returns a FloatArray containing the tangent data (or null if not present)
  90278. */
  90279. getTangents(): Nullable<FloatArray>;
  90280. /**
  90281. * Affects texture coordinates data to this target
  90282. * @param data defines the texture coordinates data to use
  90283. */
  90284. setUVs(data: Nullable<FloatArray>): void;
  90285. /**
  90286. * Gets the texture coordinates data stored in this target
  90287. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  90288. */
  90289. getUVs(): Nullable<FloatArray>;
  90290. /**
  90291. * Clone the current target
  90292. * @returns a new MorphTarget
  90293. */
  90294. clone(): MorphTarget;
  90295. /**
  90296. * Serializes the current target into a Serialization object
  90297. * @returns the serialized object
  90298. */
  90299. serialize(): any;
  90300. /**
  90301. * Returns the string "MorphTarget"
  90302. * @returns "MorphTarget"
  90303. */
  90304. getClassName(): string;
  90305. /**
  90306. * Creates a new target from serialized data
  90307. * @param serializationObject defines the serialized data to use
  90308. * @returns a new MorphTarget
  90309. */
  90310. static Parse(serializationObject: any): MorphTarget;
  90311. /**
  90312. * Creates a MorphTarget from mesh data
  90313. * @param mesh defines the source mesh
  90314. * @param name defines the name to use for the new target
  90315. * @param influence defines the influence to attach to the target
  90316. * @returns a new MorphTarget
  90317. */
  90318. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  90319. }
  90320. }
  90321. declare module BABYLON {
  90322. /**
  90323. * This class is used to deform meshes using morphing between different targets
  90324. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90325. */
  90326. export class MorphTargetManager {
  90327. private _targets;
  90328. private _targetInfluenceChangedObservers;
  90329. private _targetDataLayoutChangedObservers;
  90330. private _activeTargets;
  90331. private _scene;
  90332. private _influences;
  90333. private _supportsNormals;
  90334. private _supportsTangents;
  90335. private _supportsUVs;
  90336. private _vertexCount;
  90337. private _uniqueId;
  90338. private _tempInfluences;
  90339. /**
  90340. * Gets or sets a boolean indicating if normals must be morphed
  90341. */
  90342. enableNormalMorphing: boolean;
  90343. /**
  90344. * Gets or sets a boolean indicating if tangents must be morphed
  90345. */
  90346. enableTangentMorphing: boolean;
  90347. /**
  90348. * Gets or sets a boolean indicating if UV must be morphed
  90349. */
  90350. enableUVMorphing: boolean;
  90351. /**
  90352. * Creates a new MorphTargetManager
  90353. * @param scene defines the current scene
  90354. */
  90355. constructor(scene?: Nullable<Scene>);
  90356. /**
  90357. * Gets the unique ID of this manager
  90358. */
  90359. readonly uniqueId: number;
  90360. /**
  90361. * Gets the number of vertices handled by this manager
  90362. */
  90363. readonly vertexCount: number;
  90364. /**
  90365. * Gets a boolean indicating if this manager supports morphing of normals
  90366. */
  90367. readonly supportsNormals: boolean;
  90368. /**
  90369. * Gets a boolean indicating if this manager supports morphing of tangents
  90370. */
  90371. readonly supportsTangents: boolean;
  90372. /**
  90373. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  90374. */
  90375. readonly supportsUVs: boolean;
  90376. /**
  90377. * Gets the number of targets stored in this manager
  90378. */
  90379. readonly numTargets: number;
  90380. /**
  90381. * Gets the number of influencers (ie. the number of targets with influences > 0)
  90382. */
  90383. readonly numInfluencers: number;
  90384. /**
  90385. * Gets the list of influences (one per target)
  90386. */
  90387. readonly influences: Float32Array;
  90388. /**
  90389. * Gets the active target at specified index. An active target is a target with an influence > 0
  90390. * @param index defines the index to check
  90391. * @returns the requested target
  90392. */
  90393. getActiveTarget(index: number): MorphTarget;
  90394. /**
  90395. * Gets the target at specified index
  90396. * @param index defines the index to check
  90397. * @returns the requested target
  90398. */
  90399. getTarget(index: number): MorphTarget;
  90400. /**
  90401. * Add a new target to this manager
  90402. * @param target defines the target to add
  90403. */
  90404. addTarget(target: MorphTarget): void;
  90405. /**
  90406. * Removes a target from the manager
  90407. * @param target defines the target to remove
  90408. */
  90409. removeTarget(target: MorphTarget): void;
  90410. /**
  90411. * Clone the current manager
  90412. * @returns a new MorphTargetManager
  90413. */
  90414. clone(): MorphTargetManager;
  90415. /**
  90416. * Serializes the current manager into a Serialization object
  90417. * @returns the serialized object
  90418. */
  90419. serialize(): any;
  90420. private _syncActiveTargets;
  90421. /**
  90422. * Syncrhonize the targets with all the meshes using this morph target manager
  90423. */
  90424. synchronize(): void;
  90425. /**
  90426. * Creates a new MorphTargetManager from serialized data
  90427. * @param serializationObject defines the serialized data
  90428. * @param scene defines the hosting scene
  90429. * @returns the new MorphTargetManager
  90430. */
  90431. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  90432. }
  90433. }
  90434. declare module BABYLON {
  90435. /**
  90436. * Class used to represent a specific level of detail of a mesh
  90437. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90438. */
  90439. export class MeshLODLevel {
  90440. /** Defines the distance where this level should start being displayed */
  90441. distance: number;
  90442. /** Defines the mesh to use to render this level */
  90443. mesh: Nullable<Mesh>;
  90444. /**
  90445. * Creates a new LOD level
  90446. * @param distance defines the distance where this level should star being displayed
  90447. * @param mesh defines the mesh to use to render this level
  90448. */
  90449. constructor(
  90450. /** Defines the distance where this level should start being displayed */
  90451. distance: number,
  90452. /** Defines the mesh to use to render this level */
  90453. mesh: Nullable<Mesh>);
  90454. }
  90455. }
  90456. declare module BABYLON {
  90457. /**
  90458. * Mesh representing the gorund
  90459. */
  90460. export class GroundMesh extends Mesh {
  90461. /** If octree should be generated */
  90462. generateOctree: boolean;
  90463. private _heightQuads;
  90464. /** @hidden */
  90465. _subdivisionsX: number;
  90466. /** @hidden */
  90467. _subdivisionsY: number;
  90468. /** @hidden */
  90469. _width: number;
  90470. /** @hidden */
  90471. _height: number;
  90472. /** @hidden */
  90473. _minX: number;
  90474. /** @hidden */
  90475. _maxX: number;
  90476. /** @hidden */
  90477. _minZ: number;
  90478. /** @hidden */
  90479. _maxZ: number;
  90480. constructor(name: string, scene: Scene);
  90481. /**
  90482. * "GroundMesh"
  90483. * @returns "GroundMesh"
  90484. */
  90485. getClassName(): string;
  90486. /**
  90487. * The minimum of x and y subdivisions
  90488. */
  90489. readonly subdivisions: number;
  90490. /**
  90491. * X subdivisions
  90492. */
  90493. readonly subdivisionsX: number;
  90494. /**
  90495. * Y subdivisions
  90496. */
  90497. readonly subdivisionsY: number;
  90498. /**
  90499. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  90500. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  90501. * @param chunksCount the number of subdivisions for x and y
  90502. * @param octreeBlocksSize (Default: 32)
  90503. */
  90504. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  90505. /**
  90506. * Returns a height (y) value in the Worl system :
  90507. * the ground altitude at the coordinates (x, z) expressed in the World system.
  90508. * @param x x coordinate
  90509. * @param z z coordinate
  90510. * @returns the ground y position if (x, z) are outside the ground surface.
  90511. */
  90512. getHeightAtCoordinates(x: number, z: number): number;
  90513. /**
  90514. * Returns a normalized vector (Vector3) orthogonal to the ground
  90515. * at the ground coordinates (x, z) expressed in the World system.
  90516. * @param x x coordinate
  90517. * @param z z coordinate
  90518. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  90519. */
  90520. getNormalAtCoordinates(x: number, z: number): Vector3;
  90521. /**
  90522. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  90523. * at the ground coordinates (x, z) expressed in the World system.
  90524. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  90525. * @param x x coordinate
  90526. * @param z z coordinate
  90527. * @param ref vector to store the result
  90528. * @returns the GroundMesh.
  90529. */
  90530. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  90531. /**
  90532. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  90533. * if the ground has been updated.
  90534. * This can be used in the render loop.
  90535. * @returns the GroundMesh.
  90536. */
  90537. updateCoordinateHeights(): GroundMesh;
  90538. private _getFacetAt;
  90539. private _initHeightQuads;
  90540. private _computeHeightQuads;
  90541. /**
  90542. * Serializes this ground mesh
  90543. * @param serializationObject object to write serialization to
  90544. */
  90545. serialize(serializationObject: any): void;
  90546. /**
  90547. * Parses a serialized ground mesh
  90548. * @param parsedMesh the serialized mesh
  90549. * @param scene the scene to create the ground mesh in
  90550. * @returns the created ground mesh
  90551. */
  90552. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  90553. }
  90554. }
  90555. declare module BABYLON {
  90556. /**
  90557. * Interface for Physics-Joint data
  90558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90559. */
  90560. export interface PhysicsJointData {
  90561. /**
  90562. * The main pivot of the joint
  90563. */
  90564. mainPivot?: Vector3;
  90565. /**
  90566. * The connected pivot of the joint
  90567. */
  90568. connectedPivot?: Vector3;
  90569. /**
  90570. * The main axis of the joint
  90571. */
  90572. mainAxis?: Vector3;
  90573. /**
  90574. * The connected axis of the joint
  90575. */
  90576. connectedAxis?: Vector3;
  90577. /**
  90578. * The collision of the joint
  90579. */
  90580. collision?: boolean;
  90581. /**
  90582. * Native Oimo/Cannon/Energy data
  90583. */
  90584. nativeParams?: any;
  90585. }
  90586. /**
  90587. * This is a holder class for the physics joint created by the physics plugin
  90588. * It holds a set of functions to control the underlying joint
  90589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90590. */
  90591. export class PhysicsJoint {
  90592. /**
  90593. * The type of the physics joint
  90594. */
  90595. type: number;
  90596. /**
  90597. * The data for the physics joint
  90598. */
  90599. jointData: PhysicsJointData;
  90600. private _physicsJoint;
  90601. protected _physicsPlugin: IPhysicsEnginePlugin;
  90602. /**
  90603. * Initializes the physics joint
  90604. * @param type The type of the physics joint
  90605. * @param jointData The data for the physics joint
  90606. */
  90607. constructor(
  90608. /**
  90609. * The type of the physics joint
  90610. */
  90611. type: number,
  90612. /**
  90613. * The data for the physics joint
  90614. */
  90615. jointData: PhysicsJointData);
  90616. /**
  90617. * Gets the physics joint
  90618. */
  90619. /**
  90620. * Sets the physics joint
  90621. */
  90622. physicsJoint: any;
  90623. /**
  90624. * Sets the physics plugin
  90625. */
  90626. physicsPlugin: IPhysicsEnginePlugin;
  90627. /**
  90628. * Execute a function that is physics-plugin specific.
  90629. * @param {Function} func the function that will be executed.
  90630. * It accepts two parameters: the physics world and the physics joint
  90631. */
  90632. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  90633. /**
  90634. * Distance-Joint type
  90635. */
  90636. static DistanceJoint: number;
  90637. /**
  90638. * Hinge-Joint type
  90639. */
  90640. static HingeJoint: number;
  90641. /**
  90642. * Ball-and-Socket joint type
  90643. */
  90644. static BallAndSocketJoint: number;
  90645. /**
  90646. * Wheel-Joint type
  90647. */
  90648. static WheelJoint: number;
  90649. /**
  90650. * Slider-Joint type
  90651. */
  90652. static SliderJoint: number;
  90653. /**
  90654. * Prismatic-Joint type
  90655. */
  90656. static PrismaticJoint: number;
  90657. /**
  90658. * Universal-Joint type
  90659. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  90660. */
  90661. static UniversalJoint: number;
  90662. /**
  90663. * Hinge-Joint 2 type
  90664. */
  90665. static Hinge2Joint: number;
  90666. /**
  90667. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  90668. */
  90669. static PointToPointJoint: number;
  90670. /**
  90671. * Spring-Joint type
  90672. */
  90673. static SpringJoint: number;
  90674. /**
  90675. * Lock-Joint type
  90676. */
  90677. static LockJoint: number;
  90678. }
  90679. /**
  90680. * A class representing a physics distance joint
  90681. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90682. */
  90683. export class DistanceJoint extends PhysicsJoint {
  90684. /**
  90685. *
  90686. * @param jointData The data for the Distance-Joint
  90687. */
  90688. constructor(jointData: DistanceJointData);
  90689. /**
  90690. * Update the predefined distance.
  90691. * @param maxDistance The maximum preferred distance
  90692. * @param minDistance The minimum preferred distance
  90693. */
  90694. updateDistance(maxDistance: number, minDistance?: number): void;
  90695. }
  90696. /**
  90697. * Represents a Motor-Enabled Joint
  90698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90699. */
  90700. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  90701. /**
  90702. * Initializes the Motor-Enabled Joint
  90703. * @param type The type of the joint
  90704. * @param jointData The physica joint data for the joint
  90705. */
  90706. constructor(type: number, jointData: PhysicsJointData);
  90707. /**
  90708. * Set the motor values.
  90709. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90710. * @param force the force to apply
  90711. * @param maxForce max force for this motor.
  90712. */
  90713. setMotor(force?: number, maxForce?: number): void;
  90714. /**
  90715. * Set the motor's limits.
  90716. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90717. * @param upperLimit The upper limit of the motor
  90718. * @param lowerLimit The lower limit of the motor
  90719. */
  90720. setLimit(upperLimit: number, lowerLimit?: number): void;
  90721. }
  90722. /**
  90723. * This class represents a single physics Hinge-Joint
  90724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90725. */
  90726. export class HingeJoint extends MotorEnabledJoint {
  90727. /**
  90728. * Initializes the Hinge-Joint
  90729. * @param jointData The joint data for the Hinge-Joint
  90730. */
  90731. constructor(jointData: PhysicsJointData);
  90732. /**
  90733. * Set the motor values.
  90734. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90735. * @param {number} force the force to apply
  90736. * @param {number} maxForce max force for this motor.
  90737. */
  90738. setMotor(force?: number, maxForce?: number): void;
  90739. /**
  90740. * Set the motor's limits.
  90741. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90742. * @param upperLimit The upper limit of the motor
  90743. * @param lowerLimit The lower limit of the motor
  90744. */
  90745. setLimit(upperLimit: number, lowerLimit?: number): void;
  90746. }
  90747. /**
  90748. * This class represents a dual hinge physics joint (same as wheel joint)
  90749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90750. */
  90751. export class Hinge2Joint extends MotorEnabledJoint {
  90752. /**
  90753. * Initializes the Hinge2-Joint
  90754. * @param jointData The joint data for the Hinge2-Joint
  90755. */
  90756. constructor(jointData: PhysicsJointData);
  90757. /**
  90758. * Set the motor values.
  90759. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90760. * @param {number} targetSpeed the speed the motor is to reach
  90761. * @param {number} maxForce max force for this motor.
  90762. * @param {motorIndex} the motor's index, 0 or 1.
  90763. */
  90764. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  90765. /**
  90766. * Set the motor limits.
  90767. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90768. * @param {number} upperLimit the upper limit
  90769. * @param {number} lowerLimit lower limit
  90770. * @param {motorIndex} the motor's index, 0 or 1.
  90771. */
  90772. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90773. }
  90774. /**
  90775. * Interface for a motor enabled joint
  90776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90777. */
  90778. export interface IMotorEnabledJoint {
  90779. /**
  90780. * Physics joint
  90781. */
  90782. physicsJoint: any;
  90783. /**
  90784. * Sets the motor of the motor-enabled joint
  90785. * @param force The force of the motor
  90786. * @param maxForce The maximum force of the motor
  90787. * @param motorIndex The index of the motor
  90788. */
  90789. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  90790. /**
  90791. * Sets the limit of the motor
  90792. * @param upperLimit The upper limit of the motor
  90793. * @param lowerLimit The lower limit of the motor
  90794. * @param motorIndex The index of the motor
  90795. */
  90796. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90797. }
  90798. /**
  90799. * Joint data for a Distance-Joint
  90800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90801. */
  90802. export interface DistanceJointData extends PhysicsJointData {
  90803. /**
  90804. * Max distance the 2 joint objects can be apart
  90805. */
  90806. maxDistance: number;
  90807. }
  90808. /**
  90809. * Joint data from a spring joint
  90810. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90811. */
  90812. export interface SpringJointData extends PhysicsJointData {
  90813. /**
  90814. * Length of the spring
  90815. */
  90816. length: number;
  90817. /**
  90818. * Stiffness of the spring
  90819. */
  90820. stiffness: number;
  90821. /**
  90822. * Damping of the spring
  90823. */
  90824. damping: number;
  90825. /** this callback will be called when applying the force to the impostors. */
  90826. forceApplicationCallback: () => void;
  90827. }
  90828. }
  90829. declare module BABYLON {
  90830. /**
  90831. * Holds the data for the raycast result
  90832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90833. */
  90834. export class PhysicsRaycastResult {
  90835. private _hasHit;
  90836. private _hitDistance;
  90837. private _hitNormalWorld;
  90838. private _hitPointWorld;
  90839. private _rayFromWorld;
  90840. private _rayToWorld;
  90841. /**
  90842. * Gets if there was a hit
  90843. */
  90844. readonly hasHit: boolean;
  90845. /**
  90846. * Gets the distance from the hit
  90847. */
  90848. readonly hitDistance: number;
  90849. /**
  90850. * Gets the hit normal/direction in the world
  90851. */
  90852. readonly hitNormalWorld: Vector3;
  90853. /**
  90854. * Gets the hit point in the world
  90855. */
  90856. readonly hitPointWorld: Vector3;
  90857. /**
  90858. * Gets the ray "start point" of the ray in the world
  90859. */
  90860. readonly rayFromWorld: Vector3;
  90861. /**
  90862. * Gets the ray "end point" of the ray in the world
  90863. */
  90864. readonly rayToWorld: Vector3;
  90865. /**
  90866. * Sets the hit data (normal & point in world space)
  90867. * @param hitNormalWorld defines the normal in world space
  90868. * @param hitPointWorld defines the point in world space
  90869. */
  90870. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  90871. /**
  90872. * Sets the distance from the start point to the hit point
  90873. * @param distance
  90874. */
  90875. setHitDistance(distance: number): void;
  90876. /**
  90877. * Calculates the distance manually
  90878. */
  90879. calculateHitDistance(): void;
  90880. /**
  90881. * Resets all the values to default
  90882. * @param from The from point on world space
  90883. * @param to The to point on world space
  90884. */
  90885. reset(from?: Vector3, to?: Vector3): void;
  90886. }
  90887. /**
  90888. * Interface for the size containing width and height
  90889. */
  90890. interface IXYZ {
  90891. /**
  90892. * X
  90893. */
  90894. x: number;
  90895. /**
  90896. * Y
  90897. */
  90898. y: number;
  90899. /**
  90900. * Z
  90901. */
  90902. z: number;
  90903. }
  90904. }
  90905. declare module BABYLON {
  90906. /**
  90907. * Interface used to describe a physics joint
  90908. */
  90909. export interface PhysicsImpostorJoint {
  90910. /** Defines the main impostor to which the joint is linked */
  90911. mainImpostor: PhysicsImpostor;
  90912. /** Defines the impostor that is connected to the main impostor using this joint */
  90913. connectedImpostor: PhysicsImpostor;
  90914. /** Defines the joint itself */
  90915. joint: PhysicsJoint;
  90916. }
  90917. /** @hidden */
  90918. export interface IPhysicsEnginePlugin {
  90919. world: any;
  90920. name: string;
  90921. setGravity(gravity: Vector3): void;
  90922. setTimeStep(timeStep: number): void;
  90923. getTimeStep(): number;
  90924. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  90925. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90926. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90927. generatePhysicsBody(impostor: PhysicsImpostor): void;
  90928. removePhysicsBody(impostor: PhysicsImpostor): void;
  90929. generateJoint(joint: PhysicsImpostorJoint): void;
  90930. removeJoint(joint: PhysicsImpostorJoint): void;
  90931. isSupported(): boolean;
  90932. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  90933. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  90934. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90935. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90936. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90937. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90938. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  90939. getBodyMass(impostor: PhysicsImpostor): number;
  90940. getBodyFriction(impostor: PhysicsImpostor): number;
  90941. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  90942. getBodyRestitution(impostor: PhysicsImpostor): number;
  90943. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  90944. getBodyPressure?(impostor: PhysicsImpostor): number;
  90945. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  90946. getBodyStiffness?(impostor: PhysicsImpostor): number;
  90947. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  90948. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  90949. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  90950. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  90951. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  90952. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90953. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90954. sleepBody(impostor: PhysicsImpostor): void;
  90955. wakeUpBody(impostor: PhysicsImpostor): void;
  90956. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  90957. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  90958. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  90959. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90960. getRadius(impostor: PhysicsImpostor): number;
  90961. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  90962. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  90963. dispose(): void;
  90964. }
  90965. /**
  90966. * Interface used to define a physics engine
  90967. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  90968. */
  90969. export interface IPhysicsEngine {
  90970. /**
  90971. * Gets the gravity vector used by the simulation
  90972. */
  90973. gravity: Vector3;
  90974. /**
  90975. * Sets the gravity vector used by the simulation
  90976. * @param gravity defines the gravity vector to use
  90977. */
  90978. setGravity(gravity: Vector3): void;
  90979. /**
  90980. * Set the time step of the physics engine.
  90981. * Default is 1/60.
  90982. * To slow it down, enter 1/600 for example.
  90983. * To speed it up, 1/30
  90984. * @param newTimeStep the new timestep to apply to this world.
  90985. */
  90986. setTimeStep(newTimeStep: number): void;
  90987. /**
  90988. * Get the time step of the physics engine.
  90989. * @returns the current time step
  90990. */
  90991. getTimeStep(): number;
  90992. /**
  90993. * Release all resources
  90994. */
  90995. dispose(): void;
  90996. /**
  90997. * Gets the name of the current physics plugin
  90998. * @returns the name of the plugin
  90999. */
  91000. getPhysicsPluginName(): string;
  91001. /**
  91002. * Adding a new impostor for the impostor tracking.
  91003. * This will be done by the impostor itself.
  91004. * @param impostor the impostor to add
  91005. */
  91006. addImpostor(impostor: PhysicsImpostor): void;
  91007. /**
  91008. * Remove an impostor from the engine.
  91009. * This impostor and its mesh will not longer be updated by the physics engine.
  91010. * @param impostor the impostor to remove
  91011. */
  91012. removeImpostor(impostor: PhysicsImpostor): void;
  91013. /**
  91014. * Add a joint to the physics engine
  91015. * @param mainImpostor defines the main impostor to which the joint is added.
  91016. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  91017. * @param joint defines the joint that will connect both impostors.
  91018. */
  91019. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  91020. /**
  91021. * Removes a joint from the simulation
  91022. * @param mainImpostor defines the impostor used with the joint
  91023. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  91024. * @param joint defines the joint to remove
  91025. */
  91026. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  91027. /**
  91028. * Gets the current plugin used to run the simulation
  91029. * @returns current plugin
  91030. */
  91031. getPhysicsPlugin(): IPhysicsEnginePlugin;
  91032. /**
  91033. * Gets the list of physic impostors
  91034. * @returns an array of PhysicsImpostor
  91035. */
  91036. getImpostors(): Array<PhysicsImpostor>;
  91037. /**
  91038. * Gets the impostor for a physics enabled object
  91039. * @param object defines the object impersonated by the impostor
  91040. * @returns the PhysicsImpostor or null if not found
  91041. */
  91042. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91043. /**
  91044. * Gets the impostor for a physics body object
  91045. * @param body defines physics body used by the impostor
  91046. * @returns the PhysicsImpostor or null if not found
  91047. */
  91048. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  91049. /**
  91050. * Does a raycast in the physics world
  91051. * @param from when should the ray start?
  91052. * @param to when should the ray end?
  91053. * @returns PhysicsRaycastResult
  91054. */
  91055. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91056. /**
  91057. * Called by the scene. No need to call it.
  91058. * @param delta defines the timespam between frames
  91059. */
  91060. _step(delta: number): void;
  91061. }
  91062. }
  91063. declare module BABYLON {
  91064. /**
  91065. * The interface for the physics imposter parameters
  91066. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91067. */
  91068. export interface PhysicsImpostorParameters {
  91069. /**
  91070. * The mass of the physics imposter
  91071. */
  91072. mass: number;
  91073. /**
  91074. * The friction of the physics imposter
  91075. */
  91076. friction?: number;
  91077. /**
  91078. * The coefficient of restitution of the physics imposter
  91079. */
  91080. restitution?: number;
  91081. /**
  91082. * The native options of the physics imposter
  91083. */
  91084. nativeOptions?: any;
  91085. /**
  91086. * Specifies if the parent should be ignored
  91087. */
  91088. ignoreParent?: boolean;
  91089. /**
  91090. * Specifies if bi-directional transformations should be disabled
  91091. */
  91092. disableBidirectionalTransformation?: boolean;
  91093. /**
  91094. * The pressure inside the physics imposter, soft object only
  91095. */
  91096. pressure?: number;
  91097. /**
  91098. * The stiffness the physics imposter, soft object only
  91099. */
  91100. stiffness?: number;
  91101. /**
  91102. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  91103. */
  91104. velocityIterations?: number;
  91105. /**
  91106. * The number of iterations used in maintaining consistent vertex positions, soft object only
  91107. */
  91108. positionIterations?: number;
  91109. /**
  91110. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  91111. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  91112. * Add to fix multiple points
  91113. */
  91114. fixedPoints?: number;
  91115. /**
  91116. * The collision margin around a soft object
  91117. */
  91118. margin?: number;
  91119. /**
  91120. * The collision margin around a soft object
  91121. */
  91122. damping?: number;
  91123. /**
  91124. * The path for a rope based on an extrusion
  91125. */
  91126. path?: any;
  91127. /**
  91128. * The shape of an extrusion used for a rope based on an extrusion
  91129. */
  91130. shape?: any;
  91131. }
  91132. /**
  91133. * Interface for a physics-enabled object
  91134. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91135. */
  91136. export interface IPhysicsEnabledObject {
  91137. /**
  91138. * The position of the physics-enabled object
  91139. */
  91140. position: Vector3;
  91141. /**
  91142. * The rotation of the physics-enabled object
  91143. */
  91144. rotationQuaternion: Nullable<Quaternion>;
  91145. /**
  91146. * The scale of the physics-enabled object
  91147. */
  91148. scaling: Vector3;
  91149. /**
  91150. * The rotation of the physics-enabled object
  91151. */
  91152. rotation?: Vector3;
  91153. /**
  91154. * The parent of the physics-enabled object
  91155. */
  91156. parent?: any;
  91157. /**
  91158. * The bounding info of the physics-enabled object
  91159. * @returns The bounding info of the physics-enabled object
  91160. */
  91161. getBoundingInfo(): BoundingInfo;
  91162. /**
  91163. * Computes the world matrix
  91164. * @param force Specifies if the world matrix should be computed by force
  91165. * @returns A world matrix
  91166. */
  91167. computeWorldMatrix(force: boolean): Matrix;
  91168. /**
  91169. * Gets the world matrix
  91170. * @returns A world matrix
  91171. */
  91172. getWorldMatrix?(): Matrix;
  91173. /**
  91174. * Gets the child meshes
  91175. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  91176. * @returns An array of abstract meshes
  91177. */
  91178. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  91179. /**
  91180. * Gets the vertex data
  91181. * @param kind The type of vertex data
  91182. * @returns A nullable array of numbers, or a float32 array
  91183. */
  91184. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  91185. /**
  91186. * Gets the indices from the mesh
  91187. * @returns A nullable array of index arrays
  91188. */
  91189. getIndices?(): Nullable<IndicesArray>;
  91190. /**
  91191. * Gets the scene from the mesh
  91192. * @returns the indices array or null
  91193. */
  91194. getScene?(): Scene;
  91195. /**
  91196. * Gets the absolute position from the mesh
  91197. * @returns the absolute position
  91198. */
  91199. getAbsolutePosition(): Vector3;
  91200. /**
  91201. * Gets the absolute pivot point from the mesh
  91202. * @returns the absolute pivot point
  91203. */
  91204. getAbsolutePivotPoint(): Vector3;
  91205. /**
  91206. * Rotates the mesh
  91207. * @param axis The axis of rotation
  91208. * @param amount The amount of rotation
  91209. * @param space The space of the rotation
  91210. * @returns The rotation transform node
  91211. */
  91212. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  91213. /**
  91214. * Translates the mesh
  91215. * @param axis The axis of translation
  91216. * @param distance The distance of translation
  91217. * @param space The space of the translation
  91218. * @returns The transform node
  91219. */
  91220. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  91221. /**
  91222. * Sets the absolute position of the mesh
  91223. * @param absolutePosition The absolute position of the mesh
  91224. * @returns The transform node
  91225. */
  91226. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  91227. /**
  91228. * Gets the class name of the mesh
  91229. * @returns The class name
  91230. */
  91231. getClassName(): string;
  91232. }
  91233. /**
  91234. * Represents a physics imposter
  91235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91236. */
  91237. export class PhysicsImpostor {
  91238. /**
  91239. * The physics-enabled object used as the physics imposter
  91240. */
  91241. object: IPhysicsEnabledObject;
  91242. /**
  91243. * The type of the physics imposter
  91244. */
  91245. type: number;
  91246. private _options;
  91247. private _scene?;
  91248. /**
  91249. * The default object size of the imposter
  91250. */
  91251. static DEFAULT_OBJECT_SIZE: Vector3;
  91252. /**
  91253. * The identity quaternion of the imposter
  91254. */
  91255. static IDENTITY_QUATERNION: Quaternion;
  91256. /** @hidden */
  91257. _pluginData: any;
  91258. private _physicsEngine;
  91259. private _physicsBody;
  91260. private _bodyUpdateRequired;
  91261. private _onBeforePhysicsStepCallbacks;
  91262. private _onAfterPhysicsStepCallbacks;
  91263. /** @hidden */
  91264. _onPhysicsCollideCallbacks: Array<{
  91265. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  91266. otherImpostors: Array<PhysicsImpostor>;
  91267. }>;
  91268. private _deltaPosition;
  91269. private _deltaRotation;
  91270. private _deltaRotationConjugated;
  91271. /** @hidden */
  91272. _isFromLine: boolean;
  91273. private _parent;
  91274. private _isDisposed;
  91275. private static _tmpVecs;
  91276. private static _tmpQuat;
  91277. /**
  91278. * Specifies if the physics imposter is disposed
  91279. */
  91280. readonly isDisposed: boolean;
  91281. /**
  91282. * Gets the mass of the physics imposter
  91283. */
  91284. mass: number;
  91285. /**
  91286. * Gets the coefficient of friction
  91287. */
  91288. /**
  91289. * Sets the coefficient of friction
  91290. */
  91291. friction: number;
  91292. /**
  91293. * Gets the coefficient of restitution
  91294. */
  91295. /**
  91296. * Sets the coefficient of restitution
  91297. */
  91298. restitution: number;
  91299. /**
  91300. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  91301. */
  91302. /**
  91303. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  91304. */
  91305. pressure: number;
  91306. /**
  91307. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91308. */
  91309. /**
  91310. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91311. */
  91312. stiffness: number;
  91313. /**
  91314. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91315. */
  91316. /**
  91317. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91318. */
  91319. velocityIterations: number;
  91320. /**
  91321. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91322. */
  91323. /**
  91324. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91325. */
  91326. positionIterations: number;
  91327. /**
  91328. * The unique id of the physics imposter
  91329. * set by the physics engine when adding this impostor to the array
  91330. */
  91331. uniqueId: number;
  91332. /**
  91333. * @hidden
  91334. */
  91335. soft: boolean;
  91336. /**
  91337. * @hidden
  91338. */
  91339. segments: number;
  91340. private _joints;
  91341. /**
  91342. * Initializes the physics imposter
  91343. * @param object The physics-enabled object used as the physics imposter
  91344. * @param type The type of the physics imposter
  91345. * @param _options The options for the physics imposter
  91346. * @param _scene The Babylon scene
  91347. */
  91348. constructor(
  91349. /**
  91350. * The physics-enabled object used as the physics imposter
  91351. */
  91352. object: IPhysicsEnabledObject,
  91353. /**
  91354. * The type of the physics imposter
  91355. */
  91356. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  91357. /**
  91358. * This function will completly initialize this impostor.
  91359. * It will create a new body - but only if this mesh has no parent.
  91360. * If it has, this impostor will not be used other than to define the impostor
  91361. * of the child mesh.
  91362. * @hidden
  91363. */
  91364. _init(): void;
  91365. private _getPhysicsParent;
  91366. /**
  91367. * Should a new body be generated.
  91368. * @returns boolean specifying if body initialization is required
  91369. */
  91370. isBodyInitRequired(): boolean;
  91371. /**
  91372. * Sets the updated scaling
  91373. * @param updated Specifies if the scaling is updated
  91374. */
  91375. setScalingUpdated(): void;
  91376. /**
  91377. * Force a regeneration of this or the parent's impostor's body.
  91378. * Use under cautious - This will remove all joints already implemented.
  91379. */
  91380. forceUpdate(): void;
  91381. /**
  91382. * Gets the body that holds this impostor. Either its own, or its parent.
  91383. */
  91384. /**
  91385. * Set the physics body. Used mainly by the physics engine/plugin
  91386. */
  91387. physicsBody: any;
  91388. /**
  91389. * Get the parent of the physics imposter
  91390. * @returns Physics imposter or null
  91391. */
  91392. /**
  91393. * Sets the parent of the physics imposter
  91394. */
  91395. parent: Nullable<PhysicsImpostor>;
  91396. /**
  91397. * Resets the update flags
  91398. */
  91399. resetUpdateFlags(): void;
  91400. /**
  91401. * Gets the object extend size
  91402. * @returns the object extend size
  91403. */
  91404. getObjectExtendSize(): Vector3;
  91405. /**
  91406. * Gets the object center
  91407. * @returns The object center
  91408. */
  91409. getObjectCenter(): Vector3;
  91410. /**
  91411. * Get a specific parametes from the options parameter
  91412. * @param paramName The object parameter name
  91413. * @returns The object parameter
  91414. */
  91415. getParam(paramName: string): any;
  91416. /**
  91417. * Sets a specific parameter in the options given to the physics plugin
  91418. * @param paramName The parameter name
  91419. * @param value The value of the parameter
  91420. */
  91421. setParam(paramName: string, value: number): void;
  91422. /**
  91423. * Specifically change the body's mass option. Won't recreate the physics body object
  91424. * @param mass The mass of the physics imposter
  91425. */
  91426. setMass(mass: number): void;
  91427. /**
  91428. * Gets the linear velocity
  91429. * @returns linear velocity or null
  91430. */
  91431. getLinearVelocity(): Nullable<Vector3>;
  91432. /**
  91433. * Sets the linear velocity
  91434. * @param velocity linear velocity or null
  91435. */
  91436. setLinearVelocity(velocity: Nullable<Vector3>): void;
  91437. /**
  91438. * Gets the angular velocity
  91439. * @returns angular velocity or null
  91440. */
  91441. getAngularVelocity(): Nullable<Vector3>;
  91442. /**
  91443. * Sets the angular velocity
  91444. * @param velocity The velocity or null
  91445. */
  91446. setAngularVelocity(velocity: Nullable<Vector3>): void;
  91447. /**
  91448. * Execute a function with the physics plugin native code
  91449. * Provide a function the will have two variables - the world object and the physics body object
  91450. * @param func The function to execute with the physics plugin native code
  91451. */
  91452. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  91453. /**
  91454. * Register a function that will be executed before the physics world is stepping forward
  91455. * @param func The function to execute before the physics world is stepped forward
  91456. */
  91457. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91458. /**
  91459. * Unregister a function that will be executed before the physics world is stepping forward
  91460. * @param func The function to execute before the physics world is stepped forward
  91461. */
  91462. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91463. /**
  91464. * Register a function that will be executed after the physics step
  91465. * @param func The function to execute after physics step
  91466. */
  91467. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91468. /**
  91469. * Unregisters a function that will be executed after the physics step
  91470. * @param func The function to execute after physics step
  91471. */
  91472. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91473. /**
  91474. * register a function that will be executed when this impostor collides against a different body
  91475. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  91476. * @param func Callback that is executed on collision
  91477. */
  91478. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  91479. /**
  91480. * Unregisters the physics imposter on contact
  91481. * @param collideAgainst The physics object to collide against
  91482. * @param func Callback to execute on collision
  91483. */
  91484. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  91485. private _tmpQuat;
  91486. private _tmpQuat2;
  91487. /**
  91488. * Get the parent rotation
  91489. * @returns The parent rotation
  91490. */
  91491. getParentsRotation(): Quaternion;
  91492. /**
  91493. * this function is executed by the physics engine.
  91494. */
  91495. beforeStep: () => void;
  91496. /**
  91497. * this function is executed by the physics engine
  91498. */
  91499. afterStep: () => void;
  91500. /**
  91501. * Legacy collision detection event support
  91502. */
  91503. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  91504. /**
  91505. * event and body object due to cannon's event-based architecture.
  91506. */
  91507. onCollide: (e: {
  91508. body: any;
  91509. }) => void;
  91510. /**
  91511. * Apply a force
  91512. * @param force The force to apply
  91513. * @param contactPoint The contact point for the force
  91514. * @returns The physics imposter
  91515. */
  91516. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91517. /**
  91518. * Apply an impulse
  91519. * @param force The impulse force
  91520. * @param contactPoint The contact point for the impulse force
  91521. * @returns The physics imposter
  91522. */
  91523. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91524. /**
  91525. * A help function to create a joint
  91526. * @param otherImpostor A physics imposter used to create a joint
  91527. * @param jointType The type of joint
  91528. * @param jointData The data for the joint
  91529. * @returns The physics imposter
  91530. */
  91531. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  91532. /**
  91533. * Add a joint to this impostor with a different impostor
  91534. * @param otherImpostor A physics imposter used to add a joint
  91535. * @param joint The joint to add
  91536. * @returns The physics imposter
  91537. */
  91538. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  91539. /**
  91540. * Add an anchor to a cloth impostor
  91541. * @param otherImpostor rigid impostor to anchor to
  91542. * @param width ratio across width from 0 to 1
  91543. * @param height ratio up height from 0 to 1
  91544. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  91545. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  91546. * @returns impostor the soft imposter
  91547. */
  91548. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91549. /**
  91550. * Add a hook to a rope impostor
  91551. * @param otherImpostor rigid impostor to anchor to
  91552. * @param length ratio across rope from 0 to 1
  91553. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  91554. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  91555. * @returns impostor the rope imposter
  91556. */
  91557. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91558. /**
  91559. * Will keep this body still, in a sleep mode.
  91560. * @returns the physics imposter
  91561. */
  91562. sleep(): PhysicsImpostor;
  91563. /**
  91564. * Wake the body up.
  91565. * @returns The physics imposter
  91566. */
  91567. wakeUp(): PhysicsImpostor;
  91568. /**
  91569. * Clones the physics imposter
  91570. * @param newObject The physics imposter clones to this physics-enabled object
  91571. * @returns A nullable physics imposter
  91572. */
  91573. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91574. /**
  91575. * Disposes the physics imposter
  91576. */
  91577. dispose(): void;
  91578. /**
  91579. * Sets the delta position
  91580. * @param position The delta position amount
  91581. */
  91582. setDeltaPosition(position: Vector3): void;
  91583. /**
  91584. * Sets the delta rotation
  91585. * @param rotation The delta rotation amount
  91586. */
  91587. setDeltaRotation(rotation: Quaternion): void;
  91588. /**
  91589. * Gets the box size of the physics imposter and stores the result in the input parameter
  91590. * @param result Stores the box size
  91591. * @returns The physics imposter
  91592. */
  91593. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  91594. /**
  91595. * Gets the radius of the physics imposter
  91596. * @returns Radius of the physics imposter
  91597. */
  91598. getRadius(): number;
  91599. /**
  91600. * Sync a bone with this impostor
  91601. * @param bone The bone to sync to the impostor.
  91602. * @param boneMesh The mesh that the bone is influencing.
  91603. * @param jointPivot The pivot of the joint / bone in local space.
  91604. * @param distToJoint Optional distance from the impostor to the joint.
  91605. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91606. */
  91607. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  91608. /**
  91609. * Sync impostor to a bone
  91610. * @param bone The bone that the impostor will be synced to.
  91611. * @param boneMesh The mesh that the bone is influencing.
  91612. * @param jointPivot The pivot of the joint / bone in local space.
  91613. * @param distToJoint Optional distance from the impostor to the joint.
  91614. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91615. * @param boneAxis Optional vector3 axis the bone is aligned with
  91616. */
  91617. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  91618. /**
  91619. * No-Imposter type
  91620. */
  91621. static NoImpostor: number;
  91622. /**
  91623. * Sphere-Imposter type
  91624. */
  91625. static SphereImpostor: number;
  91626. /**
  91627. * Box-Imposter type
  91628. */
  91629. static BoxImpostor: number;
  91630. /**
  91631. * Plane-Imposter type
  91632. */
  91633. static PlaneImpostor: number;
  91634. /**
  91635. * Mesh-imposter type
  91636. */
  91637. static MeshImpostor: number;
  91638. /**
  91639. * Capsule-Impostor type (Ammo.js plugin only)
  91640. */
  91641. static CapsuleImpostor: number;
  91642. /**
  91643. * Cylinder-Imposter type
  91644. */
  91645. static CylinderImpostor: number;
  91646. /**
  91647. * Particle-Imposter type
  91648. */
  91649. static ParticleImpostor: number;
  91650. /**
  91651. * Heightmap-Imposter type
  91652. */
  91653. static HeightmapImpostor: number;
  91654. /**
  91655. * ConvexHull-Impostor type (Ammo.js plugin only)
  91656. */
  91657. static ConvexHullImpostor: number;
  91658. /**
  91659. * Rope-Imposter type
  91660. */
  91661. static RopeImpostor: number;
  91662. /**
  91663. * Cloth-Imposter type
  91664. */
  91665. static ClothImpostor: number;
  91666. /**
  91667. * Softbody-Imposter type
  91668. */
  91669. static SoftbodyImpostor: number;
  91670. }
  91671. }
  91672. declare module BABYLON {
  91673. /**
  91674. * @hidden
  91675. **/
  91676. export class _CreationDataStorage {
  91677. closePath?: boolean;
  91678. closeArray?: boolean;
  91679. idx: number[];
  91680. dashSize: number;
  91681. gapSize: number;
  91682. path3D: Path3D;
  91683. pathArray: Vector3[][];
  91684. arc: number;
  91685. radius: number;
  91686. cap: number;
  91687. tessellation: number;
  91688. }
  91689. /**
  91690. * @hidden
  91691. **/
  91692. class _InstanceDataStorage {
  91693. visibleInstances: any;
  91694. batchCache: _InstancesBatch;
  91695. instancesBufferSize: number;
  91696. instancesBuffer: Nullable<Buffer>;
  91697. instancesData: Float32Array;
  91698. overridenInstanceCount: number;
  91699. isFrozen: boolean;
  91700. previousBatch: Nullable<_InstancesBatch>;
  91701. hardwareInstancedRendering: boolean;
  91702. sideOrientation: number;
  91703. manualUpdate: boolean;
  91704. }
  91705. /**
  91706. * @hidden
  91707. **/
  91708. export class _InstancesBatch {
  91709. mustReturn: boolean;
  91710. visibleInstances: Nullable<InstancedMesh[]>[];
  91711. renderSelf: boolean[];
  91712. hardwareInstancedRendering: boolean[];
  91713. }
  91714. /**
  91715. * Class used to represent renderable models
  91716. */
  91717. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  91718. /**
  91719. * Mesh side orientation : usually the external or front surface
  91720. */
  91721. static readonly FRONTSIDE: number;
  91722. /**
  91723. * Mesh side orientation : usually the internal or back surface
  91724. */
  91725. static readonly BACKSIDE: number;
  91726. /**
  91727. * Mesh side orientation : both internal and external or front and back surfaces
  91728. */
  91729. static readonly DOUBLESIDE: number;
  91730. /**
  91731. * Mesh side orientation : by default, `FRONTSIDE`
  91732. */
  91733. static readonly DEFAULTSIDE: number;
  91734. /**
  91735. * Mesh cap setting : no cap
  91736. */
  91737. static readonly NO_CAP: number;
  91738. /**
  91739. * Mesh cap setting : one cap at the beginning of the mesh
  91740. */
  91741. static readonly CAP_START: number;
  91742. /**
  91743. * Mesh cap setting : one cap at the end of the mesh
  91744. */
  91745. static readonly CAP_END: number;
  91746. /**
  91747. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  91748. */
  91749. static readonly CAP_ALL: number;
  91750. /**
  91751. * Mesh pattern setting : no flip or rotate
  91752. */
  91753. static readonly NO_FLIP: number;
  91754. /**
  91755. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  91756. */
  91757. static readonly FLIP_TILE: number;
  91758. /**
  91759. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  91760. */
  91761. static readonly ROTATE_TILE: number;
  91762. /**
  91763. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  91764. */
  91765. static readonly FLIP_ROW: number;
  91766. /**
  91767. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  91768. */
  91769. static readonly ROTATE_ROW: number;
  91770. /**
  91771. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  91772. */
  91773. static readonly FLIP_N_ROTATE_TILE: number;
  91774. /**
  91775. * Mesh pattern setting : rotate pattern and rotate
  91776. */
  91777. static readonly FLIP_N_ROTATE_ROW: number;
  91778. /**
  91779. * Mesh tile positioning : part tiles same on left/right or top/bottom
  91780. */
  91781. static readonly CENTER: number;
  91782. /**
  91783. * Mesh tile positioning : part tiles on left
  91784. */
  91785. static readonly LEFT: number;
  91786. /**
  91787. * Mesh tile positioning : part tiles on right
  91788. */
  91789. static readonly RIGHT: number;
  91790. /**
  91791. * Mesh tile positioning : part tiles on top
  91792. */
  91793. static readonly TOP: number;
  91794. /**
  91795. * Mesh tile positioning : part tiles on bottom
  91796. */
  91797. static readonly BOTTOM: number;
  91798. /**
  91799. * Gets the default side orientation.
  91800. * @param orientation the orientation to value to attempt to get
  91801. * @returns the default orientation
  91802. * @hidden
  91803. */
  91804. static _GetDefaultSideOrientation(orientation?: number): number;
  91805. private _internalMeshDataInfo;
  91806. /**
  91807. * An event triggered before rendering the mesh
  91808. */
  91809. readonly onBeforeRenderObservable: Observable<Mesh>;
  91810. /**
  91811. * An event triggered before binding the mesh
  91812. */
  91813. readonly onBeforeBindObservable: Observable<Mesh>;
  91814. /**
  91815. * An event triggered after rendering the mesh
  91816. */
  91817. readonly onAfterRenderObservable: Observable<Mesh>;
  91818. /**
  91819. * An event triggered before drawing the mesh
  91820. */
  91821. readonly onBeforeDrawObservable: Observable<Mesh>;
  91822. private _onBeforeDrawObserver;
  91823. /**
  91824. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  91825. */
  91826. onBeforeDraw: () => void;
  91827. readonly hasInstances: boolean;
  91828. /**
  91829. * Gets the delay loading state of the mesh (when delay loading is turned on)
  91830. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  91831. */
  91832. delayLoadState: number;
  91833. /**
  91834. * Gets the list of instances created from this mesh
  91835. * it is not supposed to be modified manually.
  91836. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  91837. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91838. */
  91839. instances: InstancedMesh[];
  91840. /**
  91841. * Gets the file containing delay loading data for this mesh
  91842. */
  91843. delayLoadingFile: string;
  91844. /** @hidden */
  91845. _binaryInfo: any;
  91846. /**
  91847. * User defined function used to change how LOD level selection is done
  91848. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  91849. */
  91850. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  91851. /**
  91852. * Gets or sets the morph target manager
  91853. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91854. */
  91855. morphTargetManager: Nullable<MorphTargetManager>;
  91856. /** @hidden */
  91857. _creationDataStorage: Nullable<_CreationDataStorage>;
  91858. /** @hidden */
  91859. _geometry: Nullable<Geometry>;
  91860. /** @hidden */
  91861. _delayInfo: Array<string>;
  91862. /** @hidden */
  91863. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  91864. /** @hidden */
  91865. _instanceDataStorage: _InstanceDataStorage;
  91866. private _effectiveMaterial;
  91867. /** @hidden */
  91868. _shouldGenerateFlatShading: boolean;
  91869. /** @hidden */
  91870. _originalBuilderSideOrientation: number;
  91871. /**
  91872. * Use this property to change the original side orientation defined at construction time
  91873. */
  91874. overrideMaterialSideOrientation: Nullable<number>;
  91875. /**
  91876. * Gets the source mesh (the one used to clone this one from)
  91877. */
  91878. readonly source: Nullable<Mesh>;
  91879. /**
  91880. * Gets or sets a boolean indicating that this mesh does not use index buffer
  91881. */
  91882. isUnIndexed: boolean;
  91883. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  91884. readonly worldMatrixInstancedBuffer: Float32Array;
  91885. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  91886. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  91887. /**
  91888. * @constructor
  91889. * @param name The value used by scene.getMeshByName() to do a lookup.
  91890. * @param scene The scene to add this mesh to.
  91891. * @param parent The parent of this mesh, if it has one
  91892. * @param source An optional Mesh from which geometry is shared, cloned.
  91893. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  91894. * When false, achieved by calling a clone(), also passing False.
  91895. * This will make creation of children, recursive.
  91896. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  91897. */
  91898. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  91899. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  91900. doNotInstantiate: boolean;
  91901. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  91902. /**
  91903. * Gets the class name
  91904. * @returns the string "Mesh".
  91905. */
  91906. getClassName(): string;
  91907. /** @hidden */
  91908. readonly _isMesh: boolean;
  91909. /**
  91910. * Returns a description of this mesh
  91911. * @param fullDetails define if full details about this mesh must be used
  91912. * @returns a descriptive string representing this mesh
  91913. */
  91914. toString(fullDetails?: boolean): string;
  91915. /** @hidden */
  91916. _unBindEffect(): void;
  91917. /**
  91918. * Gets a boolean indicating if this mesh has LOD
  91919. */
  91920. readonly hasLODLevels: boolean;
  91921. /**
  91922. * Gets the list of MeshLODLevel associated with the current mesh
  91923. * @returns an array of MeshLODLevel
  91924. */
  91925. getLODLevels(): MeshLODLevel[];
  91926. private _sortLODLevels;
  91927. /**
  91928. * Add a mesh as LOD level triggered at the given distance.
  91929. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91930. * @param distance The distance from the center of the object to show this level
  91931. * @param mesh The mesh to be added as LOD level (can be null)
  91932. * @return This mesh (for chaining)
  91933. */
  91934. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  91935. /**
  91936. * Returns the LOD level mesh at the passed distance or null if not found.
  91937. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91938. * @param distance The distance from the center of the object to show this level
  91939. * @returns a Mesh or `null`
  91940. */
  91941. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  91942. /**
  91943. * Remove a mesh from the LOD array
  91944. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91945. * @param mesh defines the mesh to be removed
  91946. * @return This mesh (for chaining)
  91947. */
  91948. removeLODLevel(mesh: Mesh): Mesh;
  91949. /**
  91950. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  91951. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91952. * @param camera defines the camera to use to compute distance
  91953. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  91954. * @return This mesh (for chaining)
  91955. */
  91956. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  91957. /**
  91958. * Gets the mesh internal Geometry object
  91959. */
  91960. readonly geometry: Nullable<Geometry>;
  91961. /**
  91962. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  91963. * @returns the total number of vertices
  91964. */
  91965. getTotalVertices(): number;
  91966. /**
  91967. * Returns the content of an associated vertex buffer
  91968. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91969. * - VertexBuffer.PositionKind
  91970. * - VertexBuffer.UVKind
  91971. * - VertexBuffer.UV2Kind
  91972. * - VertexBuffer.UV3Kind
  91973. * - VertexBuffer.UV4Kind
  91974. * - VertexBuffer.UV5Kind
  91975. * - VertexBuffer.UV6Kind
  91976. * - VertexBuffer.ColorKind
  91977. * - VertexBuffer.MatricesIndicesKind
  91978. * - VertexBuffer.MatricesIndicesExtraKind
  91979. * - VertexBuffer.MatricesWeightsKind
  91980. * - VertexBuffer.MatricesWeightsExtraKind
  91981. * @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
  91982. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  91983. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  91984. */
  91985. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  91986. /**
  91987. * Returns the mesh VertexBuffer object from the requested `kind`
  91988. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91989. * - VertexBuffer.PositionKind
  91990. * - VertexBuffer.NormalKind
  91991. * - VertexBuffer.UVKind
  91992. * - VertexBuffer.UV2Kind
  91993. * - VertexBuffer.UV3Kind
  91994. * - VertexBuffer.UV4Kind
  91995. * - VertexBuffer.UV5Kind
  91996. * - VertexBuffer.UV6Kind
  91997. * - VertexBuffer.ColorKind
  91998. * - VertexBuffer.MatricesIndicesKind
  91999. * - VertexBuffer.MatricesIndicesExtraKind
  92000. * - VertexBuffer.MatricesWeightsKind
  92001. * - VertexBuffer.MatricesWeightsExtraKind
  92002. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  92003. */
  92004. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  92005. /**
  92006. * Tests if a specific vertex buffer is associated with this mesh
  92007. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  92008. * - VertexBuffer.PositionKind
  92009. * - VertexBuffer.NormalKind
  92010. * - VertexBuffer.UVKind
  92011. * - VertexBuffer.UV2Kind
  92012. * - VertexBuffer.UV3Kind
  92013. * - VertexBuffer.UV4Kind
  92014. * - VertexBuffer.UV5Kind
  92015. * - VertexBuffer.UV6Kind
  92016. * - VertexBuffer.ColorKind
  92017. * - VertexBuffer.MatricesIndicesKind
  92018. * - VertexBuffer.MatricesIndicesExtraKind
  92019. * - VertexBuffer.MatricesWeightsKind
  92020. * - VertexBuffer.MatricesWeightsExtraKind
  92021. * @returns a boolean
  92022. */
  92023. isVerticesDataPresent(kind: string): boolean;
  92024. /**
  92025. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  92026. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  92027. * - VertexBuffer.PositionKind
  92028. * - VertexBuffer.UVKind
  92029. * - VertexBuffer.UV2Kind
  92030. * - VertexBuffer.UV3Kind
  92031. * - VertexBuffer.UV4Kind
  92032. * - VertexBuffer.UV5Kind
  92033. * - VertexBuffer.UV6Kind
  92034. * - VertexBuffer.ColorKind
  92035. * - VertexBuffer.MatricesIndicesKind
  92036. * - VertexBuffer.MatricesIndicesExtraKind
  92037. * - VertexBuffer.MatricesWeightsKind
  92038. * - VertexBuffer.MatricesWeightsExtraKind
  92039. * @returns a boolean
  92040. */
  92041. isVertexBufferUpdatable(kind: string): boolean;
  92042. /**
  92043. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  92044. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92045. * - VertexBuffer.PositionKind
  92046. * - VertexBuffer.NormalKind
  92047. * - VertexBuffer.UVKind
  92048. * - VertexBuffer.UV2Kind
  92049. * - VertexBuffer.UV3Kind
  92050. * - VertexBuffer.UV4Kind
  92051. * - VertexBuffer.UV5Kind
  92052. * - VertexBuffer.UV6Kind
  92053. * - VertexBuffer.ColorKind
  92054. * - VertexBuffer.MatricesIndicesKind
  92055. * - VertexBuffer.MatricesIndicesExtraKind
  92056. * - VertexBuffer.MatricesWeightsKind
  92057. * - VertexBuffer.MatricesWeightsExtraKind
  92058. * @returns an array of strings
  92059. */
  92060. getVerticesDataKinds(): string[];
  92061. /**
  92062. * Returns a positive integer : the total number of indices in this mesh geometry.
  92063. * @returns the numner of indices or zero if the mesh has no geometry.
  92064. */
  92065. getTotalIndices(): number;
  92066. /**
  92067. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92068. * @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.
  92069. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92070. * @returns the indices array or an empty array if the mesh has no geometry
  92071. */
  92072. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92073. readonly isBlocked: boolean;
  92074. /**
  92075. * Determine if the current mesh is ready to be rendered
  92076. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92077. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  92078. * @returns true if all associated assets are ready (material, textures, shaders)
  92079. */
  92080. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  92081. /**
  92082. * 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.
  92083. */
  92084. readonly areNormalsFrozen: boolean;
  92085. /**
  92086. * 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.
  92087. * @returns the current mesh
  92088. */
  92089. freezeNormals(): Mesh;
  92090. /**
  92091. * 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
  92092. * @returns the current mesh
  92093. */
  92094. unfreezeNormals(): Mesh;
  92095. /**
  92096. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  92097. */
  92098. overridenInstanceCount: number;
  92099. /** @hidden */
  92100. _preActivate(): Mesh;
  92101. /** @hidden */
  92102. _preActivateForIntermediateRendering(renderId: number): Mesh;
  92103. /** @hidden */
  92104. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  92105. /**
  92106. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92107. * This means the mesh underlying bounding box and sphere are recomputed.
  92108. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92109. * @returns the current mesh
  92110. */
  92111. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  92112. /** @hidden */
  92113. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  92114. /**
  92115. * This function will subdivide the mesh into multiple submeshes
  92116. * @param count defines the expected number of submeshes
  92117. */
  92118. subdivide(count: number): void;
  92119. /**
  92120. * Copy a FloatArray into a specific associated vertex buffer
  92121. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92122. * - VertexBuffer.PositionKind
  92123. * - VertexBuffer.UVKind
  92124. * - VertexBuffer.UV2Kind
  92125. * - VertexBuffer.UV3Kind
  92126. * - VertexBuffer.UV4Kind
  92127. * - VertexBuffer.UV5Kind
  92128. * - VertexBuffer.UV6Kind
  92129. * - VertexBuffer.ColorKind
  92130. * - VertexBuffer.MatricesIndicesKind
  92131. * - VertexBuffer.MatricesIndicesExtraKind
  92132. * - VertexBuffer.MatricesWeightsKind
  92133. * - VertexBuffer.MatricesWeightsExtraKind
  92134. * @param data defines the data source
  92135. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92136. * @param stride defines the data stride size (can be null)
  92137. * @returns the current mesh
  92138. */
  92139. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92140. /**
  92141. * Delete a vertex buffer associated with this mesh
  92142. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  92143. * - VertexBuffer.PositionKind
  92144. * - VertexBuffer.UVKind
  92145. * - VertexBuffer.UV2Kind
  92146. * - VertexBuffer.UV3Kind
  92147. * - VertexBuffer.UV4Kind
  92148. * - VertexBuffer.UV5Kind
  92149. * - VertexBuffer.UV6Kind
  92150. * - VertexBuffer.ColorKind
  92151. * - VertexBuffer.MatricesIndicesKind
  92152. * - VertexBuffer.MatricesIndicesExtraKind
  92153. * - VertexBuffer.MatricesWeightsKind
  92154. * - VertexBuffer.MatricesWeightsExtraKind
  92155. */
  92156. removeVerticesData(kind: string): void;
  92157. /**
  92158. * Flags an associated vertex buffer as updatable
  92159. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  92160. * - VertexBuffer.PositionKind
  92161. * - VertexBuffer.UVKind
  92162. * - VertexBuffer.UV2Kind
  92163. * - VertexBuffer.UV3Kind
  92164. * - VertexBuffer.UV4Kind
  92165. * - VertexBuffer.UV5Kind
  92166. * - VertexBuffer.UV6Kind
  92167. * - VertexBuffer.ColorKind
  92168. * - VertexBuffer.MatricesIndicesKind
  92169. * - VertexBuffer.MatricesIndicesExtraKind
  92170. * - VertexBuffer.MatricesWeightsKind
  92171. * - VertexBuffer.MatricesWeightsExtraKind
  92172. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92173. */
  92174. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  92175. /**
  92176. * Sets the mesh global Vertex Buffer
  92177. * @param buffer defines the buffer to use
  92178. * @returns the current mesh
  92179. */
  92180. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  92181. /**
  92182. * Update a specific associated vertex buffer
  92183. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92184. * - VertexBuffer.PositionKind
  92185. * - VertexBuffer.UVKind
  92186. * - VertexBuffer.UV2Kind
  92187. * - VertexBuffer.UV3Kind
  92188. * - VertexBuffer.UV4Kind
  92189. * - VertexBuffer.UV5Kind
  92190. * - VertexBuffer.UV6Kind
  92191. * - VertexBuffer.ColorKind
  92192. * - VertexBuffer.MatricesIndicesKind
  92193. * - VertexBuffer.MatricesIndicesExtraKind
  92194. * - VertexBuffer.MatricesWeightsKind
  92195. * - VertexBuffer.MatricesWeightsExtraKind
  92196. * @param data defines the data source
  92197. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  92198. * @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)
  92199. * @returns the current mesh
  92200. */
  92201. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92202. /**
  92203. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  92204. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  92205. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  92206. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  92207. * @returns the current mesh
  92208. */
  92209. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  92210. /**
  92211. * Creates a un-shared specific occurence of the geometry for the mesh.
  92212. * @returns the current mesh
  92213. */
  92214. makeGeometryUnique(): Mesh;
  92215. /**
  92216. * Set the index buffer of this mesh
  92217. * @param indices defines the source data
  92218. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  92219. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  92220. * @returns the current mesh
  92221. */
  92222. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  92223. /**
  92224. * Update the current index buffer
  92225. * @param indices defines the source data
  92226. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92227. * @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)
  92228. * @returns the current mesh
  92229. */
  92230. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92231. /**
  92232. * Invert the geometry to move from a right handed system to a left handed one.
  92233. * @returns the current mesh
  92234. */
  92235. toLeftHanded(): Mesh;
  92236. /** @hidden */
  92237. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  92238. /** @hidden */
  92239. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  92240. /**
  92241. * Registers for this mesh a javascript function called just before the rendering process
  92242. * @param func defines the function to call before rendering this mesh
  92243. * @returns the current mesh
  92244. */
  92245. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92246. /**
  92247. * Disposes a previously registered javascript function called before the rendering
  92248. * @param func defines the function to remove
  92249. * @returns the current mesh
  92250. */
  92251. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92252. /**
  92253. * Registers for this mesh a javascript function called just after the rendering is complete
  92254. * @param func defines the function to call after rendering this mesh
  92255. * @returns the current mesh
  92256. */
  92257. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92258. /**
  92259. * Disposes a previously registered javascript function called after the rendering.
  92260. * @param func defines the function to remove
  92261. * @returns the current mesh
  92262. */
  92263. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92264. /** @hidden */
  92265. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  92266. /** @hidden */
  92267. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  92268. /** @hidden */
  92269. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  92270. /** @hidden */
  92271. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  92272. /** @hidden */
  92273. _rebuild(): void;
  92274. /** @hidden */
  92275. _freeze(): void;
  92276. /** @hidden */
  92277. _unFreeze(): void;
  92278. /**
  92279. * 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
  92280. * @param subMesh defines the subMesh to render
  92281. * @param enableAlphaMode defines if alpha mode can be changed
  92282. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  92283. * @returns the current mesh
  92284. */
  92285. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  92286. private _onBeforeDraw;
  92287. /**
  92288. * Renormalize the mesh and patch it up if there are no weights
  92289. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  92290. * However in the case of zero weights then we set just a single influence to 1.
  92291. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  92292. */
  92293. cleanMatrixWeights(): void;
  92294. private normalizeSkinFourWeights;
  92295. private normalizeSkinWeightsAndExtra;
  92296. /**
  92297. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  92298. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  92299. * the user know there was an issue with importing the mesh
  92300. * @returns a validation object with skinned, valid and report string
  92301. */
  92302. validateSkinning(): {
  92303. skinned: boolean;
  92304. valid: boolean;
  92305. report: string;
  92306. };
  92307. /** @hidden */
  92308. _checkDelayState(): Mesh;
  92309. private _queueLoad;
  92310. /**
  92311. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92312. * A mesh is in the frustum if its bounding box intersects the frustum
  92313. * @param frustumPlanes defines the frustum to test
  92314. * @returns true if the mesh is in the frustum planes
  92315. */
  92316. isInFrustum(frustumPlanes: Plane[]): boolean;
  92317. /**
  92318. * Sets the mesh material by the material or multiMaterial `id` property
  92319. * @param id is a string identifying the material or the multiMaterial
  92320. * @returns the current mesh
  92321. */
  92322. setMaterialByID(id: string): Mesh;
  92323. /**
  92324. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  92325. * @returns an array of IAnimatable
  92326. */
  92327. getAnimatables(): IAnimatable[];
  92328. /**
  92329. * Modifies the mesh geometry according to the passed transformation matrix.
  92330. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  92331. * The mesh normals are modified using the same transformation.
  92332. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92333. * @param transform defines the transform matrix to use
  92334. * @see http://doc.babylonjs.com/resources/baking_transformations
  92335. * @returns the current mesh
  92336. */
  92337. bakeTransformIntoVertices(transform: Matrix): Mesh;
  92338. /**
  92339. * Modifies the mesh geometry according to its own current World Matrix.
  92340. * The mesh World Matrix is then reset.
  92341. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  92342. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92343. * @see http://doc.babylonjs.com/resources/baking_transformations
  92344. * @returns the current mesh
  92345. */
  92346. bakeCurrentTransformIntoVertices(): Mesh;
  92347. /** @hidden */
  92348. readonly _positions: Nullable<Vector3[]>;
  92349. /** @hidden */
  92350. _resetPointsArrayCache(): Mesh;
  92351. /** @hidden */
  92352. _generatePointsArray(): boolean;
  92353. /**
  92354. * Returns a new Mesh object generated from the current mesh properties.
  92355. * This method must not get confused with createInstance()
  92356. * @param name is a string, the name given to the new mesh
  92357. * @param newParent can be any Node object (default `null`)
  92358. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  92359. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  92360. * @returns a new mesh
  92361. */
  92362. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  92363. /**
  92364. * Releases resources associated with this mesh.
  92365. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92366. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92367. */
  92368. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92369. /** @hidden */
  92370. _disposeInstanceSpecificData(): void;
  92371. /**
  92372. * Modifies the mesh geometry according to a displacement map.
  92373. * 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.
  92374. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92375. * @param url is a string, the URL from the image file is to be downloaded.
  92376. * @param minHeight is the lower limit of the displacement.
  92377. * @param maxHeight is the upper limit of the displacement.
  92378. * @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.
  92379. * @param uvOffset is an optional vector2 used to offset UV.
  92380. * @param uvScale is an optional vector2 used to scale UV.
  92381. * @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.
  92382. * @returns the Mesh.
  92383. */
  92384. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92385. /**
  92386. * Modifies the mesh geometry according to a displacementMap buffer.
  92387. * 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.
  92388. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92389. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  92390. * @param heightMapWidth is the width of the buffer image.
  92391. * @param heightMapHeight is the height of the buffer image.
  92392. * @param minHeight is the lower limit of the displacement.
  92393. * @param maxHeight is the upper limit of the displacement.
  92394. * @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.
  92395. * @param uvOffset is an optional vector2 used to offset UV.
  92396. * @param uvScale is an optional vector2 used to scale UV.
  92397. * @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.
  92398. * @returns the Mesh.
  92399. */
  92400. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92401. /**
  92402. * Modify the mesh to get a flat shading rendering.
  92403. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  92404. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  92405. * @returns current mesh
  92406. */
  92407. convertToFlatShadedMesh(): Mesh;
  92408. /**
  92409. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  92410. * In other words, more vertices, no more indices and a single bigger VBO.
  92411. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  92412. * @returns current mesh
  92413. */
  92414. convertToUnIndexedMesh(): Mesh;
  92415. /**
  92416. * Inverses facet orientations.
  92417. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92418. * @param flipNormals will also inverts the normals
  92419. * @returns current mesh
  92420. */
  92421. flipFaces(flipNormals?: boolean): Mesh;
  92422. /**
  92423. * Increase the number of facets and hence vertices in a mesh
  92424. * Vertex normals are interpolated from existing vertex normals
  92425. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92426. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  92427. */
  92428. increaseVertices(numberPerEdge: number): void;
  92429. /**
  92430. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  92431. * This will undo any application of covertToFlatShadedMesh
  92432. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92433. */
  92434. forceSharedVertices(): void;
  92435. /** @hidden */
  92436. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  92437. /** @hidden */
  92438. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  92439. /**
  92440. * Creates a new InstancedMesh object from the mesh model.
  92441. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92442. * @param name defines the name of the new instance
  92443. * @returns a new InstancedMesh
  92444. */
  92445. createInstance(name: string): InstancedMesh;
  92446. /**
  92447. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  92448. * After this call, all the mesh instances have the same submeshes than the current mesh.
  92449. * @returns the current mesh
  92450. */
  92451. synchronizeInstances(): Mesh;
  92452. /**
  92453. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  92454. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  92455. * This should be used together with the simplification to avoid disappearing triangles.
  92456. * @param successCallback an optional success callback to be called after the optimization finished.
  92457. * @returns the current mesh
  92458. */
  92459. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  92460. /**
  92461. * Serialize current mesh
  92462. * @param serializationObject defines the object which will receive the serialization data
  92463. */
  92464. serialize(serializationObject: any): void;
  92465. /** @hidden */
  92466. _syncGeometryWithMorphTargetManager(): void;
  92467. /** @hidden */
  92468. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  92469. /**
  92470. * Returns a new Mesh object parsed from the source provided.
  92471. * @param parsedMesh is the source
  92472. * @param scene defines the hosting scene
  92473. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  92474. * @returns a new Mesh
  92475. */
  92476. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  92477. /**
  92478. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  92479. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92480. * @param name defines the name of the mesh to create
  92481. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  92482. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  92483. * @param closePath creates a seam between the first and the last points of each path of the path array
  92484. * @param offset is taken in account only if the `pathArray` is containing a single path
  92485. * @param scene defines the hosting scene
  92486. * @param updatable defines if the mesh must be flagged as updatable
  92487. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92488. * @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)
  92489. * @returns a new Mesh
  92490. */
  92491. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92492. /**
  92493. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  92494. * @param name defines the name of the mesh to create
  92495. * @param radius sets the radius size (float) of the polygon (default 0.5)
  92496. * @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
  92497. * @param scene defines the hosting scene
  92498. * @param updatable defines if the mesh must be flagged as updatable
  92499. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92500. * @returns a new Mesh
  92501. */
  92502. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92503. /**
  92504. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  92505. * @param name defines the name of the mesh to create
  92506. * @param size sets the size (float) of each box side (default 1)
  92507. * @param scene defines the hosting scene
  92508. * @param updatable defines if the mesh must be flagged as updatable
  92509. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92510. * @returns a new Mesh
  92511. */
  92512. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92513. /**
  92514. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  92515. * @param name defines the name of the mesh to create
  92516. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92517. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92518. * @param scene defines the hosting scene
  92519. * @param updatable defines if the mesh must be flagged as updatable
  92520. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92521. * @returns a new Mesh
  92522. */
  92523. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92524. /**
  92525. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  92526. * @param name defines the name of the mesh to create
  92527. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92528. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92529. * @param scene defines the hosting scene
  92530. * @returns a new Mesh
  92531. */
  92532. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  92533. /**
  92534. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  92535. * @param name defines the name of the mesh to create
  92536. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  92537. * @param diameterTop set the top cap diameter (floats, default 1)
  92538. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  92539. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  92540. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  92541. * @param scene defines the hosting scene
  92542. * @param updatable defines if the mesh must be flagged as updatable
  92543. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92544. * @returns a new Mesh
  92545. */
  92546. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  92547. /**
  92548. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  92549. * @param name defines the name of the mesh to create
  92550. * @param diameter sets the diameter size (float) of the torus (default 1)
  92551. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  92552. * @param tessellation sets the number of torus sides (postive integer, default 16)
  92553. * @param scene defines the hosting scene
  92554. * @param updatable defines if the mesh must be flagged as updatable
  92555. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92556. * @returns a new Mesh
  92557. */
  92558. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92559. /**
  92560. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  92561. * @param name defines the name of the mesh to create
  92562. * @param radius sets the global radius size (float) of the torus knot (default 2)
  92563. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  92564. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  92565. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  92566. * @param p the number of windings on X axis (positive integers, default 2)
  92567. * @param q the number of windings on Y axis (positive integers, default 3)
  92568. * @param scene defines the hosting scene
  92569. * @param updatable defines if the mesh must be flagged as updatable
  92570. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92571. * @returns a new Mesh
  92572. */
  92573. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92574. /**
  92575. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  92576. * @param name defines the name of the mesh to create
  92577. * @param points is an array successive Vector3
  92578. * @param scene defines the hosting scene
  92579. * @param updatable defines if the mesh must be flagged as updatable
  92580. * @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).
  92581. * @returns a new Mesh
  92582. */
  92583. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  92584. /**
  92585. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  92586. * @param name defines the name of the mesh to create
  92587. * @param points is an array successive Vector3
  92588. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  92589. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  92590. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  92591. * @param scene defines the hosting scene
  92592. * @param updatable defines if the mesh must be flagged as updatable
  92593. * @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)
  92594. * @returns a new Mesh
  92595. */
  92596. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  92597. /**
  92598. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  92599. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  92600. * 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.
  92601. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92602. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92603. * Remember you can only change the shape positions, not their number when updating a polygon.
  92604. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  92605. * @param name defines the name of the mesh to create
  92606. * @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
  92607. * @param scene defines the hosting scene
  92608. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92609. * @param updatable defines if the mesh must be flagged as updatable
  92610. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92611. * @param earcutInjection can be used to inject your own earcut reference
  92612. * @returns a new Mesh
  92613. */
  92614. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92615. /**
  92616. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  92617. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  92618. * @param name defines the name of the mesh to create
  92619. * @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
  92620. * @param depth defines the height of extrusion
  92621. * @param scene defines the hosting scene
  92622. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92623. * @param updatable defines if the mesh must be flagged as updatable
  92624. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92625. * @param earcutInjection can be used to inject your own earcut reference
  92626. * @returns a new Mesh
  92627. */
  92628. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92629. /**
  92630. * Creates an extruded shape mesh.
  92631. * 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
  92632. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92633. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92634. * @param name defines the name of the mesh to create
  92635. * @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
  92636. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92637. * @param scale is the value to scale the shape
  92638. * @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
  92639. * @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
  92640. * @param scene defines the hosting scene
  92641. * @param updatable defines if the mesh must be flagged as updatable
  92642. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92643. * @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)
  92644. * @returns a new Mesh
  92645. */
  92646. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92647. /**
  92648. * Creates an custom extruded shape mesh.
  92649. * The custom extrusion is a parametric shape.
  92650. * It has no predefined shape. Its final shape will depend on the input parameters.
  92651. * Please consider using the same method from the MeshBuilder class instead
  92652. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92653. * @param name defines the name of the mesh to create
  92654. * @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
  92655. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92656. * @param scaleFunction is a custom Javascript function called on each path point
  92657. * @param rotationFunction is a custom Javascript function called on each path point
  92658. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  92659. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  92660. * @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
  92661. * @param scene defines the hosting scene
  92662. * @param updatable defines if the mesh must be flagged as updatable
  92663. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92664. * @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)
  92665. * @returns a new Mesh
  92666. */
  92667. 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;
  92668. /**
  92669. * Creates lathe mesh.
  92670. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  92671. * Please consider using the same method from the MeshBuilder class instead
  92672. * @param name defines the name of the mesh to create
  92673. * @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
  92674. * @param radius is the radius value of the lathe
  92675. * @param tessellation is the side number of the lathe.
  92676. * @param scene defines the hosting scene
  92677. * @param updatable defines if the mesh must be flagged as updatable
  92678. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92679. * @returns a new Mesh
  92680. */
  92681. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92682. /**
  92683. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  92684. * @param name defines the name of the mesh to create
  92685. * @param size sets the size (float) of both sides of the plane at once (default 1)
  92686. * @param scene defines the hosting scene
  92687. * @param updatable defines if the mesh must be flagged as updatable
  92688. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92689. * @returns a new Mesh
  92690. */
  92691. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92692. /**
  92693. * Creates a ground mesh.
  92694. * Please consider using the same method from the MeshBuilder class instead
  92695. * @param name defines the name of the mesh to create
  92696. * @param width set the width of the ground
  92697. * @param height set the height of the ground
  92698. * @param subdivisions sets the number of subdivisions per side
  92699. * @param scene defines the hosting scene
  92700. * @param updatable defines if the mesh must be flagged as updatable
  92701. * @returns a new Mesh
  92702. */
  92703. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  92704. /**
  92705. * Creates a tiled ground mesh.
  92706. * Please consider using the same method from the MeshBuilder class instead
  92707. * @param name defines the name of the mesh to create
  92708. * @param xmin set the ground minimum X coordinate
  92709. * @param zmin set the ground minimum Y coordinate
  92710. * @param xmax set the ground maximum X coordinate
  92711. * @param zmax set the ground maximum Z coordinate
  92712. * @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
  92713. * @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
  92714. * @param scene defines the hosting scene
  92715. * @param updatable defines if the mesh must be flagged as updatable
  92716. * @returns a new Mesh
  92717. */
  92718. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  92719. w: number;
  92720. h: number;
  92721. }, precision: {
  92722. w: number;
  92723. h: number;
  92724. }, scene: Scene, updatable?: boolean): Mesh;
  92725. /**
  92726. * Creates a ground mesh from a height map.
  92727. * Please consider using the same method from the MeshBuilder class instead
  92728. * @see http://doc.babylonjs.com/babylon101/height_map
  92729. * @param name defines the name of the mesh to create
  92730. * @param url sets the URL of the height map image resource
  92731. * @param width set the ground width size
  92732. * @param height set the ground height size
  92733. * @param subdivisions sets the number of subdivision per side
  92734. * @param minHeight is the minimum altitude on the ground
  92735. * @param maxHeight is the maximum altitude on the ground
  92736. * @param scene defines the hosting scene
  92737. * @param updatable defines if the mesh must be flagged as updatable
  92738. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  92739. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  92740. * @returns a new Mesh
  92741. */
  92742. 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;
  92743. /**
  92744. * Creates a tube mesh.
  92745. * The tube is a parametric shape.
  92746. * It has no predefined shape. Its final shape will depend on the input parameters.
  92747. * Please consider using the same method from the MeshBuilder class instead
  92748. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92749. * @param name defines the name of the mesh to create
  92750. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  92751. * @param radius sets the tube radius size
  92752. * @param tessellation is the number of sides on the tubular surface
  92753. * @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
  92754. * @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
  92755. * @param scene defines the hosting scene
  92756. * @param updatable defines if the mesh must be flagged as updatable
  92757. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92758. * @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)
  92759. * @returns a new Mesh
  92760. */
  92761. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  92762. (i: number, distance: number): number;
  92763. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92764. /**
  92765. * Creates a polyhedron mesh.
  92766. * Please consider using the same method from the MeshBuilder class instead.
  92767. * * 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
  92768. * * The parameter `size` (positive float, default 1) sets the polygon size
  92769. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  92770. * * 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`
  92771. * * 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
  92772. * * 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)`)
  92773. * * 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
  92774. * * 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
  92775. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92776. * * If you create a double-sided mesh, you can choose what parts of 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
  92777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92778. * @param name defines the name of the mesh to create
  92779. * @param options defines the options used to create the mesh
  92780. * @param scene defines the hosting scene
  92781. * @returns a new Mesh
  92782. */
  92783. static CreatePolyhedron(name: string, options: {
  92784. type?: number;
  92785. size?: number;
  92786. sizeX?: number;
  92787. sizeY?: number;
  92788. sizeZ?: number;
  92789. custom?: any;
  92790. faceUV?: Vector4[];
  92791. faceColors?: Color4[];
  92792. updatable?: boolean;
  92793. sideOrientation?: number;
  92794. }, scene: Scene): Mesh;
  92795. /**
  92796. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  92797. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  92798. * * 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`)
  92799. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  92800. * * 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
  92801. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92802. * * If you create a double-sided mesh, you can choose what parts of 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
  92803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92804. * @param name defines the name of the mesh
  92805. * @param options defines the options used to create the mesh
  92806. * @param scene defines the hosting scene
  92807. * @returns a new Mesh
  92808. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  92809. */
  92810. static CreateIcoSphere(name: string, options: {
  92811. radius?: number;
  92812. flat?: boolean;
  92813. subdivisions?: number;
  92814. sideOrientation?: number;
  92815. updatable?: boolean;
  92816. }, scene: Scene): Mesh;
  92817. /**
  92818. * Creates a decal mesh.
  92819. * Please consider using the same method from the MeshBuilder class instead.
  92820. * A decal is a mesh usually applied as a model onto the surface of another mesh
  92821. * @param name defines the name of the mesh
  92822. * @param sourceMesh defines the mesh receiving the decal
  92823. * @param position sets the position of the decal in world coordinates
  92824. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  92825. * @param size sets the decal scaling
  92826. * @param angle sets the angle to rotate the decal
  92827. * @returns a new Mesh
  92828. */
  92829. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  92830. /**
  92831. * Prepare internal position array for software CPU skinning
  92832. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  92833. */
  92834. setPositionsForCPUSkinning(): Float32Array;
  92835. /**
  92836. * Prepare internal normal array for software CPU skinning
  92837. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  92838. */
  92839. setNormalsForCPUSkinning(): Float32Array;
  92840. /**
  92841. * Updates the vertex buffer by applying transformation from the bones
  92842. * @param skeleton defines the skeleton to apply to current mesh
  92843. * @returns the current mesh
  92844. */
  92845. applySkeleton(skeleton: Skeleton): Mesh;
  92846. /**
  92847. * 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
  92848. * @param meshes defines the list of meshes to scan
  92849. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  92850. */
  92851. static MinMax(meshes: AbstractMesh[]): {
  92852. min: Vector3;
  92853. max: Vector3;
  92854. };
  92855. /**
  92856. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  92857. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  92858. * @returns a vector3
  92859. */
  92860. static Center(meshesOrMinMaxVector: {
  92861. min: Vector3;
  92862. max: Vector3;
  92863. } | AbstractMesh[]): Vector3;
  92864. /**
  92865. * Merge the array of meshes into a single mesh for performance reasons.
  92866. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  92867. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  92868. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  92869. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  92870. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  92871. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  92872. * @returns a new mesh
  92873. */
  92874. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  92875. /** @hidden */
  92876. addInstance(instance: InstancedMesh): void;
  92877. /** @hidden */
  92878. removeInstance(instance: InstancedMesh): void;
  92879. }
  92880. }
  92881. declare module BABYLON {
  92882. /**
  92883. * This is the base class of all the camera used in the application.
  92884. * @see http://doc.babylonjs.com/features/cameras
  92885. */
  92886. export class Camera extends Node {
  92887. /** @hidden */
  92888. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  92889. /**
  92890. * This is the default projection mode used by the cameras.
  92891. * It helps recreating a feeling of perspective and better appreciate depth.
  92892. * This is the best way to simulate real life cameras.
  92893. */
  92894. static readonly PERSPECTIVE_CAMERA: number;
  92895. /**
  92896. * This helps creating camera with an orthographic mode.
  92897. * 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.
  92898. */
  92899. static readonly ORTHOGRAPHIC_CAMERA: number;
  92900. /**
  92901. * This is the default FOV mode for perspective cameras.
  92902. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  92903. */
  92904. static readonly FOVMODE_VERTICAL_FIXED: number;
  92905. /**
  92906. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  92907. */
  92908. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  92909. /**
  92910. * This specifies ther is no need for a camera rig.
  92911. * Basically only one eye is rendered corresponding to the camera.
  92912. */
  92913. static readonly RIG_MODE_NONE: number;
  92914. /**
  92915. * Simulates a camera Rig with one blue eye and one red eye.
  92916. * This can be use with 3d blue and red glasses.
  92917. */
  92918. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  92919. /**
  92920. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  92921. */
  92922. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  92923. /**
  92924. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  92925. */
  92926. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  92927. /**
  92928. * Defines that both eyes of the camera will be rendered over under each other.
  92929. */
  92930. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  92931. /**
  92932. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  92933. */
  92934. static readonly RIG_MODE_VR: number;
  92935. /**
  92936. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  92937. */
  92938. static readonly RIG_MODE_WEBVR: number;
  92939. /**
  92940. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  92941. */
  92942. static readonly RIG_MODE_CUSTOM: number;
  92943. /**
  92944. * Defines if by default attaching controls should prevent the default javascript event to continue.
  92945. */
  92946. static ForceAttachControlToAlwaysPreventDefault: boolean;
  92947. /**
  92948. * Define the input manager associated with the camera.
  92949. */
  92950. inputs: CameraInputsManager<Camera>;
  92951. /** @hidden */
  92952. _position: Vector3;
  92953. /**
  92954. * Define the current local position of the camera in the scene
  92955. */
  92956. position: Vector3;
  92957. /**
  92958. * The vector the camera should consider as up.
  92959. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  92960. */
  92961. upVector: Vector3;
  92962. /**
  92963. * Define the current limit on the left side for an orthographic camera
  92964. * In scene unit
  92965. */
  92966. orthoLeft: Nullable<number>;
  92967. /**
  92968. * Define the current limit on the right side for an orthographic camera
  92969. * In scene unit
  92970. */
  92971. orthoRight: Nullable<number>;
  92972. /**
  92973. * Define the current limit on the bottom side for an orthographic camera
  92974. * In scene unit
  92975. */
  92976. orthoBottom: Nullable<number>;
  92977. /**
  92978. * Define the current limit on the top side for an orthographic camera
  92979. * In scene unit
  92980. */
  92981. orthoTop: Nullable<number>;
  92982. /**
  92983. * Field Of View is set in Radians. (default is 0.8)
  92984. */
  92985. fov: number;
  92986. /**
  92987. * Define the minimum distance the camera can see from.
  92988. * This is important to note that the depth buffer are not infinite and the closer it starts
  92989. * the more your scene might encounter depth fighting issue.
  92990. */
  92991. minZ: number;
  92992. /**
  92993. * Define the maximum distance the camera can see to.
  92994. * This is important to note that the depth buffer are not infinite and the further it end
  92995. * the more your scene might encounter depth fighting issue.
  92996. */
  92997. maxZ: number;
  92998. /**
  92999. * Define the default inertia of the camera.
  93000. * This helps giving a smooth feeling to the camera movement.
  93001. */
  93002. inertia: number;
  93003. /**
  93004. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  93005. */
  93006. mode: number;
  93007. /**
  93008. * Define wether the camera is intermediate.
  93009. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93010. */
  93011. isIntermediate: boolean;
  93012. /**
  93013. * Define the viewport of the camera.
  93014. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93015. */
  93016. viewport: Viewport;
  93017. /**
  93018. * Restricts the camera to viewing objects with the same layerMask.
  93019. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93020. */
  93021. layerMask: number;
  93022. /**
  93023. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93024. */
  93025. fovMode: number;
  93026. /**
  93027. * Rig mode of the camera.
  93028. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93029. * This is normally controlled byt the camera themselves as internal use.
  93030. */
  93031. cameraRigMode: number;
  93032. /**
  93033. * Defines the distance between both "eyes" in case of a RIG
  93034. */
  93035. interaxialDistance: number;
  93036. /**
  93037. * Defines if stereoscopic rendering is done side by side or over under.
  93038. */
  93039. isStereoscopicSideBySide: boolean;
  93040. /**
  93041. * 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
  93042. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93043. * else in the scene. (Eg. security camera)
  93044. *
  93045. * 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)
  93046. */
  93047. customRenderTargets: RenderTargetTexture[];
  93048. /**
  93049. * When set, the camera will render to this render target instead of the default canvas
  93050. *
  93051. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  93052. */
  93053. outputRenderTarget: Nullable<RenderTargetTexture>;
  93054. /**
  93055. * Observable triggered when the camera view matrix has changed.
  93056. */
  93057. onViewMatrixChangedObservable: Observable<Camera>;
  93058. /**
  93059. * Observable triggered when the camera Projection matrix has changed.
  93060. */
  93061. onProjectionMatrixChangedObservable: Observable<Camera>;
  93062. /**
  93063. * Observable triggered when the inputs have been processed.
  93064. */
  93065. onAfterCheckInputsObservable: Observable<Camera>;
  93066. /**
  93067. * Observable triggered when reset has been called and applied to the camera.
  93068. */
  93069. onRestoreStateObservable: Observable<Camera>;
  93070. /** @hidden */
  93071. _cameraRigParams: any;
  93072. /** @hidden */
  93073. _rigCameras: Camera[];
  93074. /** @hidden */
  93075. _rigPostProcess: Nullable<PostProcess>;
  93076. protected _webvrViewMatrix: Matrix;
  93077. /** @hidden */
  93078. _skipRendering: boolean;
  93079. /** @hidden */
  93080. _projectionMatrix: Matrix;
  93081. /** @hidden */
  93082. _postProcesses: Nullable<PostProcess>[];
  93083. /** @hidden */
  93084. _activeMeshes: SmartArray<AbstractMesh>;
  93085. protected _globalPosition: Vector3;
  93086. /** @hidden */
  93087. _computedViewMatrix: Matrix;
  93088. private _doNotComputeProjectionMatrix;
  93089. private _transformMatrix;
  93090. private _frustumPlanes;
  93091. private _refreshFrustumPlanes;
  93092. private _storedFov;
  93093. private _stateStored;
  93094. /**
  93095. * Instantiates a new camera object.
  93096. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93097. * @see http://doc.babylonjs.com/features/cameras
  93098. * @param name Defines the name of the camera in the scene
  93099. * @param position Defines the position of the camera
  93100. * @param scene Defines the scene the camera belongs too
  93101. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93102. */
  93103. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93104. /**
  93105. * Store current camera state (fov, position, etc..)
  93106. * @returns the camera
  93107. */
  93108. storeState(): Camera;
  93109. /**
  93110. * Restores the camera state values if it has been stored. You must call storeState() first
  93111. */
  93112. protected _restoreStateValues(): boolean;
  93113. /**
  93114. * Restored camera state. You must call storeState() first.
  93115. * @returns true if restored and false otherwise
  93116. */
  93117. restoreState(): boolean;
  93118. /**
  93119. * Gets the class name of the camera.
  93120. * @returns the class name
  93121. */
  93122. getClassName(): string;
  93123. /** @hidden */
  93124. readonly _isCamera: boolean;
  93125. /**
  93126. * Gets a string representation of the camera useful for debug purpose.
  93127. * @param fullDetails Defines that a more verboe level of logging is required
  93128. * @returns the string representation
  93129. */
  93130. toString(fullDetails?: boolean): string;
  93131. /**
  93132. * Gets the current world space position of the camera.
  93133. */
  93134. readonly globalPosition: Vector3;
  93135. /**
  93136. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93137. * @returns the active meshe list
  93138. */
  93139. getActiveMeshes(): SmartArray<AbstractMesh>;
  93140. /**
  93141. * Check wether a mesh is part of the current active mesh list of the camera
  93142. * @param mesh Defines the mesh to check
  93143. * @returns true if active, false otherwise
  93144. */
  93145. isActiveMesh(mesh: Mesh): boolean;
  93146. /**
  93147. * Is this camera ready to be used/rendered
  93148. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93149. * @return true if the camera is ready
  93150. */
  93151. isReady(completeCheck?: boolean): boolean;
  93152. /** @hidden */
  93153. _initCache(): void;
  93154. /** @hidden */
  93155. _updateCache(ignoreParentClass?: boolean): void;
  93156. /** @hidden */
  93157. _isSynchronized(): boolean;
  93158. /** @hidden */
  93159. _isSynchronizedViewMatrix(): boolean;
  93160. /** @hidden */
  93161. _isSynchronizedProjectionMatrix(): boolean;
  93162. /**
  93163. * Attach the input controls to a specific dom element to get the input from.
  93164. * @param element Defines the element the controls should be listened from
  93165. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93166. */
  93167. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93168. /**
  93169. * Detach the current controls from the specified dom element.
  93170. * @param element Defines the element to stop listening the inputs from
  93171. */
  93172. detachControl(element: HTMLElement): void;
  93173. /**
  93174. * Update the camera state according to the different inputs gathered during the frame.
  93175. */
  93176. update(): void;
  93177. /** @hidden */
  93178. _checkInputs(): void;
  93179. /** @hidden */
  93180. readonly rigCameras: Camera[];
  93181. /**
  93182. * Gets the post process used by the rig cameras
  93183. */
  93184. readonly rigPostProcess: Nullable<PostProcess>;
  93185. /**
  93186. * Internal, gets the first post proces.
  93187. * @returns the first post process to be run on this camera.
  93188. */
  93189. _getFirstPostProcess(): Nullable<PostProcess>;
  93190. private _cascadePostProcessesToRigCams;
  93191. /**
  93192. * Attach a post process to the camera.
  93193. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93194. * @param postProcess The post process to attach to the camera
  93195. * @param insertAt The position of the post process in case several of them are in use in the scene
  93196. * @returns the position the post process has been inserted at
  93197. */
  93198. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93199. /**
  93200. * Detach a post process to the camera.
  93201. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93202. * @param postProcess The post process to detach from the camera
  93203. */
  93204. detachPostProcess(postProcess: PostProcess): void;
  93205. /**
  93206. * Gets the current world matrix of the camera
  93207. */
  93208. getWorldMatrix(): Matrix;
  93209. /** @hidden */
  93210. _getViewMatrix(): Matrix;
  93211. /**
  93212. * Gets the current view matrix of the camera.
  93213. * @param force forces the camera to recompute the matrix without looking at the cached state
  93214. * @returns the view matrix
  93215. */
  93216. getViewMatrix(force?: boolean): Matrix;
  93217. /**
  93218. * Freeze the projection matrix.
  93219. * It will prevent the cache check of the camera projection compute and can speed up perf
  93220. * if no parameter of the camera are meant to change
  93221. * @param projection Defines manually a projection if necessary
  93222. */
  93223. freezeProjectionMatrix(projection?: Matrix): void;
  93224. /**
  93225. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93226. */
  93227. unfreezeProjectionMatrix(): void;
  93228. /**
  93229. * Gets the current projection matrix of the camera.
  93230. * @param force forces the camera to recompute the matrix without looking at the cached state
  93231. * @returns the projection matrix
  93232. */
  93233. getProjectionMatrix(force?: boolean): Matrix;
  93234. /**
  93235. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93236. * @returns a Matrix
  93237. */
  93238. getTransformationMatrix(): Matrix;
  93239. private _updateFrustumPlanes;
  93240. /**
  93241. * Checks if a cullable object (mesh...) is in the camera frustum
  93242. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93243. * @param target The object to check
  93244. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93245. * @returns true if the object is in frustum otherwise false
  93246. */
  93247. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93248. /**
  93249. * Checks if a cullable object (mesh...) is in the camera frustum
  93250. * Unlike isInFrustum this cheks the full bounding box
  93251. * @param target The object to check
  93252. * @returns true if the object is in frustum otherwise false
  93253. */
  93254. isCompletelyInFrustum(target: ICullable): boolean;
  93255. /**
  93256. * Gets a ray in the forward direction from the camera.
  93257. * @param length Defines the length of the ray to create
  93258. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93259. * @param origin Defines the start point of the ray which defaults to the camera position
  93260. * @returns the forward ray
  93261. */
  93262. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93263. /**
  93264. * Releases resources associated with this node.
  93265. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93266. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93267. */
  93268. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93269. /** @hidden */
  93270. _isLeftCamera: boolean;
  93271. /**
  93272. * Gets the left camera of a rig setup in case of Rigged Camera
  93273. */
  93274. readonly isLeftCamera: boolean;
  93275. /** @hidden */
  93276. _isRightCamera: boolean;
  93277. /**
  93278. * Gets the right camera of a rig setup in case of Rigged Camera
  93279. */
  93280. readonly isRightCamera: boolean;
  93281. /**
  93282. * Gets the left camera of a rig setup in case of Rigged Camera
  93283. */
  93284. readonly leftCamera: Nullable<FreeCamera>;
  93285. /**
  93286. * Gets the right camera of a rig setup in case of Rigged Camera
  93287. */
  93288. readonly rightCamera: Nullable<FreeCamera>;
  93289. /**
  93290. * Gets the left camera target of a rig setup in case of Rigged Camera
  93291. * @returns the target position
  93292. */
  93293. getLeftTarget(): Nullable<Vector3>;
  93294. /**
  93295. * Gets the right camera target of a rig setup in case of Rigged Camera
  93296. * @returns the target position
  93297. */
  93298. getRightTarget(): Nullable<Vector3>;
  93299. /**
  93300. * @hidden
  93301. */
  93302. setCameraRigMode(mode: number, rigParams: any): void;
  93303. /** @hidden */
  93304. static _setStereoscopicRigMode(camera: Camera): void;
  93305. /** @hidden */
  93306. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93307. /** @hidden */
  93308. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93309. /** @hidden */
  93310. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93311. /** @hidden */
  93312. _getVRProjectionMatrix(): Matrix;
  93313. protected _updateCameraRotationMatrix(): void;
  93314. protected _updateWebVRCameraRotationMatrix(): void;
  93315. /**
  93316. * This function MUST be overwritten by the different WebVR cameras available.
  93317. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93318. * @hidden
  93319. */
  93320. _getWebVRProjectionMatrix(): Matrix;
  93321. /**
  93322. * This function MUST be overwritten by the different WebVR cameras available.
  93323. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93324. * @hidden
  93325. */
  93326. _getWebVRViewMatrix(): Matrix;
  93327. /** @hidden */
  93328. setCameraRigParameter(name: string, value: any): void;
  93329. /**
  93330. * needs to be overridden by children so sub has required properties to be copied
  93331. * @hidden
  93332. */
  93333. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93334. /**
  93335. * May need to be overridden by children
  93336. * @hidden
  93337. */
  93338. _updateRigCameras(): void;
  93339. /** @hidden */
  93340. _setupInputs(): void;
  93341. /**
  93342. * Serialiaze the camera setup to a json represention
  93343. * @returns the JSON representation
  93344. */
  93345. serialize(): any;
  93346. /**
  93347. * Clones the current camera.
  93348. * @param name The cloned camera name
  93349. * @returns the cloned camera
  93350. */
  93351. clone(name: string): Camera;
  93352. /**
  93353. * Gets the direction of the camera relative to a given local axis.
  93354. * @param localAxis Defines the reference axis to provide a relative direction.
  93355. * @return the direction
  93356. */
  93357. getDirection(localAxis: Vector3): Vector3;
  93358. /**
  93359. * Returns the current camera absolute rotation
  93360. */
  93361. readonly absoluteRotation: Quaternion;
  93362. /**
  93363. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93364. * @param localAxis Defines the reference axis to provide a relative direction.
  93365. * @param result Defines the vector to store the result in
  93366. */
  93367. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93368. /**
  93369. * Gets a camera constructor for a given camera type
  93370. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93371. * @param name The name of the camera the result will be able to instantiate
  93372. * @param scene The scene the result will construct the camera in
  93373. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93374. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93375. * @returns a factory method to construc the camera
  93376. */
  93377. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93378. /**
  93379. * Compute the world matrix of the camera.
  93380. * @returns the camera world matrix
  93381. */
  93382. computeWorldMatrix(): Matrix;
  93383. /**
  93384. * Parse a JSON and creates the camera from the parsed information
  93385. * @param parsedCamera The JSON to parse
  93386. * @param scene The scene to instantiate the camera in
  93387. * @returns the newly constructed camera
  93388. */
  93389. static Parse(parsedCamera: any, scene: Scene): Camera;
  93390. }
  93391. }
  93392. declare module BABYLON {
  93393. /**
  93394. * Class containing static functions to help procedurally build meshes
  93395. */
  93396. export class DiscBuilder {
  93397. /**
  93398. * Creates a plane polygonal mesh. By default, this is a disc
  93399. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  93400. * * 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
  93401. * * 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
  93402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  93403. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  93404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93405. * @param name defines the name of the mesh
  93406. * @param options defines the options used to create the mesh
  93407. * @param scene defines the hosting scene
  93408. * @returns the plane polygonal mesh
  93409. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  93410. */
  93411. static CreateDisc(name: string, options: {
  93412. radius?: number;
  93413. tessellation?: number;
  93414. arc?: number;
  93415. updatable?: boolean;
  93416. sideOrientation?: number;
  93417. frontUVs?: Vector4;
  93418. backUVs?: Vector4;
  93419. }, scene?: Nullable<Scene>): Mesh;
  93420. }
  93421. }
  93422. declare module BABYLON {
  93423. /**
  93424. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  93425. *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.
  93426. * The SPS is also a particle system. It provides some methods to manage the particles.
  93427. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  93428. *
  93429. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  93430. */
  93431. export class SolidParticleSystem implements IDisposable {
  93432. /**
  93433. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  93434. * Example : var p = SPS.particles[i];
  93435. */
  93436. particles: SolidParticle[];
  93437. /**
  93438. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  93439. */
  93440. nbParticles: number;
  93441. /**
  93442. * If the particles must ever face the camera (default false). Useful for planar particles.
  93443. */
  93444. billboard: boolean;
  93445. /**
  93446. * Recompute normals when adding a shape
  93447. */
  93448. recomputeNormals: boolean;
  93449. /**
  93450. * This a counter ofr your own usage. It's not set by any SPS functions.
  93451. */
  93452. counter: number;
  93453. /**
  93454. * The SPS name. This name is also given to the underlying mesh.
  93455. */
  93456. name: string;
  93457. /**
  93458. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  93459. */
  93460. mesh: Mesh;
  93461. /**
  93462. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  93463. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  93464. */
  93465. vars: any;
  93466. /**
  93467. * This array is populated when the SPS is set as 'pickable'.
  93468. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  93469. * Each element of this array is an object `{idx: int, faceId: int}`.
  93470. * `idx` is the picked particle index in the `SPS.particles` array
  93471. * `faceId` is the picked face index counted within this particle.
  93472. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  93473. */
  93474. pickedParticles: {
  93475. idx: number;
  93476. faceId: number;
  93477. }[];
  93478. /**
  93479. * This array is populated when `enableDepthSort` is set to true.
  93480. * Each element of this array is an instance of the class DepthSortedParticle.
  93481. */
  93482. depthSortedParticles: DepthSortedParticle[];
  93483. /**
  93484. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  93485. * @hidden
  93486. */
  93487. _bSphereOnly: boolean;
  93488. /**
  93489. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  93490. * @hidden
  93491. */
  93492. _bSphereRadiusFactor: number;
  93493. private _scene;
  93494. private _positions;
  93495. private _indices;
  93496. private _normals;
  93497. private _colors;
  93498. private _uvs;
  93499. private _indices32;
  93500. private _positions32;
  93501. private _normals32;
  93502. private _fixedNormal32;
  93503. private _colors32;
  93504. private _uvs32;
  93505. private _index;
  93506. private _updatable;
  93507. private _pickable;
  93508. private _isVisibilityBoxLocked;
  93509. private _alwaysVisible;
  93510. private _depthSort;
  93511. private _expandable;
  93512. private _shapeCounter;
  93513. private _copy;
  93514. private _color;
  93515. private _computeParticleColor;
  93516. private _computeParticleTexture;
  93517. private _computeParticleRotation;
  93518. private _computeParticleVertex;
  93519. private _computeBoundingBox;
  93520. private _depthSortParticles;
  93521. private _camera;
  93522. private _mustUnrotateFixedNormals;
  93523. private _particlesIntersect;
  93524. private _needs32Bits;
  93525. private _isNotBuilt;
  93526. private _lastParticleId;
  93527. private _idxOfId;
  93528. /**
  93529. * Creates a SPS (Solid Particle System) object.
  93530. * @param name (String) is the SPS name, this will be the underlying mesh name.
  93531. * @param scene (Scene) is the scene in which the SPS is added.
  93532. * @param options defines the options of the sps e.g.
  93533. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  93534. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  93535. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  93536. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  93537. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  93538. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  93539. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  93540. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  93541. */
  93542. constructor(name: string, scene: Scene, options?: {
  93543. updatable?: boolean;
  93544. isPickable?: boolean;
  93545. enableDepthSort?: boolean;
  93546. particleIntersection?: boolean;
  93547. boundingSphereOnly?: boolean;
  93548. bSphereRadiusFactor?: number;
  93549. expandable?: boolean;
  93550. });
  93551. /**
  93552. * Builds the SPS underlying mesh. Returns a standard Mesh.
  93553. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  93554. * @returns the created mesh
  93555. */
  93556. buildMesh(): Mesh;
  93557. /**
  93558. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  93559. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  93560. * Thus the particles generated from `digest()` have their property `position` set yet.
  93561. * @param mesh ( Mesh ) is the mesh to be digested
  93562. * @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
  93563. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  93564. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  93565. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  93566. * @returns the current SPS
  93567. */
  93568. digest(mesh: Mesh, options?: {
  93569. facetNb?: number;
  93570. number?: number;
  93571. delta?: number;
  93572. storage?: [];
  93573. }): SolidParticleSystem;
  93574. /**
  93575. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  93576. * @hidden
  93577. */
  93578. private _unrotateFixedNormals;
  93579. /**
  93580. * Resets the temporary working copy particle
  93581. * @hidden
  93582. */
  93583. private _resetCopy;
  93584. /**
  93585. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  93586. * @param p the current index in the positions array to be updated
  93587. * @param shape a Vector3 array, the shape geometry
  93588. * @param positions the positions array to be updated
  93589. * @param meshInd the shape indices array
  93590. * @param indices the indices array to be updated
  93591. * @param meshUV the shape uv array
  93592. * @param uvs the uv array to be updated
  93593. * @param meshCol the shape color array
  93594. * @param colors the color array to be updated
  93595. * @param meshNor the shape normals array
  93596. * @param normals the normals array to be updated
  93597. * @param idx the particle index
  93598. * @param idxInShape the particle index in its shape
  93599. * @param options the addShape() method passed options
  93600. * @hidden
  93601. */
  93602. private _meshBuilder;
  93603. /**
  93604. * Returns a shape Vector3 array from positions float array
  93605. * @param positions float array
  93606. * @returns a vector3 array
  93607. * @hidden
  93608. */
  93609. private _posToShape;
  93610. /**
  93611. * Returns a shapeUV array from a float uvs (array deep copy)
  93612. * @param uvs as a float array
  93613. * @returns a shapeUV array
  93614. * @hidden
  93615. */
  93616. private _uvsToShapeUV;
  93617. /**
  93618. * Adds a new particle object in the particles array
  93619. * @param idx particle index in particles array
  93620. * @param id particle id
  93621. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  93622. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  93623. * @param model particle ModelShape object
  93624. * @param shapeId model shape identifier
  93625. * @param idxInShape index of the particle in the current model
  93626. * @param bInfo model bounding info object
  93627. * @param storage target storage array, if any
  93628. * @hidden
  93629. */
  93630. private _addParticle;
  93631. /**
  93632. * Adds some particles to the SPS from the model shape. Returns the shape id.
  93633. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  93634. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  93635. * @param nb (positive integer) the number of particles to be created from this model
  93636. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  93637. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  93638. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  93639. * @returns the number of shapes in the system
  93640. */
  93641. addShape(mesh: Mesh, nb: number, options?: {
  93642. positionFunction?: any;
  93643. vertexFunction?: any;
  93644. storage?: [];
  93645. }): number;
  93646. /**
  93647. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  93648. * @hidden
  93649. */
  93650. private _rebuildParticle;
  93651. /**
  93652. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  93653. * @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.
  93654. * @returns the SPS.
  93655. */
  93656. rebuildMesh(reset?: boolean): SolidParticleSystem;
  93657. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  93658. * Returns an array with the removed particles.
  93659. * 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.
  93660. * The SPS can't be empty so at least one particle needs to remain in place.
  93661. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  93662. * @param start index of the first particle to remove
  93663. * @param end index of the last particle to remove (included)
  93664. * @returns an array populated with the removed particles
  93665. */
  93666. removeParticles(start: number, end: number): SolidParticle[];
  93667. /**
  93668. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  93669. * @param solidParticleArray an array populated with Solid Particles objects
  93670. * @returns the SPS
  93671. */
  93672. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  93673. /**
  93674. * Creates a new particle and modifies the SPS mesh geometry :
  93675. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  93676. * - calls _addParticle() to populate the particle array
  93677. * factorized code from addShape() and insertParticlesFromArray()
  93678. * @param idx particle index in the particles array
  93679. * @param i particle index in its shape
  93680. * @param modelShape particle ModelShape object
  93681. * @param shape shape vertex array
  93682. * @param meshInd shape indices array
  93683. * @param meshUV shape uv array
  93684. * @param meshCol shape color array
  93685. * @param meshNor shape normals array
  93686. * @param bbInfo shape bounding info
  93687. * @param storage target particle storage
  93688. * @options addShape() passed options
  93689. * @hidden
  93690. */
  93691. private _insertNewParticle;
  93692. /**
  93693. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  93694. * This method calls `updateParticle()` for each particle of the SPS.
  93695. * For an animated SPS, it is usually called within the render loop.
  93696. * 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.
  93697. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  93698. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  93699. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  93700. * @returns the SPS.
  93701. */
  93702. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  93703. /**
  93704. * Disposes the SPS.
  93705. */
  93706. dispose(): void;
  93707. /**
  93708. * Returns a SolidParticle object from its identifier : particle.id
  93709. * @param id (integer) the particle Id
  93710. * @returns the searched particle or null if not found in the SPS.
  93711. */
  93712. getParticleById(id: number): Nullable<SolidParticle>;
  93713. /**
  93714. * Returns a new array populated with the particles having the passed shapeId.
  93715. * @param shapeId (integer) the shape identifier
  93716. * @returns a new solid particle array
  93717. */
  93718. getParticlesByShapeId(shapeId: number): SolidParticle[];
  93719. /**
  93720. * Populates the passed array "ref" with the particles having the passed shapeId.
  93721. * @param shapeId the shape identifier
  93722. * @returns the SPS
  93723. * @param ref
  93724. */
  93725. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  93726. /**
  93727. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  93728. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93729. * @returns the SPS.
  93730. */
  93731. refreshVisibleSize(): SolidParticleSystem;
  93732. /**
  93733. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  93734. * @param size the size (float) of the visibility box
  93735. * note : this doesn't lock the SPS mesh bounding box.
  93736. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93737. */
  93738. setVisibilityBox(size: number): void;
  93739. /**
  93740. * Gets whether the SPS as always visible or not
  93741. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93742. */
  93743. /**
  93744. * Sets the SPS as always visible or not
  93745. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93746. */
  93747. isAlwaysVisible: boolean;
  93748. /**
  93749. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  93750. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93751. */
  93752. /**
  93753. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  93754. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93755. */
  93756. isVisibilityBoxLocked: boolean;
  93757. /**
  93758. * Tells to `setParticles()` to compute the particle rotations or not.
  93759. * Default value : true. The SPS is faster when it's set to false.
  93760. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  93761. */
  93762. /**
  93763. * Gets if `setParticles()` computes the particle rotations or not.
  93764. * Default value : true. The SPS is faster when it's set to false.
  93765. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  93766. */
  93767. computeParticleRotation: boolean;
  93768. /**
  93769. * Tells to `setParticles()` to compute the particle colors or not.
  93770. * Default value : true. The SPS is faster when it's set to false.
  93771. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  93772. */
  93773. /**
  93774. * Gets if `setParticles()` computes the particle colors or not.
  93775. * Default value : true. The SPS is faster when it's set to false.
  93776. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  93777. */
  93778. computeParticleColor: boolean;
  93779. /**
  93780. * Gets if `setParticles()` computes the particle textures or not.
  93781. * Default value : true. The SPS is faster when it's set to false.
  93782. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  93783. */
  93784. computeParticleTexture: boolean;
  93785. /**
  93786. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  93787. * Default value : false. The SPS is faster when it's set to false.
  93788. * Note : the particle custom vertex positions aren't stored values.
  93789. */
  93790. /**
  93791. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  93792. * Default value : false. The SPS is faster when it's set to false.
  93793. * Note : the particle custom vertex positions aren't stored values.
  93794. */
  93795. computeParticleVertex: boolean;
  93796. /**
  93797. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  93798. */
  93799. /**
  93800. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  93801. */
  93802. computeBoundingBox: boolean;
  93803. /**
  93804. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  93805. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  93806. * Default : `true`
  93807. */
  93808. /**
  93809. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  93810. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  93811. * Default : `true`
  93812. */
  93813. depthSortParticles: boolean;
  93814. /**
  93815. * Gets if the SPS is created as expandable at construction time.
  93816. * Default : `false`
  93817. */
  93818. readonly expandable: boolean;
  93819. /**
  93820. * This function does nothing. It may be overwritten to set all the particle first values.
  93821. * The SPS doesn't call this function, you may have to call it by your own.
  93822. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93823. */
  93824. initParticles(): void;
  93825. /**
  93826. * This function does nothing. It may be overwritten to recycle a particle.
  93827. * The SPS doesn't call this function, you may have to call it by your own.
  93828. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93829. * @param particle The particle to recycle
  93830. * @returns the recycled particle
  93831. */
  93832. recycleParticle(particle: SolidParticle): SolidParticle;
  93833. /**
  93834. * Updates a particle : this function should be overwritten by the user.
  93835. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  93836. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93837. * @example : just set a particle position or velocity and recycle conditions
  93838. * @param particle The particle to update
  93839. * @returns the updated particle
  93840. */
  93841. updateParticle(particle: SolidParticle): SolidParticle;
  93842. /**
  93843. * Updates a vertex of a particle : it can be overwritten by the user.
  93844. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  93845. * @param particle the current particle
  93846. * @param vertex the current index of the current particle
  93847. * @param pt the index of the current vertex in the particle shape
  93848. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  93849. * @example : just set a vertex particle position
  93850. * @returns the updated vertex
  93851. */
  93852. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  93853. /**
  93854. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  93855. * This does nothing and may be overwritten by the user.
  93856. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93857. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93858. * @param update the boolean update value actually passed to setParticles()
  93859. */
  93860. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  93861. /**
  93862. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  93863. * This will be passed three parameters.
  93864. * This does nothing and may be overwritten by the user.
  93865. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93866. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93867. * @param update the boolean update value actually passed to setParticles()
  93868. */
  93869. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  93870. }
  93871. }
  93872. declare module BABYLON {
  93873. /**
  93874. * Represents one particle of a solid particle system.
  93875. */
  93876. export class SolidParticle {
  93877. /**
  93878. * particle global index
  93879. */
  93880. idx: number;
  93881. /**
  93882. * particle identifier
  93883. */
  93884. id: number;
  93885. /**
  93886. * The color of the particle
  93887. */
  93888. color: Nullable<Color4>;
  93889. /**
  93890. * The world space position of the particle.
  93891. */
  93892. position: Vector3;
  93893. /**
  93894. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  93895. */
  93896. rotation: Vector3;
  93897. /**
  93898. * The world space rotation quaternion of the particle.
  93899. */
  93900. rotationQuaternion: Nullable<Quaternion>;
  93901. /**
  93902. * The scaling of the particle.
  93903. */
  93904. scaling: Vector3;
  93905. /**
  93906. * The uvs of the particle.
  93907. */
  93908. uvs: Vector4;
  93909. /**
  93910. * The current speed of the particle.
  93911. */
  93912. velocity: Vector3;
  93913. /**
  93914. * The pivot point in the particle local space.
  93915. */
  93916. pivot: Vector3;
  93917. /**
  93918. * Must the particle be translated from its pivot point in its local space ?
  93919. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  93920. * Default : false
  93921. */
  93922. translateFromPivot: boolean;
  93923. /**
  93924. * Is the particle active or not ?
  93925. */
  93926. alive: boolean;
  93927. /**
  93928. * Is the particle visible or not ?
  93929. */
  93930. isVisible: boolean;
  93931. /**
  93932. * Index of this particle in the global "positions" array (Internal use)
  93933. * @hidden
  93934. */
  93935. _pos: number;
  93936. /**
  93937. * @hidden Index of this particle in the global "indices" array (Internal use)
  93938. */
  93939. _ind: number;
  93940. /**
  93941. * @hidden ModelShape of this particle (Internal use)
  93942. */
  93943. _model: ModelShape;
  93944. /**
  93945. * ModelShape id of this particle
  93946. */
  93947. shapeId: number;
  93948. /**
  93949. * Index of the particle in its shape id
  93950. */
  93951. idxInShape: number;
  93952. /**
  93953. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  93954. */
  93955. _modelBoundingInfo: BoundingInfo;
  93956. /**
  93957. * @hidden Particle BoundingInfo object (Internal use)
  93958. */
  93959. _boundingInfo: BoundingInfo;
  93960. /**
  93961. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  93962. */
  93963. _sps: SolidParticleSystem;
  93964. /**
  93965. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  93966. */
  93967. _stillInvisible: boolean;
  93968. /**
  93969. * @hidden Last computed particle rotation matrix
  93970. */
  93971. _rotationMatrix: number[];
  93972. /**
  93973. * Parent particle Id, if any.
  93974. * Default null.
  93975. */
  93976. parentId: Nullable<number>;
  93977. /**
  93978. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  93979. * The possible values are :
  93980. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  93981. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93982. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  93983. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  93984. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93985. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  93986. * */
  93987. cullingStrategy: number;
  93988. /**
  93989. * @hidden Internal global position in the SPS.
  93990. */
  93991. _globalPosition: Vector3;
  93992. /**
  93993. * Creates a Solid Particle object.
  93994. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  93995. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  93996. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  93997. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  93998. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  93999. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  94000. * @param shapeId (integer) is the model shape identifier in the SPS.
  94001. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  94002. * @param sps defines the sps it is associated to
  94003. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  94004. */
  94005. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  94006. /**
  94007. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  94008. * @param target the particle target
  94009. * @returns the current particle
  94010. */
  94011. copyToRef(target: SolidParticle): SolidParticle;
  94012. /**
  94013. * Legacy support, changed scale to scaling
  94014. */
  94015. /**
  94016. * Legacy support, changed scale to scaling
  94017. */
  94018. scale: Vector3;
  94019. /**
  94020. * Legacy support, changed quaternion to rotationQuaternion
  94021. */
  94022. /**
  94023. * Legacy support, changed quaternion to rotationQuaternion
  94024. */
  94025. quaternion: Nullable<Quaternion>;
  94026. /**
  94027. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  94028. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  94029. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  94030. * @returns true if it intersects
  94031. */
  94032. intersectsMesh(target: Mesh | SolidParticle): boolean;
  94033. /**
  94034. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  94035. * A particle is in the frustum if its bounding box intersects the frustum
  94036. * @param frustumPlanes defines the frustum to test
  94037. * @returns true if the particle is in the frustum planes
  94038. */
  94039. isInFrustum(frustumPlanes: Plane[]): boolean;
  94040. /**
  94041. * get the rotation matrix of the particle
  94042. * @hidden
  94043. */
  94044. getRotationMatrix(m: Matrix): void;
  94045. }
  94046. /**
  94047. * Represents the shape of the model used by one particle of a solid particle system.
  94048. * SPS internal tool, don't use it manually.
  94049. */
  94050. export class ModelShape {
  94051. /**
  94052. * The shape id
  94053. * @hidden
  94054. */
  94055. shapeID: number;
  94056. /**
  94057. * flat array of model positions (internal use)
  94058. * @hidden
  94059. */
  94060. _shape: Vector3[];
  94061. /**
  94062. * flat array of model UVs (internal use)
  94063. * @hidden
  94064. */
  94065. _shapeUV: number[];
  94066. /**
  94067. * color array of the model
  94068. * @hidden
  94069. */
  94070. _shapeColors: number[];
  94071. /**
  94072. * indices array of the model
  94073. * @hidden
  94074. */
  94075. _indices: number[];
  94076. /**
  94077. * normals array of the model
  94078. * @hidden
  94079. */
  94080. _normals: number[];
  94081. /**
  94082. * length of the shape in the model indices array (internal use)
  94083. * @hidden
  94084. */
  94085. _indicesLength: number;
  94086. /**
  94087. * Custom position function (internal use)
  94088. * @hidden
  94089. */
  94090. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  94091. /**
  94092. * Custom vertex function (internal use)
  94093. * @hidden
  94094. */
  94095. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  94096. /**
  94097. * 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.
  94098. * SPS internal tool, don't use it manually.
  94099. * @hidden
  94100. */
  94101. 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>);
  94102. }
  94103. /**
  94104. * Represents a Depth Sorted Particle in the solid particle system.
  94105. */
  94106. export class DepthSortedParticle {
  94107. /**
  94108. * Index of the particle in the "indices" array
  94109. */
  94110. ind: number;
  94111. /**
  94112. * Length of the particle shape in the "indices" array
  94113. */
  94114. indicesLength: number;
  94115. /**
  94116. * Squared distance from the particle to the camera
  94117. */
  94118. sqDistance: number;
  94119. }
  94120. }
  94121. declare module BABYLON {
  94122. /**
  94123. * @hidden
  94124. */
  94125. export class _MeshCollisionData {
  94126. _checkCollisions: boolean;
  94127. _collisionMask: number;
  94128. _collisionGroup: number;
  94129. _collider: Nullable<Collider>;
  94130. _oldPositionForCollisions: Vector3;
  94131. _diffPositionForCollisions: Vector3;
  94132. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  94133. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  94134. }
  94135. }
  94136. declare module BABYLON {
  94137. /** @hidden */
  94138. class _FacetDataStorage {
  94139. facetPositions: Vector3[];
  94140. facetNormals: Vector3[];
  94141. facetPartitioning: number[][];
  94142. facetNb: number;
  94143. partitioningSubdivisions: number;
  94144. partitioningBBoxRatio: number;
  94145. facetDataEnabled: boolean;
  94146. facetParameters: any;
  94147. bbSize: Vector3;
  94148. subDiv: {
  94149. max: number;
  94150. X: number;
  94151. Y: number;
  94152. Z: number;
  94153. };
  94154. facetDepthSort: boolean;
  94155. facetDepthSortEnabled: boolean;
  94156. depthSortedIndices: IndicesArray;
  94157. depthSortedFacets: {
  94158. ind: number;
  94159. sqDistance: number;
  94160. }[];
  94161. facetDepthSortFunction: (f1: {
  94162. ind: number;
  94163. sqDistance: number;
  94164. }, f2: {
  94165. ind: number;
  94166. sqDistance: number;
  94167. }) => number;
  94168. facetDepthSortFrom: Vector3;
  94169. facetDepthSortOrigin: Vector3;
  94170. invertedMatrix: Matrix;
  94171. }
  94172. /**
  94173. * @hidden
  94174. **/
  94175. class _InternalAbstractMeshDataInfo {
  94176. _hasVertexAlpha: boolean;
  94177. _useVertexColors: boolean;
  94178. _numBoneInfluencers: number;
  94179. _applyFog: boolean;
  94180. _receiveShadows: boolean;
  94181. _facetData: _FacetDataStorage;
  94182. _visibility: number;
  94183. _skeleton: Nullable<Skeleton>;
  94184. _layerMask: number;
  94185. _computeBonesUsingShaders: boolean;
  94186. _isActive: boolean;
  94187. _onlyForInstances: boolean;
  94188. _isActiveIntermediate: boolean;
  94189. _onlyForInstancesIntermediate: boolean;
  94190. _actAsRegularMesh: boolean;
  94191. }
  94192. /**
  94193. * Class used to store all common mesh properties
  94194. */
  94195. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  94196. /** No occlusion */
  94197. static OCCLUSION_TYPE_NONE: number;
  94198. /** Occlusion set to optimisitic */
  94199. static OCCLUSION_TYPE_OPTIMISTIC: number;
  94200. /** Occlusion set to strict */
  94201. static OCCLUSION_TYPE_STRICT: number;
  94202. /** Use an accurante occlusion algorithm */
  94203. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  94204. /** Use a conservative occlusion algorithm */
  94205. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  94206. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  94207. * Test order :
  94208. * Is the bounding sphere outside the frustum ?
  94209. * If not, are the bounding box vertices outside the frustum ?
  94210. * It not, then the cullable object is in the frustum.
  94211. */
  94212. static readonly CULLINGSTRATEGY_STANDARD: number;
  94213. /** Culling strategy : Bounding Sphere Only.
  94214. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  94215. * It's also less accurate than the standard because some not visible objects can still be selected.
  94216. * Test : is the bounding sphere outside the frustum ?
  94217. * If not, then the cullable object is in the frustum.
  94218. */
  94219. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  94220. /** Culling strategy : Optimistic Inclusion.
  94221. * This in an inclusion test first, then the standard exclusion test.
  94222. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  94223. * 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.
  94224. * Anyway, it's as accurate as the standard strategy.
  94225. * Test :
  94226. * Is the cullable object bounding sphere center in the frustum ?
  94227. * If not, apply the default culling strategy.
  94228. */
  94229. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  94230. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  94231. * This in an inclusion test first, then the bounding sphere only exclusion test.
  94232. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  94233. * 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.
  94234. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  94235. * Test :
  94236. * Is the cullable object bounding sphere center in the frustum ?
  94237. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  94238. */
  94239. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  94240. /**
  94241. * No billboard
  94242. */
  94243. static readonly BILLBOARDMODE_NONE: number;
  94244. /** Billboard on X axis */
  94245. static readonly BILLBOARDMODE_X: number;
  94246. /** Billboard on Y axis */
  94247. static readonly BILLBOARDMODE_Y: number;
  94248. /** Billboard on Z axis */
  94249. static readonly BILLBOARDMODE_Z: number;
  94250. /** Billboard on all axes */
  94251. static readonly BILLBOARDMODE_ALL: number;
  94252. /** Billboard on using position instead of orientation */
  94253. static readonly BILLBOARDMODE_USE_POSITION: number;
  94254. /** @hidden */
  94255. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  94256. /**
  94257. * The culling strategy to use to check whether the mesh must be rendered or not.
  94258. * This value can be changed at any time and will be used on the next render mesh selection.
  94259. * The possible values are :
  94260. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  94261. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94262. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  94263. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  94264. * Please read each static variable documentation to get details about the culling process.
  94265. * */
  94266. cullingStrategy: number;
  94267. /**
  94268. * Gets the number of facets in the mesh
  94269. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94270. */
  94271. readonly facetNb: number;
  94272. /**
  94273. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  94274. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  94275. */
  94276. partitioningSubdivisions: number;
  94277. /**
  94278. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  94279. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  94280. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  94281. */
  94282. partitioningBBoxRatio: number;
  94283. /**
  94284. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  94285. * Works only for updatable meshes.
  94286. * Doesn't work with multi-materials
  94287. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94288. */
  94289. mustDepthSortFacets: boolean;
  94290. /**
  94291. * The location (Vector3) where the facet depth sort must be computed from.
  94292. * By default, the active camera position.
  94293. * Used only when facet depth sort is enabled
  94294. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94295. */
  94296. facetDepthSortFrom: Vector3;
  94297. /**
  94298. * gets a boolean indicating if facetData is enabled
  94299. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94300. */
  94301. readonly isFacetDataEnabled: boolean;
  94302. /** @hidden */
  94303. _updateNonUniformScalingState(value: boolean): boolean;
  94304. /**
  94305. * An event triggered when this mesh collides with another one
  94306. */
  94307. onCollideObservable: Observable<AbstractMesh>;
  94308. /** Set a function to call when this mesh collides with another one */
  94309. onCollide: () => void;
  94310. /**
  94311. * An event triggered when the collision's position changes
  94312. */
  94313. onCollisionPositionChangeObservable: Observable<Vector3>;
  94314. /** Set a function to call when the collision's position changes */
  94315. onCollisionPositionChange: () => void;
  94316. /**
  94317. * An event triggered when material is changed
  94318. */
  94319. onMaterialChangedObservable: Observable<AbstractMesh>;
  94320. /**
  94321. * Gets or sets the orientation for POV movement & rotation
  94322. */
  94323. definedFacingForward: boolean;
  94324. /** @hidden */
  94325. _occlusionQuery: Nullable<WebGLQuery>;
  94326. /** @hidden */
  94327. _renderingGroup: Nullable<RenderingGroup>;
  94328. /**
  94329. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94330. */
  94331. /**
  94332. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94333. */
  94334. visibility: number;
  94335. /** Gets or sets the alpha index used to sort transparent meshes
  94336. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  94337. */
  94338. alphaIndex: number;
  94339. /**
  94340. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  94341. */
  94342. isVisible: boolean;
  94343. /**
  94344. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  94345. */
  94346. isPickable: boolean;
  94347. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  94348. showSubMeshesBoundingBox: boolean;
  94349. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  94350. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  94351. */
  94352. isBlocker: boolean;
  94353. /**
  94354. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  94355. */
  94356. enablePointerMoveEvents: boolean;
  94357. /**
  94358. * Specifies the rendering group id for this mesh (0 by default)
  94359. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  94360. */
  94361. renderingGroupId: number;
  94362. private _material;
  94363. /** Gets or sets current material */
  94364. material: Nullable<Material>;
  94365. /**
  94366. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  94367. * @see http://doc.babylonjs.com/babylon101/shadows
  94368. */
  94369. receiveShadows: boolean;
  94370. /** Defines color to use when rendering outline */
  94371. outlineColor: Color3;
  94372. /** Define width to use when rendering outline */
  94373. outlineWidth: number;
  94374. /** Defines color to use when rendering overlay */
  94375. overlayColor: Color3;
  94376. /** Defines alpha to use when rendering overlay */
  94377. overlayAlpha: number;
  94378. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  94379. hasVertexAlpha: boolean;
  94380. /** 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) */
  94381. useVertexColors: boolean;
  94382. /**
  94383. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  94384. */
  94385. computeBonesUsingShaders: boolean;
  94386. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  94387. numBoneInfluencers: number;
  94388. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  94389. applyFog: boolean;
  94390. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  94391. useOctreeForRenderingSelection: boolean;
  94392. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  94393. useOctreeForPicking: boolean;
  94394. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  94395. useOctreeForCollisions: boolean;
  94396. /**
  94397. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  94398. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  94399. */
  94400. layerMask: number;
  94401. /**
  94402. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  94403. */
  94404. alwaysSelectAsActiveMesh: boolean;
  94405. /**
  94406. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  94407. */
  94408. doNotSyncBoundingInfo: boolean;
  94409. /**
  94410. * Gets or sets the current action manager
  94411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94412. */
  94413. actionManager: Nullable<AbstractActionManager>;
  94414. private _meshCollisionData;
  94415. /**
  94416. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  94417. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94418. */
  94419. ellipsoid: Vector3;
  94420. /**
  94421. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  94422. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94423. */
  94424. ellipsoidOffset: Vector3;
  94425. /**
  94426. * Gets or sets a collision mask used to mask collisions (default is -1).
  94427. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94428. */
  94429. collisionMask: number;
  94430. /**
  94431. * Gets or sets the current collision group mask (-1 by default).
  94432. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94433. */
  94434. collisionGroup: number;
  94435. /**
  94436. * Defines edge width used when edgesRenderer is enabled
  94437. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94438. */
  94439. edgesWidth: number;
  94440. /**
  94441. * Defines edge color used when edgesRenderer is enabled
  94442. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94443. */
  94444. edgesColor: Color4;
  94445. /** @hidden */
  94446. _edgesRenderer: Nullable<IEdgesRenderer>;
  94447. /** @hidden */
  94448. _masterMesh: Nullable<AbstractMesh>;
  94449. /** @hidden */
  94450. _boundingInfo: Nullable<BoundingInfo>;
  94451. /** @hidden */
  94452. _renderId: number;
  94453. /**
  94454. * Gets or sets the list of subMeshes
  94455. * @see http://doc.babylonjs.com/how_to/multi_materials
  94456. */
  94457. subMeshes: SubMesh[];
  94458. /** @hidden */
  94459. _intersectionsInProgress: AbstractMesh[];
  94460. /** @hidden */
  94461. _unIndexed: boolean;
  94462. /** @hidden */
  94463. _lightSources: Light[];
  94464. /** Gets the list of lights affecting that mesh */
  94465. readonly lightSources: Light[];
  94466. /** @hidden */
  94467. readonly _positions: Nullable<Vector3[]>;
  94468. /** @hidden */
  94469. _waitingData: {
  94470. lods: Nullable<any>;
  94471. actions: Nullable<any>;
  94472. freezeWorldMatrix: Nullable<boolean>;
  94473. };
  94474. /** @hidden */
  94475. _bonesTransformMatrices: Nullable<Float32Array>;
  94476. /** @hidden */
  94477. _transformMatrixTexture: Nullable<RawTexture>;
  94478. /**
  94479. * Gets or sets a skeleton to apply skining transformations
  94480. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94481. */
  94482. skeleton: Nullable<Skeleton>;
  94483. /**
  94484. * An event triggered when the mesh is rebuilt.
  94485. */
  94486. onRebuildObservable: Observable<AbstractMesh>;
  94487. /**
  94488. * Creates a new AbstractMesh
  94489. * @param name defines the name of the mesh
  94490. * @param scene defines the hosting scene
  94491. */
  94492. constructor(name: string, scene?: Nullable<Scene>);
  94493. /**
  94494. * Returns the string "AbstractMesh"
  94495. * @returns "AbstractMesh"
  94496. */
  94497. getClassName(): string;
  94498. /**
  94499. * Gets a string representation of the current mesh
  94500. * @param fullDetails defines a boolean indicating if full details must be included
  94501. * @returns a string representation of the current mesh
  94502. */
  94503. toString(fullDetails?: boolean): string;
  94504. /**
  94505. * @hidden
  94506. */
  94507. protected _getEffectiveParent(): Nullable<Node>;
  94508. /** @hidden */
  94509. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  94510. /** @hidden */
  94511. _rebuild(): void;
  94512. /** @hidden */
  94513. _resyncLightSources(): void;
  94514. /** @hidden */
  94515. _resyncLighSource(light: Light): void;
  94516. /** @hidden */
  94517. _unBindEffect(): void;
  94518. /** @hidden */
  94519. _removeLightSource(light: Light, dispose: boolean): void;
  94520. private _markSubMeshesAsDirty;
  94521. /** @hidden */
  94522. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  94523. /** @hidden */
  94524. _markSubMeshesAsAttributesDirty(): void;
  94525. /** @hidden */
  94526. _markSubMeshesAsMiscDirty(): void;
  94527. /**
  94528. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  94529. */
  94530. scaling: Vector3;
  94531. /**
  94532. * Returns true if the mesh is blocked. Implemented by child classes
  94533. */
  94534. readonly isBlocked: boolean;
  94535. /**
  94536. * Returns the mesh itself by default. Implemented by child classes
  94537. * @param camera defines the camera to use to pick the right LOD level
  94538. * @returns the currentAbstractMesh
  94539. */
  94540. getLOD(camera: Camera): Nullable<AbstractMesh>;
  94541. /**
  94542. * Returns 0 by default. Implemented by child classes
  94543. * @returns an integer
  94544. */
  94545. getTotalVertices(): number;
  94546. /**
  94547. * Returns a positive integer : the total number of indices in this mesh geometry.
  94548. * @returns the numner of indices or zero if the mesh has no geometry.
  94549. */
  94550. getTotalIndices(): number;
  94551. /**
  94552. * Returns null by default. Implemented by child classes
  94553. * @returns null
  94554. */
  94555. getIndices(): Nullable<IndicesArray>;
  94556. /**
  94557. * Returns the array of the requested vertex data kind. Implemented by child classes
  94558. * @param kind defines the vertex data kind to use
  94559. * @returns null
  94560. */
  94561. getVerticesData(kind: string): Nullable<FloatArray>;
  94562. /**
  94563. * Sets the vertex data of the mesh geometry for the requested `kind`.
  94564. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  94565. * Note that a new underlying VertexBuffer object is created each call.
  94566. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  94567. * @param kind defines vertex data kind:
  94568. * * VertexBuffer.PositionKind
  94569. * * VertexBuffer.UVKind
  94570. * * VertexBuffer.UV2Kind
  94571. * * VertexBuffer.UV3Kind
  94572. * * VertexBuffer.UV4Kind
  94573. * * VertexBuffer.UV5Kind
  94574. * * VertexBuffer.UV6Kind
  94575. * * VertexBuffer.ColorKind
  94576. * * VertexBuffer.MatricesIndicesKind
  94577. * * VertexBuffer.MatricesIndicesExtraKind
  94578. * * VertexBuffer.MatricesWeightsKind
  94579. * * VertexBuffer.MatricesWeightsExtraKind
  94580. * @param data defines the data source
  94581. * @param updatable defines if the data must be flagged as updatable (or static)
  94582. * @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
  94583. * @returns the current mesh
  94584. */
  94585. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94586. /**
  94587. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  94588. * If the mesh has no geometry, it is simply returned as it is.
  94589. * @param kind defines vertex data kind:
  94590. * * VertexBuffer.PositionKind
  94591. * * VertexBuffer.UVKind
  94592. * * VertexBuffer.UV2Kind
  94593. * * VertexBuffer.UV3Kind
  94594. * * VertexBuffer.UV4Kind
  94595. * * VertexBuffer.UV5Kind
  94596. * * VertexBuffer.UV6Kind
  94597. * * VertexBuffer.ColorKind
  94598. * * VertexBuffer.MatricesIndicesKind
  94599. * * VertexBuffer.MatricesIndicesExtraKind
  94600. * * VertexBuffer.MatricesWeightsKind
  94601. * * VertexBuffer.MatricesWeightsExtraKind
  94602. * @param data defines the data source
  94603. * @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
  94604. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  94605. * @returns the current mesh
  94606. */
  94607. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  94608. /**
  94609. * Sets the mesh indices,
  94610. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  94611. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  94612. * @param totalVertices Defines the total number of vertices
  94613. * @returns the current mesh
  94614. */
  94615. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  94616. /**
  94617. * Gets a boolean indicating if specific vertex data is present
  94618. * @param kind defines the vertex data kind to use
  94619. * @returns true is data kind is present
  94620. */
  94621. isVerticesDataPresent(kind: string): boolean;
  94622. /**
  94623. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  94624. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  94625. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  94626. * @returns a BoundingInfo
  94627. */
  94628. getBoundingInfo(): BoundingInfo;
  94629. /**
  94630. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  94631. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  94632. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  94633. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  94634. * @returns the current mesh
  94635. */
  94636. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  94637. /**
  94638. * Overwrite the current bounding info
  94639. * @param boundingInfo defines the new bounding info
  94640. * @returns the current mesh
  94641. */
  94642. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  94643. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  94644. readonly useBones: boolean;
  94645. /** @hidden */
  94646. _preActivate(): void;
  94647. /** @hidden */
  94648. _preActivateForIntermediateRendering(renderId: number): void;
  94649. /** @hidden */
  94650. _activate(renderId: number, intermediateRendering: boolean): boolean;
  94651. /** @hidden */
  94652. _postActivate(): void;
  94653. /** @hidden */
  94654. _freeze(): void;
  94655. /** @hidden */
  94656. _unFreeze(): void;
  94657. /**
  94658. * Gets the current world matrix
  94659. * @returns a Matrix
  94660. */
  94661. getWorldMatrix(): Matrix;
  94662. /** @hidden */
  94663. _getWorldMatrixDeterminant(): number;
  94664. /**
  94665. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  94666. */
  94667. readonly isAnInstance: boolean;
  94668. /**
  94669. * Gets a boolean indicating if this mesh has instances
  94670. */
  94671. readonly hasInstances: boolean;
  94672. /**
  94673. * Perform relative position change from the point of view of behind the front of the mesh.
  94674. * This is performed taking into account the meshes current rotation, so you do not have to care.
  94675. * Supports definition of mesh facing forward or backward
  94676. * @param amountRight defines the distance on the right axis
  94677. * @param amountUp defines the distance on the up axis
  94678. * @param amountForward defines the distance on the forward axis
  94679. * @returns the current mesh
  94680. */
  94681. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  94682. /**
  94683. * Calculate relative position change from the point of view of behind the front of the mesh.
  94684. * This is performed taking into account the meshes current rotation, so you do not have to care.
  94685. * Supports definition of mesh facing forward or backward
  94686. * @param amountRight defines the distance on the right axis
  94687. * @param amountUp defines the distance on the up axis
  94688. * @param amountForward defines the distance on the forward axis
  94689. * @returns the new displacement vector
  94690. */
  94691. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  94692. /**
  94693. * Perform relative rotation change from the point of view of behind the front of the mesh.
  94694. * Supports definition of mesh facing forward or backward
  94695. * @param flipBack defines the flip
  94696. * @param twirlClockwise defines the twirl
  94697. * @param tiltRight defines the tilt
  94698. * @returns the current mesh
  94699. */
  94700. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  94701. /**
  94702. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  94703. * Supports definition of mesh facing forward or backward.
  94704. * @param flipBack defines the flip
  94705. * @param twirlClockwise defines the twirl
  94706. * @param tiltRight defines the tilt
  94707. * @returns the new rotation vector
  94708. */
  94709. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  94710. /**
  94711. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94712. * This means the mesh underlying bounding box and sphere are recomputed.
  94713. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94714. * @returns the current mesh
  94715. */
  94716. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  94717. /** @hidden */
  94718. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  94719. /** @hidden */
  94720. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  94721. /** @hidden */
  94722. _updateBoundingInfo(): AbstractMesh;
  94723. /** @hidden */
  94724. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  94725. /** @hidden */
  94726. protected _afterComputeWorldMatrix(): void;
  94727. /** @hidden */
  94728. readonly _effectiveMesh: AbstractMesh;
  94729. /**
  94730. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  94731. * A mesh is in the frustum if its bounding box intersects the frustum
  94732. * @param frustumPlanes defines the frustum to test
  94733. * @returns true if the mesh is in the frustum planes
  94734. */
  94735. isInFrustum(frustumPlanes: Plane[]): boolean;
  94736. /**
  94737. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  94738. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  94739. * @param frustumPlanes defines the frustum to test
  94740. * @returns true if the mesh is completely in the frustum planes
  94741. */
  94742. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94743. /**
  94744. * True if the mesh intersects another mesh or a SolidParticle object
  94745. * @param mesh defines a target mesh or SolidParticle to test
  94746. * @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)
  94747. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  94748. * @returns true if there is an intersection
  94749. */
  94750. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  94751. /**
  94752. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  94753. * @param point defines the point to test
  94754. * @returns true if there is an intersection
  94755. */
  94756. intersectsPoint(point: Vector3): boolean;
  94757. /**
  94758. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  94759. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94760. */
  94761. checkCollisions: boolean;
  94762. /**
  94763. * Gets Collider object used to compute collisions (not physics)
  94764. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94765. */
  94766. readonly collider: Nullable<Collider>;
  94767. /**
  94768. * Move the mesh using collision engine
  94769. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94770. * @param displacement defines the requested displacement vector
  94771. * @returns the current mesh
  94772. */
  94773. moveWithCollisions(displacement: Vector3): AbstractMesh;
  94774. private _onCollisionPositionChange;
  94775. /** @hidden */
  94776. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  94777. /** @hidden */
  94778. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  94779. /** @hidden */
  94780. _checkCollision(collider: Collider): AbstractMesh;
  94781. /** @hidden */
  94782. _generatePointsArray(): boolean;
  94783. /**
  94784. * Checks if the passed Ray intersects with the mesh
  94785. * @param ray defines the ray to use
  94786. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  94787. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94788. * @returns the picking info
  94789. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  94790. */
  94791. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  94792. /**
  94793. * Clones the current mesh
  94794. * @param name defines the mesh name
  94795. * @param newParent defines the new mesh parent
  94796. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  94797. * @returns the new mesh
  94798. */
  94799. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  94800. /**
  94801. * Disposes all the submeshes of the current meshnp
  94802. * @returns the current mesh
  94803. */
  94804. releaseSubMeshes(): AbstractMesh;
  94805. /**
  94806. * Releases resources associated with this abstract mesh.
  94807. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94808. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94809. */
  94810. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94811. /**
  94812. * Adds the passed mesh as a child to the current mesh
  94813. * @param mesh defines the child mesh
  94814. * @returns the current mesh
  94815. */
  94816. addChild(mesh: AbstractMesh): AbstractMesh;
  94817. /**
  94818. * Removes the passed mesh from the current mesh children list
  94819. * @param mesh defines the child mesh
  94820. * @returns the current mesh
  94821. */
  94822. removeChild(mesh: AbstractMesh): AbstractMesh;
  94823. /** @hidden */
  94824. private _initFacetData;
  94825. /**
  94826. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  94827. * This method can be called within the render loop.
  94828. * 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
  94829. * @returns the current mesh
  94830. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94831. */
  94832. updateFacetData(): AbstractMesh;
  94833. /**
  94834. * Returns the facetLocalNormals array.
  94835. * The normals are expressed in the mesh local spac
  94836. * @returns an array of Vector3
  94837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94838. */
  94839. getFacetLocalNormals(): Vector3[];
  94840. /**
  94841. * Returns the facetLocalPositions array.
  94842. * The facet positions are expressed in the mesh local space
  94843. * @returns an array of Vector3
  94844. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94845. */
  94846. getFacetLocalPositions(): Vector3[];
  94847. /**
  94848. * Returns the facetLocalPartioning array
  94849. * @returns an array of array of numbers
  94850. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94851. */
  94852. getFacetLocalPartitioning(): number[][];
  94853. /**
  94854. * Returns the i-th facet position in the world system.
  94855. * This method allocates a new Vector3 per call
  94856. * @param i defines the facet index
  94857. * @returns a new Vector3
  94858. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94859. */
  94860. getFacetPosition(i: number): Vector3;
  94861. /**
  94862. * Sets the reference Vector3 with the i-th facet position in the world system
  94863. * @param i defines the facet index
  94864. * @param ref defines the target vector
  94865. * @returns the current mesh
  94866. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94867. */
  94868. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  94869. /**
  94870. * Returns the i-th facet normal in the world system.
  94871. * This method allocates a new Vector3 per call
  94872. * @param i defines the facet index
  94873. * @returns a new Vector3
  94874. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94875. */
  94876. getFacetNormal(i: number): Vector3;
  94877. /**
  94878. * Sets the reference Vector3 with the i-th facet normal in the world system
  94879. * @param i defines the facet index
  94880. * @param ref defines the target vector
  94881. * @returns the current mesh
  94882. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94883. */
  94884. getFacetNormalToRef(i: number, ref: Vector3): this;
  94885. /**
  94886. * 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)
  94887. * @param x defines x coordinate
  94888. * @param y defines y coordinate
  94889. * @param z defines z coordinate
  94890. * @returns the array of facet indexes
  94891. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94892. */
  94893. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  94894. /**
  94895. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  94896. * @param projected sets as the (x,y,z) world projection on the facet
  94897. * @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
  94898. * @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
  94899. * @param x defines x coordinate
  94900. * @param y defines y coordinate
  94901. * @param z defines z coordinate
  94902. * @returns the face index if found (or null instead)
  94903. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94904. */
  94905. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  94906. /**
  94907. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  94908. * @param projected sets as the (x,y,z) local projection on the facet
  94909. * @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
  94910. * @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
  94911. * @param x defines x coordinate
  94912. * @param y defines y coordinate
  94913. * @param z defines z coordinate
  94914. * @returns the face index if found (or null instead)
  94915. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94916. */
  94917. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  94918. /**
  94919. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  94920. * @returns the parameters
  94921. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94922. */
  94923. getFacetDataParameters(): any;
  94924. /**
  94925. * Disables the feature FacetData and frees the related memory
  94926. * @returns the current mesh
  94927. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94928. */
  94929. disableFacetData(): AbstractMesh;
  94930. /**
  94931. * Updates the AbstractMesh indices array
  94932. * @param indices defines the data source
  94933. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  94934. * @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)
  94935. * @returns the current mesh
  94936. */
  94937. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  94938. /**
  94939. * Creates new normals data for the mesh
  94940. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  94941. * @returns the current mesh
  94942. */
  94943. createNormals(updatable: boolean): AbstractMesh;
  94944. /**
  94945. * Align the mesh with a normal
  94946. * @param normal defines the normal to use
  94947. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  94948. * @returns the current mesh
  94949. */
  94950. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  94951. /** @hidden */
  94952. _checkOcclusionQuery(): boolean;
  94953. /**
  94954. * Disables the mesh edge rendering mode
  94955. * @returns the currentAbstractMesh
  94956. */
  94957. disableEdgesRendering(): AbstractMesh;
  94958. /**
  94959. * Enables the edge rendering mode on the mesh.
  94960. * This mode makes the mesh edges visible
  94961. * @param epsilon defines the maximal distance between two angles to detect a face
  94962. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94963. * @returns the currentAbstractMesh
  94964. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94965. */
  94966. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94967. }
  94968. }
  94969. declare module BABYLON {
  94970. /**
  94971. * Interface used to define ActionEvent
  94972. */
  94973. export interface IActionEvent {
  94974. /** The mesh or sprite that triggered the action */
  94975. source: any;
  94976. /** The X mouse cursor position at the time of the event */
  94977. pointerX: number;
  94978. /** The Y mouse cursor position at the time of the event */
  94979. pointerY: number;
  94980. /** The mesh that is currently pointed at (can be null) */
  94981. meshUnderPointer: Nullable<AbstractMesh>;
  94982. /** the original (browser) event that triggered the ActionEvent */
  94983. sourceEvent?: any;
  94984. /** additional data for the event */
  94985. additionalData?: any;
  94986. }
  94987. /**
  94988. * ActionEvent is the event being sent when an action is triggered.
  94989. */
  94990. export class ActionEvent implements IActionEvent {
  94991. /** The mesh or sprite that triggered the action */
  94992. source: any;
  94993. /** The X mouse cursor position at the time of the event */
  94994. pointerX: number;
  94995. /** The Y mouse cursor position at the time of the event */
  94996. pointerY: number;
  94997. /** The mesh that is currently pointed at (can be null) */
  94998. meshUnderPointer: Nullable<AbstractMesh>;
  94999. /** the original (browser) event that triggered the ActionEvent */
  95000. sourceEvent?: any;
  95001. /** additional data for the event */
  95002. additionalData?: any;
  95003. /**
  95004. * Creates a new ActionEvent
  95005. * @param source The mesh or sprite that triggered the action
  95006. * @param pointerX The X mouse cursor position at the time of the event
  95007. * @param pointerY The Y mouse cursor position at the time of the event
  95008. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  95009. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  95010. * @param additionalData additional data for the event
  95011. */
  95012. constructor(
  95013. /** The mesh or sprite that triggered the action */
  95014. source: any,
  95015. /** The X mouse cursor position at the time of the event */
  95016. pointerX: number,
  95017. /** The Y mouse cursor position at the time of the event */
  95018. pointerY: number,
  95019. /** The mesh that is currently pointed at (can be null) */
  95020. meshUnderPointer: Nullable<AbstractMesh>,
  95021. /** the original (browser) event that triggered the ActionEvent */
  95022. sourceEvent?: any,
  95023. /** additional data for the event */
  95024. additionalData?: any);
  95025. /**
  95026. * Helper function to auto-create an ActionEvent from a source mesh.
  95027. * @param source The source mesh that triggered the event
  95028. * @param evt The original (browser) event
  95029. * @param additionalData additional data for the event
  95030. * @returns the new ActionEvent
  95031. */
  95032. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  95033. /**
  95034. * Helper function to auto-create an ActionEvent from a source sprite
  95035. * @param source The source sprite that triggered the event
  95036. * @param scene Scene associated with the sprite
  95037. * @param evt The original (browser) event
  95038. * @param additionalData additional data for the event
  95039. * @returns the new ActionEvent
  95040. */
  95041. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  95042. /**
  95043. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  95044. * @param scene the scene where the event occurred
  95045. * @param evt The original (browser) event
  95046. * @returns the new ActionEvent
  95047. */
  95048. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  95049. /**
  95050. * Helper function to auto-create an ActionEvent from a primitive
  95051. * @param prim defines the target primitive
  95052. * @param pointerPos defines the pointer position
  95053. * @param evt The original (browser) event
  95054. * @param additionalData additional data for the event
  95055. * @returns the new ActionEvent
  95056. */
  95057. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  95058. }
  95059. }
  95060. declare module BABYLON {
  95061. /**
  95062. * Abstract class used to decouple action Manager from scene and meshes.
  95063. * Do not instantiate.
  95064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95065. */
  95066. export abstract class AbstractActionManager implements IDisposable {
  95067. /** Gets the list of active triggers */
  95068. static Triggers: {
  95069. [key: string]: number;
  95070. };
  95071. /** Gets the cursor to use when hovering items */
  95072. hoverCursor: string;
  95073. /** Gets the list of actions */
  95074. actions: IAction[];
  95075. /**
  95076. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  95077. */
  95078. isRecursive: boolean;
  95079. /**
  95080. * Releases all associated resources
  95081. */
  95082. abstract dispose(): void;
  95083. /**
  95084. * Does this action manager has pointer triggers
  95085. */
  95086. abstract readonly hasPointerTriggers: boolean;
  95087. /**
  95088. * Does this action manager has pick triggers
  95089. */
  95090. abstract readonly hasPickTriggers: boolean;
  95091. /**
  95092. * Process a specific trigger
  95093. * @param trigger defines the trigger to process
  95094. * @param evt defines the event details to be processed
  95095. */
  95096. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  95097. /**
  95098. * Does this action manager handles actions of any of the given triggers
  95099. * @param triggers defines the triggers to be tested
  95100. * @return a boolean indicating whether one (or more) of the triggers is handled
  95101. */
  95102. abstract hasSpecificTriggers(triggers: number[]): boolean;
  95103. /**
  95104. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  95105. * speed.
  95106. * @param triggerA defines the trigger to be tested
  95107. * @param triggerB defines the trigger to be tested
  95108. * @return a boolean indicating whether one (or more) of the triggers is handled
  95109. */
  95110. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  95111. /**
  95112. * Does this action manager handles actions of a given trigger
  95113. * @param trigger defines the trigger to be tested
  95114. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  95115. * @return whether the trigger is handled
  95116. */
  95117. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  95118. /**
  95119. * Serialize this manager to a JSON object
  95120. * @param name defines the property name to store this manager
  95121. * @returns a JSON representation of this manager
  95122. */
  95123. abstract serialize(name: string): any;
  95124. /**
  95125. * Registers an action to this action manager
  95126. * @param action defines the action to be registered
  95127. * @return the action amended (prepared) after registration
  95128. */
  95129. abstract registerAction(action: IAction): Nullable<IAction>;
  95130. /**
  95131. * Unregisters an action to this action manager
  95132. * @param action defines the action to be unregistered
  95133. * @return a boolean indicating whether the action has been unregistered
  95134. */
  95135. abstract unregisterAction(action: IAction): Boolean;
  95136. /**
  95137. * Does exist one action manager with at least one trigger
  95138. **/
  95139. static readonly HasTriggers: boolean;
  95140. /**
  95141. * Does exist one action manager with at least one pick trigger
  95142. **/
  95143. static readonly HasPickTriggers: boolean;
  95144. /**
  95145. * Does exist one action manager that handles actions of a given trigger
  95146. * @param trigger defines the trigger to be tested
  95147. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  95148. **/
  95149. static HasSpecificTrigger(trigger: number): boolean;
  95150. }
  95151. }
  95152. declare module BABYLON {
  95153. /**
  95154. * Defines how a node can be built from a string name.
  95155. */
  95156. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  95157. /**
  95158. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  95159. */
  95160. export class Node implements IBehaviorAware<Node> {
  95161. /** @hidden */
  95162. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  95163. private static _NodeConstructors;
  95164. /**
  95165. * Add a new node constructor
  95166. * @param type defines the type name of the node to construct
  95167. * @param constructorFunc defines the constructor function
  95168. */
  95169. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  95170. /**
  95171. * Returns a node constructor based on type name
  95172. * @param type defines the type name
  95173. * @param name defines the new node name
  95174. * @param scene defines the hosting scene
  95175. * @param options defines optional options to transmit to constructors
  95176. * @returns the new constructor or null
  95177. */
  95178. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  95179. /**
  95180. * Gets or sets the name of the node
  95181. */
  95182. name: string;
  95183. /**
  95184. * Gets or sets the id of the node
  95185. */
  95186. id: string;
  95187. /**
  95188. * Gets or sets the unique id of the node
  95189. */
  95190. uniqueId: number;
  95191. /**
  95192. * Gets or sets a string used to store user defined state for the node
  95193. */
  95194. state: string;
  95195. /**
  95196. * Gets or sets an object used to store user defined information for the node
  95197. */
  95198. metadata: any;
  95199. /**
  95200. * For internal use only. Please do not use.
  95201. */
  95202. reservedDataStore: any;
  95203. /**
  95204. * List of inspectable custom properties (used by the Inspector)
  95205. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95206. */
  95207. inspectableCustomProperties: IInspectable[];
  95208. private _doNotSerialize;
  95209. /**
  95210. * Gets or sets a boolean used to define if the node must be serialized
  95211. */
  95212. doNotSerialize: boolean;
  95213. /** @hidden */
  95214. _isDisposed: boolean;
  95215. /**
  95216. * Gets a list of Animations associated with the node
  95217. */
  95218. animations: Animation[];
  95219. protected _ranges: {
  95220. [name: string]: Nullable<AnimationRange>;
  95221. };
  95222. /**
  95223. * Callback raised when the node is ready to be used
  95224. */
  95225. onReady: Nullable<(node: Node) => void>;
  95226. private _isEnabled;
  95227. private _isParentEnabled;
  95228. private _isReady;
  95229. /** @hidden */
  95230. _currentRenderId: number;
  95231. private _parentUpdateId;
  95232. /** @hidden */
  95233. _childUpdateId: number;
  95234. /** @hidden */
  95235. _waitingParentId: Nullable<string>;
  95236. /** @hidden */
  95237. _scene: Scene;
  95238. /** @hidden */
  95239. _cache: any;
  95240. private _parentNode;
  95241. private _children;
  95242. /** @hidden */
  95243. _worldMatrix: Matrix;
  95244. /** @hidden */
  95245. _worldMatrixDeterminant: number;
  95246. /** @hidden */
  95247. _worldMatrixDeterminantIsDirty: boolean;
  95248. /** @hidden */
  95249. private _sceneRootNodesIndex;
  95250. /**
  95251. * Gets a boolean indicating if the node has been disposed
  95252. * @returns true if the node was disposed
  95253. */
  95254. isDisposed(): boolean;
  95255. /**
  95256. * Gets or sets the parent of the node (without keeping the current position in the scene)
  95257. * @see https://doc.babylonjs.com/how_to/parenting
  95258. */
  95259. parent: Nullable<Node>;
  95260. /** @hidden */
  95261. _addToSceneRootNodes(): void;
  95262. /** @hidden */
  95263. _removeFromSceneRootNodes(): void;
  95264. private _animationPropertiesOverride;
  95265. /**
  95266. * Gets or sets the animation properties override
  95267. */
  95268. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  95269. /**
  95270. * Gets a string idenfifying the name of the class
  95271. * @returns "Node" string
  95272. */
  95273. getClassName(): string;
  95274. /** @hidden */
  95275. readonly _isNode: boolean;
  95276. /**
  95277. * An event triggered when the mesh is disposed
  95278. */
  95279. onDisposeObservable: Observable<Node>;
  95280. private _onDisposeObserver;
  95281. /**
  95282. * Sets a callback that will be raised when the node will be disposed
  95283. */
  95284. onDispose: () => void;
  95285. /**
  95286. * Creates a new Node
  95287. * @param name the name and id to be given to this node
  95288. * @param scene the scene this node will be added to
  95289. */
  95290. constructor(name: string, scene?: Nullable<Scene>);
  95291. /**
  95292. * Gets the scene of the node
  95293. * @returns a scene
  95294. */
  95295. getScene(): Scene;
  95296. /**
  95297. * Gets the engine of the node
  95298. * @returns a Engine
  95299. */
  95300. getEngine(): Engine;
  95301. private _behaviors;
  95302. /**
  95303. * Attach a behavior to the node
  95304. * @see http://doc.babylonjs.com/features/behaviour
  95305. * @param behavior defines the behavior to attach
  95306. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  95307. * @returns the current Node
  95308. */
  95309. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  95310. /**
  95311. * Remove an attached behavior
  95312. * @see http://doc.babylonjs.com/features/behaviour
  95313. * @param behavior defines the behavior to attach
  95314. * @returns the current Node
  95315. */
  95316. removeBehavior(behavior: Behavior<Node>): Node;
  95317. /**
  95318. * Gets the list of attached behaviors
  95319. * @see http://doc.babylonjs.com/features/behaviour
  95320. */
  95321. readonly behaviors: Behavior<Node>[];
  95322. /**
  95323. * Gets an attached behavior by name
  95324. * @param name defines the name of the behavior to look for
  95325. * @see http://doc.babylonjs.com/features/behaviour
  95326. * @returns null if behavior was not found else the requested behavior
  95327. */
  95328. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  95329. /**
  95330. * Returns the latest update of the World matrix
  95331. * @returns a Matrix
  95332. */
  95333. getWorldMatrix(): Matrix;
  95334. /** @hidden */
  95335. _getWorldMatrixDeterminant(): number;
  95336. /**
  95337. * Returns directly the latest state of the mesh World matrix.
  95338. * A Matrix is returned.
  95339. */
  95340. readonly worldMatrixFromCache: Matrix;
  95341. /** @hidden */
  95342. _initCache(): void;
  95343. /** @hidden */
  95344. updateCache(force?: boolean): void;
  95345. /** @hidden */
  95346. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  95347. /** @hidden */
  95348. _updateCache(ignoreParentClass?: boolean): void;
  95349. /** @hidden */
  95350. _isSynchronized(): boolean;
  95351. /** @hidden */
  95352. _markSyncedWithParent(): void;
  95353. /** @hidden */
  95354. isSynchronizedWithParent(): boolean;
  95355. /** @hidden */
  95356. isSynchronized(): boolean;
  95357. /**
  95358. * Is this node ready to be used/rendered
  95359. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95360. * @return true if the node is ready
  95361. */
  95362. isReady(completeCheck?: boolean): boolean;
  95363. /**
  95364. * Is this node enabled?
  95365. * 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
  95366. * @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
  95367. * @return whether this node (and its parent) is enabled
  95368. */
  95369. isEnabled(checkAncestors?: boolean): boolean;
  95370. /** @hidden */
  95371. protected _syncParentEnabledState(): void;
  95372. /**
  95373. * Set the enabled state of this node
  95374. * @param value defines the new enabled state
  95375. */
  95376. setEnabled(value: boolean): void;
  95377. /**
  95378. * Is this node a descendant of the given node?
  95379. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  95380. * @param ancestor defines the parent node to inspect
  95381. * @returns a boolean indicating if this node is a descendant of the given node
  95382. */
  95383. isDescendantOf(ancestor: Node): boolean;
  95384. /** @hidden */
  95385. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  95386. /**
  95387. * Will return all nodes that have this node as ascendant
  95388. * @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
  95389. * @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
  95390. * @return all children nodes of all types
  95391. */
  95392. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  95393. /**
  95394. * Get all child-meshes of this node
  95395. * @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)
  95396. * @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
  95397. * @returns an array of AbstractMesh
  95398. */
  95399. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  95400. /**
  95401. * Get all direct children of this node
  95402. * @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
  95403. * @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)
  95404. * @returns an array of Node
  95405. */
  95406. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  95407. /** @hidden */
  95408. _setReady(state: boolean): void;
  95409. /**
  95410. * Get an animation by name
  95411. * @param name defines the name of the animation to look for
  95412. * @returns null if not found else the requested animation
  95413. */
  95414. getAnimationByName(name: string): Nullable<Animation>;
  95415. /**
  95416. * Creates an animation range for this node
  95417. * @param name defines the name of the range
  95418. * @param from defines the starting key
  95419. * @param to defines the end key
  95420. */
  95421. createAnimationRange(name: string, from: number, to: number): void;
  95422. /**
  95423. * Delete a specific animation range
  95424. * @param name defines the name of the range to delete
  95425. * @param deleteFrames defines if animation frames from the range must be deleted as well
  95426. */
  95427. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  95428. /**
  95429. * Get an animation range by name
  95430. * @param name defines the name of the animation range to look for
  95431. * @returns null if not found else the requested animation range
  95432. */
  95433. getAnimationRange(name: string): Nullable<AnimationRange>;
  95434. /**
  95435. * Gets the list of all animation ranges defined on this node
  95436. * @returns an array
  95437. */
  95438. getAnimationRanges(): Nullable<AnimationRange>[];
  95439. /**
  95440. * Will start the animation sequence
  95441. * @param name defines the range frames for animation sequence
  95442. * @param loop defines if the animation should loop (false by default)
  95443. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  95444. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  95445. * @returns the object created for this animation. If range does not exist, it will return null
  95446. */
  95447. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  95448. /**
  95449. * Serialize animation ranges into a JSON compatible object
  95450. * @returns serialization object
  95451. */
  95452. serializeAnimationRanges(): any;
  95453. /**
  95454. * Computes the world matrix of the node
  95455. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95456. * @returns the world matrix
  95457. */
  95458. computeWorldMatrix(force?: boolean): Matrix;
  95459. /**
  95460. * Releases resources associated with this node.
  95461. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95462. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95463. */
  95464. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95465. /**
  95466. * Parse animation range data from a serialization object and store them into a given node
  95467. * @param node defines where to store the animation ranges
  95468. * @param parsedNode defines the serialization object to read data from
  95469. * @param scene defines the hosting scene
  95470. */
  95471. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  95472. /**
  95473. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  95474. * @param includeDescendants Include bounding info from descendants as well (true by default)
  95475. * @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
  95476. * @returns the new bounding vectors
  95477. */
  95478. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  95479. min: Vector3;
  95480. max: Vector3;
  95481. };
  95482. }
  95483. }
  95484. declare module BABYLON {
  95485. /**
  95486. * @hidden
  95487. */
  95488. export class _IAnimationState {
  95489. key: number;
  95490. repeatCount: number;
  95491. workValue?: any;
  95492. loopMode?: number;
  95493. offsetValue?: any;
  95494. highLimitValue?: any;
  95495. }
  95496. /**
  95497. * Class used to store any kind of animation
  95498. */
  95499. export class Animation {
  95500. /**Name of the animation */
  95501. name: string;
  95502. /**Property to animate */
  95503. targetProperty: string;
  95504. /**The frames per second of the animation */
  95505. framePerSecond: number;
  95506. /**The data type of the animation */
  95507. dataType: number;
  95508. /**The loop mode of the animation */
  95509. loopMode?: number | undefined;
  95510. /**Specifies if blending should be enabled */
  95511. enableBlending?: boolean | undefined;
  95512. /**
  95513. * Use matrix interpolation instead of using direct key value when animating matrices
  95514. */
  95515. static AllowMatricesInterpolation: boolean;
  95516. /**
  95517. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  95518. */
  95519. static AllowMatrixDecomposeForInterpolation: boolean;
  95520. /**
  95521. * Stores the key frames of the animation
  95522. */
  95523. private _keys;
  95524. /**
  95525. * Stores the easing function of the animation
  95526. */
  95527. private _easingFunction;
  95528. /**
  95529. * @hidden Internal use only
  95530. */
  95531. _runtimeAnimations: RuntimeAnimation[];
  95532. /**
  95533. * The set of event that will be linked to this animation
  95534. */
  95535. private _events;
  95536. /**
  95537. * Stores an array of target property paths
  95538. */
  95539. targetPropertyPath: string[];
  95540. /**
  95541. * Stores the blending speed of the animation
  95542. */
  95543. blendingSpeed: number;
  95544. /**
  95545. * Stores the animation ranges for the animation
  95546. */
  95547. private _ranges;
  95548. /**
  95549. * @hidden Internal use
  95550. */
  95551. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  95552. /**
  95553. * Sets up an animation
  95554. * @param property The property to animate
  95555. * @param animationType The animation type to apply
  95556. * @param framePerSecond The frames per second of the animation
  95557. * @param easingFunction The easing function used in the animation
  95558. * @returns The created animation
  95559. */
  95560. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  95561. /**
  95562. * Create and start an animation on a node
  95563. * @param name defines the name of the global animation that will be run on all nodes
  95564. * @param node defines the root node where the animation will take place
  95565. * @param targetProperty defines property to animate
  95566. * @param framePerSecond defines the number of frame per second yo use
  95567. * @param totalFrame defines the number of frames in total
  95568. * @param from defines the initial value
  95569. * @param to defines the final value
  95570. * @param loopMode defines which loop mode you want to use (off by default)
  95571. * @param easingFunction defines the easing function to use (linear by default)
  95572. * @param onAnimationEnd defines the callback to call when animation end
  95573. * @returns the animatable created for this animation
  95574. */
  95575. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95576. /**
  95577. * Create and start an animation on a node and its descendants
  95578. * @param name defines the name of the global animation that will be run on all nodes
  95579. * @param node defines the root node where the animation will take place
  95580. * @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
  95581. * @param targetProperty defines property to animate
  95582. * @param framePerSecond defines the number of frame per second to use
  95583. * @param totalFrame defines the number of frames in total
  95584. * @param from defines the initial value
  95585. * @param to defines the final value
  95586. * @param loopMode defines which loop mode you want to use (off by default)
  95587. * @param easingFunction defines the easing function to use (linear by default)
  95588. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95589. * @returns the list of animatables created for all nodes
  95590. * @example https://www.babylonjs-playground.com/#MH0VLI
  95591. */
  95592. 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[]>;
  95593. /**
  95594. * Creates a new animation, merges it with the existing animations and starts it
  95595. * @param name Name of the animation
  95596. * @param node Node which contains the scene that begins the animations
  95597. * @param targetProperty Specifies which property to animate
  95598. * @param framePerSecond The frames per second of the animation
  95599. * @param totalFrame The total number of frames
  95600. * @param from The frame at the beginning of the animation
  95601. * @param to The frame at the end of the animation
  95602. * @param loopMode Specifies the loop mode of the animation
  95603. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  95604. * @param onAnimationEnd Callback to run once the animation is complete
  95605. * @returns Nullable animation
  95606. */
  95607. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95608. /**
  95609. * Transition property of an host to the target Value
  95610. * @param property The property to transition
  95611. * @param targetValue The target Value of the property
  95612. * @param host The object where the property to animate belongs
  95613. * @param scene Scene used to run the animation
  95614. * @param frameRate Framerate (in frame/s) to use
  95615. * @param transition The transition type we want to use
  95616. * @param duration The duration of the animation, in milliseconds
  95617. * @param onAnimationEnd Callback trigger at the end of the animation
  95618. * @returns Nullable animation
  95619. */
  95620. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  95621. /**
  95622. * Return the array of runtime animations currently using this animation
  95623. */
  95624. readonly runtimeAnimations: RuntimeAnimation[];
  95625. /**
  95626. * Specifies if any of the runtime animations are currently running
  95627. */
  95628. readonly hasRunningRuntimeAnimations: boolean;
  95629. /**
  95630. * Initializes the animation
  95631. * @param name Name of the animation
  95632. * @param targetProperty Property to animate
  95633. * @param framePerSecond The frames per second of the animation
  95634. * @param dataType The data type of the animation
  95635. * @param loopMode The loop mode of the animation
  95636. * @param enableBlending Specifies if blending should be enabled
  95637. */
  95638. constructor(
  95639. /**Name of the animation */
  95640. name: string,
  95641. /**Property to animate */
  95642. targetProperty: string,
  95643. /**The frames per second of the animation */
  95644. framePerSecond: number,
  95645. /**The data type of the animation */
  95646. dataType: number,
  95647. /**The loop mode of the animation */
  95648. loopMode?: number | undefined,
  95649. /**Specifies if blending should be enabled */
  95650. enableBlending?: boolean | undefined);
  95651. /**
  95652. * Converts the animation to a string
  95653. * @param fullDetails support for multiple levels of logging within scene loading
  95654. * @returns String form of the animation
  95655. */
  95656. toString(fullDetails?: boolean): string;
  95657. /**
  95658. * Add an event to this animation
  95659. * @param event Event to add
  95660. */
  95661. addEvent(event: AnimationEvent): void;
  95662. /**
  95663. * Remove all events found at the given frame
  95664. * @param frame The frame to remove events from
  95665. */
  95666. removeEvents(frame: number): void;
  95667. /**
  95668. * Retrieves all the events from the animation
  95669. * @returns Events from the animation
  95670. */
  95671. getEvents(): AnimationEvent[];
  95672. /**
  95673. * Creates an animation range
  95674. * @param name Name of the animation range
  95675. * @param from Starting frame of the animation range
  95676. * @param to Ending frame of the animation
  95677. */
  95678. createRange(name: string, from: number, to: number): void;
  95679. /**
  95680. * Deletes an animation range by name
  95681. * @param name Name of the animation range to delete
  95682. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  95683. */
  95684. deleteRange(name: string, deleteFrames?: boolean): void;
  95685. /**
  95686. * Gets the animation range by name, or null if not defined
  95687. * @param name Name of the animation range
  95688. * @returns Nullable animation range
  95689. */
  95690. getRange(name: string): Nullable<AnimationRange>;
  95691. /**
  95692. * Gets the key frames from the animation
  95693. * @returns The key frames of the animation
  95694. */
  95695. getKeys(): Array<IAnimationKey>;
  95696. /**
  95697. * Gets the highest frame rate of the animation
  95698. * @returns Highest frame rate of the animation
  95699. */
  95700. getHighestFrame(): number;
  95701. /**
  95702. * Gets the easing function of the animation
  95703. * @returns Easing function of the animation
  95704. */
  95705. getEasingFunction(): IEasingFunction;
  95706. /**
  95707. * Sets the easing function of the animation
  95708. * @param easingFunction A custom mathematical formula for animation
  95709. */
  95710. setEasingFunction(easingFunction: EasingFunction): void;
  95711. /**
  95712. * Interpolates a scalar linearly
  95713. * @param startValue Start value of the animation curve
  95714. * @param endValue End value of the animation curve
  95715. * @param gradient Scalar amount to interpolate
  95716. * @returns Interpolated scalar value
  95717. */
  95718. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  95719. /**
  95720. * Interpolates a scalar cubically
  95721. * @param startValue Start value of the animation curve
  95722. * @param outTangent End tangent of the animation
  95723. * @param endValue End value of the animation curve
  95724. * @param inTangent Start tangent of the animation curve
  95725. * @param gradient Scalar amount to interpolate
  95726. * @returns Interpolated scalar value
  95727. */
  95728. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  95729. /**
  95730. * Interpolates a quaternion using a spherical linear interpolation
  95731. * @param startValue Start value of the animation curve
  95732. * @param endValue End value of the animation curve
  95733. * @param gradient Scalar amount to interpolate
  95734. * @returns Interpolated quaternion value
  95735. */
  95736. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  95737. /**
  95738. * Interpolates a quaternion cubically
  95739. * @param startValue Start value of the animation curve
  95740. * @param outTangent End tangent of the animation curve
  95741. * @param endValue End value of the animation curve
  95742. * @param inTangent Start tangent of the animation curve
  95743. * @param gradient Scalar amount to interpolate
  95744. * @returns Interpolated quaternion value
  95745. */
  95746. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  95747. /**
  95748. * Interpolates a Vector3 linearl
  95749. * @param startValue Start value of the animation curve
  95750. * @param endValue End value of the animation curve
  95751. * @param gradient Scalar amount to interpolate
  95752. * @returns Interpolated scalar value
  95753. */
  95754. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  95755. /**
  95756. * Interpolates a Vector3 cubically
  95757. * @param startValue Start value of the animation curve
  95758. * @param outTangent End tangent of the animation
  95759. * @param endValue End value of the animation curve
  95760. * @param inTangent Start tangent of the animation curve
  95761. * @param gradient Scalar amount to interpolate
  95762. * @returns InterpolatedVector3 value
  95763. */
  95764. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  95765. /**
  95766. * Interpolates a Vector2 linearly
  95767. * @param startValue Start value of the animation curve
  95768. * @param endValue End value of the animation curve
  95769. * @param gradient Scalar amount to interpolate
  95770. * @returns Interpolated Vector2 value
  95771. */
  95772. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  95773. /**
  95774. * Interpolates a Vector2 cubically
  95775. * @param startValue Start value of the animation curve
  95776. * @param outTangent End tangent of the animation
  95777. * @param endValue End value of the animation curve
  95778. * @param inTangent Start tangent of the animation curve
  95779. * @param gradient Scalar amount to interpolate
  95780. * @returns Interpolated Vector2 value
  95781. */
  95782. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  95783. /**
  95784. * Interpolates a size linearly
  95785. * @param startValue Start value of the animation curve
  95786. * @param endValue End value of the animation curve
  95787. * @param gradient Scalar amount to interpolate
  95788. * @returns Interpolated Size value
  95789. */
  95790. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  95791. /**
  95792. * Interpolates a Color3 linearly
  95793. * @param startValue Start value of the animation curve
  95794. * @param endValue End value of the animation curve
  95795. * @param gradient Scalar amount to interpolate
  95796. * @returns Interpolated Color3 value
  95797. */
  95798. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  95799. /**
  95800. * Interpolates a Color4 linearly
  95801. * @param startValue Start value of the animation curve
  95802. * @param endValue End value of the animation curve
  95803. * @param gradient Scalar amount to interpolate
  95804. * @returns Interpolated Color3 value
  95805. */
  95806. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  95807. /**
  95808. * @hidden Internal use only
  95809. */
  95810. _getKeyValue(value: any): any;
  95811. /**
  95812. * @hidden Internal use only
  95813. */
  95814. _interpolate(currentFrame: number, state: _IAnimationState): any;
  95815. /**
  95816. * Defines the function to use to interpolate matrices
  95817. * @param startValue defines the start matrix
  95818. * @param endValue defines the end matrix
  95819. * @param gradient defines the gradient between both matrices
  95820. * @param result defines an optional target matrix where to store the interpolation
  95821. * @returns the interpolated matrix
  95822. */
  95823. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  95824. /**
  95825. * Makes a copy of the animation
  95826. * @returns Cloned animation
  95827. */
  95828. clone(): Animation;
  95829. /**
  95830. * Sets the key frames of the animation
  95831. * @param values The animation key frames to set
  95832. */
  95833. setKeys(values: Array<IAnimationKey>): void;
  95834. /**
  95835. * Serializes the animation to an object
  95836. * @returns Serialized object
  95837. */
  95838. serialize(): any;
  95839. /**
  95840. * Float animation type
  95841. */
  95842. static readonly ANIMATIONTYPE_FLOAT: number;
  95843. /**
  95844. * Vector3 animation type
  95845. */
  95846. static readonly ANIMATIONTYPE_VECTOR3: number;
  95847. /**
  95848. * Quaternion animation type
  95849. */
  95850. static readonly ANIMATIONTYPE_QUATERNION: number;
  95851. /**
  95852. * Matrix animation type
  95853. */
  95854. static readonly ANIMATIONTYPE_MATRIX: number;
  95855. /**
  95856. * Color3 animation type
  95857. */
  95858. static readonly ANIMATIONTYPE_COLOR3: number;
  95859. /**
  95860. * Color3 animation type
  95861. */
  95862. static readonly ANIMATIONTYPE_COLOR4: number;
  95863. /**
  95864. * Vector2 animation type
  95865. */
  95866. static readonly ANIMATIONTYPE_VECTOR2: number;
  95867. /**
  95868. * Size animation type
  95869. */
  95870. static readonly ANIMATIONTYPE_SIZE: number;
  95871. /**
  95872. * Relative Loop Mode
  95873. */
  95874. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  95875. /**
  95876. * Cycle Loop Mode
  95877. */
  95878. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  95879. /**
  95880. * Constant Loop Mode
  95881. */
  95882. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  95883. /** @hidden */
  95884. static _UniversalLerp(left: any, right: any, amount: number): any;
  95885. /**
  95886. * Parses an animation object and creates an animation
  95887. * @param parsedAnimation Parsed animation object
  95888. * @returns Animation object
  95889. */
  95890. static Parse(parsedAnimation: any): Animation;
  95891. /**
  95892. * Appends the serialized animations from the source animations
  95893. * @param source Source containing the animations
  95894. * @param destination Target to store the animations
  95895. */
  95896. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95897. }
  95898. }
  95899. declare module BABYLON {
  95900. /**
  95901. * Interface containing an array of animations
  95902. */
  95903. export interface IAnimatable {
  95904. /**
  95905. * Array of animations
  95906. */
  95907. animations: Nullable<Array<Animation>>;
  95908. }
  95909. }
  95910. declare module BABYLON {
  95911. /**
  95912. * This represents all the required information to add a fresnel effect on a material:
  95913. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95914. */
  95915. export class FresnelParameters {
  95916. private _isEnabled;
  95917. /**
  95918. * Define if the fresnel effect is enable or not.
  95919. */
  95920. isEnabled: boolean;
  95921. /**
  95922. * Define the color used on edges (grazing angle)
  95923. */
  95924. leftColor: Color3;
  95925. /**
  95926. * Define the color used on center
  95927. */
  95928. rightColor: Color3;
  95929. /**
  95930. * Define bias applied to computed fresnel term
  95931. */
  95932. bias: number;
  95933. /**
  95934. * Defined the power exponent applied to fresnel term
  95935. */
  95936. power: number;
  95937. /**
  95938. * Clones the current fresnel and its valuues
  95939. * @returns a clone fresnel configuration
  95940. */
  95941. clone(): FresnelParameters;
  95942. /**
  95943. * Serializes the current fresnel parameters to a JSON representation.
  95944. * @return the JSON serialization
  95945. */
  95946. serialize(): any;
  95947. /**
  95948. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  95949. * @param parsedFresnelParameters Define the JSON representation
  95950. * @returns the parsed parameters
  95951. */
  95952. static Parse(parsedFresnelParameters: any): FresnelParameters;
  95953. }
  95954. }
  95955. declare module BABYLON {
  95956. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  95957. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95958. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95959. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95960. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95961. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95962. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95963. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95964. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95965. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95966. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95967. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95968. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95969. /**
  95970. * Decorator used to define property that can be serialized as reference to a camera
  95971. * @param sourceName defines the name of the property to decorate
  95972. */
  95973. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95974. /**
  95975. * Class used to help serialization objects
  95976. */
  95977. export class SerializationHelper {
  95978. /** @hidden */
  95979. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  95980. /** @hidden */
  95981. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  95982. /** @hidden */
  95983. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  95984. /** @hidden */
  95985. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  95986. /**
  95987. * Appends the serialized animations from the source animations
  95988. * @param source Source containing the animations
  95989. * @param destination Target to store the animations
  95990. */
  95991. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95992. /**
  95993. * Static function used to serialized a specific entity
  95994. * @param entity defines the entity to serialize
  95995. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  95996. * @returns a JSON compatible object representing the serialization of the entity
  95997. */
  95998. static Serialize<T>(entity: T, serializationObject?: any): any;
  95999. /**
  96000. * Creates a new entity from a serialization data object
  96001. * @param creationFunction defines a function used to instanciated the new entity
  96002. * @param source defines the source serialization data
  96003. * @param scene defines the hosting scene
  96004. * @param rootUrl defines the root url for resources
  96005. * @returns a new entity
  96006. */
  96007. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  96008. /**
  96009. * Clones an object
  96010. * @param creationFunction defines the function used to instanciate the new object
  96011. * @param source defines the source object
  96012. * @returns the cloned object
  96013. */
  96014. static Clone<T>(creationFunction: () => T, source: T): T;
  96015. /**
  96016. * Instanciates a new object based on a source one (some data will be shared between both object)
  96017. * @param creationFunction defines the function used to instanciate the new object
  96018. * @param source defines the source object
  96019. * @returns the new object
  96020. */
  96021. static Instanciate<T>(creationFunction: () => T, source: T): T;
  96022. }
  96023. }
  96024. declare module BABYLON {
  96025. /**
  96026. * Class used to manipulate GUIDs
  96027. */
  96028. export class GUID {
  96029. /**
  96030. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96031. * Be aware Math.random() could cause collisions, but:
  96032. * "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"
  96033. * @returns a pseudo random id
  96034. */
  96035. static RandomId(): string;
  96036. }
  96037. }
  96038. declare module BABYLON {
  96039. /**
  96040. * Base class of all the textures in babylon.
  96041. * It groups all the common properties the materials, post process, lights... might need
  96042. * in order to make a correct use of the texture.
  96043. */
  96044. export class BaseTexture implements IAnimatable {
  96045. /**
  96046. * Default anisotropic filtering level for the application.
  96047. * It is set to 4 as a good tradeoff between perf and quality.
  96048. */
  96049. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  96050. /**
  96051. * Gets or sets the unique id of the texture
  96052. */
  96053. uniqueId: number;
  96054. /**
  96055. * Define the name of the texture.
  96056. */
  96057. name: string;
  96058. /**
  96059. * Gets or sets an object used to store user defined information.
  96060. */
  96061. metadata: any;
  96062. /**
  96063. * For internal use only. Please do not use.
  96064. */
  96065. reservedDataStore: any;
  96066. private _hasAlpha;
  96067. /**
  96068. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  96069. */
  96070. hasAlpha: boolean;
  96071. /**
  96072. * Defines if the alpha value should be determined via the rgb values.
  96073. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  96074. */
  96075. getAlphaFromRGB: boolean;
  96076. /**
  96077. * Intensity or strength of the texture.
  96078. * It is commonly used by materials to fine tune the intensity of the texture
  96079. */
  96080. level: number;
  96081. /**
  96082. * Define the UV chanel to use starting from 0 and defaulting to 0.
  96083. * This is part of the texture as textures usually maps to one uv set.
  96084. */
  96085. coordinatesIndex: number;
  96086. private _coordinatesMode;
  96087. /**
  96088. * How a texture is mapped.
  96089. *
  96090. * | Value | Type | Description |
  96091. * | ----- | ----------------------------------- | ----------- |
  96092. * | 0 | EXPLICIT_MODE | |
  96093. * | 1 | SPHERICAL_MODE | |
  96094. * | 2 | PLANAR_MODE | |
  96095. * | 3 | CUBIC_MODE | |
  96096. * | 4 | PROJECTION_MODE | |
  96097. * | 5 | SKYBOX_MODE | |
  96098. * | 6 | INVCUBIC_MODE | |
  96099. * | 7 | EQUIRECTANGULAR_MODE | |
  96100. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  96101. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  96102. */
  96103. coordinatesMode: number;
  96104. /**
  96105. * | Value | Type | Description |
  96106. * | ----- | ------------------ | ----------- |
  96107. * | 0 | CLAMP_ADDRESSMODE | |
  96108. * | 1 | WRAP_ADDRESSMODE | |
  96109. * | 2 | MIRROR_ADDRESSMODE | |
  96110. */
  96111. wrapU: number;
  96112. /**
  96113. * | Value | Type | Description |
  96114. * | ----- | ------------------ | ----------- |
  96115. * | 0 | CLAMP_ADDRESSMODE | |
  96116. * | 1 | WRAP_ADDRESSMODE | |
  96117. * | 2 | MIRROR_ADDRESSMODE | |
  96118. */
  96119. wrapV: number;
  96120. /**
  96121. * | Value | Type | Description |
  96122. * | ----- | ------------------ | ----------- |
  96123. * | 0 | CLAMP_ADDRESSMODE | |
  96124. * | 1 | WRAP_ADDRESSMODE | |
  96125. * | 2 | MIRROR_ADDRESSMODE | |
  96126. */
  96127. wrapR: number;
  96128. /**
  96129. * With compliant hardware and browser (supporting anisotropic filtering)
  96130. * this defines the level of anisotropic filtering in the texture.
  96131. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  96132. */
  96133. anisotropicFilteringLevel: number;
  96134. /**
  96135. * Define if the texture is a cube texture or if false a 2d texture.
  96136. */
  96137. isCube: boolean;
  96138. /**
  96139. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  96140. */
  96141. is3D: boolean;
  96142. /**
  96143. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  96144. */
  96145. is2DArray: boolean;
  96146. /**
  96147. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  96148. * HDR texture are usually stored in linear space.
  96149. * This only impacts the PBR and Background materials
  96150. */
  96151. gammaSpace: boolean;
  96152. /**
  96153. * Gets or sets whether or not the texture contains RGBD data.
  96154. */
  96155. isRGBD: boolean;
  96156. /**
  96157. * Is Z inverted in the texture (useful in a cube texture).
  96158. */
  96159. invertZ: boolean;
  96160. /**
  96161. * Are mip maps generated for this texture or not.
  96162. */
  96163. readonly noMipmap: boolean;
  96164. /**
  96165. * @hidden
  96166. */
  96167. lodLevelInAlpha: boolean;
  96168. /**
  96169. * With prefiltered texture, defined the offset used during the prefiltering steps.
  96170. */
  96171. lodGenerationOffset: number;
  96172. /**
  96173. * With prefiltered texture, defined the scale used during the prefiltering steps.
  96174. */
  96175. lodGenerationScale: number;
  96176. /**
  96177. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  96178. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  96179. * average roughness values.
  96180. */
  96181. linearSpecularLOD: boolean;
  96182. /**
  96183. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  96184. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  96185. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  96186. */
  96187. irradianceTexture: Nullable<BaseTexture>;
  96188. /**
  96189. * Define if the texture is a render target.
  96190. */
  96191. isRenderTarget: boolean;
  96192. /**
  96193. * Define the unique id of the texture in the scene.
  96194. */
  96195. readonly uid: string;
  96196. /**
  96197. * Return a string representation of the texture.
  96198. * @returns the texture as a string
  96199. */
  96200. toString(): string;
  96201. /**
  96202. * Get the class name of the texture.
  96203. * @returns "BaseTexture"
  96204. */
  96205. getClassName(): string;
  96206. /**
  96207. * Define the list of animation attached to the texture.
  96208. */
  96209. animations: Animation[];
  96210. /**
  96211. * An event triggered when the texture is disposed.
  96212. */
  96213. onDisposeObservable: Observable<BaseTexture>;
  96214. private _onDisposeObserver;
  96215. /**
  96216. * Callback triggered when the texture has been disposed.
  96217. * Kept for back compatibility, you can use the onDisposeObservable instead.
  96218. */
  96219. onDispose: () => void;
  96220. /**
  96221. * Define the current state of the loading sequence when in delayed load mode.
  96222. */
  96223. delayLoadState: number;
  96224. private _scene;
  96225. /** @hidden */
  96226. _texture: Nullable<InternalTexture>;
  96227. private _uid;
  96228. /**
  96229. * Define if the texture is preventinga material to render or not.
  96230. * If not and the texture is not ready, the engine will use a default black texture instead.
  96231. */
  96232. readonly isBlocking: boolean;
  96233. /**
  96234. * Instantiates a new BaseTexture.
  96235. * Base class of all the textures in babylon.
  96236. * It groups all the common properties the materials, post process, lights... might need
  96237. * in order to make a correct use of the texture.
  96238. * @param scene Define the scene the texture blongs to
  96239. */
  96240. constructor(scene: Nullable<Scene>);
  96241. /**
  96242. * Get the scene the texture belongs to.
  96243. * @returns the scene or null if undefined
  96244. */
  96245. getScene(): Nullable<Scene>;
  96246. /**
  96247. * Get the texture transform matrix used to offset tile the texture for istance.
  96248. * @returns the transformation matrix
  96249. */
  96250. getTextureMatrix(): Matrix;
  96251. /**
  96252. * Get the texture reflection matrix used to rotate/transform the reflection.
  96253. * @returns the reflection matrix
  96254. */
  96255. getReflectionTextureMatrix(): Matrix;
  96256. /**
  96257. * Get the underlying lower level texture from Babylon.
  96258. * @returns the insternal texture
  96259. */
  96260. getInternalTexture(): Nullable<InternalTexture>;
  96261. /**
  96262. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  96263. * @returns true if ready or not blocking
  96264. */
  96265. isReadyOrNotBlocking(): boolean;
  96266. /**
  96267. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  96268. * @returns true if fully ready
  96269. */
  96270. isReady(): boolean;
  96271. private _cachedSize;
  96272. /**
  96273. * Get the size of the texture.
  96274. * @returns the texture size.
  96275. */
  96276. getSize(): ISize;
  96277. /**
  96278. * Get the base size of the texture.
  96279. * It can be different from the size if the texture has been resized for POT for instance
  96280. * @returns the base size
  96281. */
  96282. getBaseSize(): ISize;
  96283. /**
  96284. * Update the sampling mode of the texture.
  96285. * Default is Trilinear mode.
  96286. *
  96287. * | Value | Type | Description |
  96288. * | ----- | ------------------ | ----------- |
  96289. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  96290. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  96291. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  96292. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  96293. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  96294. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  96295. * | 7 | NEAREST_LINEAR | |
  96296. * | 8 | NEAREST_NEAREST | |
  96297. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  96298. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  96299. * | 11 | LINEAR_LINEAR | |
  96300. * | 12 | LINEAR_NEAREST | |
  96301. *
  96302. * > _mag_: magnification filter (close to the viewer)
  96303. * > _min_: minification filter (far from the viewer)
  96304. * > _mip_: filter used between mip map levels
  96305. *@param samplingMode Define the new sampling mode of the texture
  96306. */
  96307. updateSamplingMode(samplingMode: number): void;
  96308. /**
  96309. * Scales the texture if is `canRescale()`
  96310. * @param ratio the resize factor we want to use to rescale
  96311. */
  96312. scale(ratio: number): void;
  96313. /**
  96314. * Get if the texture can rescale.
  96315. */
  96316. readonly canRescale: boolean;
  96317. /** @hidden */
  96318. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  96319. /** @hidden */
  96320. _rebuild(): void;
  96321. /**
  96322. * Triggers the load sequence in delayed load mode.
  96323. */
  96324. delayLoad(): void;
  96325. /**
  96326. * Clones the texture.
  96327. * @returns the cloned texture
  96328. */
  96329. clone(): Nullable<BaseTexture>;
  96330. /**
  96331. * Get the texture underlying type (INT, FLOAT...)
  96332. */
  96333. readonly textureType: number;
  96334. /**
  96335. * Get the texture underlying format (RGB, RGBA...)
  96336. */
  96337. readonly textureFormat: number;
  96338. /**
  96339. * Indicates that textures need to be re-calculated for all materials
  96340. */
  96341. protected _markAllSubMeshesAsTexturesDirty(): void;
  96342. /**
  96343. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  96344. * This will returns an RGBA array buffer containing either in values (0-255) or
  96345. * float values (0-1) depending of the underlying buffer type.
  96346. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  96347. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  96348. * @param buffer defines a user defined buffer to fill with data (can be null)
  96349. * @returns The Array buffer containing the pixels data.
  96350. */
  96351. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  96352. /**
  96353. * Release and destroy the underlying lower level texture aka internalTexture.
  96354. */
  96355. releaseInternalTexture(): void;
  96356. /** @hidden */
  96357. readonly _lodTextureHigh: Nullable<BaseTexture>;
  96358. /** @hidden */
  96359. readonly _lodTextureMid: Nullable<BaseTexture>;
  96360. /** @hidden */
  96361. readonly _lodTextureLow: Nullable<BaseTexture>;
  96362. /**
  96363. * Dispose the texture and release its associated resources.
  96364. */
  96365. dispose(): void;
  96366. /**
  96367. * Serialize the texture into a JSON representation that can be parsed later on.
  96368. * @returns the JSON representation of the texture
  96369. */
  96370. serialize(): any;
  96371. /**
  96372. * Helper function to be called back once a list of texture contains only ready textures.
  96373. * @param textures Define the list of textures to wait for
  96374. * @param callback Define the callback triggered once the entire list will be ready
  96375. */
  96376. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  96377. }
  96378. }
  96379. declare module BABYLON {
  96380. /**
  96381. * Options to be used when creating an effect.
  96382. */
  96383. export interface IEffectCreationOptions {
  96384. /**
  96385. * Atrributes that will be used in the shader.
  96386. */
  96387. attributes: string[];
  96388. /**
  96389. * Uniform varible names that will be set in the shader.
  96390. */
  96391. uniformsNames: string[];
  96392. /**
  96393. * Uniform buffer varible names that will be set in the shader.
  96394. */
  96395. uniformBuffersNames: string[];
  96396. /**
  96397. * Sampler texture variable names that will be set in the shader.
  96398. */
  96399. samplers: string[];
  96400. /**
  96401. * Define statements that will be set in the shader.
  96402. */
  96403. defines: any;
  96404. /**
  96405. * Possible fallbacks for this effect to improve performance when needed.
  96406. */
  96407. fallbacks: Nullable<IEffectFallbacks>;
  96408. /**
  96409. * Callback that will be called when the shader is compiled.
  96410. */
  96411. onCompiled: Nullable<(effect: Effect) => void>;
  96412. /**
  96413. * Callback that will be called if an error occurs during shader compilation.
  96414. */
  96415. onError: Nullable<(effect: Effect, errors: string) => void>;
  96416. /**
  96417. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96418. */
  96419. indexParameters?: any;
  96420. /**
  96421. * Max number of lights that can be used in the shader.
  96422. */
  96423. maxSimultaneousLights?: number;
  96424. /**
  96425. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  96426. */
  96427. transformFeedbackVaryings?: Nullable<string[]>;
  96428. }
  96429. /**
  96430. * Effect containing vertex and fragment shader that can be executed on an object.
  96431. */
  96432. export class Effect implements IDisposable {
  96433. /**
  96434. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96435. */
  96436. static ShadersRepository: string;
  96437. /**
  96438. * Name of the effect.
  96439. */
  96440. name: any;
  96441. /**
  96442. * String container all the define statements that should be set on the shader.
  96443. */
  96444. defines: string;
  96445. /**
  96446. * Callback that will be called when the shader is compiled.
  96447. */
  96448. onCompiled: Nullable<(effect: Effect) => void>;
  96449. /**
  96450. * Callback that will be called if an error occurs during shader compilation.
  96451. */
  96452. onError: Nullable<(effect: Effect, errors: string) => void>;
  96453. /**
  96454. * Callback that will be called when effect is bound.
  96455. */
  96456. onBind: Nullable<(effect: Effect) => void>;
  96457. /**
  96458. * Unique ID of the effect.
  96459. */
  96460. uniqueId: number;
  96461. /**
  96462. * Observable that will be called when the shader is compiled.
  96463. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  96464. */
  96465. onCompileObservable: Observable<Effect>;
  96466. /**
  96467. * Observable that will be called if an error occurs during shader compilation.
  96468. */
  96469. onErrorObservable: Observable<Effect>;
  96470. /** @hidden */
  96471. _onBindObservable: Nullable<Observable<Effect>>;
  96472. /**
  96473. * Observable that will be called when effect is bound.
  96474. */
  96475. readonly onBindObservable: Observable<Effect>;
  96476. /** @hidden */
  96477. _bonesComputationForcedToCPU: boolean;
  96478. private static _uniqueIdSeed;
  96479. private _engine;
  96480. private _uniformBuffersNames;
  96481. private _uniformsNames;
  96482. private _samplerList;
  96483. private _samplers;
  96484. private _isReady;
  96485. private _compilationError;
  96486. private _allFallbacksProcessed;
  96487. private _attributesNames;
  96488. private _attributes;
  96489. private _uniforms;
  96490. /**
  96491. * Key for the effect.
  96492. * @hidden
  96493. */
  96494. _key: string;
  96495. private _indexParameters;
  96496. private _fallbacks;
  96497. private _vertexSourceCode;
  96498. private _fragmentSourceCode;
  96499. private _vertexSourceCodeOverride;
  96500. private _fragmentSourceCodeOverride;
  96501. private _transformFeedbackVaryings;
  96502. /**
  96503. * Compiled shader to webGL program.
  96504. * @hidden
  96505. */
  96506. _pipelineContext: Nullable<IPipelineContext>;
  96507. private _valueCache;
  96508. private static _baseCache;
  96509. /**
  96510. * Instantiates an effect.
  96511. * An effect can be used to create/manage/execute vertex and fragment shaders.
  96512. * @param baseName Name of the effect.
  96513. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  96514. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  96515. * @param samplers List of sampler variables that will be passed to the shader.
  96516. * @param engine Engine to be used to render the effect
  96517. * @param defines Define statements to be added to the shader.
  96518. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  96519. * @param onCompiled Callback that will be called when the shader is compiled.
  96520. * @param onError Callback that will be called if an error occurs during shader compilation.
  96521. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96522. */
  96523. 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);
  96524. private _useFinalCode;
  96525. /**
  96526. * Unique key for this effect
  96527. */
  96528. readonly key: string;
  96529. /**
  96530. * If the effect has been compiled and prepared.
  96531. * @returns if the effect is compiled and prepared.
  96532. */
  96533. isReady(): boolean;
  96534. private _isReadyInternal;
  96535. /**
  96536. * The engine the effect was initialized with.
  96537. * @returns the engine.
  96538. */
  96539. getEngine(): Engine;
  96540. /**
  96541. * The pipeline context for this effect
  96542. * @returns the associated pipeline context
  96543. */
  96544. getPipelineContext(): Nullable<IPipelineContext>;
  96545. /**
  96546. * The set of names of attribute variables for the shader.
  96547. * @returns An array of attribute names.
  96548. */
  96549. getAttributesNames(): string[];
  96550. /**
  96551. * Returns the attribute at the given index.
  96552. * @param index The index of the attribute.
  96553. * @returns The location of the attribute.
  96554. */
  96555. getAttributeLocation(index: number): number;
  96556. /**
  96557. * Returns the attribute based on the name of the variable.
  96558. * @param name of the attribute to look up.
  96559. * @returns the attribute location.
  96560. */
  96561. getAttributeLocationByName(name: string): number;
  96562. /**
  96563. * The number of attributes.
  96564. * @returns the numnber of attributes.
  96565. */
  96566. getAttributesCount(): number;
  96567. /**
  96568. * Gets the index of a uniform variable.
  96569. * @param uniformName of the uniform to look up.
  96570. * @returns the index.
  96571. */
  96572. getUniformIndex(uniformName: string): number;
  96573. /**
  96574. * Returns the attribute based on the name of the variable.
  96575. * @param uniformName of the uniform to look up.
  96576. * @returns the location of the uniform.
  96577. */
  96578. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  96579. /**
  96580. * Returns an array of sampler variable names
  96581. * @returns The array of sampler variable neames.
  96582. */
  96583. getSamplers(): string[];
  96584. /**
  96585. * The error from the last compilation.
  96586. * @returns the error string.
  96587. */
  96588. getCompilationError(): string;
  96589. /**
  96590. * Gets a boolean indicating that all fallbacks were used during compilation
  96591. * @returns true if all fallbacks were used
  96592. */
  96593. allFallbacksProcessed(): boolean;
  96594. /**
  96595. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  96596. * @param func The callback to be used.
  96597. */
  96598. executeWhenCompiled(func: (effect: Effect) => void): void;
  96599. private _checkIsReady;
  96600. private _loadShader;
  96601. /**
  96602. * Recompiles the webGL program
  96603. * @param vertexSourceCode The source code for the vertex shader.
  96604. * @param fragmentSourceCode The source code for the fragment shader.
  96605. * @param onCompiled Callback called when completed.
  96606. * @param onError Callback called on error.
  96607. * @hidden
  96608. */
  96609. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  96610. /**
  96611. * Prepares the effect
  96612. * @hidden
  96613. */
  96614. _prepareEffect(): void;
  96615. private _processCompilationErrors;
  96616. /**
  96617. * Checks if the effect is supported. (Must be called after compilation)
  96618. */
  96619. readonly isSupported: boolean;
  96620. /**
  96621. * Binds a texture to the engine to be used as output of the shader.
  96622. * @param channel Name of the output variable.
  96623. * @param texture Texture to bind.
  96624. * @hidden
  96625. */
  96626. _bindTexture(channel: string, texture: InternalTexture): void;
  96627. /**
  96628. * Sets a texture on the engine to be used in the shader.
  96629. * @param channel Name of the sampler variable.
  96630. * @param texture Texture to set.
  96631. */
  96632. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  96633. /**
  96634. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  96635. * @param channel Name of the sampler variable.
  96636. * @param texture Texture to set.
  96637. */
  96638. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  96639. /**
  96640. * Sets an array of textures on the engine to be used in the shader.
  96641. * @param channel Name of the variable.
  96642. * @param textures Textures to set.
  96643. */
  96644. setTextureArray(channel: string, textures: BaseTexture[]): void;
  96645. /**
  96646. * 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)
  96647. * @param channel Name of the sampler variable.
  96648. * @param postProcess Post process to get the input texture from.
  96649. */
  96650. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  96651. /**
  96652. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  96653. * 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)
  96654. * @param channel Name of the sampler variable.
  96655. * @param postProcess Post process to get the output texture from.
  96656. */
  96657. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  96658. /** @hidden */
  96659. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  96660. /** @hidden */
  96661. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  96662. /** @hidden */
  96663. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  96664. /** @hidden */
  96665. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  96666. /**
  96667. * Binds a buffer to a uniform.
  96668. * @param buffer Buffer to bind.
  96669. * @param name Name of the uniform variable to bind to.
  96670. */
  96671. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  96672. /**
  96673. * Binds block to a uniform.
  96674. * @param blockName Name of the block to bind.
  96675. * @param index Index to bind.
  96676. */
  96677. bindUniformBlock(blockName: string, index: number): void;
  96678. /**
  96679. * Sets an interger value on a uniform variable.
  96680. * @param uniformName Name of the variable.
  96681. * @param value Value to be set.
  96682. * @returns this effect.
  96683. */
  96684. setInt(uniformName: string, value: number): Effect;
  96685. /**
  96686. * Sets an int array on a uniform variable.
  96687. * @param uniformName Name of the variable.
  96688. * @param array array to be set.
  96689. * @returns this effect.
  96690. */
  96691. setIntArray(uniformName: string, array: Int32Array): Effect;
  96692. /**
  96693. * 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)
  96694. * @param uniformName Name of the variable.
  96695. * @param array array to be set.
  96696. * @returns this effect.
  96697. */
  96698. setIntArray2(uniformName: string, array: Int32Array): Effect;
  96699. /**
  96700. * 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)
  96701. * @param uniformName Name of the variable.
  96702. * @param array array to be set.
  96703. * @returns this effect.
  96704. */
  96705. setIntArray3(uniformName: string, array: Int32Array): Effect;
  96706. /**
  96707. * 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)
  96708. * @param uniformName Name of the variable.
  96709. * @param array array to be set.
  96710. * @returns this effect.
  96711. */
  96712. setIntArray4(uniformName: string, array: Int32Array): Effect;
  96713. /**
  96714. * Sets an float array on a uniform variable.
  96715. * @param uniformName Name of the variable.
  96716. * @param array array to be set.
  96717. * @returns this effect.
  96718. */
  96719. setFloatArray(uniformName: string, array: Float32Array): Effect;
  96720. /**
  96721. * 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)
  96722. * @param uniformName Name of the variable.
  96723. * @param array array to be set.
  96724. * @returns this effect.
  96725. */
  96726. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  96727. /**
  96728. * 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)
  96729. * @param uniformName Name of the variable.
  96730. * @param array array to be set.
  96731. * @returns this effect.
  96732. */
  96733. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  96734. /**
  96735. * 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)
  96736. * @param uniformName Name of the variable.
  96737. * @param array array to be set.
  96738. * @returns this effect.
  96739. */
  96740. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  96741. /**
  96742. * Sets an array on a uniform variable.
  96743. * @param uniformName Name of the variable.
  96744. * @param array array to be set.
  96745. * @returns this effect.
  96746. */
  96747. setArray(uniformName: string, array: number[]): Effect;
  96748. /**
  96749. * 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)
  96750. * @param uniformName Name of the variable.
  96751. * @param array array to be set.
  96752. * @returns this effect.
  96753. */
  96754. setArray2(uniformName: string, array: number[]): Effect;
  96755. /**
  96756. * 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)
  96757. * @param uniformName Name of the variable.
  96758. * @param array array to be set.
  96759. * @returns this effect.
  96760. */
  96761. setArray3(uniformName: string, array: number[]): Effect;
  96762. /**
  96763. * 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)
  96764. * @param uniformName Name of the variable.
  96765. * @param array array to be set.
  96766. * @returns this effect.
  96767. */
  96768. setArray4(uniformName: string, array: number[]): Effect;
  96769. /**
  96770. * Sets matrices on a uniform variable.
  96771. * @param uniformName Name of the variable.
  96772. * @param matrices matrices to be set.
  96773. * @returns this effect.
  96774. */
  96775. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  96776. /**
  96777. * Sets matrix on a uniform variable.
  96778. * @param uniformName Name of the variable.
  96779. * @param matrix matrix to be set.
  96780. * @returns this effect.
  96781. */
  96782. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  96783. /**
  96784. * 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)
  96785. * @param uniformName Name of the variable.
  96786. * @param matrix matrix to be set.
  96787. * @returns this effect.
  96788. */
  96789. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  96790. /**
  96791. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  96792. * @param uniformName Name of the variable.
  96793. * @param matrix matrix to be set.
  96794. * @returns this effect.
  96795. */
  96796. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  96797. /**
  96798. * Sets a float on a uniform variable.
  96799. * @param uniformName Name of the variable.
  96800. * @param value value to be set.
  96801. * @returns this effect.
  96802. */
  96803. setFloat(uniformName: string, value: number): Effect;
  96804. /**
  96805. * Sets a boolean on a uniform variable.
  96806. * @param uniformName Name of the variable.
  96807. * @param bool value to be set.
  96808. * @returns this effect.
  96809. */
  96810. setBool(uniformName: string, bool: boolean): Effect;
  96811. /**
  96812. * Sets a Vector2 on a uniform variable.
  96813. * @param uniformName Name of the variable.
  96814. * @param vector2 vector2 to be set.
  96815. * @returns this effect.
  96816. */
  96817. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  96818. /**
  96819. * Sets a float2 on a uniform variable.
  96820. * @param uniformName Name of the variable.
  96821. * @param x First float in float2.
  96822. * @param y Second float in float2.
  96823. * @returns this effect.
  96824. */
  96825. setFloat2(uniformName: string, x: number, y: number): Effect;
  96826. /**
  96827. * Sets a Vector3 on a uniform variable.
  96828. * @param uniformName Name of the variable.
  96829. * @param vector3 Value to be set.
  96830. * @returns this effect.
  96831. */
  96832. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  96833. /**
  96834. * Sets a float3 on a uniform variable.
  96835. * @param uniformName Name of the variable.
  96836. * @param x First float in float3.
  96837. * @param y Second float in float3.
  96838. * @param z Third float in float3.
  96839. * @returns this effect.
  96840. */
  96841. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  96842. /**
  96843. * Sets a Vector4 on a uniform variable.
  96844. * @param uniformName Name of the variable.
  96845. * @param vector4 Value to be set.
  96846. * @returns this effect.
  96847. */
  96848. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  96849. /**
  96850. * Sets a float4 on a uniform variable.
  96851. * @param uniformName Name of the variable.
  96852. * @param x First float in float4.
  96853. * @param y Second float in float4.
  96854. * @param z Third float in float4.
  96855. * @param w Fourth float in float4.
  96856. * @returns this effect.
  96857. */
  96858. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  96859. /**
  96860. * Sets a Color3 on a uniform variable.
  96861. * @param uniformName Name of the variable.
  96862. * @param color3 Value to be set.
  96863. * @returns this effect.
  96864. */
  96865. setColor3(uniformName: string, color3: IColor3Like): Effect;
  96866. /**
  96867. * Sets a Color4 on a uniform variable.
  96868. * @param uniformName Name of the variable.
  96869. * @param color3 Value to be set.
  96870. * @param alpha Alpha value to be set.
  96871. * @returns this effect.
  96872. */
  96873. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  96874. /**
  96875. * Sets a Color4 on a uniform variable
  96876. * @param uniformName defines the name of the variable
  96877. * @param color4 defines the value to be set
  96878. * @returns this effect.
  96879. */
  96880. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  96881. /** Release all associated resources */
  96882. dispose(): void;
  96883. /**
  96884. * This function will add a new shader to the shader store
  96885. * @param name the name of the shader
  96886. * @param pixelShader optional pixel shader content
  96887. * @param vertexShader optional vertex shader content
  96888. */
  96889. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  96890. /**
  96891. * Store of each shader (The can be looked up using effect.key)
  96892. */
  96893. static ShadersStore: {
  96894. [key: string]: string;
  96895. };
  96896. /**
  96897. * Store of each included file for a shader (The can be looked up using effect.key)
  96898. */
  96899. static IncludesShadersStore: {
  96900. [key: string]: string;
  96901. };
  96902. /**
  96903. * Resets the cache of effects.
  96904. */
  96905. static ResetCache(): void;
  96906. }
  96907. }
  96908. declare module BABYLON {
  96909. /**
  96910. * Interface used to describe the capabilities of the engine relatively to the current browser
  96911. */
  96912. export interface EngineCapabilities {
  96913. /** Maximum textures units per fragment shader */
  96914. maxTexturesImageUnits: number;
  96915. /** Maximum texture units per vertex shader */
  96916. maxVertexTextureImageUnits: number;
  96917. /** Maximum textures units in the entire pipeline */
  96918. maxCombinedTexturesImageUnits: number;
  96919. /** Maximum texture size */
  96920. maxTextureSize: number;
  96921. /** Maximum cube texture size */
  96922. maxCubemapTextureSize: number;
  96923. /** Maximum render texture size */
  96924. maxRenderTextureSize: number;
  96925. /** Maximum number of vertex attributes */
  96926. maxVertexAttribs: number;
  96927. /** Maximum number of varyings */
  96928. maxVaryingVectors: number;
  96929. /** Maximum number of uniforms per vertex shader */
  96930. maxVertexUniformVectors: number;
  96931. /** Maximum number of uniforms per fragment shader */
  96932. maxFragmentUniformVectors: number;
  96933. /** Defines if standard derivates (dx/dy) are supported */
  96934. standardDerivatives: boolean;
  96935. /** Defines if s3tc texture compression is supported */
  96936. s3tc?: WEBGL_compressed_texture_s3tc;
  96937. /** Defines if pvrtc texture compression is supported */
  96938. pvrtc: any;
  96939. /** Defines if etc1 texture compression is supported */
  96940. etc1: any;
  96941. /** Defines if etc2 texture compression is supported */
  96942. etc2: any;
  96943. /** Defines if astc texture compression is supported */
  96944. astc: any;
  96945. /** Defines if float textures are supported */
  96946. textureFloat: boolean;
  96947. /** Defines if vertex array objects are supported */
  96948. vertexArrayObject: boolean;
  96949. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  96950. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  96951. /** Gets the maximum level of anisotropy supported */
  96952. maxAnisotropy: number;
  96953. /** Defines if instancing is supported */
  96954. instancedArrays: boolean;
  96955. /** Defines if 32 bits indices are supported */
  96956. uintIndices: boolean;
  96957. /** Defines if high precision shaders are supported */
  96958. highPrecisionShaderSupported: boolean;
  96959. /** Defines if depth reading in the fragment shader is supported */
  96960. fragmentDepthSupported: boolean;
  96961. /** Defines if float texture linear filtering is supported*/
  96962. textureFloatLinearFiltering: boolean;
  96963. /** Defines if rendering to float textures is supported */
  96964. textureFloatRender: boolean;
  96965. /** Defines if half float textures are supported*/
  96966. textureHalfFloat: boolean;
  96967. /** Defines if half float texture linear filtering is supported*/
  96968. textureHalfFloatLinearFiltering: boolean;
  96969. /** Defines if rendering to half float textures is supported */
  96970. textureHalfFloatRender: boolean;
  96971. /** Defines if textureLOD shader command is supported */
  96972. textureLOD: boolean;
  96973. /** Defines if draw buffers extension is supported */
  96974. drawBuffersExtension: boolean;
  96975. /** Defines if depth textures are supported */
  96976. depthTextureExtension: boolean;
  96977. /** Defines if float color buffer are supported */
  96978. colorBufferFloat: boolean;
  96979. /** Gets disjoint timer query extension (null if not supported) */
  96980. timerQuery?: EXT_disjoint_timer_query;
  96981. /** Defines if timestamp can be used with timer query */
  96982. canUseTimestampForTimerQuery: boolean;
  96983. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  96984. multiview?: any;
  96985. /** Function used to let the system compiles shaders in background */
  96986. parallelShaderCompile?: {
  96987. COMPLETION_STATUS_KHR: number;
  96988. };
  96989. /** Max number of texture samples for MSAA */
  96990. maxMSAASamples: number;
  96991. /** Defines if the blend min max extension is supported */
  96992. blendMinMax: boolean;
  96993. }
  96994. }
  96995. declare module BABYLON {
  96996. /**
  96997. * @hidden
  96998. **/
  96999. export class DepthCullingState {
  97000. private _isDepthTestDirty;
  97001. private _isDepthMaskDirty;
  97002. private _isDepthFuncDirty;
  97003. private _isCullFaceDirty;
  97004. private _isCullDirty;
  97005. private _isZOffsetDirty;
  97006. private _isFrontFaceDirty;
  97007. private _depthTest;
  97008. private _depthMask;
  97009. private _depthFunc;
  97010. private _cull;
  97011. private _cullFace;
  97012. private _zOffset;
  97013. private _frontFace;
  97014. /**
  97015. * Initializes the state.
  97016. */
  97017. constructor();
  97018. readonly isDirty: boolean;
  97019. zOffset: number;
  97020. cullFace: Nullable<number>;
  97021. cull: Nullable<boolean>;
  97022. depthFunc: Nullable<number>;
  97023. depthMask: boolean;
  97024. depthTest: boolean;
  97025. frontFace: Nullable<number>;
  97026. reset(): void;
  97027. apply(gl: WebGLRenderingContext): void;
  97028. }
  97029. }
  97030. declare module BABYLON {
  97031. /**
  97032. * @hidden
  97033. **/
  97034. export class StencilState {
  97035. /** 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 */
  97036. static readonly ALWAYS: number;
  97037. /** Passed to stencilOperation to specify that stencil value must be kept */
  97038. static readonly KEEP: number;
  97039. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97040. static readonly REPLACE: number;
  97041. private _isStencilTestDirty;
  97042. private _isStencilMaskDirty;
  97043. private _isStencilFuncDirty;
  97044. private _isStencilOpDirty;
  97045. private _stencilTest;
  97046. private _stencilMask;
  97047. private _stencilFunc;
  97048. private _stencilFuncRef;
  97049. private _stencilFuncMask;
  97050. private _stencilOpStencilFail;
  97051. private _stencilOpDepthFail;
  97052. private _stencilOpStencilDepthPass;
  97053. readonly isDirty: boolean;
  97054. stencilFunc: number;
  97055. stencilFuncRef: number;
  97056. stencilFuncMask: number;
  97057. stencilOpStencilFail: number;
  97058. stencilOpDepthFail: number;
  97059. stencilOpStencilDepthPass: number;
  97060. stencilMask: number;
  97061. stencilTest: boolean;
  97062. constructor();
  97063. reset(): void;
  97064. apply(gl: WebGLRenderingContext): void;
  97065. }
  97066. }
  97067. declare module BABYLON {
  97068. /**
  97069. * @hidden
  97070. **/
  97071. export class AlphaState {
  97072. private _isAlphaBlendDirty;
  97073. private _isBlendFunctionParametersDirty;
  97074. private _isBlendEquationParametersDirty;
  97075. private _isBlendConstantsDirty;
  97076. private _alphaBlend;
  97077. private _blendFunctionParameters;
  97078. private _blendEquationParameters;
  97079. private _blendConstants;
  97080. /**
  97081. * Initializes the state.
  97082. */
  97083. constructor();
  97084. readonly isDirty: boolean;
  97085. alphaBlend: boolean;
  97086. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  97087. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  97088. setAlphaEquationParameters(rgb: number, alpha: number): void;
  97089. reset(): void;
  97090. apply(gl: WebGLRenderingContext): void;
  97091. }
  97092. }
  97093. declare module BABYLON {
  97094. /** @hidden */
  97095. export class WebGL2ShaderProcessor implements IShaderProcessor {
  97096. attributeProcessor(attribute: string): string;
  97097. varyingProcessor(varying: string, isFragment: boolean): string;
  97098. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  97099. }
  97100. }
  97101. declare module BABYLON {
  97102. /**
  97103. * Interface for attribute information associated with buffer instanciation
  97104. */
  97105. export interface InstancingAttributeInfo {
  97106. /**
  97107. * Index/offset of the attribute in the vertex shader
  97108. */
  97109. index: number;
  97110. /**
  97111. * size of the attribute, 1, 2, 3 or 4
  97112. */
  97113. attributeSize: number;
  97114. /**
  97115. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  97116. * default is FLOAT
  97117. */
  97118. attributeType: number;
  97119. /**
  97120. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  97121. */
  97122. normalized: boolean;
  97123. /**
  97124. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  97125. */
  97126. offset: number;
  97127. /**
  97128. * Name of the GLSL attribute, for debugging purpose only
  97129. */
  97130. attributeName: string;
  97131. }
  97132. }
  97133. declare module BABYLON {
  97134. interface ThinEngine {
  97135. /**
  97136. * Update a video texture
  97137. * @param texture defines the texture to update
  97138. * @param video defines the video element to use
  97139. * @param invertY defines if data must be stored with Y axis inverted
  97140. */
  97141. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  97142. }
  97143. }
  97144. declare module BABYLON {
  97145. /**
  97146. * Settings for finer control over video usage
  97147. */
  97148. export interface VideoTextureSettings {
  97149. /**
  97150. * Applies `autoplay` to video, if specified
  97151. */
  97152. autoPlay?: boolean;
  97153. /**
  97154. * Applies `loop` to video, if specified
  97155. */
  97156. loop?: boolean;
  97157. /**
  97158. * Automatically updates internal texture from video at every frame in the render loop
  97159. */
  97160. autoUpdateTexture: boolean;
  97161. /**
  97162. * Image src displayed during the video loading or until the user interacts with the video.
  97163. */
  97164. poster?: string;
  97165. }
  97166. /**
  97167. * If you want to display a video in your scene, this is the special texture for that.
  97168. * This special texture works similar to other textures, with the exception of a few parameters.
  97169. * @see https://doc.babylonjs.com/how_to/video_texture
  97170. */
  97171. export class VideoTexture extends Texture {
  97172. /**
  97173. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  97174. */
  97175. readonly autoUpdateTexture: boolean;
  97176. /**
  97177. * The video instance used by the texture internally
  97178. */
  97179. readonly video: HTMLVideoElement;
  97180. private _onUserActionRequestedObservable;
  97181. /**
  97182. * Event triggerd when a dom action is required by the user to play the video.
  97183. * This happens due to recent changes in browser policies preventing video to auto start.
  97184. */
  97185. readonly onUserActionRequestedObservable: Observable<Texture>;
  97186. private _generateMipMaps;
  97187. private _engine;
  97188. private _stillImageCaptured;
  97189. private _displayingPosterTexture;
  97190. private _settings;
  97191. private _createInternalTextureOnEvent;
  97192. private _frameId;
  97193. /**
  97194. * Creates a video texture.
  97195. * If you want to display a video in your scene, this is the special texture for that.
  97196. * This special texture works similar to other textures, with the exception of a few parameters.
  97197. * @see https://doc.babylonjs.com/how_to/video_texture
  97198. * @param name optional name, will detect from video source, if not defined
  97199. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  97200. * @param scene is obviously the current scene.
  97201. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  97202. * @param invertY is false by default but can be used to invert video on Y axis
  97203. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  97204. * @param settings allows finer control over video usage
  97205. */
  97206. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  97207. private _getName;
  97208. private _getVideo;
  97209. private _createInternalTexture;
  97210. private reset;
  97211. /**
  97212. * @hidden Internal method to initiate `update`.
  97213. */
  97214. _rebuild(): void;
  97215. /**
  97216. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  97217. */
  97218. update(): void;
  97219. /**
  97220. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  97221. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  97222. */
  97223. updateTexture(isVisible: boolean): void;
  97224. protected _updateInternalTexture: () => void;
  97225. /**
  97226. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  97227. * @param url New url.
  97228. */
  97229. updateURL(url: string): void;
  97230. /**
  97231. * Dispose the texture and release its associated resources.
  97232. */
  97233. dispose(): void;
  97234. /**
  97235. * Creates a video texture straight from a stream.
  97236. * @param scene Define the scene the texture should be created in
  97237. * @param stream Define the stream the texture should be created from
  97238. * @returns The created video texture as a promise
  97239. */
  97240. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  97241. /**
  97242. * Creates a video texture straight from your WebCam video feed.
  97243. * @param scene Define the scene the texture should be created in
  97244. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  97245. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  97246. * @returns The created video texture as a promise
  97247. */
  97248. static CreateFromWebCamAsync(scene: Scene, constraints: {
  97249. minWidth: number;
  97250. maxWidth: number;
  97251. minHeight: number;
  97252. maxHeight: number;
  97253. deviceId: string;
  97254. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  97255. /**
  97256. * Creates a video texture straight from your WebCam video feed.
  97257. * @param scene Define the scene the texture should be created in
  97258. * @param onReady Define a callback to triggered once the texture will be ready
  97259. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  97260. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  97261. */
  97262. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  97263. minWidth: number;
  97264. maxWidth: number;
  97265. minHeight: number;
  97266. maxHeight: number;
  97267. deviceId: string;
  97268. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  97269. }
  97270. }
  97271. declare module BABYLON {
  97272. /**
  97273. * Defines the interface used by objects working like Scene
  97274. * @hidden
  97275. */
  97276. interface ISceneLike {
  97277. _addPendingData(data: any): void;
  97278. _removePendingData(data: any): void;
  97279. offlineProvider: IOfflineProvider;
  97280. }
  97281. /** Interface defining initialization parameters for Engine class */
  97282. export interface EngineOptions extends WebGLContextAttributes {
  97283. /**
  97284. * Defines if the engine should no exceed a specified device ratio
  97285. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  97286. */
  97287. limitDeviceRatio?: number;
  97288. /**
  97289. * Defines if webvr should be enabled automatically
  97290. * @see http://doc.babylonjs.com/how_to/webvr_camera
  97291. */
  97292. autoEnableWebVR?: boolean;
  97293. /**
  97294. * Defines if webgl2 should be turned off even if supported
  97295. * @see http://doc.babylonjs.com/features/webgl2
  97296. */
  97297. disableWebGL2Support?: boolean;
  97298. /**
  97299. * Defines if webaudio should be initialized as well
  97300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97301. */
  97302. audioEngine?: boolean;
  97303. /**
  97304. * Defines if animations should run using a deterministic lock step
  97305. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97306. */
  97307. deterministicLockstep?: boolean;
  97308. /** Defines the maximum steps to use with deterministic lock step mode */
  97309. lockstepMaxSteps?: number;
  97310. /**
  97311. * Defines that engine should ignore context lost events
  97312. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  97313. */
  97314. doNotHandleContextLost?: boolean;
  97315. /**
  97316. * Defines that engine should ignore modifying touch action attribute and style
  97317. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  97318. */
  97319. doNotHandleTouchAction?: boolean;
  97320. /**
  97321. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  97322. */
  97323. useHighPrecisionFloats?: boolean;
  97324. }
  97325. /**
  97326. * The base engine class (root of all engines)
  97327. */
  97328. export class ThinEngine {
  97329. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  97330. static ExceptionList: ({
  97331. key: string;
  97332. capture: string;
  97333. captureConstraint: number;
  97334. targets: string[];
  97335. } | {
  97336. key: string;
  97337. capture: null;
  97338. captureConstraint: null;
  97339. targets: string[];
  97340. })[];
  97341. /** @hidden */
  97342. static _TextureLoaders: IInternalTextureLoader[];
  97343. /**
  97344. * Returns the current npm package of the sdk
  97345. */
  97346. static readonly NpmPackage: string;
  97347. /**
  97348. * Returns the current version of the framework
  97349. */
  97350. static readonly Version: string;
  97351. /**
  97352. * Returns a string describing the current engine
  97353. */
  97354. readonly description: string;
  97355. /**
  97356. * Gets or sets the epsilon value used by collision engine
  97357. */
  97358. static CollisionsEpsilon: number;
  97359. /**
  97360. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  97361. */
  97362. static ShadersRepository: string;
  97363. /** @hidden */
  97364. _shaderProcessor: IShaderProcessor;
  97365. /**
  97366. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  97367. */
  97368. forcePOTTextures: boolean;
  97369. /**
  97370. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  97371. */
  97372. isFullscreen: boolean;
  97373. /**
  97374. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  97375. */
  97376. cullBackFaces: boolean;
  97377. /**
  97378. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  97379. */
  97380. renderEvenInBackground: boolean;
  97381. /**
  97382. * Gets or sets a boolean indicating that cache can be kept between frames
  97383. */
  97384. preventCacheWipeBetweenFrames: boolean;
  97385. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  97386. validateShaderPrograms: boolean;
  97387. /**
  97388. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  97389. */
  97390. disableUniformBuffers: boolean;
  97391. /** @hidden */
  97392. _uniformBuffers: UniformBuffer[];
  97393. /**
  97394. * Gets a boolean indicating that the engine supports uniform buffers
  97395. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  97396. */
  97397. readonly supportsUniformBuffers: boolean;
  97398. /** @hidden */
  97399. _gl: WebGLRenderingContext;
  97400. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  97401. protected _windowIsBackground: boolean;
  97402. protected _webGLVersion: number;
  97403. protected _creationOptions: EngineOptions;
  97404. protected _highPrecisionShadersAllowed: boolean;
  97405. /** @hidden */
  97406. readonly _shouldUseHighPrecisionShader: boolean;
  97407. /**
  97408. * Gets a boolean indicating that only power of 2 textures are supported
  97409. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  97410. */
  97411. readonly needPOTTextures: boolean;
  97412. /** @hidden */
  97413. _badOS: boolean;
  97414. /** @hidden */
  97415. _badDesktopOS: boolean;
  97416. private _hardwareScalingLevel;
  97417. /** @hidden */
  97418. _caps: EngineCapabilities;
  97419. private _isStencilEnable;
  97420. protected _colorWrite: boolean;
  97421. private _glVersion;
  97422. private _glRenderer;
  97423. private _glVendor;
  97424. /** @hidden */
  97425. _videoTextureSupported: boolean;
  97426. protected _renderingQueueLaunched: boolean;
  97427. protected _activeRenderLoops: (() => void)[];
  97428. /**
  97429. * Observable signaled when a context lost event is raised
  97430. */
  97431. onContextLostObservable: Observable<ThinEngine>;
  97432. /**
  97433. * Observable signaled when a context restored event is raised
  97434. */
  97435. onContextRestoredObservable: Observable<ThinEngine>;
  97436. private _onContextLost;
  97437. private _onContextRestored;
  97438. protected _contextWasLost: boolean;
  97439. /** @hidden */
  97440. _doNotHandleContextLost: boolean;
  97441. /**
  97442. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  97443. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  97444. */
  97445. doNotHandleContextLost: boolean;
  97446. /**
  97447. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  97448. */
  97449. disableVertexArrayObjects: boolean;
  97450. /** @hidden */
  97451. protected _depthCullingState: DepthCullingState;
  97452. /** @hidden */
  97453. protected _stencilState: StencilState;
  97454. /** @hidden */
  97455. protected _alphaState: AlphaState;
  97456. /** @hidden */
  97457. _internalTexturesCache: InternalTexture[];
  97458. /** @hidden */
  97459. protected _activeChannel: number;
  97460. private _currentTextureChannel;
  97461. /** @hidden */
  97462. protected _boundTexturesCache: {
  97463. [key: string]: Nullable<InternalTexture>;
  97464. };
  97465. /** @hidden */
  97466. protected _currentEffect: Nullable<Effect>;
  97467. /** @hidden */
  97468. protected _currentProgram: Nullable<WebGLProgram>;
  97469. private _compiledEffects;
  97470. private _vertexAttribArraysEnabled;
  97471. /** @hidden */
  97472. protected _cachedViewport: Nullable<IViewportLike>;
  97473. private _cachedVertexArrayObject;
  97474. /** @hidden */
  97475. protected _cachedVertexBuffers: any;
  97476. /** @hidden */
  97477. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  97478. /** @hidden */
  97479. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  97480. /** @hidden */
  97481. _currentRenderTarget: Nullable<InternalTexture>;
  97482. private _uintIndicesCurrentlySet;
  97483. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  97484. /** @hidden */
  97485. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  97486. private _currentBufferPointers;
  97487. private _currentInstanceLocations;
  97488. private _currentInstanceBuffers;
  97489. private _textureUnits;
  97490. /** @hidden */
  97491. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  97492. /** @hidden */
  97493. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  97494. /** @hidden */
  97495. _boundRenderFunction: any;
  97496. private _vaoRecordInProgress;
  97497. private _mustWipeVertexAttributes;
  97498. private _emptyTexture;
  97499. private _emptyCubeTexture;
  97500. private _emptyTexture3D;
  97501. private _emptyTexture2DArray;
  97502. /** @hidden */
  97503. _frameHandler: number;
  97504. private _nextFreeTextureSlots;
  97505. private _maxSimultaneousTextures;
  97506. private _activeRequests;
  97507. protected _texturesSupported: string[];
  97508. /** @hidden */
  97509. _textureFormatInUse: Nullable<string>;
  97510. protected readonly _supportsHardwareTextureRescaling: boolean;
  97511. /**
  97512. * Gets the list of texture formats supported
  97513. */
  97514. readonly texturesSupported: Array<string>;
  97515. /**
  97516. * Gets the list of texture formats in use
  97517. */
  97518. readonly textureFormatInUse: Nullable<string>;
  97519. /**
  97520. * Gets the current viewport
  97521. */
  97522. readonly currentViewport: Nullable<IViewportLike>;
  97523. /**
  97524. * Gets the default empty texture
  97525. */
  97526. readonly emptyTexture: InternalTexture;
  97527. /**
  97528. * Gets the default empty 3D texture
  97529. */
  97530. readonly emptyTexture3D: InternalTexture;
  97531. /**
  97532. * Gets the default empty 2D array texture
  97533. */
  97534. readonly emptyTexture2DArray: InternalTexture;
  97535. /**
  97536. * Gets the default empty cube texture
  97537. */
  97538. readonly emptyCubeTexture: InternalTexture;
  97539. /**
  97540. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  97541. */
  97542. readonly premultipliedAlpha: boolean;
  97543. /**
  97544. * Observable event triggered before each texture is initialized
  97545. */
  97546. onBeforeTextureInitObservable: Observable<Texture>;
  97547. /**
  97548. * Creates a new engine
  97549. * @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
  97550. * @param antialias defines enable antialiasing (default: false)
  97551. * @param options defines further options to be sent to the getContext() function
  97552. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  97553. */
  97554. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  97555. private _rebuildInternalTextures;
  97556. private _rebuildEffects;
  97557. /**
  97558. * Gets a boolean indicating if all created effects are ready
  97559. * @returns true if all effects are ready
  97560. */
  97561. areAllEffectsReady(): boolean;
  97562. protected _rebuildBuffers(): void;
  97563. private _initGLContext;
  97564. /**
  97565. * Gets version of the current webGL context
  97566. */
  97567. readonly webGLVersion: number;
  97568. /**
  97569. * Gets a string idenfifying the name of the class
  97570. * @returns "Engine" string
  97571. */
  97572. getClassName(): string;
  97573. /**
  97574. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  97575. */
  97576. readonly isStencilEnable: boolean;
  97577. /** @hidden */
  97578. _prepareWorkingCanvas(): void;
  97579. /**
  97580. * Reset the texture cache to empty state
  97581. */
  97582. resetTextureCache(): void;
  97583. /**
  97584. * Gets an object containing information about the current webGL context
  97585. * @returns an object containing the vender, the renderer and the version of the current webGL context
  97586. */
  97587. getGlInfo(): {
  97588. vendor: string;
  97589. renderer: string;
  97590. version: string;
  97591. };
  97592. /**
  97593. * Defines the hardware scaling level.
  97594. * By default the hardware scaling level is computed from the window device ratio.
  97595. * 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.
  97596. * @param level defines the level to use
  97597. */
  97598. setHardwareScalingLevel(level: number): void;
  97599. /**
  97600. * Gets the current hardware scaling level.
  97601. * By default the hardware scaling level is computed from the window device ratio.
  97602. * 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.
  97603. * @returns a number indicating the current hardware scaling level
  97604. */
  97605. getHardwareScalingLevel(): number;
  97606. /**
  97607. * Gets the list of loaded textures
  97608. * @returns an array containing all loaded textures
  97609. */
  97610. getLoadedTexturesCache(): InternalTexture[];
  97611. /**
  97612. * Gets the object containing all engine capabilities
  97613. * @returns the EngineCapabilities object
  97614. */
  97615. getCaps(): EngineCapabilities;
  97616. /**
  97617. * stop executing a render loop function and remove it from the execution array
  97618. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  97619. */
  97620. stopRenderLoop(renderFunction?: () => void): void;
  97621. /** @hidden */
  97622. _renderLoop(): void;
  97623. /**
  97624. * Gets the HTML canvas attached with the current webGL context
  97625. * @returns a HTML canvas
  97626. */
  97627. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  97628. /**
  97629. * Gets host window
  97630. * @returns the host window object
  97631. */
  97632. getHostWindow(): Nullable<Window>;
  97633. /**
  97634. * Gets the current render width
  97635. * @param useScreen defines if screen size must be used (or the current render target if any)
  97636. * @returns a number defining the current render width
  97637. */
  97638. getRenderWidth(useScreen?: boolean): number;
  97639. /**
  97640. * Gets the current render height
  97641. * @param useScreen defines if screen size must be used (or the current render target if any)
  97642. * @returns a number defining the current render height
  97643. */
  97644. getRenderHeight(useScreen?: boolean): number;
  97645. /**
  97646. * Can be used to override the current requestAnimationFrame requester.
  97647. * @hidden
  97648. */
  97649. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  97650. /**
  97651. * Register and execute a render loop. The engine can have more than one render function
  97652. * @param renderFunction defines the function to continuously execute
  97653. */
  97654. runRenderLoop(renderFunction: () => void): void;
  97655. /**
  97656. * Clear the current render buffer or the current render target (if any is set up)
  97657. * @param color defines the color to use
  97658. * @param backBuffer defines if the back buffer must be cleared
  97659. * @param depth defines if the depth buffer must be cleared
  97660. * @param stencil defines if the stencil buffer must be cleared
  97661. */
  97662. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  97663. private _viewportCached;
  97664. /** @hidden */
  97665. _viewport(x: number, y: number, width: number, height: number): void;
  97666. /**
  97667. * Set the WebGL's viewport
  97668. * @param viewport defines the viewport element to be used
  97669. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  97670. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  97671. */
  97672. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  97673. /**
  97674. * Begin a new frame
  97675. */
  97676. beginFrame(): void;
  97677. /**
  97678. * Enf the current frame
  97679. */
  97680. endFrame(): void;
  97681. /**
  97682. * Resize the view according to the canvas' size
  97683. */
  97684. resize(): void;
  97685. /**
  97686. * Force a specific size of the canvas
  97687. * @param width defines the new canvas' width
  97688. * @param height defines the new canvas' height
  97689. */
  97690. setSize(width: number, height: number): void;
  97691. /**
  97692. * Binds the frame buffer to the specified texture.
  97693. * @param texture The texture to render to or null for the default canvas
  97694. * @param faceIndex The face of the texture to render to in case of cube texture
  97695. * @param requiredWidth The width of the target to render to
  97696. * @param requiredHeight The height of the target to render to
  97697. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  97698. * @param depthStencilTexture The depth stencil texture to use to render
  97699. * @param lodLevel defines le lod level to bind to the frame buffer
  97700. */
  97701. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  97702. /** @hidden */
  97703. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  97704. /**
  97705. * Unbind the current render target texture from the webGL context
  97706. * @param texture defines the render target texture to unbind
  97707. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  97708. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  97709. */
  97710. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  97711. /**
  97712. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  97713. */
  97714. flushFramebuffer(): void;
  97715. /**
  97716. * Unbind the current render target and bind the default framebuffer
  97717. */
  97718. restoreDefaultFramebuffer(): void;
  97719. /** @hidden */
  97720. protected _resetVertexBufferBinding(): void;
  97721. /**
  97722. * Creates a vertex buffer
  97723. * @param data the data for the vertex buffer
  97724. * @returns the new WebGL static buffer
  97725. */
  97726. createVertexBuffer(data: DataArray): DataBuffer;
  97727. private _createVertexBuffer;
  97728. /**
  97729. * Creates a dynamic vertex buffer
  97730. * @param data the data for the dynamic vertex buffer
  97731. * @returns the new WebGL dynamic buffer
  97732. */
  97733. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  97734. protected _resetIndexBufferBinding(): void;
  97735. /**
  97736. * Creates a new index buffer
  97737. * @param indices defines the content of the index buffer
  97738. * @param updatable defines if the index buffer must be updatable
  97739. * @returns a new webGL buffer
  97740. */
  97741. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  97742. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  97743. /**
  97744. * Bind a webGL buffer to the webGL context
  97745. * @param buffer defines the buffer to bind
  97746. */
  97747. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  97748. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  97749. private bindBuffer;
  97750. /**
  97751. * update the bound buffer with the given data
  97752. * @param data defines the data to update
  97753. */
  97754. updateArrayBuffer(data: Float32Array): void;
  97755. private _vertexAttribPointer;
  97756. private _bindIndexBufferWithCache;
  97757. private _bindVertexBuffersAttributes;
  97758. /**
  97759. * Records a vertex array object
  97760. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  97761. * @param vertexBuffers defines the list of vertex buffers to store
  97762. * @param indexBuffer defines the index buffer to store
  97763. * @param effect defines the effect to store
  97764. * @returns the new vertex array object
  97765. */
  97766. recordVertexArrayObject(vertexBuffers: {
  97767. [key: string]: VertexBuffer;
  97768. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  97769. /**
  97770. * Bind a specific vertex array object
  97771. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  97772. * @param vertexArrayObject defines the vertex array object to bind
  97773. * @param indexBuffer defines the index buffer to bind
  97774. */
  97775. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  97776. /**
  97777. * Bind webGl buffers directly to the webGL context
  97778. * @param vertexBuffer defines the vertex buffer to bind
  97779. * @param indexBuffer defines the index buffer to bind
  97780. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  97781. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  97782. * @param effect defines the effect associated with the vertex buffer
  97783. */
  97784. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  97785. private _unbindVertexArrayObject;
  97786. /**
  97787. * Bind a list of vertex buffers to the webGL context
  97788. * @param vertexBuffers defines the list of vertex buffers to bind
  97789. * @param indexBuffer defines the index buffer to bind
  97790. * @param effect defines the effect associated with the vertex buffers
  97791. */
  97792. bindBuffers(vertexBuffers: {
  97793. [key: string]: Nullable<VertexBuffer>;
  97794. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  97795. /**
  97796. * Unbind all instance attributes
  97797. */
  97798. unbindInstanceAttributes(): void;
  97799. /**
  97800. * Release and free the memory of a vertex array object
  97801. * @param vao defines the vertex array object to delete
  97802. */
  97803. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  97804. /** @hidden */
  97805. _releaseBuffer(buffer: DataBuffer): boolean;
  97806. protected _deleteBuffer(buffer: DataBuffer): void;
  97807. /**
  97808. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  97809. * @param instancesBuffer defines the webGL buffer to update and bind
  97810. * @param data defines the data to store in the buffer
  97811. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  97812. */
  97813. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  97814. /**
  97815. * Apply all cached states (depth, culling, stencil and alpha)
  97816. */
  97817. applyStates(): void;
  97818. /**
  97819. * Send a draw order
  97820. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  97821. * @param indexStart defines the starting index
  97822. * @param indexCount defines the number of index to draw
  97823. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97824. */
  97825. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  97826. /**
  97827. * Draw a list of points
  97828. * @param verticesStart defines the index of first vertex to draw
  97829. * @param verticesCount defines the count of vertices to draw
  97830. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97831. */
  97832. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97833. /**
  97834. * Draw a list of unindexed primitives
  97835. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  97836. * @param verticesStart defines the index of first vertex to draw
  97837. * @param verticesCount defines the count of vertices to draw
  97838. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97839. */
  97840. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97841. /**
  97842. * Draw a list of indexed primitives
  97843. * @param fillMode defines the primitive to use
  97844. * @param indexStart defines the starting index
  97845. * @param indexCount defines the number of index to draw
  97846. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97847. */
  97848. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  97849. /**
  97850. * Draw a list of unindexed primitives
  97851. * @param fillMode defines the primitive to use
  97852. * @param verticesStart defines the index of first vertex to draw
  97853. * @param verticesCount defines the count of vertices to draw
  97854. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97855. */
  97856. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97857. private _drawMode;
  97858. /** @hidden */
  97859. protected _reportDrawCall(): void;
  97860. /** @hidden */
  97861. _releaseEffect(effect: Effect): void;
  97862. /** @hidden */
  97863. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  97864. /**
  97865. * Create a new effect (used to store vertex/fragment shaders)
  97866. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  97867. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  97868. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  97869. * @param samplers defines an array of string used to represent textures
  97870. * @param defines defines the string containing the defines to use to compile the shaders
  97871. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  97872. * @param onCompiled defines a function to call when the effect creation is successful
  97873. * @param onError defines a function to call when the effect creation has failed
  97874. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  97875. * @returns the new Effect
  97876. */
  97877. 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;
  97878. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  97879. private _compileShader;
  97880. private _compileRawShader;
  97881. /**
  97882. * Directly creates a webGL program
  97883. * @param pipelineContext defines the pipeline context to attach to
  97884. * @param vertexCode defines the vertex shader code to use
  97885. * @param fragmentCode defines the fragment shader code to use
  97886. * @param context defines the webGL context to use (if not set, the current one will be used)
  97887. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  97888. * @returns the new webGL program
  97889. */
  97890. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97891. /**
  97892. * Creates a webGL program
  97893. * @param pipelineContext defines the pipeline context to attach to
  97894. * @param vertexCode defines the vertex shader code to use
  97895. * @param fragmentCode defines the fragment shader code to use
  97896. * @param defines defines the string containing the defines to use to compile the shaders
  97897. * @param context defines the webGL context to use (if not set, the current one will be used)
  97898. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  97899. * @returns the new webGL program
  97900. */
  97901. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97902. /**
  97903. * Creates a new pipeline context
  97904. * @returns the new pipeline
  97905. */
  97906. createPipelineContext(): IPipelineContext;
  97907. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97908. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  97909. /** @hidden */
  97910. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  97911. /** @hidden */
  97912. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  97913. /** @hidden */
  97914. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  97915. /**
  97916. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  97917. * @param pipelineContext defines the pipeline context to use
  97918. * @param uniformsNames defines the list of uniform names
  97919. * @returns an array of webGL uniform locations
  97920. */
  97921. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  97922. /**
  97923. * Gets the lsit of active attributes for a given webGL program
  97924. * @param pipelineContext defines the pipeline context to use
  97925. * @param attributesNames defines the list of attribute names to get
  97926. * @returns an array of indices indicating the offset of each attribute
  97927. */
  97928. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  97929. /**
  97930. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  97931. * @param effect defines the effect to activate
  97932. */
  97933. enableEffect(effect: Nullable<Effect>): void;
  97934. /**
  97935. * Set the value of an uniform to a number (int)
  97936. * @param uniform defines the webGL uniform location where to store the value
  97937. * @param value defines the int number to store
  97938. */
  97939. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97940. /**
  97941. * Set the value of an uniform to an array of int32
  97942. * @param uniform defines the webGL uniform location where to store the value
  97943. * @param array defines the array of int32 to store
  97944. */
  97945. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97946. /**
  97947. * Set the value of an uniform to an array of int32 (stored as vec2)
  97948. * @param uniform defines the webGL uniform location where to store the value
  97949. * @param array defines the array of int32 to store
  97950. */
  97951. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97952. /**
  97953. * Set the value of an uniform to an array of int32 (stored as vec3)
  97954. * @param uniform defines the webGL uniform location where to store the value
  97955. * @param array defines the array of int32 to store
  97956. */
  97957. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97958. /**
  97959. * Set the value of an uniform to an array of int32 (stored as vec4)
  97960. * @param uniform defines the webGL uniform location where to store the value
  97961. * @param array defines the array of int32 to store
  97962. */
  97963. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97964. /**
  97965. * Set the value of an uniform to an array of number
  97966. * @param uniform defines the webGL uniform location where to store the value
  97967. * @param array defines the array of number to store
  97968. */
  97969. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97970. /**
  97971. * Set the value of an uniform to an array of number (stored as vec2)
  97972. * @param uniform defines the webGL uniform location where to store the value
  97973. * @param array defines the array of number to store
  97974. */
  97975. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97976. /**
  97977. * Set the value of an uniform to an array of number (stored as vec3)
  97978. * @param uniform defines the webGL uniform location where to store the value
  97979. * @param array defines the array of number to store
  97980. */
  97981. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97982. /**
  97983. * Set the value of an uniform to an array of number (stored as vec4)
  97984. * @param uniform defines the webGL uniform location where to store the value
  97985. * @param array defines the array of number to store
  97986. */
  97987. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97988. /**
  97989. * Set the value of an uniform to an array of float32 (stored as matrices)
  97990. * @param uniform defines the webGL uniform location where to store the value
  97991. * @param matrices defines the array of float32 to store
  97992. */
  97993. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  97994. /**
  97995. * Set the value of an uniform to a matrix (3x3)
  97996. * @param uniform defines the webGL uniform location where to store the value
  97997. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  97998. */
  97999. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  98000. /**
  98001. * Set the value of an uniform to a matrix (2x2)
  98002. * @param uniform defines the webGL uniform location where to store the value
  98003. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  98004. */
  98005. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  98006. /**
  98007. * Set the value of an uniform to a number (float)
  98008. * @param uniform defines the webGL uniform location where to store the value
  98009. * @param value defines the float number to store
  98010. */
  98011. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  98012. /**
  98013. * Set the value of an uniform to a vec2
  98014. * @param uniform defines the webGL uniform location where to store the value
  98015. * @param x defines the 1st component of the value
  98016. * @param y defines the 2nd component of the value
  98017. */
  98018. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  98019. /**
  98020. * Set the value of an uniform to a vec3
  98021. * @param uniform defines the webGL uniform location where to store the value
  98022. * @param x defines the 1st component of the value
  98023. * @param y defines the 2nd component of the value
  98024. * @param z defines the 3rd component of the value
  98025. */
  98026. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  98027. /**
  98028. * Set the value of an uniform to a vec4
  98029. * @param uniform defines the webGL uniform location where to store the value
  98030. * @param x defines the 1st component of the value
  98031. * @param y defines the 2nd component of the value
  98032. * @param z defines the 3rd component of the value
  98033. * @param w defines the 4th component of the value
  98034. */
  98035. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  98036. /**
  98037. * Gets the depth culling state manager
  98038. */
  98039. readonly depthCullingState: DepthCullingState;
  98040. /**
  98041. * Gets the alpha state manager
  98042. */
  98043. readonly alphaState: AlphaState;
  98044. /**
  98045. * Gets the stencil state manager
  98046. */
  98047. readonly stencilState: StencilState;
  98048. /**
  98049. * Clears the list of texture accessible through engine.
  98050. * This can help preventing texture load conflict due to name collision.
  98051. */
  98052. clearInternalTexturesCache(): void;
  98053. /**
  98054. * Force the entire cache to be cleared
  98055. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  98056. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  98057. */
  98058. wipeCaches(bruteForce?: boolean): void;
  98059. /** @hidden */
  98060. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  98061. min: number;
  98062. mag: number;
  98063. };
  98064. /** @hidden */
  98065. _createTexture(): WebGLTexture;
  98066. /**
  98067. * Usually called from Texture.ts.
  98068. * Passed information to create a WebGLTexture
  98069. * @param urlArg defines a value which contains one of the following:
  98070. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  98071. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  98072. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  98073. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  98074. * @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)
  98075. * @param scene needed for loading to the correct scene
  98076. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  98077. * @param onLoad optional callback to be called upon successful completion
  98078. * @param onError optional callback to be called upon failure
  98079. * @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
  98080. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  98081. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  98082. * @param forcedExtension defines the extension to use to pick the right loader
  98083. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  98084. * @param mimeType defines an optional mime type
  98085. * @returns a InternalTexture for assignment back into BABYLON.Texture
  98086. */
  98087. 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;
  98088. /**
  98089. * @hidden
  98090. */
  98091. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98092. /**
  98093. * Creates a raw texture
  98094. * @param data defines the data to store in the texture
  98095. * @param width defines the width of the texture
  98096. * @param height defines the height of the texture
  98097. * @param format defines the format of the data
  98098. * @param generateMipMaps defines if the engine should generate the mip levels
  98099. * @param invertY defines if data must be stored with Y axis inverted
  98100. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  98101. * @param compression defines the compression used (null by default)
  98102. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  98103. * @returns the raw texture inside an InternalTexture
  98104. */
  98105. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  98106. /**
  98107. * Creates a new raw cube texture
  98108. * @param data defines the array of data to use to create each face
  98109. * @param size defines the size of the textures
  98110. * @param format defines the format of the data
  98111. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  98112. * @param generateMipMaps defines if the engine should generate the mip levels
  98113. * @param invertY defines if data must be stored with Y axis inverted
  98114. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98115. * @param compression defines the compression used (null by default)
  98116. * @returns the cube texture as an InternalTexture
  98117. */
  98118. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  98119. /**
  98120. * Creates a new raw 3D texture
  98121. * @param data defines the data used to create the texture
  98122. * @param width defines the width of the texture
  98123. * @param height defines the height of the texture
  98124. * @param depth defines the depth of the texture
  98125. * @param format defines the format of the texture
  98126. * @param generateMipMaps defines if the engine must generate mip levels
  98127. * @param invertY defines if data must be stored with Y axis inverted
  98128. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98129. * @param compression defines the compressed used (can be null)
  98130. * @param textureType defines the compressed used (can be null)
  98131. * @returns a new raw 3D texture (stored in an InternalTexture)
  98132. */
  98133. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98134. /**
  98135. * Creates a new raw 2D array texture
  98136. * @param data defines the data used to create the texture
  98137. * @param width defines the width of the texture
  98138. * @param height defines the height of the texture
  98139. * @param depth defines the number of layers of the texture
  98140. * @param format defines the format of the texture
  98141. * @param generateMipMaps defines if the engine must generate mip levels
  98142. * @param invertY defines if data must be stored with Y axis inverted
  98143. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98144. * @param compression defines the compressed used (can be null)
  98145. * @param textureType defines the compressed used (can be null)
  98146. * @returns a new raw 2D array texture (stored in an InternalTexture)
  98147. */
  98148. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98149. private _unpackFlipYCached;
  98150. /**
  98151. * In case you are sharing the context with other applications, it might
  98152. * be interested to not cache the unpack flip y state to ensure a consistent
  98153. * value would be set.
  98154. */
  98155. enableUnpackFlipYCached: boolean;
  98156. /** @hidden */
  98157. _unpackFlipY(value: boolean): void;
  98158. /** @hidden */
  98159. _getUnpackAlignement(): number;
  98160. /**
  98161. * Update the sampling mode of a given texture
  98162. * @param samplingMode defines the required sampling mode
  98163. * @param texture defines the texture to update
  98164. */
  98165. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  98166. /** @hidden */
  98167. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  98168. width: number;
  98169. height: number;
  98170. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  98171. /** @hidden */
  98172. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98173. /** @hidden */
  98174. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  98175. /** @hidden */
  98176. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98177. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  98178. private _prepareWebGLTexture;
  98179. /** @hidden */
  98180. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  98181. /** @hidden */
  98182. _releaseFramebufferObjects(texture: InternalTexture): void;
  98183. /** @hidden */
  98184. _releaseTexture(texture: InternalTexture): void;
  98185. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  98186. protected _setProgram(program: WebGLProgram): void;
  98187. protected _boundUniforms: {
  98188. [key: number]: WebGLUniformLocation;
  98189. };
  98190. /**
  98191. * Binds an effect to the webGL context
  98192. * @param effect defines the effect to bind
  98193. */
  98194. bindSamplers(effect: Effect): void;
  98195. private _activateCurrentTexture;
  98196. /** @hidden */
  98197. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  98198. /** @hidden */
  98199. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  98200. /**
  98201. * Unbind all textures from the webGL context
  98202. */
  98203. unbindAllTextures(): void;
  98204. /**
  98205. * Sets a texture to the according uniform.
  98206. * @param channel The texture channel
  98207. * @param uniform The uniform to set
  98208. * @param texture The texture to apply
  98209. */
  98210. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  98211. private _bindSamplerUniformToChannel;
  98212. private _getTextureWrapMode;
  98213. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  98214. /**
  98215. * Sets an array of texture to the webGL context
  98216. * @param channel defines the channel where the texture array must be set
  98217. * @param uniform defines the associated uniform location
  98218. * @param textures defines the array of textures to bind
  98219. */
  98220. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  98221. /** @hidden */
  98222. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  98223. private _setTextureParameterFloat;
  98224. private _setTextureParameterInteger;
  98225. /**
  98226. * Unbind all vertex attributes from the webGL context
  98227. */
  98228. unbindAllAttributes(): void;
  98229. /**
  98230. * 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
  98231. */
  98232. releaseEffects(): void;
  98233. /**
  98234. * Dispose and release all associated resources
  98235. */
  98236. dispose(): void;
  98237. /**
  98238. * Attach a new callback raised when context lost event is fired
  98239. * @param callback defines the callback to call
  98240. */
  98241. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  98242. /**
  98243. * Attach a new callback raised when context restored event is fired
  98244. * @param callback defines the callback to call
  98245. */
  98246. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  98247. /**
  98248. * Get the current error code of the webGL context
  98249. * @returns the error code
  98250. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  98251. */
  98252. getError(): number;
  98253. private _canRenderToFloatFramebuffer;
  98254. private _canRenderToHalfFloatFramebuffer;
  98255. private _canRenderToFramebuffer;
  98256. /** @hidden */
  98257. _getWebGLTextureType(type: number): number;
  98258. /** @hidden */
  98259. _getInternalFormat(format: number): number;
  98260. /** @hidden */
  98261. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  98262. /** @hidden */
  98263. _getRGBAMultiSampleBufferFormat(type: number): number;
  98264. /** @hidden */
  98265. _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;
  98266. /**
  98267. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  98268. * @returns true if the engine can be created
  98269. * @ignorenaming
  98270. */
  98271. static isSupported(): boolean;
  98272. /**
  98273. * Find the next highest power of two.
  98274. * @param x Number to start search from.
  98275. * @return Next highest power of two.
  98276. */
  98277. static CeilingPOT(x: number): number;
  98278. /**
  98279. * Find the next lowest power of two.
  98280. * @param x Number to start search from.
  98281. * @return Next lowest power of two.
  98282. */
  98283. static FloorPOT(x: number): number;
  98284. /**
  98285. * Find the nearest power of two.
  98286. * @param x Number to start search from.
  98287. * @return Next nearest power of two.
  98288. */
  98289. static NearestPOT(x: number): number;
  98290. /**
  98291. * Get the closest exponent of two
  98292. * @param value defines the value to approximate
  98293. * @param max defines the maximum value to return
  98294. * @param mode defines how to define the closest value
  98295. * @returns closest exponent of two of the given value
  98296. */
  98297. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  98298. /**
  98299. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  98300. * @param func - the function to be called
  98301. * @param requester - the object that will request the next frame. Falls back to window.
  98302. * @returns frame number
  98303. */
  98304. static QueueNewFrame(func: () => void, requester?: any): number;
  98305. }
  98306. }
  98307. declare module BABYLON {
  98308. /**
  98309. * Class representing spherical harmonics coefficients to the 3rd degree
  98310. */
  98311. export class SphericalHarmonics {
  98312. /**
  98313. * Defines whether or not the harmonics have been prescaled for rendering.
  98314. */
  98315. preScaled: boolean;
  98316. /**
  98317. * The l0,0 coefficients of the spherical harmonics
  98318. */
  98319. l00: Vector3;
  98320. /**
  98321. * The l1,-1 coefficients of the spherical harmonics
  98322. */
  98323. l1_1: Vector3;
  98324. /**
  98325. * The l1,0 coefficients of the spherical harmonics
  98326. */
  98327. l10: Vector3;
  98328. /**
  98329. * The l1,1 coefficients of the spherical harmonics
  98330. */
  98331. l11: Vector3;
  98332. /**
  98333. * The l2,-2 coefficients of the spherical harmonics
  98334. */
  98335. l2_2: Vector3;
  98336. /**
  98337. * The l2,-1 coefficients of the spherical harmonics
  98338. */
  98339. l2_1: Vector3;
  98340. /**
  98341. * The l2,0 coefficients of the spherical harmonics
  98342. */
  98343. l20: Vector3;
  98344. /**
  98345. * The l2,1 coefficients of the spherical harmonics
  98346. */
  98347. l21: Vector3;
  98348. /**
  98349. * The l2,2 coefficients of the spherical harmonics
  98350. */
  98351. l22: Vector3;
  98352. /**
  98353. * Adds a light to the spherical harmonics
  98354. * @param direction the direction of the light
  98355. * @param color the color of the light
  98356. * @param deltaSolidAngle the delta solid angle of the light
  98357. */
  98358. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  98359. /**
  98360. * Scales the spherical harmonics by the given amount
  98361. * @param scale the amount to scale
  98362. */
  98363. scaleInPlace(scale: number): void;
  98364. /**
  98365. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  98366. *
  98367. * ```
  98368. * E_lm = A_l * L_lm
  98369. * ```
  98370. *
  98371. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  98372. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  98373. * the scaling factors are given in equation 9.
  98374. */
  98375. convertIncidentRadianceToIrradiance(): void;
  98376. /**
  98377. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  98378. *
  98379. * ```
  98380. * L = (1/pi) * E * rho
  98381. * ```
  98382. *
  98383. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  98384. */
  98385. convertIrradianceToLambertianRadiance(): void;
  98386. /**
  98387. * Integrates the reconstruction coefficients directly in to the SH preventing further
  98388. * required operations at run time.
  98389. *
  98390. * This is simply done by scaling back the SH with Ylm constants parameter.
  98391. * The trigonometric part being applied by the shader at run time.
  98392. */
  98393. preScaleForRendering(): void;
  98394. /**
  98395. * Constructs a spherical harmonics from an array.
  98396. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  98397. * @returns the spherical harmonics
  98398. */
  98399. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  98400. /**
  98401. * Gets the spherical harmonics from polynomial
  98402. * @param polynomial the spherical polynomial
  98403. * @returns the spherical harmonics
  98404. */
  98405. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  98406. }
  98407. /**
  98408. * Class representing spherical polynomial coefficients to the 3rd degree
  98409. */
  98410. export class SphericalPolynomial {
  98411. private _harmonics;
  98412. /**
  98413. * The spherical harmonics used to create the polynomials.
  98414. */
  98415. readonly preScaledHarmonics: SphericalHarmonics;
  98416. /**
  98417. * The x coefficients of the spherical polynomial
  98418. */
  98419. x: Vector3;
  98420. /**
  98421. * The y coefficients of the spherical polynomial
  98422. */
  98423. y: Vector3;
  98424. /**
  98425. * The z coefficients of the spherical polynomial
  98426. */
  98427. z: Vector3;
  98428. /**
  98429. * The xx coefficients of the spherical polynomial
  98430. */
  98431. xx: Vector3;
  98432. /**
  98433. * The yy coefficients of the spherical polynomial
  98434. */
  98435. yy: Vector3;
  98436. /**
  98437. * The zz coefficients of the spherical polynomial
  98438. */
  98439. zz: Vector3;
  98440. /**
  98441. * The xy coefficients of the spherical polynomial
  98442. */
  98443. xy: Vector3;
  98444. /**
  98445. * The yz coefficients of the spherical polynomial
  98446. */
  98447. yz: Vector3;
  98448. /**
  98449. * The zx coefficients of the spherical polynomial
  98450. */
  98451. zx: Vector3;
  98452. /**
  98453. * Adds an ambient color to the spherical polynomial
  98454. * @param color the color to add
  98455. */
  98456. addAmbient(color: Color3): void;
  98457. /**
  98458. * Scales the spherical polynomial by the given amount
  98459. * @param scale the amount to scale
  98460. */
  98461. scaleInPlace(scale: number): void;
  98462. /**
  98463. * Gets the spherical polynomial from harmonics
  98464. * @param harmonics the spherical harmonics
  98465. * @returns the spherical polynomial
  98466. */
  98467. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  98468. /**
  98469. * Constructs a spherical polynomial from an array.
  98470. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  98471. * @returns the spherical polynomial
  98472. */
  98473. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  98474. }
  98475. }
  98476. declare module BABYLON {
  98477. /**
  98478. * Defines the source of the internal texture
  98479. */
  98480. export enum InternalTextureSource {
  98481. /**
  98482. * The source of the texture data is unknown
  98483. */
  98484. Unknown = 0,
  98485. /**
  98486. * Texture data comes from an URL
  98487. */
  98488. Url = 1,
  98489. /**
  98490. * Texture data is only used for temporary storage
  98491. */
  98492. Temp = 2,
  98493. /**
  98494. * Texture data comes from raw data (ArrayBuffer)
  98495. */
  98496. Raw = 3,
  98497. /**
  98498. * Texture content is dynamic (video or dynamic texture)
  98499. */
  98500. Dynamic = 4,
  98501. /**
  98502. * Texture content is generated by rendering to it
  98503. */
  98504. RenderTarget = 5,
  98505. /**
  98506. * Texture content is part of a multi render target process
  98507. */
  98508. MultiRenderTarget = 6,
  98509. /**
  98510. * Texture data comes from a cube data file
  98511. */
  98512. Cube = 7,
  98513. /**
  98514. * Texture data comes from a raw cube data
  98515. */
  98516. CubeRaw = 8,
  98517. /**
  98518. * Texture data come from a prefiltered cube data file
  98519. */
  98520. CubePrefiltered = 9,
  98521. /**
  98522. * Texture content is raw 3D data
  98523. */
  98524. Raw3D = 10,
  98525. /**
  98526. * Texture content is raw 2D array data
  98527. */
  98528. Raw2DArray = 11,
  98529. /**
  98530. * Texture content is a depth texture
  98531. */
  98532. Depth = 12,
  98533. /**
  98534. * Texture data comes from a raw cube data encoded with RGBD
  98535. */
  98536. CubeRawRGBD = 13
  98537. }
  98538. /**
  98539. * Class used to store data associated with WebGL texture data for the engine
  98540. * This class should not be used directly
  98541. */
  98542. export class InternalTexture {
  98543. /** @hidden */
  98544. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  98545. /**
  98546. * Defines if the texture is ready
  98547. */
  98548. isReady: boolean;
  98549. /**
  98550. * Defines if the texture is a cube texture
  98551. */
  98552. isCube: boolean;
  98553. /**
  98554. * Defines if the texture contains 3D data
  98555. */
  98556. is3D: boolean;
  98557. /**
  98558. * Defines if the texture contains 2D array data
  98559. */
  98560. is2DArray: boolean;
  98561. /**
  98562. * Defines if the texture contains multiview data
  98563. */
  98564. isMultiview: boolean;
  98565. /**
  98566. * Gets the URL used to load this texture
  98567. */
  98568. url: string;
  98569. /**
  98570. * Gets the sampling mode of the texture
  98571. */
  98572. samplingMode: number;
  98573. /**
  98574. * Gets a boolean indicating if the texture needs mipmaps generation
  98575. */
  98576. generateMipMaps: boolean;
  98577. /**
  98578. * Gets the number of samples used by the texture (WebGL2+ only)
  98579. */
  98580. samples: number;
  98581. /**
  98582. * Gets the type of the texture (int, float...)
  98583. */
  98584. type: number;
  98585. /**
  98586. * Gets the format of the texture (RGB, RGBA...)
  98587. */
  98588. format: number;
  98589. /**
  98590. * Observable called when the texture is loaded
  98591. */
  98592. onLoadedObservable: Observable<InternalTexture>;
  98593. /**
  98594. * Gets the width of the texture
  98595. */
  98596. width: number;
  98597. /**
  98598. * Gets the height of the texture
  98599. */
  98600. height: number;
  98601. /**
  98602. * Gets the depth of the texture
  98603. */
  98604. depth: number;
  98605. /**
  98606. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  98607. */
  98608. baseWidth: number;
  98609. /**
  98610. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  98611. */
  98612. baseHeight: number;
  98613. /**
  98614. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  98615. */
  98616. baseDepth: number;
  98617. /**
  98618. * Gets a boolean indicating if the texture is inverted on Y axis
  98619. */
  98620. invertY: boolean;
  98621. /** @hidden */
  98622. _invertVScale: boolean;
  98623. /** @hidden */
  98624. _associatedChannel: number;
  98625. /** @hidden */
  98626. _source: InternalTextureSource;
  98627. /** @hidden */
  98628. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  98629. /** @hidden */
  98630. _bufferView: Nullable<ArrayBufferView>;
  98631. /** @hidden */
  98632. _bufferViewArray: Nullable<ArrayBufferView[]>;
  98633. /** @hidden */
  98634. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  98635. /** @hidden */
  98636. _size: number;
  98637. /** @hidden */
  98638. _extension: string;
  98639. /** @hidden */
  98640. _files: Nullable<string[]>;
  98641. /** @hidden */
  98642. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  98643. /** @hidden */
  98644. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  98645. /** @hidden */
  98646. _framebuffer: Nullable<WebGLFramebuffer>;
  98647. /** @hidden */
  98648. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  98649. /** @hidden */
  98650. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  98651. /** @hidden */
  98652. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  98653. /** @hidden */
  98654. _attachments: Nullable<number[]>;
  98655. /** @hidden */
  98656. _cachedCoordinatesMode: Nullable<number>;
  98657. /** @hidden */
  98658. _cachedWrapU: Nullable<number>;
  98659. /** @hidden */
  98660. _cachedWrapV: Nullable<number>;
  98661. /** @hidden */
  98662. _cachedWrapR: Nullable<number>;
  98663. /** @hidden */
  98664. _cachedAnisotropicFilteringLevel: Nullable<number>;
  98665. /** @hidden */
  98666. _isDisabled: boolean;
  98667. /** @hidden */
  98668. _compression: Nullable<string>;
  98669. /** @hidden */
  98670. _generateStencilBuffer: boolean;
  98671. /** @hidden */
  98672. _generateDepthBuffer: boolean;
  98673. /** @hidden */
  98674. _comparisonFunction: number;
  98675. /** @hidden */
  98676. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  98677. /** @hidden */
  98678. _lodGenerationScale: number;
  98679. /** @hidden */
  98680. _lodGenerationOffset: number;
  98681. /** @hidden */
  98682. _colorTextureArray: Nullable<WebGLTexture>;
  98683. /** @hidden */
  98684. _depthStencilTextureArray: Nullable<WebGLTexture>;
  98685. /** @hidden */
  98686. _lodTextureHigh: Nullable<BaseTexture>;
  98687. /** @hidden */
  98688. _lodTextureMid: Nullable<BaseTexture>;
  98689. /** @hidden */
  98690. _lodTextureLow: Nullable<BaseTexture>;
  98691. /** @hidden */
  98692. _isRGBD: boolean;
  98693. /** @hidden */
  98694. _linearSpecularLOD: boolean;
  98695. /** @hidden */
  98696. _irradianceTexture: Nullable<BaseTexture>;
  98697. /** @hidden */
  98698. _webGLTexture: Nullable<WebGLTexture>;
  98699. /** @hidden */
  98700. _references: number;
  98701. private _engine;
  98702. /**
  98703. * Gets the Engine the texture belongs to.
  98704. * @returns The babylon engine
  98705. */
  98706. getEngine(): ThinEngine;
  98707. /**
  98708. * Gets the data source type of the texture
  98709. */
  98710. readonly source: InternalTextureSource;
  98711. /**
  98712. * Creates a new InternalTexture
  98713. * @param engine defines the engine to use
  98714. * @param source defines the type of data that will be used
  98715. * @param delayAllocation if the texture allocation should be delayed (default: false)
  98716. */
  98717. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  98718. /**
  98719. * Increments the number of references (ie. the number of Texture that point to it)
  98720. */
  98721. incrementReferences(): void;
  98722. /**
  98723. * Change the size of the texture (not the size of the content)
  98724. * @param width defines the new width
  98725. * @param height defines the new height
  98726. * @param depth defines the new depth (1 by default)
  98727. */
  98728. updateSize(width: int, height: int, depth?: int): void;
  98729. /** @hidden */
  98730. _rebuild(): void;
  98731. /** @hidden */
  98732. _swapAndDie(target: InternalTexture): void;
  98733. /**
  98734. * Dispose the current allocated resources
  98735. */
  98736. dispose(): void;
  98737. }
  98738. }
  98739. declare module BABYLON {
  98740. /**
  98741. * Class used to work with sound analyzer using fast fourier transform (FFT)
  98742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98743. */
  98744. export class Analyser {
  98745. /**
  98746. * Gets or sets the smoothing
  98747. * @ignorenaming
  98748. */
  98749. SMOOTHING: number;
  98750. /**
  98751. * Gets or sets the FFT table size
  98752. * @ignorenaming
  98753. */
  98754. FFT_SIZE: number;
  98755. /**
  98756. * Gets or sets the bar graph amplitude
  98757. * @ignorenaming
  98758. */
  98759. BARGRAPHAMPLITUDE: number;
  98760. /**
  98761. * Gets or sets the position of the debug canvas
  98762. * @ignorenaming
  98763. */
  98764. DEBUGCANVASPOS: {
  98765. x: number;
  98766. y: number;
  98767. };
  98768. /**
  98769. * Gets or sets the debug canvas size
  98770. * @ignorenaming
  98771. */
  98772. DEBUGCANVASSIZE: {
  98773. width: number;
  98774. height: number;
  98775. };
  98776. private _byteFreqs;
  98777. private _byteTime;
  98778. private _floatFreqs;
  98779. private _webAudioAnalyser;
  98780. private _debugCanvas;
  98781. private _debugCanvasContext;
  98782. private _scene;
  98783. private _registerFunc;
  98784. private _audioEngine;
  98785. /**
  98786. * Creates a new analyser
  98787. * @param scene defines hosting scene
  98788. */
  98789. constructor(scene: Scene);
  98790. /**
  98791. * Get the number of data values you will have to play with for the visualization
  98792. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  98793. * @returns a number
  98794. */
  98795. getFrequencyBinCount(): number;
  98796. /**
  98797. * Gets the current frequency data as a byte array
  98798. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  98799. * @returns a Uint8Array
  98800. */
  98801. getByteFrequencyData(): Uint8Array;
  98802. /**
  98803. * Gets the current waveform as a byte array
  98804. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  98805. * @returns a Uint8Array
  98806. */
  98807. getByteTimeDomainData(): Uint8Array;
  98808. /**
  98809. * Gets the current frequency data as a float array
  98810. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  98811. * @returns a Float32Array
  98812. */
  98813. getFloatFrequencyData(): Float32Array;
  98814. /**
  98815. * Renders the debug canvas
  98816. */
  98817. drawDebugCanvas(): void;
  98818. /**
  98819. * Stops rendering the debug canvas and removes it
  98820. */
  98821. stopDebugCanvas(): void;
  98822. /**
  98823. * Connects two audio nodes
  98824. * @param inputAudioNode defines first node to connect
  98825. * @param outputAudioNode defines second node to connect
  98826. */
  98827. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  98828. /**
  98829. * Releases all associated resources
  98830. */
  98831. dispose(): void;
  98832. }
  98833. }
  98834. declare module BABYLON {
  98835. /**
  98836. * This represents an audio engine and it is responsible
  98837. * to play, synchronize and analyse sounds throughout the application.
  98838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98839. */
  98840. export interface IAudioEngine extends IDisposable {
  98841. /**
  98842. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  98843. */
  98844. readonly canUseWebAudio: boolean;
  98845. /**
  98846. * Gets the current AudioContext if available.
  98847. */
  98848. readonly audioContext: Nullable<AudioContext>;
  98849. /**
  98850. * The master gain node defines the global audio volume of your audio engine.
  98851. */
  98852. readonly masterGain: GainNode;
  98853. /**
  98854. * Gets whether or not mp3 are supported by your browser.
  98855. */
  98856. readonly isMP3supported: boolean;
  98857. /**
  98858. * Gets whether or not ogg are supported by your browser.
  98859. */
  98860. readonly isOGGsupported: boolean;
  98861. /**
  98862. * Defines if Babylon should emit a warning if WebAudio is not supported.
  98863. * @ignoreNaming
  98864. */
  98865. WarnedWebAudioUnsupported: boolean;
  98866. /**
  98867. * Defines if the audio engine relies on a custom unlocked button.
  98868. * In this case, the embedded button will not be displayed.
  98869. */
  98870. useCustomUnlockedButton: boolean;
  98871. /**
  98872. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  98873. */
  98874. readonly unlocked: boolean;
  98875. /**
  98876. * Event raised when audio has been unlocked on the browser.
  98877. */
  98878. onAudioUnlockedObservable: Observable<AudioEngine>;
  98879. /**
  98880. * Event raised when audio has been locked on the browser.
  98881. */
  98882. onAudioLockedObservable: Observable<AudioEngine>;
  98883. /**
  98884. * Flags the audio engine in Locked state.
  98885. * This happens due to new browser policies preventing audio to autoplay.
  98886. */
  98887. lock(): void;
  98888. /**
  98889. * Unlocks the audio engine once a user action has been done on the dom.
  98890. * This is helpful to resume play once browser policies have been satisfied.
  98891. */
  98892. unlock(): void;
  98893. }
  98894. /**
  98895. * This represents the default audio engine used in babylon.
  98896. * It is responsible to play, synchronize and analyse sounds throughout the application.
  98897. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98898. */
  98899. export class AudioEngine implements IAudioEngine {
  98900. private _audioContext;
  98901. private _audioContextInitialized;
  98902. private _muteButton;
  98903. private _hostElement;
  98904. /**
  98905. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  98906. */
  98907. canUseWebAudio: boolean;
  98908. /**
  98909. * The master gain node defines the global audio volume of your audio engine.
  98910. */
  98911. masterGain: GainNode;
  98912. /**
  98913. * Defines if Babylon should emit a warning if WebAudio is not supported.
  98914. * @ignoreNaming
  98915. */
  98916. WarnedWebAudioUnsupported: boolean;
  98917. /**
  98918. * Gets whether or not mp3 are supported by your browser.
  98919. */
  98920. isMP3supported: boolean;
  98921. /**
  98922. * Gets whether or not ogg are supported by your browser.
  98923. */
  98924. isOGGsupported: boolean;
  98925. /**
  98926. * Gets whether audio has been unlocked on the device.
  98927. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  98928. * a user interaction has happened.
  98929. */
  98930. unlocked: boolean;
  98931. /**
  98932. * Defines if the audio engine relies on a custom unlocked button.
  98933. * In this case, the embedded button will not be displayed.
  98934. */
  98935. useCustomUnlockedButton: boolean;
  98936. /**
  98937. * Event raised when audio has been unlocked on the browser.
  98938. */
  98939. onAudioUnlockedObservable: Observable<AudioEngine>;
  98940. /**
  98941. * Event raised when audio has been locked on the browser.
  98942. */
  98943. onAudioLockedObservable: Observable<AudioEngine>;
  98944. /**
  98945. * Gets the current AudioContext if available.
  98946. */
  98947. readonly audioContext: Nullable<AudioContext>;
  98948. private _connectedAnalyser;
  98949. /**
  98950. * Instantiates a new audio engine.
  98951. *
  98952. * There should be only one per page as some browsers restrict the number
  98953. * of audio contexts you can create.
  98954. * @param hostElement defines the host element where to display the mute icon if necessary
  98955. */
  98956. constructor(hostElement?: Nullable<HTMLElement>);
  98957. /**
  98958. * Flags the audio engine in Locked state.
  98959. * This happens due to new browser policies preventing audio to autoplay.
  98960. */
  98961. lock(): void;
  98962. /**
  98963. * Unlocks the audio engine once a user action has been done on the dom.
  98964. * This is helpful to resume play once browser policies have been satisfied.
  98965. */
  98966. unlock(): void;
  98967. private _resumeAudioContext;
  98968. private _initializeAudioContext;
  98969. private _tryToRun;
  98970. private _triggerRunningState;
  98971. private _triggerSuspendedState;
  98972. private _displayMuteButton;
  98973. private _moveButtonToTopLeft;
  98974. private _onResize;
  98975. private _hideMuteButton;
  98976. /**
  98977. * Destroy and release the resources associated with the audio ccontext.
  98978. */
  98979. dispose(): void;
  98980. /**
  98981. * Gets the global volume sets on the master gain.
  98982. * @returns the global volume if set or -1 otherwise
  98983. */
  98984. getGlobalVolume(): number;
  98985. /**
  98986. * Sets the global volume of your experience (sets on the master gain).
  98987. * @param newVolume Defines the new global volume of the application
  98988. */
  98989. setGlobalVolume(newVolume: number): void;
  98990. /**
  98991. * Connect the audio engine to an audio analyser allowing some amazing
  98992. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  98993. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  98994. * @param analyser The analyser to connect to the engine
  98995. */
  98996. connectToAnalyser(analyser: Analyser): void;
  98997. }
  98998. }
  98999. declare module BABYLON {
  99000. /**
  99001. * Interface used to present a loading screen while loading a scene
  99002. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99003. */
  99004. export interface ILoadingScreen {
  99005. /**
  99006. * Function called to display the loading screen
  99007. */
  99008. displayLoadingUI: () => void;
  99009. /**
  99010. * Function called to hide the loading screen
  99011. */
  99012. hideLoadingUI: () => void;
  99013. /**
  99014. * Gets or sets the color to use for the background
  99015. */
  99016. loadingUIBackgroundColor: string;
  99017. /**
  99018. * Gets or sets the text to display while loading
  99019. */
  99020. loadingUIText: string;
  99021. }
  99022. /**
  99023. * Class used for the default loading screen
  99024. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99025. */
  99026. export class DefaultLoadingScreen implements ILoadingScreen {
  99027. private _renderingCanvas;
  99028. private _loadingText;
  99029. private _loadingDivBackgroundColor;
  99030. private _loadingDiv;
  99031. private _loadingTextDiv;
  99032. /** Gets or sets the logo url to use for the default loading screen */
  99033. static DefaultLogoUrl: string;
  99034. /** Gets or sets the spinner url to use for the default loading screen */
  99035. static DefaultSpinnerUrl: string;
  99036. /**
  99037. * Creates a new default loading screen
  99038. * @param _renderingCanvas defines the canvas used to render the scene
  99039. * @param _loadingText defines the default text to display
  99040. * @param _loadingDivBackgroundColor defines the default background color
  99041. */
  99042. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  99043. /**
  99044. * Function called to display the loading screen
  99045. */
  99046. displayLoadingUI(): void;
  99047. /**
  99048. * Function called to hide the loading screen
  99049. */
  99050. hideLoadingUI(): void;
  99051. /**
  99052. * Gets or sets the text to display while loading
  99053. */
  99054. loadingUIText: string;
  99055. /**
  99056. * Gets or sets the color to use for the background
  99057. */
  99058. loadingUIBackgroundColor: string;
  99059. private _resizeLoadingUI;
  99060. }
  99061. }
  99062. declare module BABYLON {
  99063. /**
  99064. * Interface for any object that can request an animation frame
  99065. */
  99066. export interface ICustomAnimationFrameRequester {
  99067. /**
  99068. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  99069. */
  99070. renderFunction?: Function;
  99071. /**
  99072. * Called to request the next frame to render to
  99073. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  99074. */
  99075. requestAnimationFrame: Function;
  99076. /**
  99077. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  99078. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  99079. */
  99080. requestID?: number;
  99081. }
  99082. }
  99083. declare module BABYLON {
  99084. /**
  99085. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  99086. */
  99087. export class PerformanceMonitor {
  99088. private _enabled;
  99089. private _rollingFrameTime;
  99090. private _lastFrameTimeMs;
  99091. /**
  99092. * constructor
  99093. * @param frameSampleSize The number of samples required to saturate the sliding window
  99094. */
  99095. constructor(frameSampleSize?: number);
  99096. /**
  99097. * Samples current frame
  99098. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  99099. */
  99100. sampleFrame(timeMs?: number): void;
  99101. /**
  99102. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99103. */
  99104. readonly averageFrameTime: number;
  99105. /**
  99106. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99107. */
  99108. readonly averageFrameTimeVariance: number;
  99109. /**
  99110. * Returns the frame time of the most recent frame
  99111. */
  99112. readonly instantaneousFrameTime: number;
  99113. /**
  99114. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  99115. */
  99116. readonly averageFPS: number;
  99117. /**
  99118. * Returns the average framerate in frames per second using the most recent frame time
  99119. */
  99120. readonly instantaneousFPS: number;
  99121. /**
  99122. * Returns true if enough samples have been taken to completely fill the sliding window
  99123. */
  99124. readonly isSaturated: boolean;
  99125. /**
  99126. * Enables contributions to the sliding window sample set
  99127. */
  99128. enable(): void;
  99129. /**
  99130. * Disables contributions to the sliding window sample set
  99131. * Samples will not be interpolated over the disabled period
  99132. */
  99133. disable(): void;
  99134. /**
  99135. * Returns true if sampling is enabled
  99136. */
  99137. readonly isEnabled: boolean;
  99138. /**
  99139. * Resets performance monitor
  99140. */
  99141. reset(): void;
  99142. }
  99143. /**
  99144. * RollingAverage
  99145. *
  99146. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  99147. */
  99148. export class RollingAverage {
  99149. /**
  99150. * Current average
  99151. */
  99152. average: number;
  99153. /**
  99154. * Current variance
  99155. */
  99156. variance: number;
  99157. protected _samples: Array<number>;
  99158. protected _sampleCount: number;
  99159. protected _pos: number;
  99160. protected _m2: number;
  99161. /**
  99162. * constructor
  99163. * @param length The number of samples required to saturate the sliding window
  99164. */
  99165. constructor(length: number);
  99166. /**
  99167. * Adds a sample to the sample set
  99168. * @param v The sample value
  99169. */
  99170. add(v: number): void;
  99171. /**
  99172. * Returns previously added values or null if outside of history or outside the sliding window domain
  99173. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  99174. * @return Value previously recorded with add() or null if outside of range
  99175. */
  99176. history(i: number): number;
  99177. /**
  99178. * Returns true if enough samples have been taken to completely fill the sliding window
  99179. * @return true if sample-set saturated
  99180. */
  99181. isSaturated(): boolean;
  99182. /**
  99183. * Resets the rolling average (equivalent to 0 samples taken so far)
  99184. */
  99185. reset(): void;
  99186. /**
  99187. * Wraps a value around the sample range boundaries
  99188. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  99189. * @return Wrapped position in sample range
  99190. */
  99191. protected _wrapPosition(i: number): number;
  99192. }
  99193. }
  99194. declare module BABYLON {
  99195. /**
  99196. * This class is used to track a performance counter which is number based.
  99197. * The user has access to many properties which give statistics of different nature.
  99198. *
  99199. * The implementer can track two kinds of Performance Counter: time and count.
  99200. * 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.
  99201. * 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.
  99202. */
  99203. export class PerfCounter {
  99204. /**
  99205. * Gets or sets a global boolean to turn on and off all the counters
  99206. */
  99207. static Enabled: boolean;
  99208. /**
  99209. * Returns the smallest value ever
  99210. */
  99211. readonly min: number;
  99212. /**
  99213. * Returns the biggest value ever
  99214. */
  99215. readonly max: number;
  99216. /**
  99217. * Returns the average value since the performance counter is running
  99218. */
  99219. readonly average: number;
  99220. /**
  99221. * Returns the average value of the last second the counter was monitored
  99222. */
  99223. readonly lastSecAverage: number;
  99224. /**
  99225. * Returns the current value
  99226. */
  99227. readonly current: number;
  99228. /**
  99229. * Gets the accumulated total
  99230. */
  99231. readonly total: number;
  99232. /**
  99233. * Gets the total value count
  99234. */
  99235. readonly count: number;
  99236. /**
  99237. * Creates a new counter
  99238. */
  99239. constructor();
  99240. /**
  99241. * Call this method to start monitoring a new frame.
  99242. * 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.
  99243. */
  99244. fetchNewFrame(): void;
  99245. /**
  99246. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  99247. * @param newCount the count value to add to the monitored count
  99248. * @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.
  99249. */
  99250. addCount(newCount: number, fetchResult: boolean): void;
  99251. /**
  99252. * Start monitoring this performance counter
  99253. */
  99254. beginMonitoring(): void;
  99255. /**
  99256. * Compute the time lapsed since the previous beginMonitoring() call.
  99257. * @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
  99258. */
  99259. endMonitoring(newFrame?: boolean): void;
  99260. private _fetchResult;
  99261. private _startMonitoringTime;
  99262. private _min;
  99263. private _max;
  99264. private _average;
  99265. private _current;
  99266. private _totalValueCount;
  99267. private _totalAccumulated;
  99268. private _lastSecAverage;
  99269. private _lastSecAccumulated;
  99270. private _lastSecTime;
  99271. private _lastSecValueCount;
  99272. }
  99273. }
  99274. declare module BABYLON {
  99275. /**
  99276. * Defines the interface used by display changed events
  99277. */
  99278. export interface IDisplayChangedEventArgs {
  99279. /** Gets the vrDisplay object (if any) */
  99280. vrDisplay: Nullable<any>;
  99281. /** Gets a boolean indicating if webVR is supported */
  99282. vrSupported: boolean;
  99283. }
  99284. /**
  99285. * Defines the interface used by objects containing a viewport (like a camera)
  99286. */
  99287. interface IViewportOwnerLike {
  99288. /**
  99289. * Gets or sets the viewport
  99290. */
  99291. viewport: IViewportLike;
  99292. }
  99293. /**
  99294. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  99295. */
  99296. export class Engine extends ThinEngine {
  99297. /** Defines that alpha blending is disabled */
  99298. static readonly ALPHA_DISABLE: number;
  99299. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  99300. static readonly ALPHA_ADD: number;
  99301. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  99302. static readonly ALPHA_COMBINE: number;
  99303. /** Defines that alpha blending to DEST - SRC * DEST */
  99304. static readonly ALPHA_SUBTRACT: number;
  99305. /** Defines that alpha blending to SRC * DEST */
  99306. static readonly ALPHA_MULTIPLY: number;
  99307. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  99308. static readonly ALPHA_MAXIMIZED: number;
  99309. /** Defines that alpha blending to SRC + DEST */
  99310. static readonly ALPHA_ONEONE: number;
  99311. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  99312. static readonly ALPHA_PREMULTIPLIED: number;
  99313. /**
  99314. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  99315. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  99316. */
  99317. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  99318. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  99319. static readonly ALPHA_INTERPOLATE: number;
  99320. /**
  99321. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  99322. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  99323. */
  99324. static readonly ALPHA_SCREENMODE: number;
  99325. /** Defines that the ressource is not delayed*/
  99326. static readonly DELAYLOADSTATE_NONE: number;
  99327. /** Defines that the ressource was successfully delay loaded */
  99328. static readonly DELAYLOADSTATE_LOADED: number;
  99329. /** Defines that the ressource is currently delay loading */
  99330. static readonly DELAYLOADSTATE_LOADING: number;
  99331. /** Defines that the ressource is delayed and has not started loading */
  99332. static readonly DELAYLOADSTATE_NOTLOADED: number;
  99333. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  99334. static readonly NEVER: number;
  99335. /** 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 */
  99336. static readonly ALWAYS: number;
  99337. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  99338. static readonly LESS: number;
  99339. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  99340. static readonly EQUAL: number;
  99341. /** 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 */
  99342. static readonly LEQUAL: number;
  99343. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  99344. static readonly GREATER: number;
  99345. /** 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 */
  99346. static readonly GEQUAL: number;
  99347. /** 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 */
  99348. static readonly NOTEQUAL: number;
  99349. /** Passed to stencilOperation to specify that stencil value must be kept */
  99350. static readonly KEEP: number;
  99351. /** Passed to stencilOperation to specify that stencil value must be replaced */
  99352. static readonly REPLACE: number;
  99353. /** Passed to stencilOperation to specify that stencil value must be incremented */
  99354. static readonly INCR: number;
  99355. /** Passed to stencilOperation to specify that stencil value must be decremented */
  99356. static readonly DECR: number;
  99357. /** Passed to stencilOperation to specify that stencil value must be inverted */
  99358. static readonly INVERT: number;
  99359. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  99360. static readonly INCR_WRAP: number;
  99361. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  99362. static readonly DECR_WRAP: number;
  99363. /** Texture is not repeating outside of 0..1 UVs */
  99364. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  99365. /** Texture is repeating outside of 0..1 UVs */
  99366. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  99367. /** Texture is repeating and mirrored */
  99368. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  99369. /** ALPHA */
  99370. static readonly TEXTUREFORMAT_ALPHA: number;
  99371. /** LUMINANCE */
  99372. static readonly TEXTUREFORMAT_LUMINANCE: number;
  99373. /** LUMINANCE_ALPHA */
  99374. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  99375. /** RGB */
  99376. static readonly TEXTUREFORMAT_RGB: number;
  99377. /** RGBA */
  99378. static readonly TEXTUREFORMAT_RGBA: number;
  99379. /** RED */
  99380. static readonly TEXTUREFORMAT_RED: number;
  99381. /** RED (2nd reference) */
  99382. static readonly TEXTUREFORMAT_R: number;
  99383. /** RG */
  99384. static readonly TEXTUREFORMAT_RG: number;
  99385. /** RED_INTEGER */
  99386. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  99387. /** RED_INTEGER (2nd reference) */
  99388. static readonly TEXTUREFORMAT_R_INTEGER: number;
  99389. /** RG_INTEGER */
  99390. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  99391. /** RGB_INTEGER */
  99392. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  99393. /** RGBA_INTEGER */
  99394. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  99395. /** UNSIGNED_BYTE */
  99396. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  99397. /** UNSIGNED_BYTE (2nd reference) */
  99398. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  99399. /** FLOAT */
  99400. static readonly TEXTURETYPE_FLOAT: number;
  99401. /** HALF_FLOAT */
  99402. static readonly TEXTURETYPE_HALF_FLOAT: number;
  99403. /** BYTE */
  99404. static readonly TEXTURETYPE_BYTE: number;
  99405. /** SHORT */
  99406. static readonly TEXTURETYPE_SHORT: number;
  99407. /** UNSIGNED_SHORT */
  99408. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  99409. /** INT */
  99410. static readonly TEXTURETYPE_INT: number;
  99411. /** UNSIGNED_INT */
  99412. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  99413. /** UNSIGNED_SHORT_4_4_4_4 */
  99414. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  99415. /** UNSIGNED_SHORT_5_5_5_1 */
  99416. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  99417. /** UNSIGNED_SHORT_5_6_5 */
  99418. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  99419. /** UNSIGNED_INT_2_10_10_10_REV */
  99420. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  99421. /** UNSIGNED_INT_24_8 */
  99422. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  99423. /** UNSIGNED_INT_10F_11F_11F_REV */
  99424. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  99425. /** UNSIGNED_INT_5_9_9_9_REV */
  99426. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  99427. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  99428. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  99429. /** nearest is mag = nearest and min = nearest and mip = linear */
  99430. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  99431. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99432. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  99433. /** Trilinear is mag = linear and min = linear and mip = linear */
  99434. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  99435. /** nearest is mag = nearest and min = nearest and mip = linear */
  99436. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  99437. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99438. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  99439. /** Trilinear is mag = linear and min = linear and mip = linear */
  99440. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  99441. /** mag = nearest and min = nearest and mip = nearest */
  99442. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  99443. /** mag = nearest and min = linear and mip = nearest */
  99444. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  99445. /** mag = nearest and min = linear and mip = linear */
  99446. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  99447. /** mag = nearest and min = linear and mip = none */
  99448. static readonly TEXTURE_NEAREST_LINEAR: number;
  99449. /** mag = nearest and min = nearest and mip = none */
  99450. static readonly TEXTURE_NEAREST_NEAREST: number;
  99451. /** mag = linear and min = nearest and mip = nearest */
  99452. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  99453. /** mag = linear and min = nearest and mip = linear */
  99454. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  99455. /** mag = linear and min = linear and mip = none */
  99456. static readonly TEXTURE_LINEAR_LINEAR: number;
  99457. /** mag = linear and min = nearest and mip = none */
  99458. static readonly TEXTURE_LINEAR_NEAREST: number;
  99459. /** Explicit coordinates mode */
  99460. static readonly TEXTURE_EXPLICIT_MODE: number;
  99461. /** Spherical coordinates mode */
  99462. static readonly TEXTURE_SPHERICAL_MODE: number;
  99463. /** Planar coordinates mode */
  99464. static readonly TEXTURE_PLANAR_MODE: number;
  99465. /** Cubic coordinates mode */
  99466. static readonly TEXTURE_CUBIC_MODE: number;
  99467. /** Projection coordinates mode */
  99468. static readonly TEXTURE_PROJECTION_MODE: number;
  99469. /** Skybox coordinates mode */
  99470. static readonly TEXTURE_SKYBOX_MODE: number;
  99471. /** Inverse Cubic coordinates mode */
  99472. static readonly TEXTURE_INVCUBIC_MODE: number;
  99473. /** Equirectangular coordinates mode */
  99474. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  99475. /** Equirectangular Fixed coordinates mode */
  99476. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  99477. /** Equirectangular Fixed Mirrored coordinates mode */
  99478. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  99479. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  99480. static readonly SCALEMODE_FLOOR: number;
  99481. /** Defines that texture rescaling will look for the nearest power of 2 size */
  99482. static readonly SCALEMODE_NEAREST: number;
  99483. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  99484. static readonly SCALEMODE_CEILING: number;
  99485. /**
  99486. * Returns the current npm package of the sdk
  99487. */
  99488. static readonly NpmPackage: string;
  99489. /**
  99490. * Returns the current version of the framework
  99491. */
  99492. static readonly Version: string;
  99493. /** Gets the list of created engines */
  99494. static readonly Instances: Engine[];
  99495. /**
  99496. * Gets the latest created engine
  99497. */
  99498. static readonly LastCreatedEngine: Nullable<Engine>;
  99499. /**
  99500. * Gets the latest created scene
  99501. */
  99502. static readonly LastCreatedScene: Nullable<Scene>;
  99503. /**
  99504. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  99505. * @param flag defines which part of the materials must be marked as dirty
  99506. * @param predicate defines a predicate used to filter which materials should be affected
  99507. */
  99508. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  99509. /**
  99510. * Method called to create the default loading screen.
  99511. * This can be overriden in your own app.
  99512. * @param canvas The rendering canvas element
  99513. * @returns The loading screen
  99514. */
  99515. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  99516. /**
  99517. * Method called to create the default rescale post process on each engine.
  99518. */
  99519. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  99520. /**
  99521. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  99522. **/
  99523. enableOfflineSupport: boolean;
  99524. /**
  99525. * 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)
  99526. **/
  99527. disableManifestCheck: boolean;
  99528. /**
  99529. * Gets the list of created scenes
  99530. */
  99531. scenes: Scene[];
  99532. /**
  99533. * Event raised when a new scene is created
  99534. */
  99535. onNewSceneAddedObservable: Observable<Scene>;
  99536. /**
  99537. * Gets the list of created postprocesses
  99538. */
  99539. postProcesses: PostProcess[];
  99540. /**
  99541. * Gets a boolean indicating if the pointer is currently locked
  99542. */
  99543. isPointerLock: boolean;
  99544. /**
  99545. * Observable event triggered each time the rendering canvas is resized
  99546. */
  99547. onResizeObservable: Observable<Engine>;
  99548. /**
  99549. * Observable event triggered each time the canvas loses focus
  99550. */
  99551. onCanvasBlurObservable: Observable<Engine>;
  99552. /**
  99553. * Observable event triggered each time the canvas gains focus
  99554. */
  99555. onCanvasFocusObservable: Observable<Engine>;
  99556. /**
  99557. * Observable event triggered each time the canvas receives pointerout event
  99558. */
  99559. onCanvasPointerOutObservable: Observable<PointerEvent>;
  99560. /**
  99561. * Observable raised when the engine begins a new frame
  99562. */
  99563. onBeginFrameObservable: Observable<Engine>;
  99564. /**
  99565. * If set, will be used to request the next animation frame for the render loop
  99566. */
  99567. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  99568. /**
  99569. * Observable raised when the engine ends the current frame
  99570. */
  99571. onEndFrameObservable: Observable<Engine>;
  99572. /**
  99573. * Observable raised when the engine is about to compile a shader
  99574. */
  99575. onBeforeShaderCompilationObservable: Observable<Engine>;
  99576. /**
  99577. * Observable raised when the engine has jsut compiled a shader
  99578. */
  99579. onAfterShaderCompilationObservable: Observable<Engine>;
  99580. /**
  99581. * Gets the audio engine
  99582. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99583. * @ignorenaming
  99584. */
  99585. static audioEngine: IAudioEngine;
  99586. /**
  99587. * Default AudioEngine factory responsible of creating the Audio Engine.
  99588. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  99589. */
  99590. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  99591. /**
  99592. * Default offline support factory responsible of creating a tool used to store data locally.
  99593. * By default, this will create a Database object if the workload has been embedded.
  99594. */
  99595. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  99596. private _loadingScreen;
  99597. private _pointerLockRequested;
  99598. private _dummyFramebuffer;
  99599. private _rescalePostProcess;
  99600. /** @hidden */
  99601. protected _alphaMode: number;
  99602. /** @hidden */
  99603. protected _alphaEquation: number;
  99604. private _deterministicLockstep;
  99605. private _lockstepMaxSteps;
  99606. protected readonly _supportsHardwareTextureRescaling: boolean;
  99607. private _fps;
  99608. private _deltaTime;
  99609. /** @hidden */
  99610. _drawCalls: PerfCounter;
  99611. /**
  99612. * Turn this value on if you want to pause FPS computation when in background
  99613. */
  99614. disablePerformanceMonitorInBackground: boolean;
  99615. private _performanceMonitor;
  99616. /**
  99617. * Gets the performance monitor attached to this engine
  99618. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99619. */
  99620. readonly performanceMonitor: PerformanceMonitor;
  99621. private _onFocus;
  99622. private _onBlur;
  99623. private _onCanvasPointerOut;
  99624. private _onCanvasBlur;
  99625. private _onCanvasFocus;
  99626. private _onFullscreenChange;
  99627. private _onPointerLockChange;
  99628. /**
  99629. * Gets the HTML element used to attach event listeners
  99630. * @returns a HTML element
  99631. */
  99632. getInputElement(): Nullable<HTMLElement>;
  99633. /**
  99634. * Creates a new engine
  99635. * @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
  99636. * @param antialias defines enable antialiasing (default: false)
  99637. * @param options defines further options to be sent to the getContext() function
  99638. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  99639. */
  99640. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  99641. /**
  99642. * Gets current aspect ratio
  99643. * @param viewportOwner defines the camera to use to get the aspect ratio
  99644. * @param useScreen defines if screen size must be used (or the current render target if any)
  99645. * @returns a number defining the aspect ratio
  99646. */
  99647. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  99648. /**
  99649. * Gets current screen aspect ratio
  99650. * @returns a number defining the aspect ratio
  99651. */
  99652. getScreenAspectRatio(): number;
  99653. /**
  99654. * Gets host document
  99655. * @returns the host document object
  99656. */
  99657. getHostDocument(): Document;
  99658. /**
  99659. * Gets the client rect of the HTML canvas attached with the current webGL context
  99660. * @returns a client rectanglee
  99661. */
  99662. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  99663. /**
  99664. * Gets the client rect of the HTML element used for events
  99665. * @returns a client rectanglee
  99666. */
  99667. getInputElementClientRect(): Nullable<ClientRect>;
  99668. /**
  99669. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  99670. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99671. * @returns true if engine is in deterministic lock step mode
  99672. */
  99673. isDeterministicLockStep(): boolean;
  99674. /**
  99675. * Gets the max steps when engine is running in deterministic lock step
  99676. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99677. * @returns the max steps
  99678. */
  99679. getLockstepMaxSteps(): number;
  99680. /**
  99681. * Force the mipmap generation for the given render target texture
  99682. * @param texture defines the render target texture to use
  99683. */
  99684. generateMipMapsForCubemap(texture: InternalTexture): void;
  99685. /** States */
  99686. /**
  99687. * Set various states to the webGL context
  99688. * @param culling defines backface culling state
  99689. * @param zOffset defines the value to apply to zOffset (0 by default)
  99690. * @param force defines if states must be applied even if cache is up to date
  99691. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  99692. */
  99693. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  99694. /**
  99695. * Set the z offset to apply to current rendering
  99696. * @param value defines the offset to apply
  99697. */
  99698. setZOffset(value: number): void;
  99699. /**
  99700. * Gets the current value of the zOffset
  99701. * @returns the current zOffset state
  99702. */
  99703. getZOffset(): number;
  99704. /**
  99705. * Enable or disable depth buffering
  99706. * @param enable defines the state to set
  99707. */
  99708. setDepthBuffer(enable: boolean): void;
  99709. /**
  99710. * Gets a boolean indicating if depth writing is enabled
  99711. * @returns the current depth writing state
  99712. */
  99713. getDepthWrite(): boolean;
  99714. /**
  99715. * Enable or disable depth writing
  99716. * @param enable defines the state to set
  99717. */
  99718. setDepthWrite(enable: boolean): void;
  99719. /**
  99720. * Enable or disable color writing
  99721. * @param enable defines the state to set
  99722. */
  99723. setColorWrite(enable: boolean): void;
  99724. /**
  99725. * Gets a boolean indicating if color writing is enabled
  99726. * @returns the current color writing state
  99727. */
  99728. getColorWrite(): boolean;
  99729. /**
  99730. * Sets alpha constants used by some alpha blending modes
  99731. * @param r defines the red component
  99732. * @param g defines the green component
  99733. * @param b defines the blue component
  99734. * @param a defines the alpha component
  99735. */
  99736. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  99737. /**
  99738. * Sets the current alpha mode
  99739. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  99740. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  99741. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  99742. */
  99743. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  99744. /**
  99745. * Gets the current alpha mode
  99746. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  99747. * @returns the current alpha mode
  99748. */
  99749. getAlphaMode(): number;
  99750. /**
  99751. * Sets the current alpha equation
  99752. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  99753. */
  99754. setAlphaEquation(equation: number): void;
  99755. /**
  99756. * Gets the current alpha equation.
  99757. * @returns the current alpha equation
  99758. */
  99759. getAlphaEquation(): number;
  99760. /**
  99761. * Gets a boolean indicating if stencil buffer is enabled
  99762. * @returns the current stencil buffer state
  99763. */
  99764. getStencilBuffer(): boolean;
  99765. /**
  99766. * Enable or disable the stencil buffer
  99767. * @param enable defines if the stencil buffer must be enabled or disabled
  99768. */
  99769. setStencilBuffer(enable: boolean): void;
  99770. /**
  99771. * Gets the current stencil mask
  99772. * @returns a number defining the new stencil mask to use
  99773. */
  99774. getStencilMask(): number;
  99775. /**
  99776. * Sets the current stencil mask
  99777. * @param mask defines the new stencil mask to use
  99778. */
  99779. setStencilMask(mask: number): void;
  99780. /**
  99781. * Gets the current stencil function
  99782. * @returns a number defining the stencil function to use
  99783. */
  99784. getStencilFunction(): number;
  99785. /**
  99786. * Gets the current stencil reference value
  99787. * @returns a number defining the stencil reference value to use
  99788. */
  99789. getStencilFunctionReference(): number;
  99790. /**
  99791. * Gets the current stencil mask
  99792. * @returns a number defining the stencil mask to use
  99793. */
  99794. getStencilFunctionMask(): number;
  99795. /**
  99796. * Sets the current stencil function
  99797. * @param stencilFunc defines the new stencil function to use
  99798. */
  99799. setStencilFunction(stencilFunc: number): void;
  99800. /**
  99801. * Sets the current stencil reference
  99802. * @param reference defines the new stencil reference to use
  99803. */
  99804. setStencilFunctionReference(reference: number): void;
  99805. /**
  99806. * Sets the current stencil mask
  99807. * @param mask defines the new stencil mask to use
  99808. */
  99809. setStencilFunctionMask(mask: number): void;
  99810. /**
  99811. * Gets the current stencil operation when stencil fails
  99812. * @returns a number defining stencil operation to use when stencil fails
  99813. */
  99814. getStencilOperationFail(): number;
  99815. /**
  99816. * Gets the current stencil operation when depth fails
  99817. * @returns a number defining stencil operation to use when depth fails
  99818. */
  99819. getStencilOperationDepthFail(): number;
  99820. /**
  99821. * Gets the current stencil operation when stencil passes
  99822. * @returns a number defining stencil operation to use when stencil passes
  99823. */
  99824. getStencilOperationPass(): number;
  99825. /**
  99826. * Sets the stencil operation to use when stencil fails
  99827. * @param operation defines the stencil operation to use when stencil fails
  99828. */
  99829. setStencilOperationFail(operation: number): void;
  99830. /**
  99831. * Sets the stencil operation to use when depth fails
  99832. * @param operation defines the stencil operation to use when depth fails
  99833. */
  99834. setStencilOperationDepthFail(operation: number): void;
  99835. /**
  99836. * Sets the stencil operation to use when stencil passes
  99837. * @param operation defines the stencil operation to use when stencil passes
  99838. */
  99839. setStencilOperationPass(operation: number): void;
  99840. /**
  99841. * Sets a boolean indicating if the dithering state is enabled or disabled
  99842. * @param value defines the dithering state
  99843. */
  99844. setDitheringState(value: boolean): void;
  99845. /**
  99846. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  99847. * @param value defines the rasterizer state
  99848. */
  99849. setRasterizerState(value: boolean): void;
  99850. /**
  99851. * Gets the current depth function
  99852. * @returns a number defining the depth function
  99853. */
  99854. getDepthFunction(): Nullable<number>;
  99855. /**
  99856. * Sets the current depth function
  99857. * @param depthFunc defines the function to use
  99858. */
  99859. setDepthFunction(depthFunc: number): void;
  99860. /**
  99861. * Sets the current depth function to GREATER
  99862. */
  99863. setDepthFunctionToGreater(): void;
  99864. /**
  99865. * Sets the current depth function to GEQUAL
  99866. */
  99867. setDepthFunctionToGreaterOrEqual(): void;
  99868. /**
  99869. * Sets the current depth function to LESS
  99870. */
  99871. setDepthFunctionToLess(): void;
  99872. /**
  99873. * Sets the current depth function to LEQUAL
  99874. */
  99875. setDepthFunctionToLessOrEqual(): void;
  99876. private _cachedStencilBuffer;
  99877. private _cachedStencilFunction;
  99878. private _cachedStencilMask;
  99879. private _cachedStencilOperationPass;
  99880. private _cachedStencilOperationFail;
  99881. private _cachedStencilOperationDepthFail;
  99882. private _cachedStencilReference;
  99883. /**
  99884. * Caches the the state of the stencil buffer
  99885. */
  99886. cacheStencilState(): void;
  99887. /**
  99888. * Restores the state of the stencil buffer
  99889. */
  99890. restoreStencilState(): void;
  99891. /**
  99892. * Directly set the WebGL Viewport
  99893. * @param x defines the x coordinate of the viewport (in screen space)
  99894. * @param y defines the y coordinate of the viewport (in screen space)
  99895. * @param width defines the width of the viewport (in screen space)
  99896. * @param height defines the height of the viewport (in screen space)
  99897. * @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
  99898. */
  99899. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  99900. /**
  99901. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  99902. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  99903. * @param y defines the y-coordinate of the corner of the clear rectangle
  99904. * @param width defines the width of the clear rectangle
  99905. * @param height defines the height of the clear rectangle
  99906. * @param clearColor defines the clear color
  99907. */
  99908. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  99909. /**
  99910. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  99911. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  99912. * @param y defines the y-coordinate of the corner of the clear rectangle
  99913. * @param width defines the width of the clear rectangle
  99914. * @param height defines the height of the clear rectangle
  99915. */
  99916. enableScissor(x: number, y: number, width: number, height: number): void;
  99917. /**
  99918. * Disable previously set scissor test rectangle
  99919. */
  99920. disableScissor(): void;
  99921. protected _reportDrawCall(): void;
  99922. /**
  99923. * Initializes a webVR display and starts listening to display change events
  99924. * The onVRDisplayChangedObservable will be notified upon these changes
  99925. * @returns The onVRDisplayChangedObservable
  99926. */
  99927. initWebVR(): Observable<IDisplayChangedEventArgs>;
  99928. /** @hidden */
  99929. _prepareVRComponent(): void;
  99930. /** @hidden */
  99931. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  99932. /** @hidden */
  99933. _submitVRFrame(): void;
  99934. /**
  99935. * Call this function to leave webVR mode
  99936. * Will do nothing if webVR is not supported or if there is no webVR device
  99937. * @see http://doc.babylonjs.com/how_to/webvr_camera
  99938. */
  99939. disableVR(): void;
  99940. /**
  99941. * Gets a boolean indicating that the system is in VR mode and is presenting
  99942. * @returns true if VR mode is engaged
  99943. */
  99944. isVRPresenting(): boolean;
  99945. /** @hidden */
  99946. _requestVRFrame(): void;
  99947. /** @hidden */
  99948. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  99949. /**
  99950. * Gets the source code of the vertex shader associated with a specific webGL program
  99951. * @param program defines the program to use
  99952. * @returns a string containing the source code of the vertex shader associated with the program
  99953. */
  99954. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  99955. /**
  99956. * Gets the source code of the fragment shader associated with a specific webGL program
  99957. * @param program defines the program to use
  99958. * @returns a string containing the source code of the fragment shader associated with the program
  99959. */
  99960. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  99961. /**
  99962. * Reads pixels from the current frame buffer. Please note that this function can be slow
  99963. * @param x defines the x coordinate of the rectangle where pixels must be read
  99964. * @param y defines the y coordinate of the rectangle where pixels must be read
  99965. * @param width defines the width of the rectangle where pixels must be read
  99966. * @param height defines the height of the rectangle where pixels must be read
  99967. * @returns a Uint8Array containing RGBA colors
  99968. */
  99969. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  99970. /**
  99971. * Sets a depth stencil texture from a render target to the according uniform.
  99972. * @param channel The texture channel
  99973. * @param uniform The uniform to set
  99974. * @param texture The render target texture containing the depth stencil texture to apply
  99975. */
  99976. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  99977. /**
  99978. * Sets a texture to the webGL context from a postprocess
  99979. * @param channel defines the channel to use
  99980. * @param postProcess defines the source postprocess
  99981. */
  99982. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  99983. /**
  99984. * Binds the output of the passed in post process to the texture channel specified
  99985. * @param channel The channel the texture should be bound to
  99986. * @param postProcess The post process which's output should be bound
  99987. */
  99988. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  99989. /** @hidden */
  99990. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  99991. protected _rebuildBuffers(): void;
  99992. /** @hidden */
  99993. _renderFrame(): void;
  99994. _renderLoop(): void;
  99995. /** @hidden */
  99996. _renderViews(): boolean;
  99997. /**
  99998. * Toggle full screen mode
  99999. * @param requestPointerLock defines if a pointer lock should be requested from the user
  100000. */
  100001. switchFullscreen(requestPointerLock: boolean): void;
  100002. /**
  100003. * Enters full screen mode
  100004. * @param requestPointerLock defines if a pointer lock should be requested from the user
  100005. */
  100006. enterFullscreen(requestPointerLock: boolean): void;
  100007. /**
  100008. * Exits full screen mode
  100009. */
  100010. exitFullscreen(): void;
  100011. /**
  100012. * Enters Pointerlock mode
  100013. */
  100014. enterPointerlock(): void;
  100015. /**
  100016. * Exits Pointerlock mode
  100017. */
  100018. exitPointerlock(): void;
  100019. /**
  100020. * Begin a new frame
  100021. */
  100022. beginFrame(): void;
  100023. /**
  100024. * Enf the current frame
  100025. */
  100026. endFrame(): void;
  100027. resize(): void;
  100028. /**
  100029. * Set the compressed texture format to use, based on the formats you have, and the formats
  100030. * supported by the hardware / browser.
  100031. *
  100032. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  100033. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  100034. * to API arguments needed to compressed textures. This puts the burden on the container
  100035. * generator to house the arcane code for determining these for current & future formats.
  100036. *
  100037. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  100038. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  100039. *
  100040. * Note: The result of this call is not taken into account when a texture is base64.
  100041. *
  100042. * @param formatsAvailable defines the list of those format families you have created
  100043. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  100044. *
  100045. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  100046. * @returns The extension selected.
  100047. */
  100048. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  100049. /**
  100050. * Force a specific size of the canvas
  100051. * @param width defines the new canvas' width
  100052. * @param height defines the new canvas' height
  100053. */
  100054. setSize(width: number, height: number): void;
  100055. /**
  100056. * Updates a dynamic vertex buffer.
  100057. * @param vertexBuffer the vertex buffer to update
  100058. * @param data the data used to update the vertex buffer
  100059. * @param byteOffset the byte offset of the data
  100060. * @param byteLength the byte length of the data
  100061. */
  100062. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  100063. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  100064. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100065. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100066. _releaseTexture(texture: InternalTexture): void;
  100067. /**
  100068. * @hidden
  100069. * Rescales a texture
  100070. * @param source input texutre
  100071. * @param destination destination texture
  100072. * @param scene scene to use to render the resize
  100073. * @param internalFormat format to use when resizing
  100074. * @param onComplete callback to be called when resize has completed
  100075. */
  100076. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  100077. /**
  100078. * Gets the current framerate
  100079. * @returns a number representing the framerate
  100080. */
  100081. getFps(): number;
  100082. /**
  100083. * Gets the time spent between current and previous frame
  100084. * @returns a number representing the delta time in ms
  100085. */
  100086. getDeltaTime(): number;
  100087. private _measureFps;
  100088. /** @hidden */
  100089. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  100090. /**
  100091. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  100092. * @param renderTarget The render target to set the frame buffer for
  100093. */
  100094. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  100095. /**
  100096. * Update a dynamic index buffer
  100097. * @param indexBuffer defines the target index buffer
  100098. * @param indices defines the data to update
  100099. * @param offset defines the offset in the target index buffer where update should start
  100100. */
  100101. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  100102. /**
  100103. * Updates the sample count of a render target texture
  100104. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  100105. * @param texture defines the texture to update
  100106. * @param samples defines the sample count to set
  100107. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  100108. */
  100109. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  100110. /**
  100111. * Updates a depth texture Comparison Mode and Function.
  100112. * If the comparison Function is equal to 0, the mode will be set to none.
  100113. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  100114. * @param texture The texture to set the comparison function for
  100115. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  100116. */
  100117. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  100118. /**
  100119. * Creates a webGL buffer to use with instanciation
  100120. * @param capacity defines the size of the buffer
  100121. * @returns the webGL buffer
  100122. */
  100123. createInstancesBuffer(capacity: number): DataBuffer;
  100124. /**
  100125. * Delete a webGL buffer used with instanciation
  100126. * @param buffer defines the webGL buffer to delete
  100127. */
  100128. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  100129. /** @hidden */
  100130. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  100131. dispose(): void;
  100132. private _disableTouchAction;
  100133. /**
  100134. * Display the loading screen
  100135. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100136. */
  100137. displayLoadingUI(): void;
  100138. /**
  100139. * Hide the loading screen
  100140. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100141. */
  100142. hideLoadingUI(): void;
  100143. /**
  100144. * Gets the current loading screen object
  100145. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100146. */
  100147. /**
  100148. * Sets the current loading screen object
  100149. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100150. */
  100151. loadingScreen: ILoadingScreen;
  100152. /**
  100153. * Sets the current loading screen text
  100154. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100155. */
  100156. loadingUIText: string;
  100157. /**
  100158. * Sets the current loading screen background color
  100159. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100160. */
  100161. loadingUIBackgroundColor: string;
  100162. /** Pointerlock and fullscreen */
  100163. /**
  100164. * Ask the browser to promote the current element to pointerlock mode
  100165. * @param element defines the DOM element to promote
  100166. */
  100167. static _RequestPointerlock(element: HTMLElement): void;
  100168. /**
  100169. * Asks the browser to exit pointerlock mode
  100170. */
  100171. static _ExitPointerlock(): void;
  100172. /**
  100173. * Ask the browser to promote the current element to fullscreen rendering mode
  100174. * @param element defines the DOM element to promote
  100175. */
  100176. static _RequestFullscreen(element: HTMLElement): void;
  100177. /**
  100178. * Asks the browser to exit fullscreen mode
  100179. */
  100180. static _ExitFullscreen(): void;
  100181. }
  100182. }
  100183. declare module BABYLON {
  100184. /**
  100185. * The engine store class is responsible to hold all the instances of Engine and Scene created
  100186. * during the life time of the application.
  100187. */
  100188. export class EngineStore {
  100189. /** Gets the list of created engines */
  100190. static Instances: Engine[];
  100191. /** @hidden */
  100192. static _LastCreatedScene: Nullable<Scene>;
  100193. /**
  100194. * Gets the latest created engine
  100195. */
  100196. static readonly LastCreatedEngine: Nullable<Engine>;
  100197. /**
  100198. * Gets the latest created scene
  100199. */
  100200. static readonly LastCreatedScene: Nullable<Scene>;
  100201. /**
  100202. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100203. * @ignorenaming
  100204. */
  100205. static UseFallbackTexture: boolean;
  100206. /**
  100207. * Texture content used if a texture cannot loaded
  100208. * @ignorenaming
  100209. */
  100210. static FallbackTexture: string;
  100211. }
  100212. }
  100213. declare module BABYLON {
  100214. /**
  100215. * Helper class that provides a small promise polyfill
  100216. */
  100217. export class PromisePolyfill {
  100218. /**
  100219. * Static function used to check if the polyfill is required
  100220. * If this is the case then the function will inject the polyfill to window.Promise
  100221. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  100222. */
  100223. static Apply(force?: boolean): void;
  100224. }
  100225. }
  100226. declare module BABYLON {
  100227. /**
  100228. * Interface for screenshot methods with describe argument called `size` as object with options
  100229. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  100230. */
  100231. export interface IScreenshotSize {
  100232. /**
  100233. * number in pixels for canvas height
  100234. */
  100235. height?: number;
  100236. /**
  100237. * multiplier allowing render at a higher or lower resolution
  100238. * If value is defined then height and width will be ignored and taken from camera
  100239. */
  100240. precision?: number;
  100241. /**
  100242. * number in pixels for canvas width
  100243. */
  100244. width?: number;
  100245. }
  100246. }
  100247. declare module BABYLON {
  100248. interface IColor4Like {
  100249. r: float;
  100250. g: float;
  100251. b: float;
  100252. a: float;
  100253. }
  100254. /**
  100255. * Class containing a set of static utilities functions
  100256. */
  100257. export class Tools {
  100258. /**
  100259. * Gets or sets the base URL to use to load assets
  100260. */
  100261. static BaseUrl: string;
  100262. /**
  100263. * Enable/Disable Custom HTTP Request Headers globally.
  100264. * default = false
  100265. * @see CustomRequestHeaders
  100266. */
  100267. static UseCustomRequestHeaders: boolean;
  100268. /**
  100269. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  100270. * i.e. when loading files, where the server/service expects an Authorization header
  100271. */
  100272. static CustomRequestHeaders: {
  100273. [key: string]: string;
  100274. };
  100275. /**
  100276. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  100277. */
  100278. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  100279. /**
  100280. * Default behaviour for cors in the application.
  100281. * It can be a string if the expected behavior is identical in the entire app.
  100282. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  100283. */
  100284. static CorsBehavior: string | ((url: string | string[]) => string);
  100285. /**
  100286. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100287. * @ignorenaming
  100288. */
  100289. static UseFallbackTexture: boolean;
  100290. /**
  100291. * Use this object to register external classes like custom textures or material
  100292. * to allow the laoders to instantiate them
  100293. */
  100294. static RegisteredExternalClasses: {
  100295. [key: string]: Object;
  100296. };
  100297. /**
  100298. * Texture content used if a texture cannot loaded
  100299. * @ignorenaming
  100300. */
  100301. static fallbackTexture: string;
  100302. /**
  100303. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  100304. * @param u defines the coordinate on X axis
  100305. * @param v defines the coordinate on Y axis
  100306. * @param width defines the width of the source data
  100307. * @param height defines the height of the source data
  100308. * @param pixels defines the source byte array
  100309. * @param color defines the output color
  100310. */
  100311. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  100312. /**
  100313. * Interpolates between a and b via alpha
  100314. * @param a The lower value (returned when alpha = 0)
  100315. * @param b The upper value (returned when alpha = 1)
  100316. * @param alpha The interpolation-factor
  100317. * @return The mixed value
  100318. */
  100319. static Mix(a: number, b: number, alpha: number): number;
  100320. /**
  100321. * Tries to instantiate a new object from a given class name
  100322. * @param className defines the class name to instantiate
  100323. * @returns the new object or null if the system was not able to do the instantiation
  100324. */
  100325. static Instantiate(className: string): any;
  100326. /**
  100327. * Provides a slice function that will work even on IE
  100328. * @param data defines the array to slice
  100329. * @param start defines the start of the data (optional)
  100330. * @param end defines the end of the data (optional)
  100331. * @returns the new sliced array
  100332. */
  100333. static Slice<T>(data: T, start?: number, end?: number): T;
  100334. /**
  100335. * Polyfill for setImmediate
  100336. * @param action defines the action to execute after the current execution block
  100337. */
  100338. static SetImmediate(action: () => void): void;
  100339. /**
  100340. * Function indicating if a number is an exponent of 2
  100341. * @param value defines the value to test
  100342. * @returns true if the value is an exponent of 2
  100343. */
  100344. static IsExponentOfTwo(value: number): boolean;
  100345. private static _tmpFloatArray;
  100346. /**
  100347. * Returns the nearest 32-bit single precision float representation of a Number
  100348. * @param value A Number. If the parameter is of a different type, it will get converted
  100349. * to a number or to NaN if it cannot be converted
  100350. * @returns number
  100351. */
  100352. static FloatRound(value: number): number;
  100353. /**
  100354. * Extracts the filename from a path
  100355. * @param path defines the path to use
  100356. * @returns the filename
  100357. */
  100358. static GetFilename(path: string): string;
  100359. /**
  100360. * Extracts the "folder" part of a path (everything before the filename).
  100361. * @param uri The URI to extract the info from
  100362. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  100363. * @returns The "folder" part of the path
  100364. */
  100365. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  100366. /**
  100367. * Extracts text content from a DOM element hierarchy
  100368. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  100369. */
  100370. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  100371. /**
  100372. * Convert an angle in radians to degrees
  100373. * @param angle defines the angle to convert
  100374. * @returns the angle in degrees
  100375. */
  100376. static ToDegrees(angle: number): number;
  100377. /**
  100378. * Convert an angle in degrees to radians
  100379. * @param angle defines the angle to convert
  100380. * @returns the angle in radians
  100381. */
  100382. static ToRadians(angle: number): number;
  100383. /**
  100384. * Returns an array if obj is not an array
  100385. * @param obj defines the object to evaluate as an array
  100386. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  100387. * @returns either obj directly if obj is an array or a new array containing obj
  100388. */
  100389. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  100390. /**
  100391. * Gets the pointer prefix to use
  100392. * @returns "pointer" if touch is enabled. Else returns "mouse"
  100393. */
  100394. static GetPointerPrefix(): string;
  100395. /**
  100396. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  100397. * @param url define the url we are trying
  100398. * @param element define the dom element where to configure the cors policy
  100399. */
  100400. static SetCorsBehavior(url: string | string[], element: {
  100401. crossOrigin: string | null;
  100402. }): void;
  100403. /**
  100404. * Removes unwanted characters from an url
  100405. * @param url defines the url to clean
  100406. * @returns the cleaned url
  100407. */
  100408. static CleanUrl(url: string): string;
  100409. /**
  100410. * Gets or sets a function used to pre-process url before using them to load assets
  100411. */
  100412. static PreprocessUrl: (url: string) => string;
  100413. /**
  100414. * Loads an image as an HTMLImageElement.
  100415. * @param input url string, ArrayBuffer, or Blob to load
  100416. * @param onLoad callback called when the image successfully loads
  100417. * @param onError callback called when the image fails to load
  100418. * @param offlineProvider offline provider for caching
  100419. * @param mimeType optional mime type
  100420. * @returns the HTMLImageElement of the loaded image
  100421. */
  100422. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  100423. /**
  100424. * Loads a file from a url
  100425. * @param url url string, ArrayBuffer, or Blob to load
  100426. * @param onSuccess callback called when the file successfully loads
  100427. * @param onProgress callback called while file is loading (if the server supports this mode)
  100428. * @param offlineProvider defines the offline provider for caching
  100429. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  100430. * @param onError callback called when the file fails to load
  100431. * @returns a file request object
  100432. */
  100433. 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;
  100434. /**
  100435. * Loads a file from a url
  100436. * @param url the file url to load
  100437. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  100438. */
  100439. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  100440. /**
  100441. * Load a script (identified by an url). When the url returns, the
  100442. * content of this file is added into a new script element, attached to the DOM (body element)
  100443. * @param scriptUrl defines the url of the script to laod
  100444. * @param onSuccess defines the callback called when the script is loaded
  100445. * @param onError defines the callback to call if an error occurs
  100446. * @param scriptId defines the id of the script element
  100447. */
  100448. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  100449. /**
  100450. * Load an asynchronous script (identified by an url). When the url returns, the
  100451. * content of this file is added into a new script element, attached to the DOM (body element)
  100452. * @param scriptUrl defines the url of the script to laod
  100453. * @param scriptId defines the id of the script element
  100454. * @returns a promise request object
  100455. */
  100456. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  100457. /**
  100458. * Loads a file from a blob
  100459. * @param fileToLoad defines the blob to use
  100460. * @param callback defines the callback to call when data is loaded
  100461. * @param progressCallback defines the callback to call during loading process
  100462. * @returns a file request object
  100463. */
  100464. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  100465. /**
  100466. * Reads a file from a File object
  100467. * @param file defines the file to load
  100468. * @param onSuccess defines the callback to call when data is loaded
  100469. * @param onProgress defines the callback to call during loading process
  100470. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  100471. * @param onError defines the callback to call when an error occurs
  100472. * @returns a file request object
  100473. */
  100474. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  100475. /**
  100476. * Creates a data url from a given string content
  100477. * @param content defines the content to convert
  100478. * @returns the new data url link
  100479. */
  100480. static FileAsURL(content: string): string;
  100481. /**
  100482. * Format the given number to a specific decimal format
  100483. * @param value defines the number to format
  100484. * @param decimals defines the number of decimals to use
  100485. * @returns the formatted string
  100486. */
  100487. static Format(value: number, decimals?: number): string;
  100488. /**
  100489. * Tries to copy an object by duplicating every property
  100490. * @param source defines the source object
  100491. * @param destination defines the target object
  100492. * @param doNotCopyList defines a list of properties to avoid
  100493. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  100494. */
  100495. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  100496. /**
  100497. * Gets a boolean indicating if the given object has no own property
  100498. * @param obj defines the object to test
  100499. * @returns true if object has no own property
  100500. */
  100501. static IsEmpty(obj: any): boolean;
  100502. /**
  100503. * Function used to register events at window level
  100504. * @param windowElement defines the Window object to use
  100505. * @param events defines the events to register
  100506. */
  100507. static RegisterTopRootEvents(windowElement: Window, events: {
  100508. name: string;
  100509. handler: Nullable<(e: FocusEvent) => any>;
  100510. }[]): void;
  100511. /**
  100512. * Function used to unregister events from window level
  100513. * @param windowElement defines the Window object to use
  100514. * @param events defines the events to unregister
  100515. */
  100516. static UnregisterTopRootEvents(windowElement: Window, events: {
  100517. name: string;
  100518. handler: Nullable<(e: FocusEvent) => any>;
  100519. }[]): void;
  100520. /**
  100521. * @ignore
  100522. */
  100523. static _ScreenshotCanvas: HTMLCanvasElement;
  100524. /**
  100525. * Dumps the current bound framebuffer
  100526. * @param width defines the rendering width
  100527. * @param height defines the rendering height
  100528. * @param engine defines the hosting engine
  100529. * @param successCallback defines the callback triggered once the data are available
  100530. * @param mimeType defines the mime type of the result
  100531. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  100532. */
  100533. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  100534. /**
  100535. * Converts the canvas data to blob.
  100536. * This acts as a polyfill for browsers not supporting the to blob function.
  100537. * @param canvas Defines the canvas to extract the data from
  100538. * @param successCallback Defines the callback triggered once the data are available
  100539. * @param mimeType Defines the mime type of the result
  100540. */
  100541. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  100542. /**
  100543. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  100544. * @param successCallback defines the callback triggered once the data are available
  100545. * @param mimeType defines the mime type of the result
  100546. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  100547. */
  100548. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  100549. /**
  100550. * Downloads a blob in the browser
  100551. * @param blob defines the blob to download
  100552. * @param fileName defines the name of the downloaded file
  100553. */
  100554. static Download(blob: Blob, fileName: string): void;
  100555. /**
  100556. * Captures a screenshot of the current rendering
  100557. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100558. * @param engine defines the rendering engine
  100559. * @param camera defines the source camera
  100560. * @param size This parameter can be set to a single number or to an object with the
  100561. * following (optional) properties: precision, width, height. If a single number is passed,
  100562. * it will be used for both width and height. If an object is passed, the screenshot size
  100563. * will be derived from the parameters. The precision property is a multiplier allowing
  100564. * rendering at a higher or lower resolution
  100565. * @param successCallback defines the callback receives a single parameter which contains the
  100566. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100567. * src parameter of an <img> to display it
  100568. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100569. * Check your browser for supported MIME types
  100570. */
  100571. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  100572. /**
  100573. * Captures a screenshot of the current rendering
  100574. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100575. * @param engine defines the rendering engine
  100576. * @param camera defines the source camera
  100577. * @param size This parameter can be set to a single number or to an object with the
  100578. * following (optional) properties: precision, width, height. If a single number is passed,
  100579. * it will be used for both width and height. If an object is passed, the screenshot size
  100580. * will be derived from the parameters. The precision property is a multiplier allowing
  100581. * rendering at a higher or lower resolution
  100582. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100583. * Check your browser for supported MIME types
  100584. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100585. * to the src parameter of an <img> to display it
  100586. */
  100587. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  100588. /**
  100589. * Generates an image screenshot from the specified camera.
  100590. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100591. * @param engine The engine to use for rendering
  100592. * @param camera The camera to use for rendering
  100593. * @param size This parameter can be set to a single number or to an object with the
  100594. * following (optional) properties: precision, width, height. If a single number is passed,
  100595. * it will be used for both width and height. If an object is passed, the screenshot size
  100596. * will be derived from the parameters. The precision property is a multiplier allowing
  100597. * rendering at a higher or lower resolution
  100598. * @param successCallback The callback receives a single parameter which contains the
  100599. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100600. * src parameter of an <img> to display it
  100601. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100602. * Check your browser for supported MIME types
  100603. * @param samples Texture samples (default: 1)
  100604. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100605. * @param fileName A name for for the downloaded file.
  100606. */
  100607. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  100608. /**
  100609. * Generates an image screenshot from the specified camera.
  100610. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100611. * @param engine The engine to use for rendering
  100612. * @param camera The camera to use for rendering
  100613. * @param size This parameter can be set to a single number or to an object with the
  100614. * following (optional) properties: precision, width, height. If a single number is passed,
  100615. * it will be used for both width and height. If an object is passed, the screenshot size
  100616. * will be derived from the parameters. The precision property is a multiplier allowing
  100617. * rendering at a higher or lower resolution
  100618. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100619. * Check your browser for supported MIME types
  100620. * @param samples Texture samples (default: 1)
  100621. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100622. * @param fileName A name for for the downloaded file.
  100623. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100624. * to the src parameter of an <img> to display it
  100625. */
  100626. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  100627. /**
  100628. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100629. * Be aware Math.random() could cause collisions, but:
  100630. * "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"
  100631. * @returns a pseudo random id
  100632. */
  100633. static RandomId(): string;
  100634. /**
  100635. * Test if the given uri is a base64 string
  100636. * @param uri The uri to test
  100637. * @return True if the uri is a base64 string or false otherwise
  100638. */
  100639. static IsBase64(uri: string): boolean;
  100640. /**
  100641. * Decode the given base64 uri.
  100642. * @param uri The uri to decode
  100643. * @return The decoded base64 data.
  100644. */
  100645. static DecodeBase64(uri: string): ArrayBuffer;
  100646. /**
  100647. * Gets the absolute url.
  100648. * @param url the input url
  100649. * @return the absolute url
  100650. */
  100651. static GetAbsoluteUrl(url: string): string;
  100652. /**
  100653. * No log
  100654. */
  100655. static readonly NoneLogLevel: number;
  100656. /**
  100657. * Only message logs
  100658. */
  100659. static readonly MessageLogLevel: number;
  100660. /**
  100661. * Only warning logs
  100662. */
  100663. static readonly WarningLogLevel: number;
  100664. /**
  100665. * Only error logs
  100666. */
  100667. static readonly ErrorLogLevel: number;
  100668. /**
  100669. * All logs
  100670. */
  100671. static readonly AllLogLevel: number;
  100672. /**
  100673. * Gets a value indicating the number of loading errors
  100674. * @ignorenaming
  100675. */
  100676. static readonly errorsCount: number;
  100677. /**
  100678. * Callback called when a new log is added
  100679. */
  100680. static OnNewCacheEntry: (entry: string) => void;
  100681. /**
  100682. * Log a message to the console
  100683. * @param message defines the message to log
  100684. */
  100685. static Log(message: string): void;
  100686. /**
  100687. * Write a warning message to the console
  100688. * @param message defines the message to log
  100689. */
  100690. static Warn(message: string): void;
  100691. /**
  100692. * Write an error message to the console
  100693. * @param message defines the message to log
  100694. */
  100695. static Error(message: string): void;
  100696. /**
  100697. * Gets current log cache (list of logs)
  100698. */
  100699. static readonly LogCache: string;
  100700. /**
  100701. * Clears the log cache
  100702. */
  100703. static ClearLogCache(): void;
  100704. /**
  100705. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  100706. */
  100707. static LogLevels: number;
  100708. /**
  100709. * Checks if the window object exists
  100710. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  100711. */
  100712. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  100713. /**
  100714. * No performance log
  100715. */
  100716. static readonly PerformanceNoneLogLevel: number;
  100717. /**
  100718. * Use user marks to log performance
  100719. */
  100720. static readonly PerformanceUserMarkLogLevel: number;
  100721. /**
  100722. * Log performance to the console
  100723. */
  100724. static readonly PerformanceConsoleLogLevel: number;
  100725. private static _performance;
  100726. /**
  100727. * Sets the current performance log level
  100728. */
  100729. static PerformanceLogLevel: number;
  100730. private static _StartPerformanceCounterDisabled;
  100731. private static _EndPerformanceCounterDisabled;
  100732. private static _StartUserMark;
  100733. private static _EndUserMark;
  100734. private static _StartPerformanceConsole;
  100735. private static _EndPerformanceConsole;
  100736. /**
  100737. * Starts a performance counter
  100738. */
  100739. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  100740. /**
  100741. * Ends a specific performance coutner
  100742. */
  100743. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  100744. /**
  100745. * Gets either window.performance.now() if supported or Date.now() else
  100746. */
  100747. static readonly Now: number;
  100748. /**
  100749. * This method will return the name of the class used to create the instance of the given object.
  100750. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  100751. * @param object the object to get the class name from
  100752. * @param isType defines if the object is actually a type
  100753. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  100754. */
  100755. static GetClassName(object: any, isType?: boolean): string;
  100756. /**
  100757. * Gets the first element of an array satisfying a given predicate
  100758. * @param array defines the array to browse
  100759. * @param predicate defines the predicate to use
  100760. * @returns null if not found or the element
  100761. */
  100762. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  100763. /**
  100764. * This method will return the name of the full name of the class, including its owning module (if any).
  100765. * 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).
  100766. * @param object the object to get the class name from
  100767. * @param isType defines if the object is actually a type
  100768. * @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.
  100769. * @ignorenaming
  100770. */
  100771. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  100772. /**
  100773. * Returns a promise that resolves after the given amount of time.
  100774. * @param delay Number of milliseconds to delay
  100775. * @returns Promise that resolves after the given amount of time
  100776. */
  100777. static DelayAsync(delay: number): Promise<void>;
  100778. }
  100779. /**
  100780. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  100781. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  100782. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  100783. * @param name The name of the class, case should be preserved
  100784. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  100785. */
  100786. export function className(name: string, module?: string): (target: Object) => void;
  100787. /**
  100788. * An implementation of a loop for asynchronous functions.
  100789. */
  100790. export class AsyncLoop {
  100791. /**
  100792. * Defines the number of iterations for the loop
  100793. */
  100794. iterations: number;
  100795. /**
  100796. * Defines the current index of the loop.
  100797. */
  100798. index: number;
  100799. private _done;
  100800. private _fn;
  100801. private _successCallback;
  100802. /**
  100803. * Constructor.
  100804. * @param iterations the number of iterations.
  100805. * @param func the function to run each iteration
  100806. * @param successCallback the callback that will be called upon succesful execution
  100807. * @param offset starting offset.
  100808. */
  100809. constructor(
  100810. /**
  100811. * Defines the number of iterations for the loop
  100812. */
  100813. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  100814. /**
  100815. * Execute the next iteration. Must be called after the last iteration was finished.
  100816. */
  100817. executeNext(): void;
  100818. /**
  100819. * Break the loop and run the success callback.
  100820. */
  100821. breakLoop(): void;
  100822. /**
  100823. * Create and run an async loop.
  100824. * @param iterations the number of iterations.
  100825. * @param fn the function to run each iteration
  100826. * @param successCallback the callback that will be called upon succesful execution
  100827. * @param offset starting offset.
  100828. * @returns the created async loop object
  100829. */
  100830. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  100831. /**
  100832. * A for-loop that will run a given number of iterations synchronous and the rest async.
  100833. * @param iterations total number of iterations
  100834. * @param syncedIterations number of synchronous iterations in each async iteration.
  100835. * @param fn the function to call each iteration.
  100836. * @param callback a success call back that will be called when iterating stops.
  100837. * @param breakFunction a break condition (optional)
  100838. * @param timeout timeout settings for the setTimeout function. default - 0.
  100839. * @returns the created async loop object
  100840. */
  100841. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  100842. }
  100843. }
  100844. declare module BABYLON {
  100845. /**
  100846. * This class implement a typical dictionary using a string as key and the generic type T as value.
  100847. * The underlying implementation relies on an associative array to ensure the best performances.
  100848. * The value can be anything including 'null' but except 'undefined'
  100849. */
  100850. export class StringDictionary<T> {
  100851. /**
  100852. * This will clear this dictionary and copy the content from the 'source' one.
  100853. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  100854. * @param source the dictionary to take the content from and copy to this dictionary
  100855. */
  100856. copyFrom(source: StringDictionary<T>): void;
  100857. /**
  100858. * Get a value based from its key
  100859. * @param key the given key to get the matching value from
  100860. * @return the value if found, otherwise undefined is returned
  100861. */
  100862. get(key: string): T | undefined;
  100863. /**
  100864. * Get a value from its key or add it if it doesn't exist.
  100865. * This method will ensure you that a given key/data will be present in the dictionary.
  100866. * @param key the given key to get the matching value from
  100867. * @param factory the factory that will create the value if the key is not present in the dictionary.
  100868. * The factory will only be invoked if there's no data for the given key.
  100869. * @return the value corresponding to the key.
  100870. */
  100871. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  100872. /**
  100873. * Get a value from its key if present in the dictionary otherwise add it
  100874. * @param key the key to get the value from
  100875. * @param val if there's no such key/value pair in the dictionary add it with this value
  100876. * @return the value corresponding to the key
  100877. */
  100878. getOrAdd(key: string, val: T): T;
  100879. /**
  100880. * Check if there's a given key in the dictionary
  100881. * @param key the key to check for
  100882. * @return true if the key is present, false otherwise
  100883. */
  100884. contains(key: string): boolean;
  100885. /**
  100886. * Add a new key and its corresponding value
  100887. * @param key the key to add
  100888. * @param value the value corresponding to the key
  100889. * @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
  100890. */
  100891. add(key: string, value: T): boolean;
  100892. /**
  100893. * Update a specific value associated to a key
  100894. * @param key defines the key to use
  100895. * @param value defines the value to store
  100896. * @returns true if the value was updated (or false if the key was not found)
  100897. */
  100898. set(key: string, value: T): boolean;
  100899. /**
  100900. * Get the element of the given key and remove it from the dictionary
  100901. * @param key defines the key to search
  100902. * @returns the value associated with the key or null if not found
  100903. */
  100904. getAndRemove(key: string): Nullable<T>;
  100905. /**
  100906. * Remove a key/value from the dictionary.
  100907. * @param key the key to remove
  100908. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  100909. */
  100910. remove(key: string): boolean;
  100911. /**
  100912. * Clear the whole content of the dictionary
  100913. */
  100914. clear(): void;
  100915. /**
  100916. * Gets the current count
  100917. */
  100918. readonly count: number;
  100919. /**
  100920. * Execute a callback on each key/val of the dictionary.
  100921. * Note that you can remove any element in this dictionary in the callback implementation
  100922. * @param callback the callback to execute on a given key/value pair
  100923. */
  100924. forEach(callback: (key: string, val: T) => void): void;
  100925. /**
  100926. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  100927. * If the callback returns null or undefined the method will iterate to the next key/value pair
  100928. * Note that you can remove any element in this dictionary in the callback implementation
  100929. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  100930. * @returns the first item
  100931. */
  100932. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  100933. private _count;
  100934. private _data;
  100935. }
  100936. }
  100937. declare module BABYLON {
  100938. /** @hidden */
  100939. export interface ICollisionCoordinator {
  100940. createCollider(): Collider;
  100941. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  100942. init(scene: Scene): void;
  100943. }
  100944. /** @hidden */
  100945. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  100946. private _scene;
  100947. private _scaledPosition;
  100948. private _scaledVelocity;
  100949. private _finalPosition;
  100950. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  100951. createCollider(): Collider;
  100952. init(scene: Scene): void;
  100953. private _collideWithWorld;
  100954. }
  100955. }
  100956. declare module BABYLON {
  100957. /**
  100958. * Class used to manage all inputs for the scene.
  100959. */
  100960. export class InputManager {
  100961. /** The distance in pixel that you have to move to prevent some events */
  100962. static DragMovementThreshold: number;
  100963. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  100964. static LongPressDelay: number;
  100965. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  100966. static DoubleClickDelay: number;
  100967. /** If you need to check double click without raising a single click at first click, enable this flag */
  100968. static ExclusiveDoubleClickMode: boolean;
  100969. private _wheelEventName;
  100970. private _onPointerMove;
  100971. private _onPointerDown;
  100972. private _onPointerUp;
  100973. private _initClickEvent;
  100974. private _initActionManager;
  100975. private _delayedSimpleClick;
  100976. private _delayedSimpleClickTimeout;
  100977. private _previousDelayedSimpleClickTimeout;
  100978. private _meshPickProceed;
  100979. private _previousButtonPressed;
  100980. private _currentPickResult;
  100981. private _previousPickResult;
  100982. private _totalPointersPressed;
  100983. private _doubleClickOccured;
  100984. private _pointerOverMesh;
  100985. private _pickedDownMesh;
  100986. private _pickedUpMesh;
  100987. private _pointerX;
  100988. private _pointerY;
  100989. private _unTranslatedPointerX;
  100990. private _unTranslatedPointerY;
  100991. private _startingPointerPosition;
  100992. private _previousStartingPointerPosition;
  100993. private _startingPointerTime;
  100994. private _previousStartingPointerTime;
  100995. private _pointerCaptures;
  100996. private _onKeyDown;
  100997. private _onKeyUp;
  100998. private _onCanvasFocusObserver;
  100999. private _onCanvasBlurObserver;
  101000. private _scene;
  101001. /**
  101002. * Creates a new InputManager
  101003. * @param scene defines the hosting scene
  101004. */
  101005. constructor(scene: Scene);
  101006. /**
  101007. * Gets the mesh that is currently under the pointer
  101008. */
  101009. readonly meshUnderPointer: Nullable<AbstractMesh>;
  101010. /**
  101011. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  101012. */
  101013. readonly unTranslatedPointer: Vector2;
  101014. /**
  101015. * Gets or sets the current on-screen X position of the pointer
  101016. */
  101017. pointerX: number;
  101018. /**
  101019. * Gets or sets the current on-screen Y position of the pointer
  101020. */
  101021. pointerY: number;
  101022. private _updatePointerPosition;
  101023. private _processPointerMove;
  101024. private _setRayOnPointerInfo;
  101025. private _checkPrePointerObservable;
  101026. /**
  101027. * Use this method to simulate a pointer move on a mesh
  101028. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101029. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101030. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101031. */
  101032. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  101033. /**
  101034. * Use this method to simulate a pointer down on a mesh
  101035. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101036. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101037. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101038. */
  101039. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  101040. private _processPointerDown;
  101041. /** @hidden */
  101042. _isPointerSwiping(): boolean;
  101043. /**
  101044. * Use this method to simulate a pointer up on a mesh
  101045. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101046. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101047. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101048. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  101049. */
  101050. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  101051. private _processPointerUp;
  101052. /**
  101053. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  101054. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  101055. * @returns true if the pointer was captured
  101056. */
  101057. isPointerCaptured(pointerId?: number): boolean;
  101058. /**
  101059. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  101060. * @param attachUp defines if you want to attach events to pointerup
  101061. * @param attachDown defines if you want to attach events to pointerdown
  101062. * @param attachMove defines if you want to attach events to pointermove
  101063. */
  101064. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  101065. /**
  101066. * Detaches all event handlers
  101067. */
  101068. detachControl(): void;
  101069. /**
  101070. * Force the value of meshUnderPointer
  101071. * @param mesh defines the mesh to use
  101072. */
  101073. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101074. /**
  101075. * Gets the mesh under the pointer
  101076. * @returns a Mesh or null if no mesh is under the pointer
  101077. */
  101078. getPointerOverMesh(): Nullable<AbstractMesh>;
  101079. }
  101080. }
  101081. declare module BABYLON {
  101082. /**
  101083. * Helper class used to generate session unique ID
  101084. */
  101085. export class UniqueIdGenerator {
  101086. private static _UniqueIdCounter;
  101087. /**
  101088. * Gets an unique (relatively to the current scene) Id
  101089. */
  101090. static readonly UniqueId: number;
  101091. }
  101092. }
  101093. declare module BABYLON {
  101094. /**
  101095. * This class defines the direct association between an animation and a target
  101096. */
  101097. export class TargetedAnimation {
  101098. /**
  101099. * Animation to perform
  101100. */
  101101. animation: Animation;
  101102. /**
  101103. * Target to animate
  101104. */
  101105. target: any;
  101106. /**
  101107. * Serialize the object
  101108. * @returns the JSON object representing the current entity
  101109. */
  101110. serialize(): any;
  101111. }
  101112. /**
  101113. * Use this class to create coordinated animations on multiple targets
  101114. */
  101115. export class AnimationGroup implements IDisposable {
  101116. /** The name of the animation group */
  101117. name: string;
  101118. private _scene;
  101119. private _targetedAnimations;
  101120. private _animatables;
  101121. private _from;
  101122. private _to;
  101123. private _isStarted;
  101124. private _isPaused;
  101125. private _speedRatio;
  101126. private _loopAnimation;
  101127. /**
  101128. * Gets or sets the unique id of the node
  101129. */
  101130. uniqueId: number;
  101131. /**
  101132. * This observable will notify when one animation have ended
  101133. */
  101134. onAnimationEndObservable: Observable<TargetedAnimation>;
  101135. /**
  101136. * Observer raised when one animation loops
  101137. */
  101138. onAnimationLoopObservable: Observable<TargetedAnimation>;
  101139. /**
  101140. * Observer raised when all animations have looped
  101141. */
  101142. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  101143. /**
  101144. * This observable will notify when all animations have ended.
  101145. */
  101146. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  101147. /**
  101148. * This observable will notify when all animations have paused.
  101149. */
  101150. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  101151. /**
  101152. * This observable will notify when all animations are playing.
  101153. */
  101154. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  101155. /**
  101156. * Gets the first frame
  101157. */
  101158. readonly from: number;
  101159. /**
  101160. * Gets the last frame
  101161. */
  101162. readonly to: number;
  101163. /**
  101164. * Define if the animations are started
  101165. */
  101166. readonly isStarted: boolean;
  101167. /**
  101168. * Gets a value indicating that the current group is playing
  101169. */
  101170. readonly isPlaying: boolean;
  101171. /**
  101172. * Gets or sets the speed ratio to use for all animations
  101173. */
  101174. /**
  101175. * Gets or sets the speed ratio to use for all animations
  101176. */
  101177. speedRatio: number;
  101178. /**
  101179. * Gets or sets if all animations should loop or not
  101180. */
  101181. loopAnimation: boolean;
  101182. /**
  101183. * Gets the targeted animations for this animation group
  101184. */
  101185. readonly targetedAnimations: Array<TargetedAnimation>;
  101186. /**
  101187. * returning the list of animatables controlled by this animation group.
  101188. */
  101189. readonly animatables: Array<Animatable>;
  101190. /**
  101191. * Instantiates a new Animation Group.
  101192. * This helps managing several animations at once.
  101193. * @see http://doc.babylonjs.com/how_to/group
  101194. * @param name Defines the name of the group
  101195. * @param scene Defines the scene the group belongs to
  101196. */
  101197. constructor(
  101198. /** The name of the animation group */
  101199. name: string, scene?: Nullable<Scene>);
  101200. /**
  101201. * Add an animation (with its target) in the group
  101202. * @param animation defines the animation we want to add
  101203. * @param target defines the target of the animation
  101204. * @returns the TargetedAnimation object
  101205. */
  101206. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  101207. /**
  101208. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  101209. * It can add constant keys at begin or end
  101210. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  101211. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  101212. * @returns the animation group
  101213. */
  101214. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  101215. private _animationLoopCount;
  101216. private _animationLoopFlags;
  101217. private _processLoop;
  101218. /**
  101219. * Start all animations on given targets
  101220. * @param loop defines if animations must loop
  101221. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  101222. * @param from defines the from key (optional)
  101223. * @param to defines the to key (optional)
  101224. * @returns the current animation group
  101225. */
  101226. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  101227. /**
  101228. * Pause all animations
  101229. * @returns the animation group
  101230. */
  101231. pause(): AnimationGroup;
  101232. /**
  101233. * Play all animations to initial state
  101234. * This function will start() the animations if they were not started or will restart() them if they were paused
  101235. * @param loop defines if animations must loop
  101236. * @returns the animation group
  101237. */
  101238. play(loop?: boolean): AnimationGroup;
  101239. /**
  101240. * Reset all animations to initial state
  101241. * @returns the animation group
  101242. */
  101243. reset(): AnimationGroup;
  101244. /**
  101245. * Restart animations from key 0
  101246. * @returns the animation group
  101247. */
  101248. restart(): AnimationGroup;
  101249. /**
  101250. * Stop all animations
  101251. * @returns the animation group
  101252. */
  101253. stop(): AnimationGroup;
  101254. /**
  101255. * Set animation weight for all animatables
  101256. * @param weight defines the weight to use
  101257. * @return the animationGroup
  101258. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  101259. */
  101260. setWeightForAllAnimatables(weight: number): AnimationGroup;
  101261. /**
  101262. * Synchronize and normalize all animatables with a source animatable
  101263. * @param root defines the root animatable to synchronize with
  101264. * @return the animationGroup
  101265. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  101266. */
  101267. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  101268. /**
  101269. * Goes to a specific frame in this animation group
  101270. * @param frame the frame number to go to
  101271. * @return the animationGroup
  101272. */
  101273. goToFrame(frame: number): AnimationGroup;
  101274. /**
  101275. * Dispose all associated resources
  101276. */
  101277. dispose(): void;
  101278. private _checkAnimationGroupEnded;
  101279. /**
  101280. * Clone the current animation group and returns a copy
  101281. * @param newName defines the name of the new group
  101282. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  101283. * @returns the new aniamtion group
  101284. */
  101285. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  101286. /**
  101287. * Serializes the animationGroup to an object
  101288. * @returns Serialized object
  101289. */
  101290. serialize(): any;
  101291. /**
  101292. * Returns a new AnimationGroup object parsed from the source provided.
  101293. * @param parsedAnimationGroup defines the source
  101294. * @param scene defines the scene that will receive the animationGroup
  101295. * @returns a new AnimationGroup
  101296. */
  101297. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  101298. /**
  101299. * Returns the string "AnimationGroup"
  101300. * @returns "AnimationGroup"
  101301. */
  101302. getClassName(): string;
  101303. /**
  101304. * Creates a detailled string about the object
  101305. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  101306. * @returns a string representing the object
  101307. */
  101308. toString(fullDetails?: boolean): string;
  101309. }
  101310. }
  101311. declare module BABYLON {
  101312. /**
  101313. * Define an interface for all classes that will hold resources
  101314. */
  101315. export interface IDisposable {
  101316. /**
  101317. * Releases all held resources
  101318. */
  101319. dispose(): void;
  101320. }
  101321. /** Interface defining initialization parameters for Scene class */
  101322. export interface SceneOptions {
  101323. /**
  101324. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  101325. * It will improve performance when the number of geometries becomes important.
  101326. */
  101327. useGeometryUniqueIdsMap?: boolean;
  101328. /**
  101329. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  101330. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101331. */
  101332. useMaterialMeshMap?: boolean;
  101333. /**
  101334. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  101335. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101336. */
  101337. useClonedMeshhMap?: boolean;
  101338. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  101339. virtual?: boolean;
  101340. }
  101341. /**
  101342. * Represents a scene to be rendered by the engine.
  101343. * @see http://doc.babylonjs.com/features/scene
  101344. */
  101345. export class Scene extends AbstractScene implements IAnimatable {
  101346. /** The fog is deactivated */
  101347. static readonly FOGMODE_NONE: number;
  101348. /** The fog density is following an exponential function */
  101349. static readonly FOGMODE_EXP: number;
  101350. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  101351. static readonly FOGMODE_EXP2: number;
  101352. /** The fog density is following a linear function. */
  101353. static readonly FOGMODE_LINEAR: number;
  101354. /**
  101355. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  101356. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101357. */
  101358. static MinDeltaTime: number;
  101359. /**
  101360. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  101361. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101362. */
  101363. static MaxDeltaTime: number;
  101364. /**
  101365. * Factory used to create the default material.
  101366. * @param name The name of the material to create
  101367. * @param scene The scene to create the material for
  101368. * @returns The default material
  101369. */
  101370. static DefaultMaterialFactory(scene: Scene): Material;
  101371. /**
  101372. * Factory used to create the a collision coordinator.
  101373. * @returns The collision coordinator
  101374. */
  101375. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  101376. /** @hidden */
  101377. _inputManager: InputManager;
  101378. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  101379. cameraToUseForPointers: Nullable<Camera>;
  101380. /** @hidden */
  101381. readonly _isScene: boolean;
  101382. /**
  101383. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  101384. */
  101385. autoClear: boolean;
  101386. /**
  101387. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  101388. */
  101389. autoClearDepthAndStencil: boolean;
  101390. /**
  101391. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  101392. */
  101393. clearColor: Color4;
  101394. /**
  101395. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  101396. */
  101397. ambientColor: Color3;
  101398. /**
  101399. * This is use to store the default BRDF lookup for PBR materials in your scene.
  101400. * It should only be one of the following (if not the default embedded one):
  101401. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101402. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  101403. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101404. * The material properties need to be setup according to the type of texture in use.
  101405. */
  101406. environmentBRDFTexture: BaseTexture;
  101407. /** @hidden */
  101408. protected _environmentTexture: Nullable<BaseTexture>;
  101409. /**
  101410. * Texture used in all pbr material as the reflection texture.
  101411. * As in the majority of the scene they are the same (exception for multi room and so on),
  101412. * this is easier to reference from here than from all the materials.
  101413. */
  101414. /**
  101415. * Texture used in all pbr material as the reflection texture.
  101416. * As in the majority of the scene they are the same (exception for multi room and so on),
  101417. * this is easier to set here than in all the materials.
  101418. */
  101419. environmentTexture: Nullable<BaseTexture>;
  101420. /** @hidden */
  101421. protected _environmentIntensity: number;
  101422. /**
  101423. * Intensity of the environment in all pbr material.
  101424. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  101425. * As in the majority of the scene they are the same (exception for multi room and so on),
  101426. * this is easier to reference from here than from all the materials.
  101427. */
  101428. /**
  101429. * Intensity of the environment in all pbr material.
  101430. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  101431. * As in the majority of the scene they are the same (exception for multi room and so on),
  101432. * this is easier to set here than in all the materials.
  101433. */
  101434. environmentIntensity: number;
  101435. /** @hidden */
  101436. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101437. /**
  101438. * Default image processing configuration used either in the rendering
  101439. * Forward main pass or through the imageProcessingPostProcess if present.
  101440. * As in the majority of the scene they are the same (exception for multi camera),
  101441. * this is easier to reference from here than from all the materials and post process.
  101442. *
  101443. * No setter as we it is a shared configuration, you can set the values instead.
  101444. */
  101445. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  101446. private _forceWireframe;
  101447. /**
  101448. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  101449. */
  101450. forceWireframe: boolean;
  101451. private _forcePointsCloud;
  101452. /**
  101453. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  101454. */
  101455. forcePointsCloud: boolean;
  101456. /**
  101457. * Gets or sets the active clipplane 1
  101458. */
  101459. clipPlane: Nullable<Plane>;
  101460. /**
  101461. * Gets or sets the active clipplane 2
  101462. */
  101463. clipPlane2: Nullable<Plane>;
  101464. /**
  101465. * Gets or sets the active clipplane 3
  101466. */
  101467. clipPlane3: Nullable<Plane>;
  101468. /**
  101469. * Gets or sets the active clipplane 4
  101470. */
  101471. clipPlane4: Nullable<Plane>;
  101472. /**
  101473. * Gets or sets a boolean indicating if animations are enabled
  101474. */
  101475. animationsEnabled: boolean;
  101476. private _animationPropertiesOverride;
  101477. /**
  101478. * Gets or sets the animation properties override
  101479. */
  101480. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  101481. /**
  101482. * Gets or sets a boolean indicating if a constant deltatime has to be used
  101483. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  101484. */
  101485. useConstantAnimationDeltaTime: boolean;
  101486. /**
  101487. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  101488. * Please note that it requires to run a ray cast through the scene on every frame
  101489. */
  101490. constantlyUpdateMeshUnderPointer: boolean;
  101491. /**
  101492. * Defines the HTML cursor to use when hovering over interactive elements
  101493. */
  101494. hoverCursor: string;
  101495. /**
  101496. * Defines the HTML default cursor to use (empty by default)
  101497. */
  101498. defaultCursor: string;
  101499. /**
  101500. * Defines wether cursors are handled by the scene.
  101501. */
  101502. doNotHandleCursors: boolean;
  101503. /**
  101504. * This is used to call preventDefault() on pointer down
  101505. * in order to block unwanted artifacts like system double clicks
  101506. */
  101507. preventDefaultOnPointerDown: boolean;
  101508. /**
  101509. * This is used to call preventDefault() on pointer up
  101510. * in order to block unwanted artifacts like system double clicks
  101511. */
  101512. preventDefaultOnPointerUp: boolean;
  101513. /**
  101514. * Gets or sets user defined metadata
  101515. */
  101516. metadata: any;
  101517. /**
  101518. * For internal use only. Please do not use.
  101519. */
  101520. reservedDataStore: any;
  101521. /**
  101522. * Gets the name of the plugin used to load this scene (null by default)
  101523. */
  101524. loadingPluginName: string;
  101525. /**
  101526. * Use this array to add regular expressions used to disable offline support for specific urls
  101527. */
  101528. disableOfflineSupportExceptionRules: RegExp[];
  101529. /**
  101530. * An event triggered when the scene is disposed.
  101531. */
  101532. onDisposeObservable: Observable<Scene>;
  101533. private _onDisposeObserver;
  101534. /** Sets a function to be executed when this scene is disposed. */
  101535. onDispose: () => void;
  101536. /**
  101537. * An event triggered before rendering the scene (right after animations and physics)
  101538. */
  101539. onBeforeRenderObservable: Observable<Scene>;
  101540. private _onBeforeRenderObserver;
  101541. /** Sets a function to be executed before rendering this scene */
  101542. beforeRender: Nullable<() => void>;
  101543. /**
  101544. * An event triggered after rendering the scene
  101545. */
  101546. onAfterRenderObservable: Observable<Scene>;
  101547. /**
  101548. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  101549. */
  101550. onAfterRenderCameraObservable: Observable<Camera>;
  101551. private _onAfterRenderObserver;
  101552. /** Sets a function to be executed after rendering this scene */
  101553. afterRender: Nullable<() => void>;
  101554. /**
  101555. * An event triggered before animating the scene
  101556. */
  101557. onBeforeAnimationsObservable: Observable<Scene>;
  101558. /**
  101559. * An event triggered after animations processing
  101560. */
  101561. onAfterAnimationsObservable: Observable<Scene>;
  101562. /**
  101563. * An event triggered before draw calls are ready to be sent
  101564. */
  101565. onBeforeDrawPhaseObservable: Observable<Scene>;
  101566. /**
  101567. * An event triggered after draw calls have been sent
  101568. */
  101569. onAfterDrawPhaseObservable: Observable<Scene>;
  101570. /**
  101571. * An event triggered when the scene is ready
  101572. */
  101573. onReadyObservable: Observable<Scene>;
  101574. /**
  101575. * An event triggered before rendering a camera
  101576. */
  101577. onBeforeCameraRenderObservable: Observable<Camera>;
  101578. private _onBeforeCameraRenderObserver;
  101579. /** Sets a function to be executed before rendering a camera*/
  101580. beforeCameraRender: () => void;
  101581. /**
  101582. * An event triggered after rendering a camera
  101583. */
  101584. onAfterCameraRenderObservable: Observable<Camera>;
  101585. private _onAfterCameraRenderObserver;
  101586. /** Sets a function to be executed after rendering a camera*/
  101587. afterCameraRender: () => void;
  101588. /**
  101589. * An event triggered when active meshes evaluation is about to start
  101590. */
  101591. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  101592. /**
  101593. * An event triggered when active meshes evaluation is done
  101594. */
  101595. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  101596. /**
  101597. * An event triggered when particles rendering is about to start
  101598. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  101599. */
  101600. onBeforeParticlesRenderingObservable: Observable<Scene>;
  101601. /**
  101602. * An event triggered when particles rendering is done
  101603. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  101604. */
  101605. onAfterParticlesRenderingObservable: Observable<Scene>;
  101606. /**
  101607. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  101608. */
  101609. onDataLoadedObservable: Observable<Scene>;
  101610. /**
  101611. * An event triggered when a camera is created
  101612. */
  101613. onNewCameraAddedObservable: Observable<Camera>;
  101614. /**
  101615. * An event triggered when a camera is removed
  101616. */
  101617. onCameraRemovedObservable: Observable<Camera>;
  101618. /**
  101619. * An event triggered when a light is created
  101620. */
  101621. onNewLightAddedObservable: Observable<Light>;
  101622. /**
  101623. * An event triggered when a light is removed
  101624. */
  101625. onLightRemovedObservable: Observable<Light>;
  101626. /**
  101627. * An event triggered when a geometry is created
  101628. */
  101629. onNewGeometryAddedObservable: Observable<Geometry>;
  101630. /**
  101631. * An event triggered when a geometry is removed
  101632. */
  101633. onGeometryRemovedObservable: Observable<Geometry>;
  101634. /**
  101635. * An event triggered when a transform node is created
  101636. */
  101637. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  101638. /**
  101639. * An event triggered when a transform node is removed
  101640. */
  101641. onTransformNodeRemovedObservable: Observable<TransformNode>;
  101642. /**
  101643. * An event triggered when a mesh is created
  101644. */
  101645. onNewMeshAddedObservable: Observable<AbstractMesh>;
  101646. /**
  101647. * An event triggered when a mesh is removed
  101648. */
  101649. onMeshRemovedObservable: Observable<AbstractMesh>;
  101650. /**
  101651. * An event triggered when a skeleton is created
  101652. */
  101653. onNewSkeletonAddedObservable: Observable<Skeleton>;
  101654. /**
  101655. * An event triggered when a skeleton is removed
  101656. */
  101657. onSkeletonRemovedObservable: Observable<Skeleton>;
  101658. /**
  101659. * An event triggered when a material is created
  101660. */
  101661. onNewMaterialAddedObservable: Observable<Material>;
  101662. /**
  101663. * An event triggered when a material is removed
  101664. */
  101665. onMaterialRemovedObservable: Observable<Material>;
  101666. /**
  101667. * An event triggered when a texture is created
  101668. */
  101669. onNewTextureAddedObservable: Observable<BaseTexture>;
  101670. /**
  101671. * An event triggered when a texture is removed
  101672. */
  101673. onTextureRemovedObservable: Observable<BaseTexture>;
  101674. /**
  101675. * An event triggered when render targets are about to be rendered
  101676. * Can happen multiple times per frame.
  101677. */
  101678. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  101679. /**
  101680. * An event triggered when render targets were rendered.
  101681. * Can happen multiple times per frame.
  101682. */
  101683. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  101684. /**
  101685. * An event triggered before calculating deterministic simulation step
  101686. */
  101687. onBeforeStepObservable: Observable<Scene>;
  101688. /**
  101689. * An event triggered after calculating deterministic simulation step
  101690. */
  101691. onAfterStepObservable: Observable<Scene>;
  101692. /**
  101693. * An event triggered when the activeCamera property is updated
  101694. */
  101695. onActiveCameraChanged: Observable<Scene>;
  101696. /**
  101697. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  101698. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  101699. * 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)
  101700. */
  101701. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  101702. /**
  101703. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  101704. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  101705. * 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)
  101706. */
  101707. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  101708. /**
  101709. * This Observable will when a mesh has been imported into the scene.
  101710. */
  101711. onMeshImportedObservable: Observable<AbstractMesh>;
  101712. /**
  101713. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  101714. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  101715. */
  101716. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  101717. /** @hidden */
  101718. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  101719. /**
  101720. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  101721. */
  101722. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  101723. /**
  101724. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  101725. */
  101726. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  101727. /**
  101728. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  101729. */
  101730. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  101731. /** Callback called when a pointer move is detected */
  101732. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  101733. /** Callback called when a pointer down is detected */
  101734. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  101735. /** Callback called when a pointer up is detected */
  101736. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  101737. /** Callback called when a pointer pick is detected */
  101738. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  101739. /**
  101740. * 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).
  101741. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  101742. */
  101743. onPrePointerObservable: Observable<PointerInfoPre>;
  101744. /**
  101745. * Observable event triggered each time an input event is received from the rendering canvas
  101746. */
  101747. onPointerObservable: Observable<PointerInfo>;
  101748. /**
  101749. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  101750. */
  101751. readonly unTranslatedPointer: Vector2;
  101752. /**
  101753. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  101754. */
  101755. static DragMovementThreshold: number;
  101756. /**
  101757. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  101758. */
  101759. static LongPressDelay: number;
  101760. /**
  101761. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  101762. */
  101763. static DoubleClickDelay: number;
  101764. /** If you need to check double click without raising a single click at first click, enable this flag */
  101765. static ExclusiveDoubleClickMode: boolean;
  101766. /** @hidden */
  101767. _mirroredCameraPosition: Nullable<Vector3>;
  101768. /**
  101769. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  101770. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  101771. */
  101772. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  101773. /**
  101774. * Observable event triggered each time an keyboard event is received from the hosting window
  101775. */
  101776. onKeyboardObservable: Observable<KeyboardInfo>;
  101777. private _useRightHandedSystem;
  101778. /**
  101779. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  101780. */
  101781. useRightHandedSystem: boolean;
  101782. private _timeAccumulator;
  101783. private _currentStepId;
  101784. private _currentInternalStep;
  101785. /**
  101786. * Sets the step Id used by deterministic lock step
  101787. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101788. * @param newStepId defines the step Id
  101789. */
  101790. setStepId(newStepId: number): void;
  101791. /**
  101792. * Gets the step Id used by deterministic lock step
  101793. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101794. * @returns the step Id
  101795. */
  101796. getStepId(): number;
  101797. /**
  101798. * Gets the internal step used by deterministic lock step
  101799. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101800. * @returns the internal step
  101801. */
  101802. getInternalStep(): number;
  101803. private _fogEnabled;
  101804. /**
  101805. * Gets or sets a boolean indicating if fog is enabled on this scene
  101806. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101807. * (Default is true)
  101808. */
  101809. fogEnabled: boolean;
  101810. private _fogMode;
  101811. /**
  101812. * Gets or sets the fog mode to use
  101813. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101814. * | mode | value |
  101815. * | --- | --- |
  101816. * | FOGMODE_NONE | 0 |
  101817. * | FOGMODE_EXP | 1 |
  101818. * | FOGMODE_EXP2 | 2 |
  101819. * | FOGMODE_LINEAR | 3 |
  101820. */
  101821. fogMode: number;
  101822. /**
  101823. * Gets or sets the fog color to use
  101824. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101825. * (Default is Color3(0.2, 0.2, 0.3))
  101826. */
  101827. fogColor: Color3;
  101828. /**
  101829. * Gets or sets the fog density to use
  101830. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101831. * (Default is 0.1)
  101832. */
  101833. fogDensity: number;
  101834. /**
  101835. * Gets or sets the fog start distance to use
  101836. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101837. * (Default is 0)
  101838. */
  101839. fogStart: number;
  101840. /**
  101841. * Gets or sets the fog end distance to use
  101842. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101843. * (Default is 1000)
  101844. */
  101845. fogEnd: number;
  101846. private _shadowsEnabled;
  101847. /**
  101848. * Gets or sets a boolean indicating if shadows are enabled on this scene
  101849. */
  101850. shadowsEnabled: boolean;
  101851. private _lightsEnabled;
  101852. /**
  101853. * Gets or sets a boolean indicating if lights are enabled on this scene
  101854. */
  101855. lightsEnabled: boolean;
  101856. /** All of the active cameras added to this scene. */
  101857. activeCameras: Camera[];
  101858. /** @hidden */
  101859. _activeCamera: Nullable<Camera>;
  101860. /** Gets or sets the current active camera */
  101861. activeCamera: Nullable<Camera>;
  101862. private _defaultMaterial;
  101863. /** The default material used on meshes when no material is affected */
  101864. /** The default material used on meshes when no material is affected */
  101865. defaultMaterial: Material;
  101866. private _texturesEnabled;
  101867. /**
  101868. * Gets or sets a boolean indicating if textures are enabled on this scene
  101869. */
  101870. texturesEnabled: boolean;
  101871. /**
  101872. * Gets or sets a boolean indicating if particles are enabled on this scene
  101873. */
  101874. particlesEnabled: boolean;
  101875. /**
  101876. * Gets or sets a boolean indicating if sprites are enabled on this scene
  101877. */
  101878. spritesEnabled: boolean;
  101879. private _skeletonsEnabled;
  101880. /**
  101881. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  101882. */
  101883. skeletonsEnabled: boolean;
  101884. /**
  101885. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  101886. */
  101887. lensFlaresEnabled: boolean;
  101888. /**
  101889. * Gets or sets a boolean indicating if collisions are enabled on this scene
  101890. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101891. */
  101892. collisionsEnabled: boolean;
  101893. private _collisionCoordinator;
  101894. /** @hidden */
  101895. readonly collisionCoordinator: ICollisionCoordinator;
  101896. /**
  101897. * Defines the gravity applied to this scene (used only for collisions)
  101898. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101899. */
  101900. gravity: Vector3;
  101901. /**
  101902. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  101903. */
  101904. postProcessesEnabled: boolean;
  101905. /**
  101906. * The list of postprocesses added to the scene
  101907. */
  101908. postProcesses: PostProcess[];
  101909. /**
  101910. * Gets the current postprocess manager
  101911. */
  101912. postProcessManager: PostProcessManager;
  101913. /**
  101914. * Gets or sets a boolean indicating if render targets are enabled on this scene
  101915. */
  101916. renderTargetsEnabled: boolean;
  101917. /**
  101918. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  101919. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  101920. */
  101921. dumpNextRenderTargets: boolean;
  101922. /**
  101923. * The list of user defined render targets added to the scene
  101924. */
  101925. customRenderTargets: RenderTargetTexture[];
  101926. /**
  101927. * Defines if texture loading must be delayed
  101928. * If true, textures will only be loaded when they need to be rendered
  101929. */
  101930. useDelayedTextureLoading: boolean;
  101931. /**
  101932. * Gets the list of meshes imported to the scene through SceneLoader
  101933. */
  101934. importedMeshesFiles: String[];
  101935. /**
  101936. * Gets or sets a boolean indicating if probes are enabled on this scene
  101937. */
  101938. probesEnabled: boolean;
  101939. /**
  101940. * Gets or sets the current offline provider to use to store scene data
  101941. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  101942. */
  101943. offlineProvider: IOfflineProvider;
  101944. /**
  101945. * Gets or sets the action manager associated with the scene
  101946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101947. */
  101948. actionManager: AbstractActionManager;
  101949. private _meshesForIntersections;
  101950. /**
  101951. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  101952. */
  101953. proceduralTexturesEnabled: boolean;
  101954. private _engine;
  101955. private _totalVertices;
  101956. /** @hidden */
  101957. _activeIndices: PerfCounter;
  101958. /** @hidden */
  101959. _activeParticles: PerfCounter;
  101960. /** @hidden */
  101961. _activeBones: PerfCounter;
  101962. private _animationRatio;
  101963. /** @hidden */
  101964. _animationTimeLast: number;
  101965. /** @hidden */
  101966. _animationTime: number;
  101967. /**
  101968. * Gets or sets a general scale for animation speed
  101969. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  101970. */
  101971. animationTimeScale: number;
  101972. /** @hidden */
  101973. _cachedMaterial: Nullable<Material>;
  101974. /** @hidden */
  101975. _cachedEffect: Nullable<Effect>;
  101976. /** @hidden */
  101977. _cachedVisibility: Nullable<number>;
  101978. private _renderId;
  101979. private _frameId;
  101980. private _executeWhenReadyTimeoutId;
  101981. private _intermediateRendering;
  101982. private _viewUpdateFlag;
  101983. private _projectionUpdateFlag;
  101984. /** @hidden */
  101985. _toBeDisposed: Nullable<IDisposable>[];
  101986. private _activeRequests;
  101987. /** @hidden */
  101988. _pendingData: any[];
  101989. private _isDisposed;
  101990. /**
  101991. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  101992. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  101993. */
  101994. dispatchAllSubMeshesOfActiveMeshes: boolean;
  101995. private _activeMeshes;
  101996. private _processedMaterials;
  101997. private _renderTargets;
  101998. /** @hidden */
  101999. _activeParticleSystems: SmartArray<IParticleSystem>;
  102000. private _activeSkeletons;
  102001. private _softwareSkinnedMeshes;
  102002. private _renderingManager;
  102003. /** @hidden */
  102004. _activeAnimatables: Animatable[];
  102005. private _transformMatrix;
  102006. private _sceneUbo;
  102007. /** @hidden */
  102008. _viewMatrix: Matrix;
  102009. private _projectionMatrix;
  102010. /** @hidden */
  102011. _forcedViewPosition: Nullable<Vector3>;
  102012. /** @hidden */
  102013. _frustumPlanes: Plane[];
  102014. /**
  102015. * Gets the list of frustum planes (built from the active camera)
  102016. */
  102017. readonly frustumPlanes: Plane[];
  102018. /**
  102019. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  102020. * This is useful if there are more lights that the maximum simulteanous authorized
  102021. */
  102022. requireLightSorting: boolean;
  102023. /** @hidden */
  102024. readonly useMaterialMeshMap: boolean;
  102025. /** @hidden */
  102026. readonly useClonedMeshhMap: boolean;
  102027. private _externalData;
  102028. private _uid;
  102029. /**
  102030. * @hidden
  102031. * Backing store of defined scene components.
  102032. */
  102033. _components: ISceneComponent[];
  102034. /**
  102035. * @hidden
  102036. * Backing store of defined scene components.
  102037. */
  102038. _serializableComponents: ISceneSerializableComponent[];
  102039. /**
  102040. * List of components to register on the next registration step.
  102041. */
  102042. private _transientComponents;
  102043. /**
  102044. * Registers the transient components if needed.
  102045. */
  102046. private _registerTransientComponents;
  102047. /**
  102048. * @hidden
  102049. * Add a component to the scene.
  102050. * Note that the ccomponent could be registered on th next frame if this is called after
  102051. * the register component stage.
  102052. * @param component Defines the component to add to the scene
  102053. */
  102054. _addComponent(component: ISceneComponent): void;
  102055. /**
  102056. * @hidden
  102057. * Gets a component from the scene.
  102058. * @param name defines the name of the component to retrieve
  102059. * @returns the component or null if not present
  102060. */
  102061. _getComponent(name: string): Nullable<ISceneComponent>;
  102062. /**
  102063. * @hidden
  102064. * Defines the actions happening before camera updates.
  102065. */
  102066. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  102067. /**
  102068. * @hidden
  102069. * Defines the actions happening before clear the canvas.
  102070. */
  102071. _beforeClearStage: Stage<SimpleStageAction>;
  102072. /**
  102073. * @hidden
  102074. * Defines the actions when collecting render targets for the frame.
  102075. */
  102076. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102077. /**
  102078. * @hidden
  102079. * Defines the actions happening for one camera in the frame.
  102080. */
  102081. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102082. /**
  102083. * @hidden
  102084. * Defines the actions happening during the per mesh ready checks.
  102085. */
  102086. _isReadyForMeshStage: Stage<MeshStageAction>;
  102087. /**
  102088. * @hidden
  102089. * Defines the actions happening before evaluate active mesh checks.
  102090. */
  102091. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  102092. /**
  102093. * @hidden
  102094. * Defines the actions happening during the evaluate sub mesh checks.
  102095. */
  102096. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  102097. /**
  102098. * @hidden
  102099. * Defines the actions happening during the active mesh stage.
  102100. */
  102101. _activeMeshStage: Stage<ActiveMeshStageAction>;
  102102. /**
  102103. * @hidden
  102104. * Defines the actions happening during the per camera render target step.
  102105. */
  102106. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  102107. /**
  102108. * @hidden
  102109. * Defines the actions happening just before the active camera is drawing.
  102110. */
  102111. _beforeCameraDrawStage: Stage<CameraStageAction>;
  102112. /**
  102113. * @hidden
  102114. * Defines the actions happening just before a render target is drawing.
  102115. */
  102116. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102117. /**
  102118. * @hidden
  102119. * Defines the actions happening just before a rendering group is drawing.
  102120. */
  102121. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102122. /**
  102123. * @hidden
  102124. * Defines the actions happening just before a mesh is drawing.
  102125. */
  102126. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102127. /**
  102128. * @hidden
  102129. * Defines the actions happening just after a mesh has been drawn.
  102130. */
  102131. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102132. /**
  102133. * @hidden
  102134. * Defines the actions happening just after a rendering group has been drawn.
  102135. */
  102136. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102137. /**
  102138. * @hidden
  102139. * Defines the actions happening just after the active camera has been drawn.
  102140. */
  102141. _afterCameraDrawStage: Stage<CameraStageAction>;
  102142. /**
  102143. * @hidden
  102144. * Defines the actions happening just after a render target has been drawn.
  102145. */
  102146. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102147. /**
  102148. * @hidden
  102149. * Defines the actions happening just after rendering all cameras and computing intersections.
  102150. */
  102151. _afterRenderStage: Stage<SimpleStageAction>;
  102152. /**
  102153. * @hidden
  102154. * Defines the actions happening when a pointer move event happens.
  102155. */
  102156. _pointerMoveStage: Stage<PointerMoveStageAction>;
  102157. /**
  102158. * @hidden
  102159. * Defines the actions happening when a pointer down event happens.
  102160. */
  102161. _pointerDownStage: Stage<PointerUpDownStageAction>;
  102162. /**
  102163. * @hidden
  102164. * Defines the actions happening when a pointer up event happens.
  102165. */
  102166. _pointerUpStage: Stage<PointerUpDownStageAction>;
  102167. /**
  102168. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  102169. */
  102170. private geometriesByUniqueId;
  102171. /**
  102172. * Creates a new Scene
  102173. * @param engine defines the engine to use to render this scene
  102174. * @param options defines the scene options
  102175. */
  102176. constructor(engine: Engine, options?: SceneOptions);
  102177. /**
  102178. * Gets a string idenfifying the name of the class
  102179. * @returns "Scene" string
  102180. */
  102181. getClassName(): string;
  102182. private _defaultMeshCandidates;
  102183. /**
  102184. * @hidden
  102185. */
  102186. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  102187. private _defaultSubMeshCandidates;
  102188. /**
  102189. * @hidden
  102190. */
  102191. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  102192. /**
  102193. * Sets the default candidate providers for the scene.
  102194. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  102195. * and getCollidingSubMeshCandidates to their default function
  102196. */
  102197. setDefaultCandidateProviders(): void;
  102198. /**
  102199. * Gets the mesh that is currently under the pointer
  102200. */
  102201. readonly meshUnderPointer: Nullable<AbstractMesh>;
  102202. /**
  102203. * Gets or sets the current on-screen X position of the pointer
  102204. */
  102205. pointerX: number;
  102206. /**
  102207. * Gets or sets the current on-screen Y position of the pointer
  102208. */
  102209. pointerY: number;
  102210. /**
  102211. * Gets the cached material (ie. the latest rendered one)
  102212. * @returns the cached material
  102213. */
  102214. getCachedMaterial(): Nullable<Material>;
  102215. /**
  102216. * Gets the cached effect (ie. the latest rendered one)
  102217. * @returns the cached effect
  102218. */
  102219. getCachedEffect(): Nullable<Effect>;
  102220. /**
  102221. * Gets the cached visibility state (ie. the latest rendered one)
  102222. * @returns the cached visibility state
  102223. */
  102224. getCachedVisibility(): Nullable<number>;
  102225. /**
  102226. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  102227. * @param material defines the current material
  102228. * @param effect defines the current effect
  102229. * @param visibility defines the current visibility state
  102230. * @returns true if one parameter is not cached
  102231. */
  102232. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  102233. /**
  102234. * Gets the engine associated with the scene
  102235. * @returns an Engine
  102236. */
  102237. getEngine(): Engine;
  102238. /**
  102239. * Gets the total number of vertices rendered per frame
  102240. * @returns the total number of vertices rendered per frame
  102241. */
  102242. getTotalVertices(): number;
  102243. /**
  102244. * Gets the performance counter for total vertices
  102245. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102246. */
  102247. readonly totalVerticesPerfCounter: PerfCounter;
  102248. /**
  102249. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  102250. * @returns the total number of active indices rendered per frame
  102251. */
  102252. getActiveIndices(): number;
  102253. /**
  102254. * Gets the performance counter for active indices
  102255. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102256. */
  102257. readonly totalActiveIndicesPerfCounter: PerfCounter;
  102258. /**
  102259. * Gets the total number of active particles rendered per frame
  102260. * @returns the total number of active particles rendered per frame
  102261. */
  102262. getActiveParticles(): number;
  102263. /**
  102264. * Gets the performance counter for active particles
  102265. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102266. */
  102267. readonly activeParticlesPerfCounter: PerfCounter;
  102268. /**
  102269. * Gets the total number of active bones rendered per frame
  102270. * @returns the total number of active bones rendered per frame
  102271. */
  102272. getActiveBones(): number;
  102273. /**
  102274. * Gets the performance counter for active bones
  102275. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102276. */
  102277. readonly activeBonesPerfCounter: PerfCounter;
  102278. /**
  102279. * Gets the array of active meshes
  102280. * @returns an array of AbstractMesh
  102281. */
  102282. getActiveMeshes(): SmartArray<AbstractMesh>;
  102283. /**
  102284. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  102285. * @returns a number
  102286. */
  102287. getAnimationRatio(): number;
  102288. /**
  102289. * Gets an unique Id for the current render phase
  102290. * @returns a number
  102291. */
  102292. getRenderId(): number;
  102293. /**
  102294. * Gets an unique Id for the current frame
  102295. * @returns a number
  102296. */
  102297. getFrameId(): number;
  102298. /** Call this function if you want to manually increment the render Id*/
  102299. incrementRenderId(): void;
  102300. private _createUbo;
  102301. /**
  102302. * Use this method to simulate a pointer move on a mesh
  102303. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102304. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102305. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102306. * @returns the current scene
  102307. */
  102308. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102309. /**
  102310. * Use this method to simulate a pointer down on a mesh
  102311. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102312. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102313. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102314. * @returns the current scene
  102315. */
  102316. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102317. /**
  102318. * Use this method to simulate a pointer up on a mesh
  102319. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102320. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102321. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102322. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  102323. * @returns the current scene
  102324. */
  102325. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  102326. /**
  102327. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  102328. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  102329. * @returns true if the pointer was captured
  102330. */
  102331. isPointerCaptured(pointerId?: number): boolean;
  102332. /**
  102333. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  102334. * @param attachUp defines if you want to attach events to pointerup
  102335. * @param attachDown defines if you want to attach events to pointerdown
  102336. * @param attachMove defines if you want to attach events to pointermove
  102337. */
  102338. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  102339. /** Detaches all event handlers*/
  102340. detachControl(): void;
  102341. /**
  102342. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  102343. * Delay loaded resources are not taking in account
  102344. * @return true if all required resources are ready
  102345. */
  102346. isReady(): boolean;
  102347. /** Resets all cached information relative to material (including effect and visibility) */
  102348. resetCachedMaterial(): void;
  102349. /**
  102350. * Registers a function to be called before every frame render
  102351. * @param func defines the function to register
  102352. */
  102353. registerBeforeRender(func: () => void): void;
  102354. /**
  102355. * Unregisters a function called before every frame render
  102356. * @param func defines the function to unregister
  102357. */
  102358. unregisterBeforeRender(func: () => void): void;
  102359. /**
  102360. * Registers a function to be called after every frame render
  102361. * @param func defines the function to register
  102362. */
  102363. registerAfterRender(func: () => void): void;
  102364. /**
  102365. * Unregisters a function called after every frame render
  102366. * @param func defines the function to unregister
  102367. */
  102368. unregisterAfterRender(func: () => void): void;
  102369. private _executeOnceBeforeRender;
  102370. /**
  102371. * The provided function will run before render once and will be disposed afterwards.
  102372. * A timeout delay can be provided so that the function will be executed in N ms.
  102373. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  102374. * @param func The function to be executed.
  102375. * @param timeout optional delay in ms
  102376. */
  102377. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  102378. /** @hidden */
  102379. _addPendingData(data: any): void;
  102380. /** @hidden */
  102381. _removePendingData(data: any): void;
  102382. /**
  102383. * Returns the number of items waiting to be loaded
  102384. * @returns the number of items waiting to be loaded
  102385. */
  102386. getWaitingItemsCount(): number;
  102387. /**
  102388. * Returns a boolean indicating if the scene is still loading data
  102389. */
  102390. readonly isLoading: boolean;
  102391. /**
  102392. * Registers a function to be executed when the scene is ready
  102393. * @param {Function} func - the function to be executed
  102394. */
  102395. executeWhenReady(func: () => void): void;
  102396. /**
  102397. * Returns a promise that resolves when the scene is ready
  102398. * @returns A promise that resolves when the scene is ready
  102399. */
  102400. whenReadyAsync(): Promise<void>;
  102401. /** @hidden */
  102402. _checkIsReady(): void;
  102403. /**
  102404. * Gets all animatable attached to the scene
  102405. */
  102406. readonly animatables: Animatable[];
  102407. /**
  102408. * Resets the last animation time frame.
  102409. * Useful to override when animations start running when loading a scene for the first time.
  102410. */
  102411. resetLastAnimationTimeFrame(): void;
  102412. /**
  102413. * Gets the current view matrix
  102414. * @returns a Matrix
  102415. */
  102416. getViewMatrix(): Matrix;
  102417. /**
  102418. * Gets the current projection matrix
  102419. * @returns a Matrix
  102420. */
  102421. getProjectionMatrix(): Matrix;
  102422. /**
  102423. * Gets the current transform matrix
  102424. * @returns a Matrix made of View * Projection
  102425. */
  102426. getTransformMatrix(): Matrix;
  102427. /**
  102428. * Sets the current transform matrix
  102429. * @param viewL defines the View matrix to use
  102430. * @param projectionL defines the Projection matrix to use
  102431. * @param viewR defines the right View matrix to use (if provided)
  102432. * @param projectionR defines the right Projection matrix to use (if provided)
  102433. */
  102434. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  102435. /**
  102436. * Gets the uniform buffer used to store scene data
  102437. * @returns a UniformBuffer
  102438. */
  102439. getSceneUniformBuffer(): UniformBuffer;
  102440. /**
  102441. * Gets an unique (relatively to the current scene) Id
  102442. * @returns an unique number for the scene
  102443. */
  102444. getUniqueId(): number;
  102445. /**
  102446. * Add a mesh to the list of scene's meshes
  102447. * @param newMesh defines the mesh to add
  102448. * @param recursive if all child meshes should also be added to the scene
  102449. */
  102450. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  102451. /**
  102452. * Remove a mesh for the list of scene's meshes
  102453. * @param toRemove defines the mesh to remove
  102454. * @param recursive if all child meshes should also be removed from the scene
  102455. * @returns the index where the mesh was in the mesh list
  102456. */
  102457. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  102458. /**
  102459. * Add a transform node to the list of scene's transform nodes
  102460. * @param newTransformNode defines the transform node to add
  102461. */
  102462. addTransformNode(newTransformNode: TransformNode): void;
  102463. /**
  102464. * Remove a transform node for the list of scene's transform nodes
  102465. * @param toRemove defines the transform node to remove
  102466. * @returns the index where the transform node was in the transform node list
  102467. */
  102468. removeTransformNode(toRemove: TransformNode): number;
  102469. /**
  102470. * Remove a skeleton for the list of scene's skeletons
  102471. * @param toRemove defines the skeleton to remove
  102472. * @returns the index where the skeleton was in the skeleton list
  102473. */
  102474. removeSkeleton(toRemove: Skeleton): number;
  102475. /**
  102476. * Remove a morph target for the list of scene's morph targets
  102477. * @param toRemove defines the morph target to remove
  102478. * @returns the index where the morph target was in the morph target list
  102479. */
  102480. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  102481. /**
  102482. * Remove a light for the list of scene's lights
  102483. * @param toRemove defines the light to remove
  102484. * @returns the index where the light was in the light list
  102485. */
  102486. removeLight(toRemove: Light): number;
  102487. /**
  102488. * Remove a camera for the list of scene's cameras
  102489. * @param toRemove defines the camera to remove
  102490. * @returns the index where the camera was in the camera list
  102491. */
  102492. removeCamera(toRemove: Camera): number;
  102493. /**
  102494. * Remove a particle system for the list of scene's particle systems
  102495. * @param toRemove defines the particle system to remove
  102496. * @returns the index where the particle system was in the particle system list
  102497. */
  102498. removeParticleSystem(toRemove: IParticleSystem): number;
  102499. /**
  102500. * Remove a animation for the list of scene's animations
  102501. * @param toRemove defines the animation to remove
  102502. * @returns the index where the animation was in the animation list
  102503. */
  102504. removeAnimation(toRemove: Animation): number;
  102505. /**
  102506. * Will stop the animation of the given target
  102507. * @param target - the target
  102508. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  102509. * @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)
  102510. */
  102511. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  102512. /**
  102513. * Removes the given animation group from this scene.
  102514. * @param toRemove The animation group to remove
  102515. * @returns The index of the removed animation group
  102516. */
  102517. removeAnimationGroup(toRemove: AnimationGroup): number;
  102518. /**
  102519. * Removes the given multi-material from this scene.
  102520. * @param toRemove The multi-material to remove
  102521. * @returns The index of the removed multi-material
  102522. */
  102523. removeMultiMaterial(toRemove: MultiMaterial): number;
  102524. /**
  102525. * Removes the given material from this scene.
  102526. * @param toRemove The material to remove
  102527. * @returns The index of the removed material
  102528. */
  102529. removeMaterial(toRemove: Material): number;
  102530. /**
  102531. * Removes the given action manager from this scene.
  102532. * @param toRemove The action manager to remove
  102533. * @returns The index of the removed action manager
  102534. */
  102535. removeActionManager(toRemove: AbstractActionManager): number;
  102536. /**
  102537. * Removes the given texture from this scene.
  102538. * @param toRemove The texture to remove
  102539. * @returns The index of the removed texture
  102540. */
  102541. removeTexture(toRemove: BaseTexture): number;
  102542. /**
  102543. * Adds the given light to this scene
  102544. * @param newLight The light to add
  102545. */
  102546. addLight(newLight: Light): void;
  102547. /**
  102548. * Sorts the list list based on light priorities
  102549. */
  102550. sortLightsByPriority(): void;
  102551. /**
  102552. * Adds the given camera to this scene
  102553. * @param newCamera The camera to add
  102554. */
  102555. addCamera(newCamera: Camera): void;
  102556. /**
  102557. * Adds the given skeleton to this scene
  102558. * @param newSkeleton The skeleton to add
  102559. */
  102560. addSkeleton(newSkeleton: Skeleton): void;
  102561. /**
  102562. * Adds the given particle system to this scene
  102563. * @param newParticleSystem The particle system to add
  102564. */
  102565. addParticleSystem(newParticleSystem: IParticleSystem): void;
  102566. /**
  102567. * Adds the given animation to this scene
  102568. * @param newAnimation The animation to add
  102569. */
  102570. addAnimation(newAnimation: Animation): void;
  102571. /**
  102572. * Adds the given animation group to this scene.
  102573. * @param newAnimationGroup The animation group to add
  102574. */
  102575. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  102576. /**
  102577. * Adds the given multi-material to this scene
  102578. * @param newMultiMaterial The multi-material to add
  102579. */
  102580. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  102581. /**
  102582. * Adds the given material to this scene
  102583. * @param newMaterial The material to add
  102584. */
  102585. addMaterial(newMaterial: Material): void;
  102586. /**
  102587. * Adds the given morph target to this scene
  102588. * @param newMorphTargetManager The morph target to add
  102589. */
  102590. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  102591. /**
  102592. * Adds the given geometry to this scene
  102593. * @param newGeometry The geometry to add
  102594. */
  102595. addGeometry(newGeometry: Geometry): void;
  102596. /**
  102597. * Adds the given action manager to this scene
  102598. * @param newActionManager The action manager to add
  102599. */
  102600. addActionManager(newActionManager: AbstractActionManager): void;
  102601. /**
  102602. * Adds the given texture to this scene.
  102603. * @param newTexture The texture to add
  102604. */
  102605. addTexture(newTexture: BaseTexture): void;
  102606. /**
  102607. * Switch active camera
  102608. * @param newCamera defines the new active camera
  102609. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  102610. */
  102611. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  102612. /**
  102613. * sets the active camera of the scene using its ID
  102614. * @param id defines the camera's ID
  102615. * @return the new active camera or null if none found.
  102616. */
  102617. setActiveCameraByID(id: string): Nullable<Camera>;
  102618. /**
  102619. * sets the active camera of the scene using its name
  102620. * @param name defines the camera's name
  102621. * @returns the new active camera or null if none found.
  102622. */
  102623. setActiveCameraByName(name: string): Nullable<Camera>;
  102624. /**
  102625. * get an animation group using its name
  102626. * @param name defines the material's name
  102627. * @return the animation group or null if none found.
  102628. */
  102629. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  102630. /**
  102631. * Get a material using its unique id
  102632. * @param uniqueId defines the material's unique id
  102633. * @return the material or null if none found.
  102634. */
  102635. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  102636. /**
  102637. * get a material using its id
  102638. * @param id defines the material's ID
  102639. * @return the material or null if none found.
  102640. */
  102641. getMaterialByID(id: string): Nullable<Material>;
  102642. /**
  102643. * Gets a the last added material using a given id
  102644. * @param id defines the material's ID
  102645. * @return the last material with the given id or null if none found.
  102646. */
  102647. getLastMaterialByID(id: string): Nullable<Material>;
  102648. /**
  102649. * Gets a material using its name
  102650. * @param name defines the material's name
  102651. * @return the material or null if none found.
  102652. */
  102653. getMaterialByName(name: string): Nullable<Material>;
  102654. /**
  102655. * Get a texture using its unique id
  102656. * @param uniqueId defines the texture's unique id
  102657. * @return the texture or null if none found.
  102658. */
  102659. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  102660. /**
  102661. * Gets a camera using its id
  102662. * @param id defines the id to look for
  102663. * @returns the camera or null if not found
  102664. */
  102665. getCameraByID(id: string): Nullable<Camera>;
  102666. /**
  102667. * Gets a camera using its unique id
  102668. * @param uniqueId defines the unique id to look for
  102669. * @returns the camera or null if not found
  102670. */
  102671. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  102672. /**
  102673. * Gets a camera using its name
  102674. * @param name defines the camera's name
  102675. * @return the camera or null if none found.
  102676. */
  102677. getCameraByName(name: string): Nullable<Camera>;
  102678. /**
  102679. * Gets a bone using its id
  102680. * @param id defines the bone's id
  102681. * @return the bone or null if not found
  102682. */
  102683. getBoneByID(id: string): Nullable<Bone>;
  102684. /**
  102685. * Gets a bone using its id
  102686. * @param name defines the bone's name
  102687. * @return the bone or null if not found
  102688. */
  102689. getBoneByName(name: string): Nullable<Bone>;
  102690. /**
  102691. * Gets a light node using its name
  102692. * @param name defines the the light's name
  102693. * @return the light or null if none found.
  102694. */
  102695. getLightByName(name: string): Nullable<Light>;
  102696. /**
  102697. * Gets a light node using its id
  102698. * @param id defines the light's id
  102699. * @return the light or null if none found.
  102700. */
  102701. getLightByID(id: string): Nullable<Light>;
  102702. /**
  102703. * Gets a light node using its scene-generated unique ID
  102704. * @param uniqueId defines the light's unique id
  102705. * @return the light or null if none found.
  102706. */
  102707. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  102708. /**
  102709. * Gets a particle system by id
  102710. * @param id defines the particle system id
  102711. * @return the corresponding system or null if none found
  102712. */
  102713. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  102714. /**
  102715. * Gets a geometry using its ID
  102716. * @param id defines the geometry's id
  102717. * @return the geometry or null if none found.
  102718. */
  102719. getGeometryByID(id: string): Nullable<Geometry>;
  102720. private _getGeometryByUniqueID;
  102721. /**
  102722. * Add a new geometry to this scene
  102723. * @param geometry defines the geometry to be added to the scene.
  102724. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  102725. * @return a boolean defining if the geometry was added or not
  102726. */
  102727. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  102728. /**
  102729. * Removes an existing geometry
  102730. * @param geometry defines the geometry to be removed from the scene
  102731. * @return a boolean defining if the geometry was removed or not
  102732. */
  102733. removeGeometry(geometry: Geometry): boolean;
  102734. /**
  102735. * Gets the list of geometries attached to the scene
  102736. * @returns an array of Geometry
  102737. */
  102738. getGeometries(): Geometry[];
  102739. /**
  102740. * Gets the first added mesh found of a given ID
  102741. * @param id defines the id to search for
  102742. * @return the mesh found or null if not found at all
  102743. */
  102744. getMeshByID(id: string): Nullable<AbstractMesh>;
  102745. /**
  102746. * Gets a list of meshes using their id
  102747. * @param id defines the id to search for
  102748. * @returns a list of meshes
  102749. */
  102750. getMeshesByID(id: string): Array<AbstractMesh>;
  102751. /**
  102752. * Gets the first added transform node found of a given ID
  102753. * @param id defines the id to search for
  102754. * @return the found transform node or null if not found at all.
  102755. */
  102756. getTransformNodeByID(id: string): Nullable<TransformNode>;
  102757. /**
  102758. * Gets a transform node with its auto-generated unique id
  102759. * @param uniqueId efines the unique id to search for
  102760. * @return the found transform node or null if not found at all.
  102761. */
  102762. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  102763. /**
  102764. * Gets a list of transform nodes using their id
  102765. * @param id defines the id to search for
  102766. * @returns a list of transform nodes
  102767. */
  102768. getTransformNodesByID(id: string): Array<TransformNode>;
  102769. /**
  102770. * Gets a mesh with its auto-generated unique id
  102771. * @param uniqueId defines the unique id to search for
  102772. * @return the found mesh or null if not found at all.
  102773. */
  102774. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  102775. /**
  102776. * Gets a the last added mesh using a given id
  102777. * @param id defines the id to search for
  102778. * @return the found mesh or null if not found at all.
  102779. */
  102780. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  102781. /**
  102782. * Gets a the last added node (Mesh, Camera, Light) using a given id
  102783. * @param id defines the id to search for
  102784. * @return the found node or null if not found at all
  102785. */
  102786. getLastEntryByID(id: string): Nullable<Node>;
  102787. /**
  102788. * Gets a node (Mesh, Camera, Light) using a given id
  102789. * @param id defines the id to search for
  102790. * @return the found node or null if not found at all
  102791. */
  102792. getNodeByID(id: string): Nullable<Node>;
  102793. /**
  102794. * Gets a node (Mesh, Camera, Light) using a given name
  102795. * @param name defines the name to search for
  102796. * @return the found node or null if not found at all.
  102797. */
  102798. getNodeByName(name: string): Nullable<Node>;
  102799. /**
  102800. * Gets a mesh using a given name
  102801. * @param name defines the name to search for
  102802. * @return the found mesh or null if not found at all.
  102803. */
  102804. getMeshByName(name: string): Nullable<AbstractMesh>;
  102805. /**
  102806. * Gets a transform node using a given name
  102807. * @param name defines the name to search for
  102808. * @return the found transform node or null if not found at all.
  102809. */
  102810. getTransformNodeByName(name: string): Nullable<TransformNode>;
  102811. /**
  102812. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  102813. * @param id defines the id to search for
  102814. * @return the found skeleton or null if not found at all.
  102815. */
  102816. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  102817. /**
  102818. * Gets a skeleton using a given auto generated unique id
  102819. * @param uniqueId defines the unique id to search for
  102820. * @return the found skeleton or null if not found at all.
  102821. */
  102822. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  102823. /**
  102824. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  102825. * @param id defines the id to search for
  102826. * @return the found skeleton or null if not found at all.
  102827. */
  102828. getSkeletonById(id: string): Nullable<Skeleton>;
  102829. /**
  102830. * Gets a skeleton using a given name
  102831. * @param name defines the name to search for
  102832. * @return the found skeleton or null if not found at all.
  102833. */
  102834. getSkeletonByName(name: string): Nullable<Skeleton>;
  102835. /**
  102836. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  102837. * @param id defines the id to search for
  102838. * @return the found morph target manager or null if not found at all.
  102839. */
  102840. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  102841. /**
  102842. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  102843. * @param id defines the id to search for
  102844. * @return the found morph target or null if not found at all.
  102845. */
  102846. getMorphTargetById(id: string): Nullable<MorphTarget>;
  102847. /**
  102848. * Gets a boolean indicating if the given mesh is active
  102849. * @param mesh defines the mesh to look for
  102850. * @returns true if the mesh is in the active list
  102851. */
  102852. isActiveMesh(mesh: AbstractMesh): boolean;
  102853. /**
  102854. * Return a unique id as a string which can serve as an identifier for the scene
  102855. */
  102856. readonly uid: string;
  102857. /**
  102858. * Add an externaly attached data from its key.
  102859. * This method call will fail and return false, if such key already exists.
  102860. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  102861. * @param key the unique key that identifies the data
  102862. * @param data the data object to associate to the key for this Engine instance
  102863. * @return true if no such key were already present and the data was added successfully, false otherwise
  102864. */
  102865. addExternalData<T>(key: string, data: T): boolean;
  102866. /**
  102867. * Get an externaly attached data from its key
  102868. * @param key the unique key that identifies the data
  102869. * @return the associated data, if present (can be null), or undefined if not present
  102870. */
  102871. getExternalData<T>(key: string): Nullable<T>;
  102872. /**
  102873. * Get an externaly attached data from its key, create it using a factory if it's not already present
  102874. * @param key the unique key that identifies the data
  102875. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  102876. * @return the associated data, can be null if the factory returned null.
  102877. */
  102878. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  102879. /**
  102880. * Remove an externaly attached data from the Engine instance
  102881. * @param key the unique key that identifies the data
  102882. * @return true if the data was successfully removed, false if it doesn't exist
  102883. */
  102884. removeExternalData(key: string): boolean;
  102885. private _evaluateSubMesh;
  102886. /**
  102887. * Clear the processed materials smart array preventing retention point in material dispose.
  102888. */
  102889. freeProcessedMaterials(): void;
  102890. private _preventFreeActiveMeshesAndRenderingGroups;
  102891. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  102892. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  102893. * when disposing several meshes in a row or a hierarchy of meshes.
  102894. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  102895. */
  102896. blockfreeActiveMeshesAndRenderingGroups: boolean;
  102897. /**
  102898. * Clear the active meshes smart array preventing retention point in mesh dispose.
  102899. */
  102900. freeActiveMeshes(): void;
  102901. /**
  102902. * Clear the info related to rendering groups preventing retention points during dispose.
  102903. */
  102904. freeRenderingGroups(): void;
  102905. /** @hidden */
  102906. _isInIntermediateRendering(): boolean;
  102907. /**
  102908. * Lambda returning the list of potentially active meshes.
  102909. */
  102910. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  102911. /**
  102912. * Lambda returning the list of potentially active sub meshes.
  102913. */
  102914. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  102915. /**
  102916. * Lambda returning the list of potentially intersecting sub meshes.
  102917. */
  102918. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  102919. /**
  102920. * Lambda returning the list of potentially colliding sub meshes.
  102921. */
  102922. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  102923. private _activeMeshesFrozen;
  102924. private _skipEvaluateActiveMeshesCompletely;
  102925. /**
  102926. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  102927. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  102928. * @returns the current scene
  102929. */
  102930. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  102931. /**
  102932. * Use this function to restart evaluating active meshes on every frame
  102933. * @returns the current scene
  102934. */
  102935. unfreezeActiveMeshes(): Scene;
  102936. private _evaluateActiveMeshes;
  102937. private _activeMesh;
  102938. /**
  102939. * Update the transform matrix to update from the current active camera
  102940. * @param force defines a boolean used to force the update even if cache is up to date
  102941. */
  102942. updateTransformMatrix(force?: boolean): void;
  102943. private _bindFrameBuffer;
  102944. /** @hidden */
  102945. _allowPostProcessClearColor: boolean;
  102946. /** @hidden */
  102947. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  102948. private _processSubCameras;
  102949. private _checkIntersections;
  102950. /** @hidden */
  102951. _advancePhysicsEngineStep(step: number): void;
  102952. /**
  102953. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  102954. */
  102955. getDeterministicFrameTime: () => number;
  102956. /** @hidden */
  102957. _animate(): void;
  102958. /** Execute all animations (for a frame) */
  102959. animate(): void;
  102960. /**
  102961. * Render the scene
  102962. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  102963. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  102964. */
  102965. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  102966. /**
  102967. * Freeze all materials
  102968. * A frozen material will not be updatable but should be faster to render
  102969. */
  102970. freezeMaterials(): void;
  102971. /**
  102972. * Unfreeze all materials
  102973. * A frozen material will not be updatable but should be faster to render
  102974. */
  102975. unfreezeMaterials(): void;
  102976. /**
  102977. * Releases all held ressources
  102978. */
  102979. dispose(): void;
  102980. /**
  102981. * Gets if the scene is already disposed
  102982. */
  102983. readonly isDisposed: boolean;
  102984. /**
  102985. * Call this function to reduce memory footprint of the scene.
  102986. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  102987. */
  102988. clearCachedVertexData(): void;
  102989. /**
  102990. * This function will remove the local cached buffer data from texture.
  102991. * It will save memory but will prevent the texture from being rebuilt
  102992. */
  102993. cleanCachedTextureBuffer(): void;
  102994. /**
  102995. * Get the world extend vectors with an optional filter
  102996. *
  102997. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  102998. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  102999. */
  103000. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  103001. min: Vector3;
  103002. max: Vector3;
  103003. };
  103004. /**
  103005. * Creates a ray that can be used to pick in the scene
  103006. * @param x defines the x coordinate of the origin (on-screen)
  103007. * @param y defines the y coordinate of the origin (on-screen)
  103008. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  103009. * @param camera defines the camera to use for the picking
  103010. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  103011. * @returns a Ray
  103012. */
  103013. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  103014. /**
  103015. * Creates a ray that can be used to pick in the scene
  103016. * @param x defines the x coordinate of the origin (on-screen)
  103017. * @param y defines the y coordinate of the origin (on-screen)
  103018. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  103019. * @param result defines the ray where to store the picking ray
  103020. * @param camera defines the camera to use for the picking
  103021. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  103022. * @returns the current scene
  103023. */
  103024. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  103025. /**
  103026. * Creates a ray that can be used to pick in the scene
  103027. * @param x defines the x coordinate of the origin (on-screen)
  103028. * @param y defines the y coordinate of the origin (on-screen)
  103029. * @param camera defines the camera to use for the picking
  103030. * @returns a Ray
  103031. */
  103032. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  103033. /**
  103034. * Creates a ray that can be used to pick in the scene
  103035. * @param x defines the x coordinate of the origin (on-screen)
  103036. * @param y defines the y coordinate of the origin (on-screen)
  103037. * @param result defines the ray where to store the picking ray
  103038. * @param camera defines the camera to use for the picking
  103039. * @returns the current scene
  103040. */
  103041. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  103042. /** Launch a ray to try to pick a mesh in the scene
  103043. * @param x position on screen
  103044. * @param y position on screen
  103045. * @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
  103046. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  103047. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103048. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103049. * @returns a PickingInfo
  103050. */
  103051. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103052. /** Use the given ray to pick a mesh in the scene
  103053. * @param ray The ray to use to pick meshes
  103054. * @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
  103055. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  103056. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103057. * @returns a PickingInfo
  103058. */
  103059. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103060. /**
  103061. * Launch a ray to try to pick a mesh in the scene
  103062. * @param x X position on screen
  103063. * @param y Y position on screen
  103064. * @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
  103065. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103066. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103067. * @returns an array of PickingInfo
  103068. */
  103069. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103070. /**
  103071. * Launch a ray to try to pick a mesh in the scene
  103072. * @param ray Ray to use
  103073. * @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
  103074. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103075. * @returns an array of PickingInfo
  103076. */
  103077. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103078. /**
  103079. * Force the value of meshUnderPointer
  103080. * @param mesh defines the mesh to use
  103081. */
  103082. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  103083. /**
  103084. * Gets the mesh under the pointer
  103085. * @returns a Mesh or null if no mesh is under the pointer
  103086. */
  103087. getPointerOverMesh(): Nullable<AbstractMesh>;
  103088. /** @hidden */
  103089. _rebuildGeometries(): void;
  103090. /** @hidden */
  103091. _rebuildTextures(): void;
  103092. private _getByTags;
  103093. /**
  103094. * Get a list of meshes by tags
  103095. * @param tagsQuery defines the tags query to use
  103096. * @param forEach defines a predicate used to filter results
  103097. * @returns an array of Mesh
  103098. */
  103099. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  103100. /**
  103101. * Get a list of cameras by tags
  103102. * @param tagsQuery defines the tags query to use
  103103. * @param forEach defines a predicate used to filter results
  103104. * @returns an array of Camera
  103105. */
  103106. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  103107. /**
  103108. * Get a list of lights by tags
  103109. * @param tagsQuery defines the tags query to use
  103110. * @param forEach defines a predicate used to filter results
  103111. * @returns an array of Light
  103112. */
  103113. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  103114. /**
  103115. * Get a list of materials by tags
  103116. * @param tagsQuery defines the tags query to use
  103117. * @param forEach defines a predicate used to filter results
  103118. * @returns an array of Material
  103119. */
  103120. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  103121. /**
  103122. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  103123. * This allowed control for front to back rendering or reversly depending of the special needs.
  103124. *
  103125. * @param renderingGroupId The rendering group id corresponding to its index
  103126. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  103127. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  103128. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  103129. */
  103130. 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;
  103131. /**
  103132. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  103133. *
  103134. * @param renderingGroupId The rendering group id corresponding to its index
  103135. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103136. * @param depth Automatically clears depth between groups if true and autoClear is true.
  103137. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  103138. */
  103139. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  103140. /**
  103141. * Gets the current auto clear configuration for one rendering group of the rendering
  103142. * manager.
  103143. * @param index the rendering group index to get the information for
  103144. * @returns The auto clear setup for the requested rendering group
  103145. */
  103146. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  103147. private _blockMaterialDirtyMechanism;
  103148. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  103149. blockMaterialDirtyMechanism: boolean;
  103150. /**
  103151. * Will flag all materials as dirty to trigger new shader compilation
  103152. * @param flag defines the flag used to specify which material part must be marked as dirty
  103153. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  103154. */
  103155. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  103156. /** @hidden */
  103157. _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;
  103158. /** @hidden */
  103159. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103160. /** @hidden */
  103161. _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;
  103162. /** @hidden */
  103163. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  103164. /** @hidden */
  103165. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  103166. /** @hidden */
  103167. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103168. }
  103169. }
  103170. declare module BABYLON {
  103171. /**
  103172. * Set of assets to keep when moving a scene into an asset container.
  103173. */
  103174. export class KeepAssets extends AbstractScene {
  103175. }
  103176. /**
  103177. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  103178. */
  103179. export class InstantiatedEntries {
  103180. /**
  103181. * List of new root nodes (eg. nodes with no parent)
  103182. */
  103183. rootNodes: TransformNode[];
  103184. /**
  103185. * List of new skeletons
  103186. */
  103187. skeletons: Skeleton[];
  103188. /**
  103189. * List of new animation groups
  103190. */
  103191. animationGroups: AnimationGroup[];
  103192. }
  103193. /**
  103194. * Container with a set of assets that can be added or removed from a scene.
  103195. */
  103196. export class AssetContainer extends AbstractScene {
  103197. /**
  103198. * The scene the AssetContainer belongs to.
  103199. */
  103200. scene: Scene;
  103201. /**
  103202. * Instantiates an AssetContainer.
  103203. * @param scene The scene the AssetContainer belongs to.
  103204. */
  103205. constructor(scene: Scene);
  103206. /**
  103207. * Instantiate or clone all meshes and add the new ones to the scene.
  103208. * Skeletons and animation groups will all be cloned
  103209. * @param nameFunction defines an optional function used to get new names for clones
  103210. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  103211. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  103212. */
  103213. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  103214. /**
  103215. * Adds all the assets from the container to the scene.
  103216. */
  103217. addAllToScene(): void;
  103218. /**
  103219. * Removes all the assets in the container from the scene
  103220. */
  103221. removeAllFromScene(): void;
  103222. /**
  103223. * Disposes all the assets in the container
  103224. */
  103225. dispose(): void;
  103226. private _moveAssets;
  103227. /**
  103228. * Removes all the assets contained in the scene and adds them to the container.
  103229. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  103230. */
  103231. moveAllFromScene(keepAssets?: KeepAssets): void;
  103232. /**
  103233. * 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.
  103234. * @returns the root mesh
  103235. */
  103236. createRootMesh(): Mesh;
  103237. }
  103238. }
  103239. declare module BABYLON {
  103240. /**
  103241. * Defines how the parser contract is defined.
  103242. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  103243. */
  103244. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  103245. /**
  103246. * Defines how the individual parser contract is defined.
  103247. * These parser can parse an individual asset
  103248. */
  103249. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  103250. /**
  103251. * Base class of the scene acting as a container for the different elements composing a scene.
  103252. * This class is dynamically extended by the different components of the scene increasing
  103253. * flexibility and reducing coupling
  103254. */
  103255. export abstract class AbstractScene {
  103256. /**
  103257. * Stores the list of available parsers in the application.
  103258. */
  103259. private static _BabylonFileParsers;
  103260. /**
  103261. * Stores the list of available individual parsers in the application.
  103262. */
  103263. private static _IndividualBabylonFileParsers;
  103264. /**
  103265. * Adds a parser in the list of available ones
  103266. * @param name Defines the name of the parser
  103267. * @param parser Defines the parser to add
  103268. */
  103269. static AddParser(name: string, parser: BabylonFileParser): void;
  103270. /**
  103271. * Gets a general parser from the list of avaialble ones
  103272. * @param name Defines the name of the parser
  103273. * @returns the requested parser or null
  103274. */
  103275. static GetParser(name: string): Nullable<BabylonFileParser>;
  103276. /**
  103277. * Adds n individual parser in the list of available ones
  103278. * @param name Defines the name of the parser
  103279. * @param parser Defines the parser to add
  103280. */
  103281. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  103282. /**
  103283. * Gets an individual parser from the list of avaialble ones
  103284. * @param name Defines the name of the parser
  103285. * @returns the requested parser or null
  103286. */
  103287. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  103288. /**
  103289. * Parser json data and populate both a scene and its associated container object
  103290. * @param jsonData Defines the data to parse
  103291. * @param scene Defines the scene to parse the data for
  103292. * @param container Defines the container attached to the parsing sequence
  103293. * @param rootUrl Defines the root url of the data
  103294. */
  103295. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  103296. /**
  103297. * Gets the list of root nodes (ie. nodes with no parent)
  103298. */
  103299. rootNodes: Node[];
  103300. /** All of the cameras added to this scene
  103301. * @see http://doc.babylonjs.com/babylon101/cameras
  103302. */
  103303. cameras: Camera[];
  103304. /**
  103305. * All of the lights added to this scene
  103306. * @see http://doc.babylonjs.com/babylon101/lights
  103307. */
  103308. lights: Light[];
  103309. /**
  103310. * All of the (abstract) meshes added to this scene
  103311. */
  103312. meshes: AbstractMesh[];
  103313. /**
  103314. * The list of skeletons added to the scene
  103315. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  103316. */
  103317. skeletons: Skeleton[];
  103318. /**
  103319. * All of the particle systems added to this scene
  103320. * @see http://doc.babylonjs.com/babylon101/particles
  103321. */
  103322. particleSystems: IParticleSystem[];
  103323. /**
  103324. * Gets a list of Animations associated with the scene
  103325. */
  103326. animations: Animation[];
  103327. /**
  103328. * All of the animation groups added to this scene
  103329. * @see http://doc.babylonjs.com/how_to/group
  103330. */
  103331. animationGroups: AnimationGroup[];
  103332. /**
  103333. * All of the multi-materials added to this scene
  103334. * @see http://doc.babylonjs.com/how_to/multi_materials
  103335. */
  103336. multiMaterials: MultiMaterial[];
  103337. /**
  103338. * All of the materials added to this scene
  103339. * In the context of a Scene, it is not supposed to be modified manually.
  103340. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  103341. * Note also that the order of the Material within the array is not significant and might change.
  103342. * @see http://doc.babylonjs.com/babylon101/materials
  103343. */
  103344. materials: Material[];
  103345. /**
  103346. * The list of morph target managers added to the scene
  103347. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  103348. */
  103349. morphTargetManagers: MorphTargetManager[];
  103350. /**
  103351. * The list of geometries used in the scene.
  103352. */
  103353. geometries: Geometry[];
  103354. /**
  103355. * All of the tranform nodes added to this scene
  103356. * In the context of a Scene, it is not supposed to be modified manually.
  103357. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  103358. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  103359. * @see http://doc.babylonjs.com/how_to/transformnode
  103360. */
  103361. transformNodes: TransformNode[];
  103362. /**
  103363. * ActionManagers available on the scene.
  103364. */
  103365. actionManagers: AbstractActionManager[];
  103366. /**
  103367. * Textures to keep.
  103368. */
  103369. textures: BaseTexture[];
  103370. /**
  103371. * Environment texture for the scene
  103372. */
  103373. environmentTexture: Nullable<BaseTexture>;
  103374. }
  103375. }
  103376. declare module BABYLON {
  103377. /**
  103378. * Interface used to define options for Sound class
  103379. */
  103380. export interface ISoundOptions {
  103381. /**
  103382. * Does the sound autoplay once loaded.
  103383. */
  103384. autoplay?: boolean;
  103385. /**
  103386. * Does the sound loop after it finishes playing once.
  103387. */
  103388. loop?: boolean;
  103389. /**
  103390. * Sound's volume
  103391. */
  103392. volume?: number;
  103393. /**
  103394. * Is it a spatial sound?
  103395. */
  103396. spatialSound?: boolean;
  103397. /**
  103398. * Maximum distance to hear that sound
  103399. */
  103400. maxDistance?: number;
  103401. /**
  103402. * Uses user defined attenuation function
  103403. */
  103404. useCustomAttenuation?: boolean;
  103405. /**
  103406. * Define the roll off factor of spatial sounds.
  103407. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103408. */
  103409. rolloffFactor?: number;
  103410. /**
  103411. * Define the reference distance the sound should be heard perfectly.
  103412. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103413. */
  103414. refDistance?: number;
  103415. /**
  103416. * Define the distance attenuation model the sound will follow.
  103417. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103418. */
  103419. distanceModel?: string;
  103420. /**
  103421. * Defines the playback speed (1 by default)
  103422. */
  103423. playbackRate?: number;
  103424. /**
  103425. * Defines if the sound is from a streaming source
  103426. */
  103427. streaming?: boolean;
  103428. /**
  103429. * Defines an optional length (in seconds) inside the sound file
  103430. */
  103431. length?: number;
  103432. /**
  103433. * Defines an optional offset (in seconds) inside the sound file
  103434. */
  103435. offset?: number;
  103436. /**
  103437. * If true, URLs will not be required to state the audio file codec to use.
  103438. */
  103439. skipCodecCheck?: boolean;
  103440. }
  103441. /**
  103442. * Defines a sound that can be played in the application.
  103443. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  103444. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103445. */
  103446. export class Sound {
  103447. /**
  103448. * The name of the sound in the scene.
  103449. */
  103450. name: string;
  103451. /**
  103452. * Does the sound autoplay once loaded.
  103453. */
  103454. autoplay: boolean;
  103455. /**
  103456. * Does the sound loop after it finishes playing once.
  103457. */
  103458. loop: boolean;
  103459. /**
  103460. * Does the sound use a custom attenuation curve to simulate the falloff
  103461. * happening when the source gets further away from the camera.
  103462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103463. */
  103464. useCustomAttenuation: boolean;
  103465. /**
  103466. * The sound track id this sound belongs to.
  103467. */
  103468. soundTrackId: number;
  103469. /**
  103470. * Is this sound currently played.
  103471. */
  103472. isPlaying: boolean;
  103473. /**
  103474. * Is this sound currently paused.
  103475. */
  103476. isPaused: boolean;
  103477. /**
  103478. * Does this sound enables spatial sound.
  103479. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103480. */
  103481. spatialSound: boolean;
  103482. /**
  103483. * Define the reference distance the sound should be heard perfectly.
  103484. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103485. */
  103486. refDistance: number;
  103487. /**
  103488. * Define the roll off factor of spatial sounds.
  103489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103490. */
  103491. rolloffFactor: number;
  103492. /**
  103493. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  103494. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103495. */
  103496. maxDistance: number;
  103497. /**
  103498. * Define the distance attenuation model the sound will follow.
  103499. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103500. */
  103501. distanceModel: string;
  103502. /**
  103503. * @hidden
  103504. * Back Compat
  103505. **/
  103506. onended: () => any;
  103507. /**
  103508. * Observable event when the current playing sound finishes.
  103509. */
  103510. onEndedObservable: Observable<Sound>;
  103511. private _panningModel;
  103512. private _playbackRate;
  103513. private _streaming;
  103514. private _startTime;
  103515. private _startOffset;
  103516. private _position;
  103517. /** @hidden */
  103518. _positionInEmitterSpace: boolean;
  103519. private _localDirection;
  103520. private _volume;
  103521. private _isReadyToPlay;
  103522. private _isDirectional;
  103523. private _readyToPlayCallback;
  103524. private _audioBuffer;
  103525. private _soundSource;
  103526. private _streamingSource;
  103527. private _soundPanner;
  103528. private _soundGain;
  103529. private _inputAudioNode;
  103530. private _outputAudioNode;
  103531. private _coneInnerAngle;
  103532. private _coneOuterAngle;
  103533. private _coneOuterGain;
  103534. private _scene;
  103535. private _connectedTransformNode;
  103536. private _customAttenuationFunction;
  103537. private _registerFunc;
  103538. private _isOutputConnected;
  103539. private _htmlAudioElement;
  103540. private _urlType;
  103541. private _length?;
  103542. private _offset?;
  103543. /** @hidden */
  103544. static _SceneComponentInitialization: (scene: Scene) => void;
  103545. /**
  103546. * Create a sound and attach it to a scene
  103547. * @param name Name of your sound
  103548. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  103549. * @param scene defines the scene the sound belongs to
  103550. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  103551. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  103552. */
  103553. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  103554. /**
  103555. * Release the sound and its associated resources
  103556. */
  103557. dispose(): void;
  103558. /**
  103559. * Gets if the sounds is ready to be played or not.
  103560. * @returns true if ready, otherwise false
  103561. */
  103562. isReady(): boolean;
  103563. private _soundLoaded;
  103564. /**
  103565. * Sets the data of the sound from an audiobuffer
  103566. * @param audioBuffer The audioBuffer containing the data
  103567. */
  103568. setAudioBuffer(audioBuffer: AudioBuffer): void;
  103569. /**
  103570. * Updates the current sounds options such as maxdistance, loop...
  103571. * @param options A JSON object containing values named as the object properties
  103572. */
  103573. updateOptions(options: ISoundOptions): void;
  103574. private _createSpatialParameters;
  103575. private _updateSpatialParameters;
  103576. /**
  103577. * Switch the panning model to HRTF:
  103578. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  103579. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103580. */
  103581. switchPanningModelToHRTF(): void;
  103582. /**
  103583. * Switch the panning model to Equal Power:
  103584. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  103585. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103586. */
  103587. switchPanningModelToEqualPower(): void;
  103588. private _switchPanningModel;
  103589. /**
  103590. * Connect this sound to a sound track audio node like gain...
  103591. * @param soundTrackAudioNode the sound track audio node to connect to
  103592. */
  103593. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  103594. /**
  103595. * Transform this sound into a directional source
  103596. * @param coneInnerAngle Size of the inner cone in degree
  103597. * @param coneOuterAngle Size of the outer cone in degree
  103598. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  103599. */
  103600. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  103601. /**
  103602. * Gets or sets the inner angle for the directional cone.
  103603. */
  103604. /**
  103605. * Gets or sets the inner angle for the directional cone.
  103606. */
  103607. directionalConeInnerAngle: number;
  103608. /**
  103609. * Gets or sets the outer angle for the directional cone.
  103610. */
  103611. /**
  103612. * Gets or sets the outer angle for the directional cone.
  103613. */
  103614. directionalConeOuterAngle: number;
  103615. /**
  103616. * Sets the position of the emitter if spatial sound is enabled
  103617. * @param newPosition Defines the new posisiton
  103618. */
  103619. setPosition(newPosition: Vector3): void;
  103620. /**
  103621. * Sets the local direction of the emitter if spatial sound is enabled
  103622. * @param newLocalDirection Defines the new local direction
  103623. */
  103624. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  103625. private _updateDirection;
  103626. /** @hidden */
  103627. updateDistanceFromListener(): void;
  103628. /**
  103629. * Sets a new custom attenuation function for the sound.
  103630. * @param callback Defines the function used for the attenuation
  103631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103632. */
  103633. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  103634. /**
  103635. * Play the sound
  103636. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  103637. * @param offset (optional) Start the sound at a specific time in seconds
  103638. * @param length (optional) Sound duration (in seconds)
  103639. */
  103640. play(time?: number, offset?: number, length?: number): void;
  103641. private _onended;
  103642. /**
  103643. * Stop the sound
  103644. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  103645. */
  103646. stop(time?: number): void;
  103647. /**
  103648. * Put the sound in pause
  103649. */
  103650. pause(): void;
  103651. /**
  103652. * Sets a dedicated volume for this sounds
  103653. * @param newVolume Define the new volume of the sound
  103654. * @param time Define time for gradual change to new volume
  103655. */
  103656. setVolume(newVolume: number, time?: number): void;
  103657. /**
  103658. * Set the sound play back rate
  103659. * @param newPlaybackRate Define the playback rate the sound should be played at
  103660. */
  103661. setPlaybackRate(newPlaybackRate: number): void;
  103662. /**
  103663. * Gets the volume of the sound.
  103664. * @returns the volume of the sound
  103665. */
  103666. getVolume(): number;
  103667. /**
  103668. * Attach the sound to a dedicated mesh
  103669. * @param transformNode The transform node to connect the sound with
  103670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  103671. */
  103672. attachToMesh(transformNode: TransformNode): void;
  103673. /**
  103674. * Detach the sound from the previously attached mesh
  103675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  103676. */
  103677. detachFromMesh(): void;
  103678. private _onRegisterAfterWorldMatrixUpdate;
  103679. /**
  103680. * Clone the current sound in the scene.
  103681. * @returns the new sound clone
  103682. */
  103683. clone(): Nullable<Sound>;
  103684. /**
  103685. * Gets the current underlying audio buffer containing the data
  103686. * @returns the audio buffer
  103687. */
  103688. getAudioBuffer(): Nullable<AudioBuffer>;
  103689. /**
  103690. * Serializes the Sound in a JSON representation
  103691. * @returns the JSON representation of the sound
  103692. */
  103693. serialize(): any;
  103694. /**
  103695. * Parse a JSON representation of a sound to innstantiate in a given scene
  103696. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  103697. * @param scene Define the scene the new parsed sound should be created in
  103698. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  103699. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  103700. * @returns the newly parsed sound
  103701. */
  103702. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  103703. }
  103704. }
  103705. declare module BABYLON {
  103706. /**
  103707. * This defines an action helpful to play a defined sound on a triggered action.
  103708. */
  103709. export class PlaySoundAction extends Action {
  103710. private _sound;
  103711. /**
  103712. * Instantiate the action
  103713. * @param triggerOptions defines the trigger options
  103714. * @param sound defines the sound to play
  103715. * @param condition defines the trigger related conditions
  103716. */
  103717. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  103718. /** @hidden */
  103719. _prepare(): void;
  103720. /**
  103721. * Execute the action and play the sound.
  103722. */
  103723. execute(): void;
  103724. /**
  103725. * Serializes the actions and its related information.
  103726. * @param parent defines the object to serialize in
  103727. * @returns the serialized object
  103728. */
  103729. serialize(parent: any): any;
  103730. }
  103731. /**
  103732. * This defines an action helpful to stop a defined sound on a triggered action.
  103733. */
  103734. export class StopSoundAction extends Action {
  103735. private _sound;
  103736. /**
  103737. * Instantiate the action
  103738. * @param triggerOptions defines the trigger options
  103739. * @param sound defines the sound to stop
  103740. * @param condition defines the trigger related conditions
  103741. */
  103742. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  103743. /** @hidden */
  103744. _prepare(): void;
  103745. /**
  103746. * Execute the action and stop the sound.
  103747. */
  103748. execute(): void;
  103749. /**
  103750. * Serializes the actions and its related information.
  103751. * @param parent defines the object to serialize in
  103752. * @returns the serialized object
  103753. */
  103754. serialize(parent: any): any;
  103755. }
  103756. }
  103757. declare module BABYLON {
  103758. /**
  103759. * This defines an action responsible to change the value of a property
  103760. * by interpolating between its current value and the newly set one once triggered.
  103761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103762. */
  103763. export class InterpolateValueAction extends Action {
  103764. /**
  103765. * Defines the path of the property where the value should be interpolated
  103766. */
  103767. propertyPath: string;
  103768. /**
  103769. * Defines the target value at the end of the interpolation.
  103770. */
  103771. value: any;
  103772. /**
  103773. * Defines the time it will take for the property to interpolate to the value.
  103774. */
  103775. duration: number;
  103776. /**
  103777. * Defines if the other scene animations should be stopped when the action has been triggered
  103778. */
  103779. stopOtherAnimations?: boolean;
  103780. /**
  103781. * Defines a callback raised once the interpolation animation has been done.
  103782. */
  103783. onInterpolationDone?: () => void;
  103784. /**
  103785. * Observable triggered once the interpolation animation has been done.
  103786. */
  103787. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  103788. private _target;
  103789. private _effectiveTarget;
  103790. private _property;
  103791. /**
  103792. * Instantiate the action
  103793. * @param triggerOptions defines the trigger options
  103794. * @param target defines the object containing the value to interpolate
  103795. * @param propertyPath defines the path to the property in the target object
  103796. * @param value defines the target value at the end of the interpolation
  103797. * @param duration deines the time it will take for the property to interpolate to the value.
  103798. * @param condition defines the trigger related conditions
  103799. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  103800. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  103801. */
  103802. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  103803. /** @hidden */
  103804. _prepare(): void;
  103805. /**
  103806. * Execute the action starts the value interpolation.
  103807. */
  103808. execute(): void;
  103809. /**
  103810. * Serializes the actions and its related information.
  103811. * @param parent defines the object to serialize in
  103812. * @returns the serialized object
  103813. */
  103814. serialize(parent: any): any;
  103815. }
  103816. }
  103817. declare module BABYLON {
  103818. /**
  103819. * Options allowed during the creation of a sound track.
  103820. */
  103821. export interface ISoundTrackOptions {
  103822. /**
  103823. * The volume the sound track should take during creation
  103824. */
  103825. volume?: number;
  103826. /**
  103827. * Define if the sound track is the main sound track of the scene
  103828. */
  103829. mainTrack?: boolean;
  103830. }
  103831. /**
  103832. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  103833. * It will be also used in a future release to apply effects on a specific track.
  103834. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  103835. */
  103836. export class SoundTrack {
  103837. /**
  103838. * The unique identifier of the sound track in the scene.
  103839. */
  103840. id: number;
  103841. /**
  103842. * The list of sounds included in the sound track.
  103843. */
  103844. soundCollection: Array<Sound>;
  103845. private _outputAudioNode;
  103846. private _scene;
  103847. private _connectedAnalyser;
  103848. private _options;
  103849. private _isInitialized;
  103850. /**
  103851. * Creates a new sound track.
  103852. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  103853. * @param scene Define the scene the sound track belongs to
  103854. * @param options
  103855. */
  103856. constructor(scene: Scene, options?: ISoundTrackOptions);
  103857. private _initializeSoundTrackAudioGraph;
  103858. /**
  103859. * Release the sound track and its associated resources
  103860. */
  103861. dispose(): void;
  103862. /**
  103863. * Adds a sound to this sound track
  103864. * @param sound define the cound to add
  103865. * @ignoreNaming
  103866. */
  103867. AddSound(sound: Sound): void;
  103868. /**
  103869. * Removes a sound to this sound track
  103870. * @param sound define the cound to remove
  103871. * @ignoreNaming
  103872. */
  103873. RemoveSound(sound: Sound): void;
  103874. /**
  103875. * Set a global volume for the full sound track.
  103876. * @param newVolume Define the new volume of the sound track
  103877. */
  103878. setVolume(newVolume: number): void;
  103879. /**
  103880. * Switch the panning model to HRTF:
  103881. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  103882. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103883. */
  103884. switchPanningModelToHRTF(): void;
  103885. /**
  103886. * Switch the panning model to Equal Power:
  103887. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  103888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103889. */
  103890. switchPanningModelToEqualPower(): void;
  103891. /**
  103892. * Connect the sound track to an audio analyser allowing some amazing
  103893. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  103894. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  103895. * @param analyser The analyser to connect to the engine
  103896. */
  103897. connectToAnalyser(analyser: Analyser): void;
  103898. }
  103899. }
  103900. declare module BABYLON {
  103901. interface AbstractScene {
  103902. /**
  103903. * The list of sounds used in the scene.
  103904. */
  103905. sounds: Nullable<Array<Sound>>;
  103906. }
  103907. interface Scene {
  103908. /**
  103909. * @hidden
  103910. * Backing field
  103911. */
  103912. _mainSoundTrack: SoundTrack;
  103913. /**
  103914. * The main sound track played by the scene.
  103915. * It cotains your primary collection of sounds.
  103916. */
  103917. mainSoundTrack: SoundTrack;
  103918. /**
  103919. * The list of sound tracks added to the scene
  103920. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103921. */
  103922. soundTracks: Nullable<Array<SoundTrack>>;
  103923. /**
  103924. * Gets a sound using a given name
  103925. * @param name defines the name to search for
  103926. * @return the found sound or null if not found at all.
  103927. */
  103928. getSoundByName(name: string): Nullable<Sound>;
  103929. /**
  103930. * Gets or sets if audio support is enabled
  103931. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103932. */
  103933. audioEnabled: boolean;
  103934. /**
  103935. * Gets or sets if audio will be output to headphones
  103936. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103937. */
  103938. headphone: boolean;
  103939. /**
  103940. * Gets or sets custom audio listener position provider
  103941. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103942. */
  103943. audioListenerPositionProvider: Nullable<() => Vector3>;
  103944. /**
  103945. * Gets or sets a refresh rate when using 3D audio positioning
  103946. */
  103947. audioPositioningRefreshRate: number;
  103948. }
  103949. /**
  103950. * Defines the sound scene component responsible to manage any sounds
  103951. * in a given scene.
  103952. */
  103953. export class AudioSceneComponent implements ISceneSerializableComponent {
  103954. /**
  103955. * The component name helpfull to identify the component in the list of scene components.
  103956. */
  103957. readonly name: string;
  103958. /**
  103959. * The scene the component belongs to.
  103960. */
  103961. scene: Scene;
  103962. private _audioEnabled;
  103963. /**
  103964. * Gets whether audio is enabled or not.
  103965. * Please use related enable/disable method to switch state.
  103966. */
  103967. readonly audioEnabled: boolean;
  103968. private _headphone;
  103969. /**
  103970. * Gets whether audio is outputing to headphone or not.
  103971. * Please use the according Switch methods to change output.
  103972. */
  103973. readonly headphone: boolean;
  103974. /**
  103975. * Gets or sets a refresh rate when using 3D audio positioning
  103976. */
  103977. audioPositioningRefreshRate: number;
  103978. private _audioListenerPositionProvider;
  103979. /**
  103980. * Gets the current audio listener position provider
  103981. */
  103982. /**
  103983. * Sets a custom listener position for all sounds in the scene
  103984. * By default, this is the position of the first active camera
  103985. */
  103986. audioListenerPositionProvider: Nullable<() => Vector3>;
  103987. /**
  103988. * Creates a new instance of the component for the given scene
  103989. * @param scene Defines the scene to register the component in
  103990. */
  103991. constructor(scene: Scene);
  103992. /**
  103993. * Registers the component in a given scene
  103994. */
  103995. register(): void;
  103996. /**
  103997. * Rebuilds the elements related to this component in case of
  103998. * context lost for instance.
  103999. */
  104000. rebuild(): void;
  104001. /**
  104002. * Serializes the component data to the specified json object
  104003. * @param serializationObject The object to serialize to
  104004. */
  104005. serialize(serializationObject: any): void;
  104006. /**
  104007. * Adds all the elements from the container to the scene
  104008. * @param container the container holding the elements
  104009. */
  104010. addFromContainer(container: AbstractScene): void;
  104011. /**
  104012. * Removes all the elements in the container from the scene
  104013. * @param container contains the elements to remove
  104014. * @param dispose if the removed element should be disposed (default: false)
  104015. */
  104016. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  104017. /**
  104018. * Disposes the component and the associated ressources.
  104019. */
  104020. dispose(): void;
  104021. /**
  104022. * Disables audio in the associated scene.
  104023. */
  104024. disableAudio(): void;
  104025. /**
  104026. * Enables audio in the associated scene.
  104027. */
  104028. enableAudio(): void;
  104029. /**
  104030. * Switch audio to headphone output.
  104031. */
  104032. switchAudioModeForHeadphones(): void;
  104033. /**
  104034. * Switch audio to normal speakers.
  104035. */
  104036. switchAudioModeForNormalSpeakers(): void;
  104037. private _cachedCameraDirection;
  104038. private _cachedCameraPosition;
  104039. private _lastCheck;
  104040. private _afterRender;
  104041. }
  104042. }
  104043. declare module BABYLON {
  104044. /**
  104045. * Wraps one or more Sound objects and selects one with random weight for playback.
  104046. */
  104047. export class WeightedSound {
  104048. /** When true a Sound will be selected and played when the current playing Sound completes. */
  104049. loop: boolean;
  104050. private _coneInnerAngle;
  104051. private _coneOuterAngle;
  104052. private _volume;
  104053. /** A Sound is currently playing. */
  104054. isPlaying: boolean;
  104055. /** A Sound is currently paused. */
  104056. isPaused: boolean;
  104057. private _sounds;
  104058. private _weights;
  104059. private _currentIndex?;
  104060. /**
  104061. * Creates a new WeightedSound from the list of sounds given.
  104062. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  104063. * @param sounds Array of Sounds that will be selected from.
  104064. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  104065. */
  104066. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  104067. /**
  104068. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  104069. */
  104070. /**
  104071. * The size of cone in degress for a directional sound in which there will be no attenuation.
  104072. */
  104073. directionalConeInnerAngle: number;
  104074. /**
  104075. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104076. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104077. */
  104078. /**
  104079. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104080. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104081. */
  104082. directionalConeOuterAngle: number;
  104083. /**
  104084. * Playback volume.
  104085. */
  104086. /**
  104087. * Playback volume.
  104088. */
  104089. volume: number;
  104090. private _onended;
  104091. /**
  104092. * Suspend playback
  104093. */
  104094. pause(): void;
  104095. /**
  104096. * Stop playback
  104097. */
  104098. stop(): void;
  104099. /**
  104100. * Start playback.
  104101. * @param startOffset Position the clip head at a specific time in seconds.
  104102. */
  104103. play(startOffset?: number): void;
  104104. }
  104105. }
  104106. declare module BABYLON {
  104107. /**
  104108. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  104109. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104110. */
  104111. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  104112. /**
  104113. * Gets the name of the behavior.
  104114. */
  104115. readonly name: string;
  104116. /**
  104117. * The easing function used by animations
  104118. */
  104119. static EasingFunction: BackEase;
  104120. /**
  104121. * The easing mode used by animations
  104122. */
  104123. static EasingMode: number;
  104124. /**
  104125. * The duration of the animation, in milliseconds
  104126. */
  104127. transitionDuration: number;
  104128. /**
  104129. * Length of the distance animated by the transition when lower radius is reached
  104130. */
  104131. lowerRadiusTransitionRange: number;
  104132. /**
  104133. * Length of the distance animated by the transition when upper radius is reached
  104134. */
  104135. upperRadiusTransitionRange: number;
  104136. private _autoTransitionRange;
  104137. /**
  104138. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104139. */
  104140. /**
  104141. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104142. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  104143. */
  104144. autoTransitionRange: boolean;
  104145. private _attachedCamera;
  104146. private _onAfterCheckInputsObserver;
  104147. private _onMeshTargetChangedObserver;
  104148. /**
  104149. * Initializes the behavior.
  104150. */
  104151. init(): void;
  104152. /**
  104153. * Attaches the behavior to its arc rotate camera.
  104154. * @param camera Defines the camera to attach the behavior to
  104155. */
  104156. attach(camera: ArcRotateCamera): void;
  104157. /**
  104158. * Detaches the behavior from its current arc rotate camera.
  104159. */
  104160. detach(): void;
  104161. private _radiusIsAnimating;
  104162. private _radiusBounceTransition;
  104163. private _animatables;
  104164. private _cachedWheelPrecision;
  104165. /**
  104166. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  104167. * @param radiusLimit The limit to check against.
  104168. * @return Bool to indicate if at limit.
  104169. */
  104170. private _isRadiusAtLimit;
  104171. /**
  104172. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  104173. * @param radiusDelta The delta by which to animate to. Can be negative.
  104174. */
  104175. private _applyBoundRadiusAnimation;
  104176. /**
  104177. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  104178. */
  104179. protected _clearAnimationLocks(): void;
  104180. /**
  104181. * Stops and removes all animations that have been applied to the camera
  104182. */
  104183. stopAllAnimations(): void;
  104184. }
  104185. }
  104186. declare module BABYLON {
  104187. /**
  104188. * 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.
  104189. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104190. */
  104191. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  104192. /**
  104193. * Gets the name of the behavior.
  104194. */
  104195. readonly name: string;
  104196. private _mode;
  104197. private _radiusScale;
  104198. private _positionScale;
  104199. private _defaultElevation;
  104200. private _elevationReturnTime;
  104201. private _elevationReturnWaitTime;
  104202. private _zoomStopsAnimation;
  104203. private _framingTime;
  104204. /**
  104205. * The easing function used by animations
  104206. */
  104207. static EasingFunction: ExponentialEase;
  104208. /**
  104209. * The easing mode used by animations
  104210. */
  104211. static EasingMode: number;
  104212. /**
  104213. * Sets the current mode used by the behavior
  104214. */
  104215. /**
  104216. * Gets current mode used by the behavior.
  104217. */
  104218. mode: number;
  104219. /**
  104220. * Sets the scale applied to the radius (1 by default)
  104221. */
  104222. /**
  104223. * Gets the scale applied to the radius
  104224. */
  104225. radiusScale: number;
  104226. /**
  104227. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  104228. */
  104229. /**
  104230. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  104231. */
  104232. positionScale: number;
  104233. /**
  104234. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  104235. * behaviour is triggered, in radians.
  104236. */
  104237. /**
  104238. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  104239. * behaviour is triggered, in radians.
  104240. */
  104241. defaultElevation: number;
  104242. /**
  104243. * Sets the time (in milliseconds) taken to return to the default beta position.
  104244. * Negative value indicates camera should not return to default.
  104245. */
  104246. /**
  104247. * Gets the time (in milliseconds) taken to return to the default beta position.
  104248. * Negative value indicates camera should not return to default.
  104249. */
  104250. elevationReturnTime: number;
  104251. /**
  104252. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  104253. */
  104254. /**
  104255. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  104256. */
  104257. elevationReturnWaitTime: number;
  104258. /**
  104259. * Sets the flag that indicates if user zooming should stop animation.
  104260. */
  104261. /**
  104262. * Gets the flag that indicates if user zooming should stop animation.
  104263. */
  104264. zoomStopsAnimation: boolean;
  104265. /**
  104266. * Sets the transition time when framing the mesh, in milliseconds
  104267. */
  104268. /**
  104269. * Gets the transition time when framing the mesh, in milliseconds
  104270. */
  104271. framingTime: number;
  104272. /**
  104273. * Define if the behavior should automatically change the configured
  104274. * camera limits and sensibilities.
  104275. */
  104276. autoCorrectCameraLimitsAndSensibility: boolean;
  104277. private _onPrePointerObservableObserver;
  104278. private _onAfterCheckInputsObserver;
  104279. private _onMeshTargetChangedObserver;
  104280. private _attachedCamera;
  104281. private _isPointerDown;
  104282. private _lastInteractionTime;
  104283. /**
  104284. * Initializes the behavior.
  104285. */
  104286. init(): void;
  104287. /**
  104288. * Attaches the behavior to its arc rotate camera.
  104289. * @param camera Defines the camera to attach the behavior to
  104290. */
  104291. attach(camera: ArcRotateCamera): void;
  104292. /**
  104293. * Detaches the behavior from its current arc rotate camera.
  104294. */
  104295. detach(): void;
  104296. private _animatables;
  104297. private _betaIsAnimating;
  104298. private _betaTransition;
  104299. private _radiusTransition;
  104300. private _vectorTransition;
  104301. /**
  104302. * Targets the given mesh and updates zoom level accordingly.
  104303. * @param mesh The mesh to target.
  104304. * @param radius Optional. If a cached radius position already exists, overrides default.
  104305. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104306. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104307. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104308. */
  104309. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104310. /**
  104311. * Targets the given mesh with its children and updates zoom level accordingly.
  104312. * @param mesh The mesh to target.
  104313. * @param radius Optional. If a cached radius position already exists, overrides default.
  104314. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104315. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104316. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104317. */
  104318. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104319. /**
  104320. * Targets the given meshes with their children and updates zoom level accordingly.
  104321. * @param meshes The mesh to target.
  104322. * @param radius Optional. If a cached radius position already exists, overrides default.
  104323. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104324. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104325. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104326. */
  104327. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104328. /**
  104329. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  104330. * @param minimumWorld Determines the smaller position of the bounding box extend
  104331. * @param maximumWorld Determines the bigger position of the bounding box extend
  104332. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104333. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104334. */
  104335. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104336. /**
  104337. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  104338. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  104339. * frustum width.
  104340. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  104341. * to fully enclose the mesh in the viewing frustum.
  104342. */
  104343. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  104344. /**
  104345. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  104346. * is automatically returned to its default position (expected to be above ground plane).
  104347. */
  104348. private _maintainCameraAboveGround;
  104349. /**
  104350. * Returns the frustum slope based on the canvas ratio and camera FOV
  104351. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  104352. */
  104353. private _getFrustumSlope;
  104354. /**
  104355. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  104356. */
  104357. private _clearAnimationLocks;
  104358. /**
  104359. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  104360. */
  104361. private _applyUserInteraction;
  104362. /**
  104363. * Stops and removes all animations that have been applied to the camera
  104364. */
  104365. stopAllAnimations(): void;
  104366. /**
  104367. * Gets a value indicating if the user is moving the camera
  104368. */
  104369. readonly isUserIsMoving: boolean;
  104370. /**
  104371. * The camera can move all the way towards the mesh.
  104372. */
  104373. static IgnoreBoundsSizeMode: number;
  104374. /**
  104375. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  104376. */
  104377. static FitFrustumSidesMode: number;
  104378. }
  104379. }
  104380. declare module BABYLON {
  104381. /**
  104382. * Base class for Camera Pointer Inputs.
  104383. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  104384. * for example usage.
  104385. */
  104386. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  104387. /**
  104388. * Defines the camera the input is attached to.
  104389. */
  104390. abstract camera: Camera;
  104391. /**
  104392. * Whether keyboard modifier keys are pressed at time of last mouse event.
  104393. */
  104394. protected _altKey: boolean;
  104395. protected _ctrlKey: boolean;
  104396. protected _metaKey: boolean;
  104397. protected _shiftKey: boolean;
  104398. /**
  104399. * Which mouse buttons were pressed at time of last mouse event.
  104400. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  104401. */
  104402. protected _buttonsPressed: number;
  104403. /**
  104404. * Defines the buttons associated with the input to handle camera move.
  104405. */
  104406. buttons: number[];
  104407. /**
  104408. * Attach the input controls to a specific dom element to get the input from.
  104409. * @param element Defines the element the controls should be listened from
  104410. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104411. */
  104412. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104413. /**
  104414. * Detach the current controls from the specified dom element.
  104415. * @param element Defines the element to stop listening the inputs from
  104416. */
  104417. detachControl(element: Nullable<HTMLElement>): void;
  104418. /**
  104419. * Gets the class name of the current input.
  104420. * @returns the class name
  104421. */
  104422. getClassName(): string;
  104423. /**
  104424. * Get the friendly name associated with the input class.
  104425. * @returns the input friendly name
  104426. */
  104427. getSimpleName(): string;
  104428. /**
  104429. * Called on pointer POINTERDOUBLETAP event.
  104430. * Override this method to provide functionality on POINTERDOUBLETAP event.
  104431. */
  104432. protected onDoubleTap(type: string): void;
  104433. /**
  104434. * Called on pointer POINTERMOVE event if only a single touch is active.
  104435. * Override this method to provide functionality.
  104436. */
  104437. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104438. /**
  104439. * Called on pointer POINTERMOVE event if multiple touches are active.
  104440. * Override this method to provide functionality.
  104441. */
  104442. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104443. /**
  104444. * Called on JS contextmenu event.
  104445. * Override this method to provide functionality.
  104446. */
  104447. protected onContextMenu(evt: PointerEvent): void;
  104448. /**
  104449. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  104450. * press.
  104451. * Override this method to provide functionality.
  104452. */
  104453. protected onButtonDown(evt: PointerEvent): void;
  104454. /**
  104455. * Called each time a new POINTERUP event occurs. Ie, for each button
  104456. * release.
  104457. * Override this method to provide functionality.
  104458. */
  104459. protected onButtonUp(evt: PointerEvent): void;
  104460. /**
  104461. * Called when window becomes inactive.
  104462. * Override this method to provide functionality.
  104463. */
  104464. protected onLostFocus(): void;
  104465. private _pointerInput;
  104466. private _observer;
  104467. private _onLostFocus;
  104468. private pointA;
  104469. private pointB;
  104470. }
  104471. }
  104472. declare module BABYLON {
  104473. /**
  104474. * Manage the pointers inputs to control an arc rotate camera.
  104475. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104476. */
  104477. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  104478. /**
  104479. * Defines the camera the input is attached to.
  104480. */
  104481. camera: ArcRotateCamera;
  104482. /**
  104483. * Gets the class name of the current input.
  104484. * @returns the class name
  104485. */
  104486. getClassName(): string;
  104487. /**
  104488. * Defines the buttons associated with the input to handle camera move.
  104489. */
  104490. buttons: number[];
  104491. /**
  104492. * Defines the pointer angular sensibility along the X axis or how fast is
  104493. * the camera rotating.
  104494. */
  104495. angularSensibilityX: number;
  104496. /**
  104497. * Defines the pointer angular sensibility along the Y axis or how fast is
  104498. * the camera rotating.
  104499. */
  104500. angularSensibilityY: number;
  104501. /**
  104502. * Defines the pointer pinch precision or how fast is the camera zooming.
  104503. */
  104504. pinchPrecision: number;
  104505. /**
  104506. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104507. * from 0.
  104508. * It defines the percentage of current camera.radius to use as delta when
  104509. * pinch zoom is used.
  104510. */
  104511. pinchDeltaPercentage: number;
  104512. /**
  104513. * Defines the pointer panning sensibility or how fast is the camera moving.
  104514. */
  104515. panningSensibility: number;
  104516. /**
  104517. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  104518. */
  104519. multiTouchPanning: boolean;
  104520. /**
  104521. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  104522. * zoom (pinch) through multitouch.
  104523. */
  104524. multiTouchPanAndZoom: boolean;
  104525. /**
  104526. * Revers pinch action direction.
  104527. */
  104528. pinchInwards: boolean;
  104529. private _isPanClick;
  104530. private _twoFingerActivityCount;
  104531. private _isPinching;
  104532. /**
  104533. * Called on pointer POINTERMOVE event if only a single touch is active.
  104534. */
  104535. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104536. /**
  104537. * Called on pointer POINTERDOUBLETAP event.
  104538. */
  104539. protected onDoubleTap(type: string): void;
  104540. /**
  104541. * Called on pointer POINTERMOVE event if multiple touches are active.
  104542. */
  104543. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104544. /**
  104545. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  104546. * press.
  104547. */
  104548. protected onButtonDown(evt: PointerEvent): void;
  104549. /**
  104550. * Called each time a new POINTERUP event occurs. Ie, for each button
  104551. * release.
  104552. */
  104553. protected onButtonUp(evt: PointerEvent): void;
  104554. /**
  104555. * Called when window becomes inactive.
  104556. */
  104557. protected onLostFocus(): void;
  104558. }
  104559. }
  104560. declare module BABYLON {
  104561. /**
  104562. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  104563. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104564. */
  104565. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  104566. /**
  104567. * Defines the camera the input is attached to.
  104568. */
  104569. camera: ArcRotateCamera;
  104570. /**
  104571. * Defines the list of key codes associated with the up action (increase alpha)
  104572. */
  104573. keysUp: number[];
  104574. /**
  104575. * Defines the list of key codes associated with the down action (decrease alpha)
  104576. */
  104577. keysDown: number[];
  104578. /**
  104579. * Defines the list of key codes associated with the left action (increase beta)
  104580. */
  104581. keysLeft: number[];
  104582. /**
  104583. * Defines the list of key codes associated with the right action (decrease beta)
  104584. */
  104585. keysRight: number[];
  104586. /**
  104587. * Defines the list of key codes associated with the reset action.
  104588. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  104589. */
  104590. keysReset: number[];
  104591. /**
  104592. * Defines the panning sensibility of the inputs.
  104593. * (How fast is the camera paning)
  104594. */
  104595. panningSensibility: number;
  104596. /**
  104597. * Defines the zooming sensibility of the inputs.
  104598. * (How fast is the camera zooming)
  104599. */
  104600. zoomingSensibility: number;
  104601. /**
  104602. * Defines wether maintaining the alt key down switch the movement mode from
  104603. * orientation to zoom.
  104604. */
  104605. useAltToZoom: boolean;
  104606. /**
  104607. * Rotation speed of the camera
  104608. */
  104609. angularSpeed: number;
  104610. private _keys;
  104611. private _ctrlPressed;
  104612. private _altPressed;
  104613. private _onCanvasBlurObserver;
  104614. private _onKeyboardObserver;
  104615. private _engine;
  104616. private _scene;
  104617. /**
  104618. * Attach the input controls to a specific dom element to get the input from.
  104619. * @param element Defines the element the controls should be listened from
  104620. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104621. */
  104622. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104623. /**
  104624. * Detach the current controls from the specified dom element.
  104625. * @param element Defines the element to stop listening the inputs from
  104626. */
  104627. detachControl(element: Nullable<HTMLElement>): void;
  104628. /**
  104629. * Update the current camera state depending on the inputs that have been used this frame.
  104630. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104631. */
  104632. checkInputs(): void;
  104633. /**
  104634. * Gets the class name of the current intput.
  104635. * @returns the class name
  104636. */
  104637. getClassName(): string;
  104638. /**
  104639. * Get the friendly name associated with the input class.
  104640. * @returns the input friendly name
  104641. */
  104642. getSimpleName(): string;
  104643. }
  104644. }
  104645. declare module BABYLON {
  104646. /**
  104647. * Manage the mouse wheel inputs to control an arc rotate camera.
  104648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104649. */
  104650. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  104651. /**
  104652. * Defines the camera the input is attached to.
  104653. */
  104654. camera: ArcRotateCamera;
  104655. /**
  104656. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  104657. */
  104658. wheelPrecision: number;
  104659. /**
  104660. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104661. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104662. */
  104663. wheelDeltaPercentage: number;
  104664. private _wheel;
  104665. private _observer;
  104666. private computeDeltaFromMouseWheelLegacyEvent;
  104667. /**
  104668. * Attach the input controls to a specific dom element to get the input from.
  104669. * @param element Defines the element the controls should be listened from
  104670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104671. */
  104672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104673. /**
  104674. * Detach the current controls from the specified dom element.
  104675. * @param element Defines the element to stop listening the inputs from
  104676. */
  104677. detachControl(element: Nullable<HTMLElement>): void;
  104678. /**
  104679. * Gets the class name of the current intput.
  104680. * @returns the class name
  104681. */
  104682. getClassName(): string;
  104683. /**
  104684. * Get the friendly name associated with the input class.
  104685. * @returns the input friendly name
  104686. */
  104687. getSimpleName(): string;
  104688. }
  104689. }
  104690. declare module BABYLON {
  104691. /**
  104692. * Default Inputs manager for the ArcRotateCamera.
  104693. * It groups all the default supported inputs for ease of use.
  104694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104695. */
  104696. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  104697. /**
  104698. * Instantiates a new ArcRotateCameraInputsManager.
  104699. * @param camera Defines the camera the inputs belong to
  104700. */
  104701. constructor(camera: ArcRotateCamera);
  104702. /**
  104703. * Add mouse wheel input support to the input manager.
  104704. * @returns the current input manager
  104705. */
  104706. addMouseWheel(): ArcRotateCameraInputsManager;
  104707. /**
  104708. * Add pointers input support to the input manager.
  104709. * @returns the current input manager
  104710. */
  104711. addPointers(): ArcRotateCameraInputsManager;
  104712. /**
  104713. * Add keyboard input support to the input manager.
  104714. * @returns the current input manager
  104715. */
  104716. addKeyboard(): ArcRotateCameraInputsManager;
  104717. }
  104718. }
  104719. declare module BABYLON {
  104720. /**
  104721. * This represents an orbital type of camera.
  104722. *
  104723. * 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.
  104724. * 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.
  104725. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  104726. */
  104727. export class ArcRotateCamera extends TargetCamera {
  104728. /**
  104729. * Defines the rotation angle of the camera along the longitudinal axis.
  104730. */
  104731. alpha: number;
  104732. /**
  104733. * Defines the rotation angle of the camera along the latitudinal axis.
  104734. */
  104735. beta: number;
  104736. /**
  104737. * Defines the radius of the camera from it s target point.
  104738. */
  104739. radius: number;
  104740. protected _target: Vector3;
  104741. protected _targetHost: Nullable<AbstractMesh>;
  104742. /**
  104743. * Defines the target point of the camera.
  104744. * The camera looks towards it form the radius distance.
  104745. */
  104746. target: Vector3;
  104747. /**
  104748. * Define the current local position of the camera in the scene
  104749. */
  104750. position: Vector3;
  104751. protected _upVector: Vector3;
  104752. protected _upToYMatrix: Matrix;
  104753. protected _YToUpMatrix: Matrix;
  104754. /**
  104755. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  104756. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  104757. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  104758. */
  104759. upVector: Vector3;
  104760. /**
  104761. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  104762. */
  104763. setMatUp(): void;
  104764. /**
  104765. * Current inertia value on the longitudinal axis.
  104766. * The bigger this number the longer it will take for the camera to stop.
  104767. */
  104768. inertialAlphaOffset: number;
  104769. /**
  104770. * Current inertia value on the latitudinal axis.
  104771. * The bigger this number the longer it will take for the camera to stop.
  104772. */
  104773. inertialBetaOffset: number;
  104774. /**
  104775. * Current inertia value on the radius axis.
  104776. * The bigger this number the longer it will take for the camera to stop.
  104777. */
  104778. inertialRadiusOffset: number;
  104779. /**
  104780. * Minimum allowed angle on the longitudinal axis.
  104781. * This can help limiting how the Camera is able to move in the scene.
  104782. */
  104783. lowerAlphaLimit: Nullable<number>;
  104784. /**
  104785. * Maximum allowed angle on the longitudinal axis.
  104786. * This can help limiting how the Camera is able to move in the scene.
  104787. */
  104788. upperAlphaLimit: Nullable<number>;
  104789. /**
  104790. * Minimum allowed angle on the latitudinal axis.
  104791. * This can help limiting how the Camera is able to move in the scene.
  104792. */
  104793. lowerBetaLimit: number;
  104794. /**
  104795. * Maximum allowed angle on the latitudinal axis.
  104796. * This can help limiting how the Camera is able to move in the scene.
  104797. */
  104798. upperBetaLimit: number;
  104799. /**
  104800. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  104801. * This can help limiting how the Camera is able to move in the scene.
  104802. */
  104803. lowerRadiusLimit: Nullable<number>;
  104804. /**
  104805. * Maximum allowed distance of the camera to the target (The camera can not get further).
  104806. * This can help limiting how the Camera is able to move in the scene.
  104807. */
  104808. upperRadiusLimit: Nullable<number>;
  104809. /**
  104810. * Defines the current inertia value used during panning of the camera along the X axis.
  104811. */
  104812. inertialPanningX: number;
  104813. /**
  104814. * Defines the current inertia value used during panning of the camera along the Y axis.
  104815. */
  104816. inertialPanningY: number;
  104817. /**
  104818. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  104819. * Basically if your fingers moves away from more than this distance you will be considered
  104820. * in pinch mode.
  104821. */
  104822. pinchToPanMaxDistance: number;
  104823. /**
  104824. * Defines the maximum distance the camera can pan.
  104825. * This could help keeping the cammera always in your scene.
  104826. */
  104827. panningDistanceLimit: Nullable<number>;
  104828. /**
  104829. * Defines the target of the camera before paning.
  104830. */
  104831. panningOriginTarget: Vector3;
  104832. /**
  104833. * Defines the value of the inertia used during panning.
  104834. * 0 would mean stop inertia and one would mean no decelleration at all.
  104835. */
  104836. panningInertia: number;
  104837. /**
  104838. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  104839. */
  104840. angularSensibilityX: number;
  104841. /**
  104842. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  104843. */
  104844. angularSensibilityY: number;
  104845. /**
  104846. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  104847. */
  104848. pinchPrecision: number;
  104849. /**
  104850. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  104851. * It will be used instead of pinchDeltaPrecision if different from 0.
  104852. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  104853. */
  104854. pinchDeltaPercentage: number;
  104855. /**
  104856. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  104857. */
  104858. panningSensibility: number;
  104859. /**
  104860. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  104861. */
  104862. keysUp: number[];
  104863. /**
  104864. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  104865. */
  104866. keysDown: number[];
  104867. /**
  104868. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  104869. */
  104870. keysLeft: number[];
  104871. /**
  104872. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  104873. */
  104874. keysRight: number[];
  104875. /**
  104876. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  104877. */
  104878. wheelPrecision: number;
  104879. /**
  104880. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  104881. * It will be used instead of pinchDeltaPrecision if different from 0.
  104882. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  104883. */
  104884. wheelDeltaPercentage: number;
  104885. /**
  104886. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  104887. */
  104888. zoomOnFactor: number;
  104889. /**
  104890. * Defines a screen offset for the camera position.
  104891. */
  104892. targetScreenOffset: Vector2;
  104893. /**
  104894. * Allows the camera to be completely reversed.
  104895. * If false the camera can not arrive upside down.
  104896. */
  104897. allowUpsideDown: boolean;
  104898. /**
  104899. * Define if double tap/click is used to restore the previously saved state of the camera.
  104900. */
  104901. useInputToRestoreState: boolean;
  104902. /** @hidden */
  104903. _viewMatrix: Matrix;
  104904. /** @hidden */
  104905. _useCtrlForPanning: boolean;
  104906. /** @hidden */
  104907. _panningMouseButton: number;
  104908. /**
  104909. * Defines the input associated to the camera.
  104910. */
  104911. inputs: ArcRotateCameraInputsManager;
  104912. /** @hidden */
  104913. _reset: () => void;
  104914. /**
  104915. * Defines the allowed panning axis.
  104916. */
  104917. panningAxis: Vector3;
  104918. protected _localDirection: Vector3;
  104919. protected _transformedDirection: Vector3;
  104920. private _bouncingBehavior;
  104921. /**
  104922. * Gets the bouncing behavior of the camera if it has been enabled.
  104923. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104924. */
  104925. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  104926. /**
  104927. * Defines if the bouncing behavior of the camera is enabled on the camera.
  104928. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104929. */
  104930. useBouncingBehavior: boolean;
  104931. private _framingBehavior;
  104932. /**
  104933. * Gets the framing behavior of the camera if it has been enabled.
  104934. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104935. */
  104936. readonly framingBehavior: Nullable<FramingBehavior>;
  104937. /**
  104938. * Defines if the framing behavior of the camera is enabled on the camera.
  104939. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104940. */
  104941. useFramingBehavior: boolean;
  104942. private _autoRotationBehavior;
  104943. /**
  104944. * Gets the auto rotation behavior of the camera if it has been enabled.
  104945. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104946. */
  104947. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  104948. /**
  104949. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  104950. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104951. */
  104952. useAutoRotationBehavior: boolean;
  104953. /**
  104954. * Observable triggered when the mesh target has been changed on the camera.
  104955. */
  104956. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  104957. /**
  104958. * Event raised when the camera is colliding with a mesh.
  104959. */
  104960. onCollide: (collidedMesh: AbstractMesh) => void;
  104961. /**
  104962. * Defines whether the camera should check collision with the objects oh the scene.
  104963. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  104964. */
  104965. checkCollisions: boolean;
  104966. /**
  104967. * Defines the collision radius of the camera.
  104968. * This simulates a sphere around the camera.
  104969. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104970. */
  104971. collisionRadius: Vector3;
  104972. protected _collider: Collider;
  104973. protected _previousPosition: Vector3;
  104974. protected _collisionVelocity: Vector3;
  104975. protected _newPosition: Vector3;
  104976. protected _previousAlpha: number;
  104977. protected _previousBeta: number;
  104978. protected _previousRadius: number;
  104979. protected _collisionTriggered: boolean;
  104980. protected _targetBoundingCenter: Nullable<Vector3>;
  104981. private _computationVector;
  104982. /**
  104983. * Instantiates a new ArcRotateCamera in a given scene
  104984. * @param name Defines the name of the camera
  104985. * @param alpha Defines the camera rotation along the logitudinal axis
  104986. * @param beta Defines the camera rotation along the latitudinal axis
  104987. * @param radius Defines the camera distance from its target
  104988. * @param target Defines the camera target
  104989. * @param scene Defines the scene the camera belongs to
  104990. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  104991. */
  104992. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104993. /** @hidden */
  104994. _initCache(): void;
  104995. /** @hidden */
  104996. _updateCache(ignoreParentClass?: boolean): void;
  104997. protected _getTargetPosition(): Vector3;
  104998. private _storedAlpha;
  104999. private _storedBeta;
  105000. private _storedRadius;
  105001. private _storedTarget;
  105002. private _storedTargetScreenOffset;
  105003. /**
  105004. * Stores the current state of the camera (alpha, beta, radius and target)
  105005. * @returns the camera itself
  105006. */
  105007. storeState(): Camera;
  105008. /**
  105009. * @hidden
  105010. * Restored camera state. You must call storeState() first
  105011. */
  105012. _restoreStateValues(): boolean;
  105013. /** @hidden */
  105014. _isSynchronizedViewMatrix(): boolean;
  105015. /**
  105016. * Attached controls to the current camera.
  105017. * @param element Defines the element the controls should be listened from
  105018. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105019. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  105020. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  105021. */
  105022. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  105023. /**
  105024. * Detach the current controls from the camera.
  105025. * The camera will stop reacting to inputs.
  105026. * @param element Defines the element to stop listening the inputs from
  105027. */
  105028. detachControl(element: HTMLElement): void;
  105029. /** @hidden */
  105030. _checkInputs(): void;
  105031. protected _checkLimits(): void;
  105032. /**
  105033. * Rebuilds angles (alpha, beta) and radius from the give position and target
  105034. */
  105035. rebuildAnglesAndRadius(): void;
  105036. /**
  105037. * Use a position to define the current camera related information like alpha, beta and radius
  105038. * @param position Defines the position to set the camera at
  105039. */
  105040. setPosition(position: Vector3): void;
  105041. /**
  105042. * Defines the target the camera should look at.
  105043. * This will automatically adapt alpha beta and radius to fit within the new target.
  105044. * @param target Defines the new target as a Vector or a mesh
  105045. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  105046. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  105047. */
  105048. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  105049. /** @hidden */
  105050. _getViewMatrix(): Matrix;
  105051. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  105052. /**
  105053. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  105054. * @param meshes Defines the mesh to zoom on
  105055. * @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)
  105056. */
  105057. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  105058. /**
  105059. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  105060. * The target will be changed but the radius
  105061. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  105062. * @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)
  105063. */
  105064. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  105065. min: Vector3;
  105066. max: Vector3;
  105067. distance: number;
  105068. }, doNotUpdateMaxZ?: boolean): void;
  105069. /**
  105070. * @override
  105071. * Override Camera.createRigCamera
  105072. */
  105073. createRigCamera(name: string, cameraIndex: number): Camera;
  105074. /**
  105075. * @hidden
  105076. * @override
  105077. * Override Camera._updateRigCameras
  105078. */
  105079. _updateRigCameras(): void;
  105080. /**
  105081. * Destroy the camera and release the current resources hold by it.
  105082. */
  105083. dispose(): void;
  105084. /**
  105085. * Gets the current object class name.
  105086. * @return the class name
  105087. */
  105088. getClassName(): string;
  105089. }
  105090. }
  105091. declare module BABYLON {
  105092. /**
  105093. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  105094. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105095. */
  105096. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  105097. /**
  105098. * Gets the name of the behavior.
  105099. */
  105100. readonly name: string;
  105101. private _zoomStopsAnimation;
  105102. private _idleRotationSpeed;
  105103. private _idleRotationWaitTime;
  105104. private _idleRotationSpinupTime;
  105105. /**
  105106. * Sets the flag that indicates if user zooming should stop animation.
  105107. */
  105108. /**
  105109. * Gets the flag that indicates if user zooming should stop animation.
  105110. */
  105111. zoomStopsAnimation: boolean;
  105112. /**
  105113. * Sets the default speed at which the camera rotates around the model.
  105114. */
  105115. /**
  105116. * Gets the default speed at which the camera rotates around the model.
  105117. */
  105118. idleRotationSpeed: number;
  105119. /**
  105120. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  105121. */
  105122. /**
  105123. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  105124. */
  105125. idleRotationWaitTime: number;
  105126. /**
  105127. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105128. */
  105129. /**
  105130. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105131. */
  105132. idleRotationSpinupTime: number;
  105133. /**
  105134. * Gets a value indicating if the camera is currently rotating because of this behavior
  105135. */
  105136. readonly rotationInProgress: boolean;
  105137. private _onPrePointerObservableObserver;
  105138. private _onAfterCheckInputsObserver;
  105139. private _attachedCamera;
  105140. private _isPointerDown;
  105141. private _lastFrameTime;
  105142. private _lastInteractionTime;
  105143. private _cameraRotationSpeed;
  105144. /**
  105145. * Initializes the behavior.
  105146. */
  105147. init(): void;
  105148. /**
  105149. * Attaches the behavior to its arc rotate camera.
  105150. * @param camera Defines the camera to attach the behavior to
  105151. */
  105152. attach(camera: ArcRotateCamera): void;
  105153. /**
  105154. * Detaches the behavior from its current arc rotate camera.
  105155. */
  105156. detach(): void;
  105157. /**
  105158. * Returns true if user is scrolling.
  105159. * @return true if user is scrolling.
  105160. */
  105161. private _userIsZooming;
  105162. private _lastFrameRadius;
  105163. private _shouldAnimationStopForInteraction;
  105164. /**
  105165. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  105166. */
  105167. private _applyUserInteraction;
  105168. private _userIsMoving;
  105169. }
  105170. }
  105171. declare module BABYLON {
  105172. /**
  105173. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  105174. */
  105175. export class AttachToBoxBehavior implements Behavior<Mesh> {
  105176. private ui;
  105177. /**
  105178. * The name of the behavior
  105179. */
  105180. name: string;
  105181. /**
  105182. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  105183. */
  105184. distanceAwayFromFace: number;
  105185. /**
  105186. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  105187. */
  105188. distanceAwayFromBottomOfFace: number;
  105189. private _faceVectors;
  105190. private _target;
  105191. private _scene;
  105192. private _onRenderObserver;
  105193. private _tmpMatrix;
  105194. private _tmpVector;
  105195. /**
  105196. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  105197. * @param ui The transform node that should be attched to the mesh
  105198. */
  105199. constructor(ui: TransformNode);
  105200. /**
  105201. * Initializes the behavior
  105202. */
  105203. init(): void;
  105204. private _closestFace;
  105205. private _zeroVector;
  105206. private _lookAtTmpMatrix;
  105207. private _lookAtToRef;
  105208. /**
  105209. * Attaches the AttachToBoxBehavior to the passed in mesh
  105210. * @param target The mesh that the specified node will be attached to
  105211. */
  105212. attach(target: Mesh): void;
  105213. /**
  105214. * Detaches the behavior from the mesh
  105215. */
  105216. detach(): void;
  105217. }
  105218. }
  105219. declare module BABYLON {
  105220. /**
  105221. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  105222. */
  105223. export class FadeInOutBehavior implements Behavior<Mesh> {
  105224. /**
  105225. * Time in milliseconds to delay before fading in (Default: 0)
  105226. */
  105227. delay: number;
  105228. /**
  105229. * Time in milliseconds for the mesh to fade in (Default: 300)
  105230. */
  105231. fadeInTime: number;
  105232. private _millisecondsPerFrame;
  105233. private _hovered;
  105234. private _hoverValue;
  105235. private _ownerNode;
  105236. /**
  105237. * Instatiates the FadeInOutBehavior
  105238. */
  105239. constructor();
  105240. /**
  105241. * The name of the behavior
  105242. */
  105243. readonly name: string;
  105244. /**
  105245. * Initializes the behavior
  105246. */
  105247. init(): void;
  105248. /**
  105249. * Attaches the fade behavior on the passed in mesh
  105250. * @param ownerNode The mesh that will be faded in/out once attached
  105251. */
  105252. attach(ownerNode: Mesh): void;
  105253. /**
  105254. * Detaches the behavior from the mesh
  105255. */
  105256. detach(): void;
  105257. /**
  105258. * Triggers the mesh to begin fading in or out
  105259. * @param value if the object should fade in or out (true to fade in)
  105260. */
  105261. fadeIn(value: boolean): void;
  105262. private _update;
  105263. private _setAllVisibility;
  105264. }
  105265. }
  105266. declare module BABYLON {
  105267. /**
  105268. * Class containing a set of static utilities functions for managing Pivots
  105269. * @hidden
  105270. */
  105271. export class PivotTools {
  105272. private static _PivotCached;
  105273. private static _OldPivotPoint;
  105274. private static _PivotTranslation;
  105275. private static _PivotTmpVector;
  105276. /** @hidden */
  105277. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  105278. /** @hidden */
  105279. static _RestorePivotPoint(mesh: AbstractMesh): void;
  105280. }
  105281. }
  105282. declare module BABYLON {
  105283. /**
  105284. * Class containing static functions to help procedurally build meshes
  105285. */
  105286. export class PlaneBuilder {
  105287. /**
  105288. * Creates a plane mesh
  105289. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  105290. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  105291. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  105292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105293. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105295. * @param name defines the name of the mesh
  105296. * @param options defines the options used to create the mesh
  105297. * @param scene defines the hosting scene
  105298. * @returns the plane mesh
  105299. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  105300. */
  105301. static CreatePlane(name: string, options: {
  105302. size?: number;
  105303. width?: number;
  105304. height?: number;
  105305. sideOrientation?: number;
  105306. frontUVs?: Vector4;
  105307. backUVs?: Vector4;
  105308. updatable?: boolean;
  105309. sourcePlane?: Plane;
  105310. }, scene?: Nullable<Scene>): Mesh;
  105311. }
  105312. }
  105313. declare module BABYLON {
  105314. /**
  105315. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  105316. */
  105317. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  105318. private static _AnyMouseID;
  105319. /**
  105320. * Abstract mesh the behavior is set on
  105321. */
  105322. attachedNode: AbstractMesh;
  105323. private _dragPlane;
  105324. private _scene;
  105325. private _pointerObserver;
  105326. private _beforeRenderObserver;
  105327. private static _planeScene;
  105328. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  105329. /**
  105330. * 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)
  105331. */
  105332. maxDragAngle: number;
  105333. /**
  105334. * @hidden
  105335. */
  105336. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  105337. /**
  105338. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105339. */
  105340. currentDraggingPointerID: number;
  105341. /**
  105342. * The last position where the pointer hit the drag plane in world space
  105343. */
  105344. lastDragPosition: Vector3;
  105345. /**
  105346. * If the behavior is currently in a dragging state
  105347. */
  105348. dragging: boolean;
  105349. /**
  105350. * 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)
  105351. */
  105352. dragDeltaRatio: number;
  105353. /**
  105354. * If the drag plane orientation should be updated during the dragging (Default: true)
  105355. */
  105356. updateDragPlane: boolean;
  105357. private _debugMode;
  105358. private _moving;
  105359. /**
  105360. * Fires each time the attached mesh is dragged with the pointer
  105361. * * delta between last drag position and current drag position in world space
  105362. * * dragDistance along the drag axis
  105363. * * dragPlaneNormal normal of the current drag plane used during the drag
  105364. * * dragPlanePoint in world space where the drag intersects the drag plane
  105365. */
  105366. onDragObservable: Observable<{
  105367. delta: Vector3;
  105368. dragPlanePoint: Vector3;
  105369. dragPlaneNormal: Vector3;
  105370. dragDistance: number;
  105371. pointerId: number;
  105372. }>;
  105373. /**
  105374. * Fires each time a drag begins (eg. mouse down on mesh)
  105375. */
  105376. onDragStartObservable: Observable<{
  105377. dragPlanePoint: Vector3;
  105378. pointerId: number;
  105379. }>;
  105380. /**
  105381. * Fires each time a drag ends (eg. mouse release after drag)
  105382. */
  105383. onDragEndObservable: Observable<{
  105384. dragPlanePoint: Vector3;
  105385. pointerId: number;
  105386. }>;
  105387. /**
  105388. * If the attached mesh should be moved when dragged
  105389. */
  105390. moveAttached: boolean;
  105391. /**
  105392. * If the drag behavior will react to drag events (Default: true)
  105393. */
  105394. enabled: boolean;
  105395. /**
  105396. * If pointer events should start and release the drag (Default: true)
  105397. */
  105398. startAndReleaseDragOnPointerEvents: boolean;
  105399. /**
  105400. * If camera controls should be detached during the drag
  105401. */
  105402. detachCameraControls: boolean;
  105403. /**
  105404. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  105405. */
  105406. useObjectOrienationForDragging: boolean;
  105407. private _options;
  105408. /**
  105409. * Creates a pointer drag behavior that can be attached to a mesh
  105410. * @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)
  105411. */
  105412. constructor(options?: {
  105413. dragAxis?: Vector3;
  105414. dragPlaneNormal?: Vector3;
  105415. });
  105416. /**
  105417. * Predicate to determine if it is valid to move the object to a new position when it is moved
  105418. */
  105419. validateDrag: (targetPosition: Vector3) => boolean;
  105420. /**
  105421. * The name of the behavior
  105422. */
  105423. readonly name: string;
  105424. /**
  105425. * Initializes the behavior
  105426. */
  105427. init(): void;
  105428. private _tmpVector;
  105429. private _alternatePickedPoint;
  105430. private _worldDragAxis;
  105431. private _targetPosition;
  105432. private _attachedElement;
  105433. /**
  105434. * Attaches the drag behavior the passed in mesh
  105435. * @param ownerNode The mesh that will be dragged around once attached
  105436. * @param predicate Predicate to use for pick filtering
  105437. */
  105438. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  105439. /**
  105440. * Force relase the drag action by code.
  105441. */
  105442. releaseDrag(): void;
  105443. private _startDragRay;
  105444. private _lastPointerRay;
  105445. /**
  105446. * Simulates the start of a pointer drag event on the behavior
  105447. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  105448. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  105449. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  105450. */
  105451. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  105452. private _startDrag;
  105453. private _dragDelta;
  105454. private _moveDrag;
  105455. private _pickWithRayOnDragPlane;
  105456. private _pointA;
  105457. private _pointB;
  105458. private _pointC;
  105459. private _lineA;
  105460. private _lineB;
  105461. private _localAxis;
  105462. private _lookAt;
  105463. private _updateDragPlanePosition;
  105464. /**
  105465. * Detaches the behavior from the mesh
  105466. */
  105467. detach(): void;
  105468. }
  105469. }
  105470. declare module BABYLON {
  105471. /**
  105472. * A behavior that when attached to a mesh will allow the mesh to be scaled
  105473. */
  105474. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  105475. private _dragBehaviorA;
  105476. private _dragBehaviorB;
  105477. private _startDistance;
  105478. private _initialScale;
  105479. private _targetScale;
  105480. private _ownerNode;
  105481. private _sceneRenderObserver;
  105482. /**
  105483. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  105484. */
  105485. constructor();
  105486. /**
  105487. * The name of the behavior
  105488. */
  105489. readonly name: string;
  105490. /**
  105491. * Initializes the behavior
  105492. */
  105493. init(): void;
  105494. private _getCurrentDistance;
  105495. /**
  105496. * Attaches the scale behavior the passed in mesh
  105497. * @param ownerNode The mesh that will be scaled around once attached
  105498. */
  105499. attach(ownerNode: Mesh): void;
  105500. /**
  105501. * Detaches the behavior from the mesh
  105502. */
  105503. detach(): void;
  105504. }
  105505. }
  105506. declare module BABYLON {
  105507. /**
  105508. * 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
  105509. */
  105510. export class SixDofDragBehavior implements Behavior<Mesh> {
  105511. private static _virtualScene;
  105512. private _ownerNode;
  105513. private _sceneRenderObserver;
  105514. private _scene;
  105515. private _targetPosition;
  105516. private _virtualOriginMesh;
  105517. private _virtualDragMesh;
  105518. private _pointerObserver;
  105519. private _moving;
  105520. private _startingOrientation;
  105521. /**
  105522. * 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)
  105523. */
  105524. private zDragFactor;
  105525. /**
  105526. * If the object should rotate to face the drag origin
  105527. */
  105528. rotateDraggedObject: boolean;
  105529. /**
  105530. * If the behavior is currently in a dragging state
  105531. */
  105532. dragging: boolean;
  105533. /**
  105534. * 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)
  105535. */
  105536. dragDeltaRatio: number;
  105537. /**
  105538. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105539. */
  105540. currentDraggingPointerID: number;
  105541. /**
  105542. * If camera controls should be detached during the drag
  105543. */
  105544. detachCameraControls: boolean;
  105545. /**
  105546. * Fires each time a drag starts
  105547. */
  105548. onDragStartObservable: Observable<{}>;
  105549. /**
  105550. * Fires each time a drag ends (eg. mouse release after drag)
  105551. */
  105552. onDragEndObservable: Observable<{}>;
  105553. /**
  105554. * 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
  105555. */
  105556. constructor();
  105557. /**
  105558. * The name of the behavior
  105559. */
  105560. readonly name: string;
  105561. /**
  105562. * Initializes the behavior
  105563. */
  105564. init(): void;
  105565. /**
  105566. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  105567. */
  105568. private readonly _pointerCamera;
  105569. /**
  105570. * Attaches the scale behavior the passed in mesh
  105571. * @param ownerNode The mesh that will be scaled around once attached
  105572. */
  105573. attach(ownerNode: Mesh): void;
  105574. /**
  105575. * Detaches the behavior from the mesh
  105576. */
  105577. detach(): void;
  105578. }
  105579. }
  105580. declare module BABYLON {
  105581. /**
  105582. * Class used to apply inverse kinematics to bones
  105583. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  105584. */
  105585. export class BoneIKController {
  105586. private static _tmpVecs;
  105587. private static _tmpQuat;
  105588. private static _tmpMats;
  105589. /**
  105590. * Gets or sets the target mesh
  105591. */
  105592. targetMesh: AbstractMesh;
  105593. /** Gets or sets the mesh used as pole */
  105594. poleTargetMesh: AbstractMesh;
  105595. /**
  105596. * Gets or sets the bone used as pole
  105597. */
  105598. poleTargetBone: Nullable<Bone>;
  105599. /**
  105600. * Gets or sets the target position
  105601. */
  105602. targetPosition: Vector3;
  105603. /**
  105604. * Gets or sets the pole target position
  105605. */
  105606. poleTargetPosition: Vector3;
  105607. /**
  105608. * Gets or sets the pole target local offset
  105609. */
  105610. poleTargetLocalOffset: Vector3;
  105611. /**
  105612. * Gets or sets the pole angle
  105613. */
  105614. poleAngle: number;
  105615. /**
  105616. * Gets or sets the mesh associated with the controller
  105617. */
  105618. mesh: AbstractMesh;
  105619. /**
  105620. * 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)
  105621. */
  105622. slerpAmount: number;
  105623. private _bone1Quat;
  105624. private _bone1Mat;
  105625. private _bone2Ang;
  105626. private _bone1;
  105627. private _bone2;
  105628. private _bone1Length;
  105629. private _bone2Length;
  105630. private _maxAngle;
  105631. private _maxReach;
  105632. private _rightHandedSystem;
  105633. private _bendAxis;
  105634. private _slerping;
  105635. private _adjustRoll;
  105636. /**
  105637. * Gets or sets maximum allowed angle
  105638. */
  105639. maxAngle: number;
  105640. /**
  105641. * Creates a new BoneIKController
  105642. * @param mesh defines the mesh to control
  105643. * @param bone defines the bone to control
  105644. * @param options defines options to set up the controller
  105645. */
  105646. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  105647. targetMesh?: AbstractMesh;
  105648. poleTargetMesh?: AbstractMesh;
  105649. poleTargetBone?: Bone;
  105650. poleTargetLocalOffset?: Vector3;
  105651. poleAngle?: number;
  105652. bendAxis?: Vector3;
  105653. maxAngle?: number;
  105654. slerpAmount?: number;
  105655. });
  105656. private _setMaxAngle;
  105657. /**
  105658. * Force the controller to update the bones
  105659. */
  105660. update(): void;
  105661. }
  105662. }
  105663. declare module BABYLON {
  105664. /**
  105665. * Class used to make a bone look toward a point in space
  105666. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  105667. */
  105668. export class BoneLookController {
  105669. private static _tmpVecs;
  105670. private static _tmpQuat;
  105671. private static _tmpMats;
  105672. /**
  105673. * The target Vector3 that the bone will look at
  105674. */
  105675. target: Vector3;
  105676. /**
  105677. * The mesh that the bone is attached to
  105678. */
  105679. mesh: AbstractMesh;
  105680. /**
  105681. * The bone that will be looking to the target
  105682. */
  105683. bone: Bone;
  105684. /**
  105685. * The up axis of the coordinate system that is used when the bone is rotated
  105686. */
  105687. upAxis: Vector3;
  105688. /**
  105689. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  105690. */
  105691. upAxisSpace: Space;
  105692. /**
  105693. * Used to make an adjustment to the yaw of the bone
  105694. */
  105695. adjustYaw: number;
  105696. /**
  105697. * Used to make an adjustment to the pitch of the bone
  105698. */
  105699. adjustPitch: number;
  105700. /**
  105701. * Used to make an adjustment to the roll of the bone
  105702. */
  105703. adjustRoll: number;
  105704. /**
  105705. * 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)
  105706. */
  105707. slerpAmount: number;
  105708. private _minYaw;
  105709. private _maxYaw;
  105710. private _minPitch;
  105711. private _maxPitch;
  105712. private _minYawSin;
  105713. private _minYawCos;
  105714. private _maxYawSin;
  105715. private _maxYawCos;
  105716. private _midYawConstraint;
  105717. private _minPitchTan;
  105718. private _maxPitchTan;
  105719. private _boneQuat;
  105720. private _slerping;
  105721. private _transformYawPitch;
  105722. private _transformYawPitchInv;
  105723. private _firstFrameSkipped;
  105724. private _yawRange;
  105725. private _fowardAxis;
  105726. /**
  105727. * Gets or sets the minimum yaw angle that the bone can look to
  105728. */
  105729. minYaw: number;
  105730. /**
  105731. * Gets or sets the maximum yaw angle that the bone can look to
  105732. */
  105733. maxYaw: number;
  105734. /**
  105735. * Gets or sets the minimum pitch angle that the bone can look to
  105736. */
  105737. minPitch: number;
  105738. /**
  105739. * Gets or sets the maximum pitch angle that the bone can look to
  105740. */
  105741. maxPitch: number;
  105742. /**
  105743. * Create a BoneLookController
  105744. * @param mesh the mesh that the bone belongs to
  105745. * @param bone the bone that will be looking to the target
  105746. * @param target the target Vector3 to look at
  105747. * @param options optional settings:
  105748. * * maxYaw: the maximum angle the bone will yaw to
  105749. * * minYaw: the minimum angle the bone will yaw to
  105750. * * maxPitch: the maximum angle the bone will pitch to
  105751. * * minPitch: the minimum angle the bone will yaw to
  105752. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  105753. * * upAxis: the up axis of the coordinate system
  105754. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  105755. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  105756. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  105757. * * adjustYaw: used to make an adjustment to the yaw of the bone
  105758. * * adjustPitch: used to make an adjustment to the pitch of the bone
  105759. * * adjustRoll: used to make an adjustment to the roll of the bone
  105760. **/
  105761. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  105762. maxYaw?: number;
  105763. minYaw?: number;
  105764. maxPitch?: number;
  105765. minPitch?: number;
  105766. slerpAmount?: number;
  105767. upAxis?: Vector3;
  105768. upAxisSpace?: Space;
  105769. yawAxis?: Vector3;
  105770. pitchAxis?: Vector3;
  105771. adjustYaw?: number;
  105772. adjustPitch?: number;
  105773. adjustRoll?: number;
  105774. });
  105775. /**
  105776. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  105777. */
  105778. update(): void;
  105779. private _getAngleDiff;
  105780. private _getAngleBetween;
  105781. private _isAngleBetween;
  105782. }
  105783. }
  105784. declare module BABYLON {
  105785. /**
  105786. * Manage the gamepad inputs to control an arc rotate camera.
  105787. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105788. */
  105789. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  105790. /**
  105791. * Defines the camera the input is attached to.
  105792. */
  105793. camera: ArcRotateCamera;
  105794. /**
  105795. * Defines the gamepad the input is gathering event from.
  105796. */
  105797. gamepad: Nullable<Gamepad>;
  105798. /**
  105799. * Defines the gamepad rotation sensiblity.
  105800. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105801. */
  105802. gamepadRotationSensibility: number;
  105803. /**
  105804. * Defines the gamepad move sensiblity.
  105805. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105806. */
  105807. gamepadMoveSensibility: number;
  105808. private _yAxisScale;
  105809. /**
  105810. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  105811. */
  105812. invertYAxis: boolean;
  105813. private _onGamepadConnectedObserver;
  105814. private _onGamepadDisconnectedObserver;
  105815. /**
  105816. * Attach the input controls to a specific dom element to get the input from.
  105817. * @param element Defines the element the controls should be listened from
  105818. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105819. */
  105820. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105821. /**
  105822. * Detach the current controls from the specified dom element.
  105823. * @param element Defines the element to stop listening the inputs from
  105824. */
  105825. detachControl(element: Nullable<HTMLElement>): void;
  105826. /**
  105827. * Update the current camera state depending on the inputs that have been used this frame.
  105828. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105829. */
  105830. checkInputs(): void;
  105831. /**
  105832. * Gets the class name of the current intput.
  105833. * @returns the class name
  105834. */
  105835. getClassName(): string;
  105836. /**
  105837. * Get the friendly name associated with the input class.
  105838. * @returns the input friendly name
  105839. */
  105840. getSimpleName(): string;
  105841. }
  105842. }
  105843. declare module BABYLON {
  105844. interface ArcRotateCameraInputsManager {
  105845. /**
  105846. * Add orientation input support to the input manager.
  105847. * @returns the current input manager
  105848. */
  105849. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  105850. }
  105851. /**
  105852. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  105853. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105854. */
  105855. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  105856. /**
  105857. * Defines the camera the input is attached to.
  105858. */
  105859. camera: ArcRotateCamera;
  105860. /**
  105861. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  105862. */
  105863. alphaCorrection: number;
  105864. /**
  105865. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  105866. */
  105867. gammaCorrection: number;
  105868. private _alpha;
  105869. private _gamma;
  105870. private _dirty;
  105871. private _deviceOrientationHandler;
  105872. /**
  105873. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  105874. */
  105875. constructor();
  105876. /**
  105877. * Attach the input controls to a specific dom element to get the input from.
  105878. * @param element Defines the element the controls should be listened from
  105879. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105880. */
  105881. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105882. /** @hidden */
  105883. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  105884. /**
  105885. * Update the current camera state depending on the inputs that have been used this frame.
  105886. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105887. */
  105888. checkInputs(): void;
  105889. /**
  105890. * Detach the current controls from the specified dom element.
  105891. * @param element Defines the element to stop listening the inputs from
  105892. */
  105893. detachControl(element: Nullable<HTMLElement>): void;
  105894. /**
  105895. * Gets the class name of the current intput.
  105896. * @returns the class name
  105897. */
  105898. getClassName(): string;
  105899. /**
  105900. * Get the friendly name associated with the input class.
  105901. * @returns the input friendly name
  105902. */
  105903. getSimpleName(): string;
  105904. }
  105905. }
  105906. declare module BABYLON {
  105907. /**
  105908. * Listen to mouse events to control the camera.
  105909. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105910. */
  105911. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  105912. /**
  105913. * Defines the camera the input is attached to.
  105914. */
  105915. camera: FlyCamera;
  105916. /**
  105917. * Defines if touch is enabled. (Default is true.)
  105918. */
  105919. touchEnabled: boolean;
  105920. /**
  105921. * Defines the buttons associated with the input to handle camera rotation.
  105922. */
  105923. buttons: number[];
  105924. /**
  105925. * Assign buttons for Yaw control.
  105926. */
  105927. buttonsYaw: number[];
  105928. /**
  105929. * Assign buttons for Pitch control.
  105930. */
  105931. buttonsPitch: number[];
  105932. /**
  105933. * Assign buttons for Roll control.
  105934. */
  105935. buttonsRoll: number[];
  105936. /**
  105937. * Detect if any button is being pressed while mouse is moved.
  105938. * -1 = Mouse locked.
  105939. * 0 = Left button.
  105940. * 1 = Middle Button.
  105941. * 2 = Right Button.
  105942. */
  105943. activeButton: number;
  105944. /**
  105945. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  105946. * Higher values reduce its sensitivity.
  105947. */
  105948. angularSensibility: number;
  105949. private _mousemoveCallback;
  105950. private _observer;
  105951. private _rollObserver;
  105952. private previousPosition;
  105953. private noPreventDefault;
  105954. private element;
  105955. /**
  105956. * Listen to mouse events to control the camera.
  105957. * @param touchEnabled Define if touch is enabled. (Default is true.)
  105958. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105959. */
  105960. constructor(touchEnabled?: boolean);
  105961. /**
  105962. * Attach the mouse control to the HTML DOM element.
  105963. * @param element Defines the element that listens to the input events.
  105964. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  105965. */
  105966. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105967. /**
  105968. * Detach the current controls from the specified dom element.
  105969. * @param element Defines the element to stop listening the inputs from
  105970. */
  105971. detachControl(element: Nullable<HTMLElement>): void;
  105972. /**
  105973. * Gets the class name of the current input.
  105974. * @returns the class name.
  105975. */
  105976. getClassName(): string;
  105977. /**
  105978. * Get the friendly name associated with the input class.
  105979. * @returns the input's friendly name.
  105980. */
  105981. getSimpleName(): string;
  105982. private _pointerInput;
  105983. private _onMouseMove;
  105984. /**
  105985. * Rotate camera by mouse offset.
  105986. */
  105987. private rotateCamera;
  105988. }
  105989. }
  105990. declare module BABYLON {
  105991. /**
  105992. * Default Inputs manager for the FlyCamera.
  105993. * It groups all the default supported inputs for ease of use.
  105994. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105995. */
  105996. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  105997. /**
  105998. * Instantiates a new FlyCameraInputsManager.
  105999. * @param camera Defines the camera the inputs belong to.
  106000. */
  106001. constructor(camera: FlyCamera);
  106002. /**
  106003. * Add keyboard input support to the input manager.
  106004. * @returns the new FlyCameraKeyboardMoveInput().
  106005. */
  106006. addKeyboard(): FlyCameraInputsManager;
  106007. /**
  106008. * Add mouse input support to the input manager.
  106009. * @param touchEnabled Enable touch screen support.
  106010. * @returns the new FlyCameraMouseInput().
  106011. */
  106012. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  106013. }
  106014. }
  106015. declare module BABYLON {
  106016. /**
  106017. * This is a flying camera, designed for 3D movement and rotation in all directions,
  106018. * such as in a 3D Space Shooter or a Flight Simulator.
  106019. */
  106020. export class FlyCamera extends TargetCamera {
  106021. /**
  106022. * Define the collision ellipsoid of the camera.
  106023. * This is helpful for simulating a camera body, like a player's body.
  106024. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  106025. */
  106026. ellipsoid: Vector3;
  106027. /**
  106028. * Define an offset for the position of the ellipsoid around the camera.
  106029. * This can be helpful if the camera is attached away from the player's body center,
  106030. * such as at its head.
  106031. */
  106032. ellipsoidOffset: Vector3;
  106033. /**
  106034. * Enable or disable collisions of the camera with the rest of the scene objects.
  106035. */
  106036. checkCollisions: boolean;
  106037. /**
  106038. * Enable or disable gravity on the camera.
  106039. */
  106040. applyGravity: boolean;
  106041. /**
  106042. * Define the current direction the camera is moving to.
  106043. */
  106044. cameraDirection: Vector3;
  106045. /**
  106046. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  106047. * This overrides and empties cameraRotation.
  106048. */
  106049. rotationQuaternion: Quaternion;
  106050. /**
  106051. * Track Roll to maintain the wanted Rolling when looking around.
  106052. */
  106053. _trackRoll: number;
  106054. /**
  106055. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  106056. */
  106057. rollCorrect: number;
  106058. /**
  106059. * Mimic a banked turn, Rolling the camera when Yawing.
  106060. * It's recommended to use rollCorrect = 10 for faster banking correction.
  106061. */
  106062. bankedTurn: boolean;
  106063. /**
  106064. * Limit in radians for how much Roll banking will add. (Default: 90°)
  106065. */
  106066. bankedTurnLimit: number;
  106067. /**
  106068. * Value of 0 disables the banked Roll.
  106069. * Value of 1 is equal to the Yaw angle in radians.
  106070. */
  106071. bankedTurnMultiplier: number;
  106072. /**
  106073. * The inputs manager loads all the input sources, such as keyboard and mouse.
  106074. */
  106075. inputs: FlyCameraInputsManager;
  106076. /**
  106077. * Gets the input sensibility for mouse input.
  106078. * Higher values reduce sensitivity.
  106079. */
  106080. /**
  106081. * Sets the input sensibility for a mouse input.
  106082. * Higher values reduce sensitivity.
  106083. */
  106084. angularSensibility: number;
  106085. /**
  106086. * Get the keys for camera movement forward.
  106087. */
  106088. /**
  106089. * Set the keys for camera movement forward.
  106090. */
  106091. keysForward: number[];
  106092. /**
  106093. * Get the keys for camera movement backward.
  106094. */
  106095. keysBackward: number[];
  106096. /**
  106097. * Get the keys for camera movement up.
  106098. */
  106099. /**
  106100. * Set the keys for camera movement up.
  106101. */
  106102. keysUp: number[];
  106103. /**
  106104. * Get the keys for camera movement down.
  106105. */
  106106. /**
  106107. * Set the keys for camera movement down.
  106108. */
  106109. keysDown: number[];
  106110. /**
  106111. * Get the keys for camera movement left.
  106112. */
  106113. /**
  106114. * Set the keys for camera movement left.
  106115. */
  106116. keysLeft: number[];
  106117. /**
  106118. * Set the keys for camera movement right.
  106119. */
  106120. /**
  106121. * Set the keys for camera movement right.
  106122. */
  106123. keysRight: number[];
  106124. /**
  106125. * Event raised when the camera collides with a mesh in the scene.
  106126. */
  106127. onCollide: (collidedMesh: AbstractMesh) => void;
  106128. private _collider;
  106129. private _needMoveForGravity;
  106130. private _oldPosition;
  106131. private _diffPosition;
  106132. private _newPosition;
  106133. /** @hidden */
  106134. _localDirection: Vector3;
  106135. /** @hidden */
  106136. _transformedDirection: Vector3;
  106137. /**
  106138. * Instantiates a FlyCamera.
  106139. * This is a flying camera, designed for 3D movement and rotation in all directions,
  106140. * such as in a 3D Space Shooter or a Flight Simulator.
  106141. * @param name Define the name of the camera in the scene.
  106142. * @param position Define the starting position of the camera in the scene.
  106143. * @param scene Define the scene the camera belongs to.
  106144. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  106145. */
  106146. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106147. /**
  106148. * Attach a control to the HTML DOM element.
  106149. * @param element Defines the element that listens to the input events.
  106150. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  106151. */
  106152. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106153. /**
  106154. * Detach a control from the HTML DOM element.
  106155. * The camera will stop reacting to that input.
  106156. * @param element Defines the element that listens to the input events.
  106157. */
  106158. detachControl(element: HTMLElement): void;
  106159. private _collisionMask;
  106160. /**
  106161. * Get the mask that the camera ignores in collision events.
  106162. */
  106163. /**
  106164. * Set the mask that the camera ignores in collision events.
  106165. */
  106166. collisionMask: number;
  106167. /** @hidden */
  106168. _collideWithWorld(displacement: Vector3): void;
  106169. /** @hidden */
  106170. private _onCollisionPositionChange;
  106171. /** @hidden */
  106172. _checkInputs(): void;
  106173. /** @hidden */
  106174. _decideIfNeedsToMove(): boolean;
  106175. /** @hidden */
  106176. _updatePosition(): void;
  106177. /**
  106178. * Restore the Roll to its target value at the rate specified.
  106179. * @param rate - Higher means slower restoring.
  106180. * @hidden
  106181. */
  106182. restoreRoll(rate: number): void;
  106183. /**
  106184. * Destroy the camera and release the current resources held by it.
  106185. */
  106186. dispose(): void;
  106187. /**
  106188. * Get the current object class name.
  106189. * @returns the class name.
  106190. */
  106191. getClassName(): string;
  106192. }
  106193. }
  106194. declare module BABYLON {
  106195. /**
  106196. * Listen to keyboard events to control the camera.
  106197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106198. */
  106199. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  106200. /**
  106201. * Defines the camera the input is attached to.
  106202. */
  106203. camera: FlyCamera;
  106204. /**
  106205. * The list of keyboard keys used to control the forward move of the camera.
  106206. */
  106207. keysForward: number[];
  106208. /**
  106209. * The list of keyboard keys used to control the backward move of the camera.
  106210. */
  106211. keysBackward: number[];
  106212. /**
  106213. * The list of keyboard keys used to control the forward move of the camera.
  106214. */
  106215. keysUp: number[];
  106216. /**
  106217. * The list of keyboard keys used to control the backward move of the camera.
  106218. */
  106219. keysDown: number[];
  106220. /**
  106221. * The list of keyboard keys used to control the right strafe move of the camera.
  106222. */
  106223. keysRight: number[];
  106224. /**
  106225. * The list of keyboard keys used to control the left strafe move of the camera.
  106226. */
  106227. keysLeft: number[];
  106228. private _keys;
  106229. private _onCanvasBlurObserver;
  106230. private _onKeyboardObserver;
  106231. private _engine;
  106232. private _scene;
  106233. /**
  106234. * Attach the input controls to a specific dom element to get the input from.
  106235. * @param element Defines the element the controls should be listened from
  106236. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106237. */
  106238. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106239. /**
  106240. * Detach the current controls from the specified dom element.
  106241. * @param element Defines the element to stop listening the inputs from
  106242. */
  106243. detachControl(element: Nullable<HTMLElement>): void;
  106244. /**
  106245. * Gets the class name of the current intput.
  106246. * @returns the class name
  106247. */
  106248. getClassName(): string;
  106249. /** @hidden */
  106250. _onLostFocus(e: FocusEvent): void;
  106251. /**
  106252. * Get the friendly name associated with the input class.
  106253. * @returns the input friendly name
  106254. */
  106255. getSimpleName(): string;
  106256. /**
  106257. * Update the current camera state depending on the inputs that have been used this frame.
  106258. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106259. */
  106260. checkInputs(): void;
  106261. }
  106262. }
  106263. declare module BABYLON {
  106264. /**
  106265. * Manage the mouse wheel inputs to control a follow camera.
  106266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106267. */
  106268. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  106269. /**
  106270. * Defines the camera the input is attached to.
  106271. */
  106272. camera: FollowCamera;
  106273. /**
  106274. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  106275. */
  106276. axisControlRadius: boolean;
  106277. /**
  106278. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  106279. */
  106280. axisControlHeight: boolean;
  106281. /**
  106282. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  106283. */
  106284. axisControlRotation: boolean;
  106285. /**
  106286. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  106287. * relation to mouseWheel events.
  106288. */
  106289. wheelPrecision: number;
  106290. /**
  106291. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  106292. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  106293. */
  106294. wheelDeltaPercentage: number;
  106295. private _wheel;
  106296. private _observer;
  106297. /**
  106298. * Attach the input controls to a specific dom element to get the input from.
  106299. * @param element Defines the element the controls should be listened from
  106300. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106301. */
  106302. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106303. /**
  106304. * Detach the current controls from the specified dom element.
  106305. * @param element Defines the element to stop listening the inputs from
  106306. */
  106307. detachControl(element: Nullable<HTMLElement>): void;
  106308. /**
  106309. * Gets the class name of the current intput.
  106310. * @returns the class name
  106311. */
  106312. getClassName(): string;
  106313. /**
  106314. * Get the friendly name associated with the input class.
  106315. * @returns the input friendly name
  106316. */
  106317. getSimpleName(): string;
  106318. }
  106319. }
  106320. declare module BABYLON {
  106321. /**
  106322. * Manage the pointers inputs to control an follow camera.
  106323. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106324. */
  106325. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  106326. /**
  106327. * Defines the camera the input is attached to.
  106328. */
  106329. camera: FollowCamera;
  106330. /**
  106331. * Gets the class name of the current input.
  106332. * @returns the class name
  106333. */
  106334. getClassName(): string;
  106335. /**
  106336. * Defines the pointer angular sensibility along the X axis or how fast is
  106337. * the camera rotating.
  106338. * A negative number will reverse the axis direction.
  106339. */
  106340. angularSensibilityX: number;
  106341. /**
  106342. * Defines the pointer angular sensibility along the Y axis or how fast is
  106343. * the camera rotating.
  106344. * A negative number will reverse the axis direction.
  106345. */
  106346. angularSensibilityY: number;
  106347. /**
  106348. * Defines the pointer pinch precision or how fast is the camera zooming.
  106349. * A negative number will reverse the axis direction.
  106350. */
  106351. pinchPrecision: number;
  106352. /**
  106353. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  106354. * from 0.
  106355. * It defines the percentage of current camera.radius to use as delta when
  106356. * pinch zoom is used.
  106357. */
  106358. pinchDeltaPercentage: number;
  106359. /**
  106360. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  106361. */
  106362. axisXControlRadius: boolean;
  106363. /**
  106364. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  106365. */
  106366. axisXControlHeight: boolean;
  106367. /**
  106368. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  106369. */
  106370. axisXControlRotation: boolean;
  106371. /**
  106372. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  106373. */
  106374. axisYControlRadius: boolean;
  106375. /**
  106376. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  106377. */
  106378. axisYControlHeight: boolean;
  106379. /**
  106380. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  106381. */
  106382. axisYControlRotation: boolean;
  106383. /**
  106384. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  106385. */
  106386. axisPinchControlRadius: boolean;
  106387. /**
  106388. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  106389. */
  106390. axisPinchControlHeight: boolean;
  106391. /**
  106392. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  106393. */
  106394. axisPinchControlRotation: boolean;
  106395. /**
  106396. * Log error messages if basic misconfiguration has occurred.
  106397. */
  106398. warningEnable: boolean;
  106399. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106400. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106401. private _warningCounter;
  106402. private _warning;
  106403. }
  106404. }
  106405. declare module BABYLON {
  106406. /**
  106407. * Default Inputs manager for the FollowCamera.
  106408. * It groups all the default supported inputs for ease of use.
  106409. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106410. */
  106411. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  106412. /**
  106413. * Instantiates a new FollowCameraInputsManager.
  106414. * @param camera Defines the camera the inputs belong to
  106415. */
  106416. constructor(camera: FollowCamera);
  106417. /**
  106418. * Add keyboard input support to the input manager.
  106419. * @returns the current input manager
  106420. */
  106421. addKeyboard(): FollowCameraInputsManager;
  106422. /**
  106423. * Add mouse wheel input support to the input manager.
  106424. * @returns the current input manager
  106425. */
  106426. addMouseWheel(): FollowCameraInputsManager;
  106427. /**
  106428. * Add pointers input support to the input manager.
  106429. * @returns the current input manager
  106430. */
  106431. addPointers(): FollowCameraInputsManager;
  106432. /**
  106433. * Add orientation input support to the input manager.
  106434. * @returns the current input manager
  106435. */
  106436. addVRDeviceOrientation(): FollowCameraInputsManager;
  106437. }
  106438. }
  106439. declare module BABYLON {
  106440. /**
  106441. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  106442. * an arc rotate version arcFollowCamera are available.
  106443. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106444. */
  106445. export class FollowCamera extends TargetCamera {
  106446. /**
  106447. * Distance the follow camera should follow an object at
  106448. */
  106449. radius: number;
  106450. /**
  106451. * Minimum allowed distance of the camera to the axis of rotation
  106452. * (The camera can not get closer).
  106453. * This can help limiting how the Camera is able to move in the scene.
  106454. */
  106455. lowerRadiusLimit: Nullable<number>;
  106456. /**
  106457. * Maximum allowed distance of the camera to the axis of rotation
  106458. * (The camera can not get further).
  106459. * This can help limiting how the Camera is able to move in the scene.
  106460. */
  106461. upperRadiusLimit: Nullable<number>;
  106462. /**
  106463. * Define a rotation offset between the camera and the object it follows
  106464. */
  106465. rotationOffset: number;
  106466. /**
  106467. * Minimum allowed angle to camera position relative to target object.
  106468. * This can help limiting how the Camera is able to move in the scene.
  106469. */
  106470. lowerRotationOffsetLimit: Nullable<number>;
  106471. /**
  106472. * Maximum allowed angle to camera position relative to target object.
  106473. * This can help limiting how the Camera is able to move in the scene.
  106474. */
  106475. upperRotationOffsetLimit: Nullable<number>;
  106476. /**
  106477. * Define a height offset between the camera and the object it follows.
  106478. * It can help following an object from the top (like a car chaing a plane)
  106479. */
  106480. heightOffset: number;
  106481. /**
  106482. * Minimum allowed height of camera position relative to target object.
  106483. * This can help limiting how the Camera is able to move in the scene.
  106484. */
  106485. lowerHeightOffsetLimit: Nullable<number>;
  106486. /**
  106487. * Maximum allowed height of camera position relative to target object.
  106488. * This can help limiting how the Camera is able to move in the scene.
  106489. */
  106490. upperHeightOffsetLimit: Nullable<number>;
  106491. /**
  106492. * Define how fast the camera can accelerate to follow it s target.
  106493. */
  106494. cameraAcceleration: number;
  106495. /**
  106496. * Define the speed limit of the camera following an object.
  106497. */
  106498. maxCameraSpeed: number;
  106499. /**
  106500. * Define the target of the camera.
  106501. */
  106502. lockedTarget: Nullable<AbstractMesh>;
  106503. /**
  106504. * Defines the input associated with the camera.
  106505. */
  106506. inputs: FollowCameraInputsManager;
  106507. /**
  106508. * Instantiates the follow camera.
  106509. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106510. * @param name Define the name of the camera in the scene
  106511. * @param position Define the position of the camera
  106512. * @param scene Define the scene the camera belong to
  106513. * @param lockedTarget Define the target of the camera
  106514. */
  106515. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  106516. private _follow;
  106517. /**
  106518. * Attached controls to the current camera.
  106519. * @param element Defines the element the controls should be listened from
  106520. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106521. */
  106522. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106523. /**
  106524. * Detach the current controls from the camera.
  106525. * The camera will stop reacting to inputs.
  106526. * @param element Defines the element to stop listening the inputs from
  106527. */
  106528. detachControl(element: HTMLElement): void;
  106529. /** @hidden */
  106530. _checkInputs(): void;
  106531. private _checkLimits;
  106532. /**
  106533. * Gets the camera class name.
  106534. * @returns the class name
  106535. */
  106536. getClassName(): string;
  106537. }
  106538. /**
  106539. * Arc Rotate version of the follow camera.
  106540. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  106541. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106542. */
  106543. export class ArcFollowCamera extends TargetCamera {
  106544. /** The longitudinal angle of the camera */
  106545. alpha: number;
  106546. /** The latitudinal angle of the camera */
  106547. beta: number;
  106548. /** The radius of the camera from its target */
  106549. radius: number;
  106550. /** Define the camera target (the messh it should follow) */
  106551. target: Nullable<AbstractMesh>;
  106552. private _cartesianCoordinates;
  106553. /**
  106554. * Instantiates a new ArcFollowCamera
  106555. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106556. * @param name Define the name of the camera
  106557. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  106558. * @param beta Define the rotation angle of the camera around the elevation axis
  106559. * @param radius Define the radius of the camera from its target point
  106560. * @param target Define the target of the camera
  106561. * @param scene Define the scene the camera belongs to
  106562. */
  106563. constructor(name: string,
  106564. /** The longitudinal angle of the camera */
  106565. alpha: number,
  106566. /** The latitudinal angle of the camera */
  106567. beta: number,
  106568. /** The radius of the camera from its target */
  106569. radius: number,
  106570. /** Define the camera target (the messh it should follow) */
  106571. target: Nullable<AbstractMesh>, scene: Scene);
  106572. private _follow;
  106573. /** @hidden */
  106574. _checkInputs(): void;
  106575. /**
  106576. * Returns the class name of the object.
  106577. * It is mostly used internally for serialization purposes.
  106578. */
  106579. getClassName(): string;
  106580. }
  106581. }
  106582. declare module BABYLON {
  106583. /**
  106584. * Manage the keyboard inputs to control the movement of a follow camera.
  106585. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106586. */
  106587. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  106588. /**
  106589. * Defines the camera the input is attached to.
  106590. */
  106591. camera: FollowCamera;
  106592. /**
  106593. * Defines the list of key codes associated with the up action (increase heightOffset)
  106594. */
  106595. keysHeightOffsetIncr: number[];
  106596. /**
  106597. * Defines the list of key codes associated with the down action (decrease heightOffset)
  106598. */
  106599. keysHeightOffsetDecr: number[];
  106600. /**
  106601. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  106602. */
  106603. keysHeightOffsetModifierAlt: boolean;
  106604. /**
  106605. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  106606. */
  106607. keysHeightOffsetModifierCtrl: boolean;
  106608. /**
  106609. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  106610. */
  106611. keysHeightOffsetModifierShift: boolean;
  106612. /**
  106613. * Defines the list of key codes associated with the left action (increase rotationOffset)
  106614. */
  106615. keysRotationOffsetIncr: number[];
  106616. /**
  106617. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  106618. */
  106619. keysRotationOffsetDecr: number[];
  106620. /**
  106621. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  106622. */
  106623. keysRotationOffsetModifierAlt: boolean;
  106624. /**
  106625. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  106626. */
  106627. keysRotationOffsetModifierCtrl: boolean;
  106628. /**
  106629. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  106630. */
  106631. keysRotationOffsetModifierShift: boolean;
  106632. /**
  106633. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  106634. */
  106635. keysRadiusIncr: number[];
  106636. /**
  106637. * Defines the list of key codes associated with the zoom-out action (increase radius)
  106638. */
  106639. keysRadiusDecr: number[];
  106640. /**
  106641. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  106642. */
  106643. keysRadiusModifierAlt: boolean;
  106644. /**
  106645. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  106646. */
  106647. keysRadiusModifierCtrl: boolean;
  106648. /**
  106649. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  106650. */
  106651. keysRadiusModifierShift: boolean;
  106652. /**
  106653. * Defines the rate of change of heightOffset.
  106654. */
  106655. heightSensibility: number;
  106656. /**
  106657. * Defines the rate of change of rotationOffset.
  106658. */
  106659. rotationSensibility: number;
  106660. /**
  106661. * Defines the rate of change of radius.
  106662. */
  106663. radiusSensibility: number;
  106664. private _keys;
  106665. private _ctrlPressed;
  106666. private _altPressed;
  106667. private _shiftPressed;
  106668. private _onCanvasBlurObserver;
  106669. private _onKeyboardObserver;
  106670. private _engine;
  106671. private _scene;
  106672. /**
  106673. * Attach the input controls to a specific dom element to get the input from.
  106674. * @param element Defines the element the controls should be listened from
  106675. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106676. */
  106677. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106678. /**
  106679. * Detach the current controls from the specified dom element.
  106680. * @param element Defines the element to stop listening the inputs from
  106681. */
  106682. detachControl(element: Nullable<HTMLElement>): void;
  106683. /**
  106684. * Update the current camera state depending on the inputs that have been used this frame.
  106685. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106686. */
  106687. checkInputs(): void;
  106688. /**
  106689. * Gets the class name of the current input.
  106690. * @returns the class name
  106691. */
  106692. getClassName(): string;
  106693. /**
  106694. * Get the friendly name associated with the input class.
  106695. * @returns the input friendly name
  106696. */
  106697. getSimpleName(): string;
  106698. /**
  106699. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106700. * allow modification of the heightOffset value.
  106701. */
  106702. private _modifierHeightOffset;
  106703. /**
  106704. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106705. * allow modification of the rotationOffset value.
  106706. */
  106707. private _modifierRotationOffset;
  106708. /**
  106709. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106710. * allow modification of the radius value.
  106711. */
  106712. private _modifierRadius;
  106713. }
  106714. }
  106715. declare module BABYLON {
  106716. interface FreeCameraInputsManager {
  106717. /**
  106718. * @hidden
  106719. */
  106720. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  106721. /**
  106722. * Add orientation input support to the input manager.
  106723. * @returns the current input manager
  106724. */
  106725. addDeviceOrientation(): FreeCameraInputsManager;
  106726. }
  106727. /**
  106728. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  106729. * Screen rotation is taken into account.
  106730. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106731. */
  106732. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  106733. private _camera;
  106734. private _screenOrientationAngle;
  106735. private _constantTranform;
  106736. private _screenQuaternion;
  106737. private _alpha;
  106738. private _beta;
  106739. private _gamma;
  106740. /**
  106741. * Can be used to detect if a device orientation sensor is availible on a device
  106742. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  106743. * @returns a promise that will resolve on orientation change
  106744. */
  106745. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  106746. /**
  106747. * @hidden
  106748. */
  106749. _onDeviceOrientationChangedObservable: Observable<void>;
  106750. /**
  106751. * Instantiates a new input
  106752. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106753. */
  106754. constructor();
  106755. /**
  106756. * Define the camera controlled by the input.
  106757. */
  106758. camera: FreeCamera;
  106759. /**
  106760. * Attach the input controls to a specific dom element to get the input from.
  106761. * @param element Defines the element the controls should be listened from
  106762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106763. */
  106764. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106765. private _orientationChanged;
  106766. private _deviceOrientation;
  106767. /**
  106768. * Detach the current controls from the specified dom element.
  106769. * @param element Defines the element to stop listening the inputs from
  106770. */
  106771. detachControl(element: Nullable<HTMLElement>): void;
  106772. /**
  106773. * Update the current camera state depending on the inputs that have been used this frame.
  106774. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106775. */
  106776. checkInputs(): void;
  106777. /**
  106778. * Gets the class name of the current intput.
  106779. * @returns the class name
  106780. */
  106781. getClassName(): string;
  106782. /**
  106783. * Get the friendly name associated with the input class.
  106784. * @returns the input friendly name
  106785. */
  106786. getSimpleName(): string;
  106787. }
  106788. }
  106789. declare module BABYLON {
  106790. /**
  106791. * Manage the gamepad inputs to control a free camera.
  106792. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106793. */
  106794. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  106795. /**
  106796. * Define the camera the input is attached to.
  106797. */
  106798. camera: FreeCamera;
  106799. /**
  106800. * Define the Gamepad controlling the input
  106801. */
  106802. gamepad: Nullable<Gamepad>;
  106803. /**
  106804. * Defines the gamepad rotation sensiblity.
  106805. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106806. */
  106807. gamepadAngularSensibility: number;
  106808. /**
  106809. * Defines the gamepad move sensiblity.
  106810. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106811. */
  106812. gamepadMoveSensibility: number;
  106813. private _yAxisScale;
  106814. /**
  106815. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  106816. */
  106817. invertYAxis: boolean;
  106818. private _onGamepadConnectedObserver;
  106819. private _onGamepadDisconnectedObserver;
  106820. private _cameraTransform;
  106821. private _deltaTransform;
  106822. private _vector3;
  106823. private _vector2;
  106824. /**
  106825. * Attach the input controls to a specific dom element to get the input from.
  106826. * @param element Defines the element the controls should be listened from
  106827. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106828. */
  106829. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106830. /**
  106831. * Detach the current controls from the specified dom element.
  106832. * @param element Defines the element to stop listening the inputs from
  106833. */
  106834. detachControl(element: Nullable<HTMLElement>): void;
  106835. /**
  106836. * Update the current camera state depending on the inputs that have been used this frame.
  106837. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106838. */
  106839. checkInputs(): void;
  106840. /**
  106841. * Gets the class name of the current intput.
  106842. * @returns the class name
  106843. */
  106844. getClassName(): string;
  106845. /**
  106846. * Get the friendly name associated with the input class.
  106847. * @returns the input friendly name
  106848. */
  106849. getSimpleName(): string;
  106850. }
  106851. }
  106852. declare module BABYLON {
  106853. /**
  106854. * Defines the potential axis of a Joystick
  106855. */
  106856. export enum JoystickAxis {
  106857. /** X axis */
  106858. X = 0,
  106859. /** Y axis */
  106860. Y = 1,
  106861. /** Z axis */
  106862. Z = 2
  106863. }
  106864. /**
  106865. * Class used to define virtual joystick (used in touch mode)
  106866. */
  106867. export class VirtualJoystick {
  106868. /**
  106869. * Gets or sets a boolean indicating that left and right values must be inverted
  106870. */
  106871. reverseLeftRight: boolean;
  106872. /**
  106873. * Gets or sets a boolean indicating that up and down values must be inverted
  106874. */
  106875. reverseUpDown: boolean;
  106876. /**
  106877. * Gets the offset value for the position (ie. the change of the position value)
  106878. */
  106879. deltaPosition: Vector3;
  106880. /**
  106881. * Gets a boolean indicating if the virtual joystick was pressed
  106882. */
  106883. pressed: boolean;
  106884. /**
  106885. * Canvas the virtual joystick will render onto, default z-index of this is 5
  106886. */
  106887. static Canvas: Nullable<HTMLCanvasElement>;
  106888. private static _globalJoystickIndex;
  106889. private static vjCanvasContext;
  106890. private static vjCanvasWidth;
  106891. private static vjCanvasHeight;
  106892. private static halfWidth;
  106893. private _action;
  106894. private _axisTargetedByLeftAndRight;
  106895. private _axisTargetedByUpAndDown;
  106896. private _joystickSensibility;
  106897. private _inversedSensibility;
  106898. private _joystickPointerID;
  106899. private _joystickColor;
  106900. private _joystickPointerPos;
  106901. private _joystickPreviousPointerPos;
  106902. private _joystickPointerStartPos;
  106903. private _deltaJoystickVector;
  106904. private _leftJoystick;
  106905. private _touches;
  106906. private _onPointerDownHandlerRef;
  106907. private _onPointerMoveHandlerRef;
  106908. private _onPointerUpHandlerRef;
  106909. private _onResize;
  106910. /**
  106911. * Creates a new virtual joystick
  106912. * @param leftJoystick defines that the joystick is for left hand (false by default)
  106913. */
  106914. constructor(leftJoystick?: boolean);
  106915. /**
  106916. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  106917. * @param newJoystickSensibility defines the new sensibility
  106918. */
  106919. setJoystickSensibility(newJoystickSensibility: number): void;
  106920. private _onPointerDown;
  106921. private _onPointerMove;
  106922. private _onPointerUp;
  106923. /**
  106924. * Change the color of the virtual joystick
  106925. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  106926. */
  106927. setJoystickColor(newColor: string): void;
  106928. /**
  106929. * Defines a callback to call when the joystick is touched
  106930. * @param action defines the callback
  106931. */
  106932. setActionOnTouch(action: () => any): void;
  106933. /**
  106934. * Defines which axis you'd like to control for left & right
  106935. * @param axis defines the axis to use
  106936. */
  106937. setAxisForLeftRight(axis: JoystickAxis): void;
  106938. /**
  106939. * Defines which axis you'd like to control for up & down
  106940. * @param axis defines the axis to use
  106941. */
  106942. setAxisForUpDown(axis: JoystickAxis): void;
  106943. private _drawVirtualJoystick;
  106944. /**
  106945. * Release internal HTML canvas
  106946. */
  106947. releaseCanvas(): void;
  106948. }
  106949. }
  106950. declare module BABYLON {
  106951. interface FreeCameraInputsManager {
  106952. /**
  106953. * Add virtual joystick input support to the input manager.
  106954. * @returns the current input manager
  106955. */
  106956. addVirtualJoystick(): FreeCameraInputsManager;
  106957. }
  106958. /**
  106959. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  106960. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106961. */
  106962. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  106963. /**
  106964. * Defines the camera the input is attached to.
  106965. */
  106966. camera: FreeCamera;
  106967. private _leftjoystick;
  106968. private _rightjoystick;
  106969. /**
  106970. * Gets the left stick of the virtual joystick.
  106971. * @returns The virtual Joystick
  106972. */
  106973. getLeftJoystick(): VirtualJoystick;
  106974. /**
  106975. * Gets the right stick of the virtual joystick.
  106976. * @returns The virtual Joystick
  106977. */
  106978. getRightJoystick(): VirtualJoystick;
  106979. /**
  106980. * Update the current camera state depending on the inputs that have been used this frame.
  106981. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106982. */
  106983. checkInputs(): void;
  106984. /**
  106985. * Attach the input controls to a specific dom element to get the input from.
  106986. * @param element Defines the element the controls should be listened from
  106987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106988. */
  106989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106990. /**
  106991. * Detach the current controls from the specified dom element.
  106992. * @param element Defines the element to stop listening the inputs from
  106993. */
  106994. detachControl(element: Nullable<HTMLElement>): void;
  106995. /**
  106996. * Gets the class name of the current intput.
  106997. * @returns the class name
  106998. */
  106999. getClassName(): string;
  107000. /**
  107001. * Get the friendly name associated with the input class.
  107002. * @returns the input friendly name
  107003. */
  107004. getSimpleName(): string;
  107005. }
  107006. }
  107007. declare module BABYLON {
  107008. /**
  107009. * This represents a FPS type of camera controlled by touch.
  107010. * This is like a universal camera minus the Gamepad controls.
  107011. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107012. */
  107013. export class TouchCamera extends FreeCamera {
  107014. /**
  107015. * Defines the touch sensibility for rotation.
  107016. * The higher the faster.
  107017. */
  107018. touchAngularSensibility: number;
  107019. /**
  107020. * Defines the touch sensibility for move.
  107021. * The higher the faster.
  107022. */
  107023. touchMoveSensibility: number;
  107024. /**
  107025. * Instantiates a new touch camera.
  107026. * This represents a FPS type of camera controlled by touch.
  107027. * This is like a universal camera minus the Gamepad controls.
  107028. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107029. * @param name Define the name of the camera in the scene
  107030. * @param position Define the start position of the camera in the scene
  107031. * @param scene Define the scene the camera belongs to
  107032. */
  107033. constructor(name: string, position: Vector3, scene: Scene);
  107034. /**
  107035. * Gets the current object class name.
  107036. * @return the class name
  107037. */
  107038. getClassName(): string;
  107039. /** @hidden */
  107040. _setupInputs(): void;
  107041. }
  107042. }
  107043. declare module BABYLON {
  107044. /**
  107045. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  107046. * being tilted forward or back and left or right.
  107047. */
  107048. export class DeviceOrientationCamera extends FreeCamera {
  107049. private _initialQuaternion;
  107050. private _quaternionCache;
  107051. private _tmpDragQuaternion;
  107052. private _disablePointerInputWhenUsingDeviceOrientation;
  107053. /**
  107054. * Creates a new device orientation camera
  107055. * @param name The name of the camera
  107056. * @param position The start position camera
  107057. * @param scene The scene the camera belongs to
  107058. */
  107059. constructor(name: string, position: Vector3, scene: Scene);
  107060. /**
  107061. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  107062. */
  107063. disablePointerInputWhenUsingDeviceOrientation: boolean;
  107064. private _dragFactor;
  107065. /**
  107066. * Enabled turning on the y axis when the orientation sensor is active
  107067. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  107068. */
  107069. enableHorizontalDragging(dragFactor?: number): void;
  107070. /**
  107071. * Gets the current instance class name ("DeviceOrientationCamera").
  107072. * This helps avoiding instanceof at run time.
  107073. * @returns the class name
  107074. */
  107075. getClassName(): string;
  107076. /**
  107077. * @hidden
  107078. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  107079. */
  107080. _checkInputs(): void;
  107081. /**
  107082. * Reset the camera to its default orientation on the specified axis only.
  107083. * @param axis The axis to reset
  107084. */
  107085. resetToCurrentRotation(axis?: Axis): void;
  107086. }
  107087. }
  107088. declare module BABYLON {
  107089. /**
  107090. * Defines supported buttons for XBox360 compatible gamepads
  107091. */
  107092. export enum Xbox360Button {
  107093. /** A */
  107094. A = 0,
  107095. /** B */
  107096. B = 1,
  107097. /** X */
  107098. X = 2,
  107099. /** Y */
  107100. Y = 3,
  107101. /** Start */
  107102. Start = 4,
  107103. /** Back */
  107104. Back = 5,
  107105. /** Left button */
  107106. LB = 6,
  107107. /** Right button */
  107108. RB = 7,
  107109. /** Left stick */
  107110. LeftStick = 8,
  107111. /** Right stick */
  107112. RightStick = 9
  107113. }
  107114. /** Defines values for XBox360 DPad */
  107115. export enum Xbox360Dpad {
  107116. /** Up */
  107117. Up = 0,
  107118. /** Down */
  107119. Down = 1,
  107120. /** Left */
  107121. Left = 2,
  107122. /** Right */
  107123. Right = 3
  107124. }
  107125. /**
  107126. * Defines a XBox360 gamepad
  107127. */
  107128. export class Xbox360Pad extends Gamepad {
  107129. private _leftTrigger;
  107130. private _rightTrigger;
  107131. private _onlefttriggerchanged;
  107132. private _onrighttriggerchanged;
  107133. private _onbuttondown;
  107134. private _onbuttonup;
  107135. private _ondpaddown;
  107136. private _ondpadup;
  107137. /** Observable raised when a button is pressed */
  107138. onButtonDownObservable: Observable<Xbox360Button>;
  107139. /** Observable raised when a button is released */
  107140. onButtonUpObservable: Observable<Xbox360Button>;
  107141. /** Observable raised when a pad is pressed */
  107142. onPadDownObservable: Observable<Xbox360Dpad>;
  107143. /** Observable raised when a pad is released */
  107144. onPadUpObservable: Observable<Xbox360Dpad>;
  107145. private _buttonA;
  107146. private _buttonB;
  107147. private _buttonX;
  107148. private _buttonY;
  107149. private _buttonBack;
  107150. private _buttonStart;
  107151. private _buttonLB;
  107152. private _buttonRB;
  107153. private _buttonLeftStick;
  107154. private _buttonRightStick;
  107155. private _dPadUp;
  107156. private _dPadDown;
  107157. private _dPadLeft;
  107158. private _dPadRight;
  107159. private _isXboxOnePad;
  107160. /**
  107161. * Creates a new XBox360 gamepad object
  107162. * @param id defines the id of this gamepad
  107163. * @param index defines its index
  107164. * @param gamepad defines the internal HTML gamepad object
  107165. * @param xboxOne defines if it is a XBox One gamepad
  107166. */
  107167. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  107168. /**
  107169. * Defines the callback to call when left trigger is pressed
  107170. * @param callback defines the callback to use
  107171. */
  107172. onlefttriggerchanged(callback: (value: number) => void): void;
  107173. /**
  107174. * Defines the callback to call when right trigger is pressed
  107175. * @param callback defines the callback to use
  107176. */
  107177. onrighttriggerchanged(callback: (value: number) => void): void;
  107178. /**
  107179. * Gets the left trigger value
  107180. */
  107181. /**
  107182. * Sets the left trigger value
  107183. */
  107184. leftTrigger: number;
  107185. /**
  107186. * Gets the right trigger value
  107187. */
  107188. /**
  107189. * Sets the right trigger value
  107190. */
  107191. rightTrigger: number;
  107192. /**
  107193. * Defines the callback to call when a button is pressed
  107194. * @param callback defines the callback to use
  107195. */
  107196. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  107197. /**
  107198. * Defines the callback to call when a button is released
  107199. * @param callback defines the callback to use
  107200. */
  107201. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  107202. /**
  107203. * Defines the callback to call when a pad is pressed
  107204. * @param callback defines the callback to use
  107205. */
  107206. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  107207. /**
  107208. * Defines the callback to call when a pad is released
  107209. * @param callback defines the callback to use
  107210. */
  107211. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  107212. private _setButtonValue;
  107213. private _setDPadValue;
  107214. /**
  107215. * Gets the value of the `A` button
  107216. */
  107217. /**
  107218. * Sets the value of the `A` button
  107219. */
  107220. buttonA: number;
  107221. /**
  107222. * Gets the value of the `B` button
  107223. */
  107224. /**
  107225. * Sets the value of the `B` button
  107226. */
  107227. buttonB: number;
  107228. /**
  107229. * Gets the value of the `X` button
  107230. */
  107231. /**
  107232. * Sets the value of the `X` button
  107233. */
  107234. buttonX: number;
  107235. /**
  107236. * Gets the value of the `Y` button
  107237. */
  107238. /**
  107239. * Sets the value of the `Y` button
  107240. */
  107241. buttonY: number;
  107242. /**
  107243. * Gets the value of the `Start` button
  107244. */
  107245. /**
  107246. * Sets the value of the `Start` button
  107247. */
  107248. buttonStart: number;
  107249. /**
  107250. * Gets the value of the `Back` button
  107251. */
  107252. /**
  107253. * Sets the value of the `Back` button
  107254. */
  107255. buttonBack: number;
  107256. /**
  107257. * Gets the value of the `Left` button
  107258. */
  107259. /**
  107260. * Sets the value of the `Left` button
  107261. */
  107262. buttonLB: number;
  107263. /**
  107264. * Gets the value of the `Right` button
  107265. */
  107266. /**
  107267. * Sets the value of the `Right` button
  107268. */
  107269. buttonRB: number;
  107270. /**
  107271. * Gets the value of the Left joystick
  107272. */
  107273. /**
  107274. * Sets the value of the Left joystick
  107275. */
  107276. buttonLeftStick: number;
  107277. /**
  107278. * Gets the value of the Right joystick
  107279. */
  107280. /**
  107281. * Sets the value of the Right joystick
  107282. */
  107283. buttonRightStick: number;
  107284. /**
  107285. * Gets the value of D-pad up
  107286. */
  107287. /**
  107288. * Sets the value of D-pad up
  107289. */
  107290. dPadUp: number;
  107291. /**
  107292. * Gets the value of D-pad down
  107293. */
  107294. /**
  107295. * Sets the value of D-pad down
  107296. */
  107297. dPadDown: number;
  107298. /**
  107299. * Gets the value of D-pad left
  107300. */
  107301. /**
  107302. * Sets the value of D-pad left
  107303. */
  107304. dPadLeft: number;
  107305. /**
  107306. * Gets the value of D-pad right
  107307. */
  107308. /**
  107309. * Sets the value of D-pad right
  107310. */
  107311. dPadRight: number;
  107312. /**
  107313. * Force the gamepad to synchronize with device values
  107314. */
  107315. update(): void;
  107316. /**
  107317. * Disposes the gamepad
  107318. */
  107319. dispose(): void;
  107320. }
  107321. }
  107322. declare module BABYLON {
  107323. /**
  107324. * Defines supported buttons for DualShock compatible gamepads
  107325. */
  107326. export enum DualShockButton {
  107327. /** Cross */
  107328. Cross = 0,
  107329. /** Circle */
  107330. Circle = 1,
  107331. /** Square */
  107332. Square = 2,
  107333. /** Triangle */
  107334. Triangle = 3,
  107335. /** Options */
  107336. Options = 4,
  107337. /** Share */
  107338. Share = 5,
  107339. /** L1 */
  107340. L1 = 6,
  107341. /** R1 */
  107342. R1 = 7,
  107343. /** Left stick */
  107344. LeftStick = 8,
  107345. /** Right stick */
  107346. RightStick = 9
  107347. }
  107348. /** Defines values for DualShock DPad */
  107349. export enum DualShockDpad {
  107350. /** Up */
  107351. Up = 0,
  107352. /** Down */
  107353. Down = 1,
  107354. /** Left */
  107355. Left = 2,
  107356. /** Right */
  107357. Right = 3
  107358. }
  107359. /**
  107360. * Defines a DualShock gamepad
  107361. */
  107362. export class DualShockPad extends Gamepad {
  107363. private _leftTrigger;
  107364. private _rightTrigger;
  107365. private _onlefttriggerchanged;
  107366. private _onrighttriggerchanged;
  107367. private _onbuttondown;
  107368. private _onbuttonup;
  107369. private _ondpaddown;
  107370. private _ondpadup;
  107371. /** Observable raised when a button is pressed */
  107372. onButtonDownObservable: Observable<DualShockButton>;
  107373. /** Observable raised when a button is released */
  107374. onButtonUpObservable: Observable<DualShockButton>;
  107375. /** Observable raised when a pad is pressed */
  107376. onPadDownObservable: Observable<DualShockDpad>;
  107377. /** Observable raised when a pad is released */
  107378. onPadUpObservable: Observable<DualShockDpad>;
  107379. private _buttonCross;
  107380. private _buttonCircle;
  107381. private _buttonSquare;
  107382. private _buttonTriangle;
  107383. private _buttonShare;
  107384. private _buttonOptions;
  107385. private _buttonL1;
  107386. private _buttonR1;
  107387. private _buttonLeftStick;
  107388. private _buttonRightStick;
  107389. private _dPadUp;
  107390. private _dPadDown;
  107391. private _dPadLeft;
  107392. private _dPadRight;
  107393. /**
  107394. * Creates a new DualShock gamepad object
  107395. * @param id defines the id of this gamepad
  107396. * @param index defines its index
  107397. * @param gamepad defines the internal HTML gamepad object
  107398. */
  107399. constructor(id: string, index: number, gamepad: any);
  107400. /**
  107401. * Defines the callback to call when left trigger is pressed
  107402. * @param callback defines the callback to use
  107403. */
  107404. onlefttriggerchanged(callback: (value: number) => void): void;
  107405. /**
  107406. * Defines the callback to call when right trigger is pressed
  107407. * @param callback defines the callback to use
  107408. */
  107409. onrighttriggerchanged(callback: (value: number) => void): void;
  107410. /**
  107411. * Gets the left trigger value
  107412. */
  107413. /**
  107414. * Sets the left trigger value
  107415. */
  107416. leftTrigger: number;
  107417. /**
  107418. * Gets the right trigger value
  107419. */
  107420. /**
  107421. * Sets the right trigger value
  107422. */
  107423. rightTrigger: number;
  107424. /**
  107425. * Defines the callback to call when a button is pressed
  107426. * @param callback defines the callback to use
  107427. */
  107428. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  107429. /**
  107430. * Defines the callback to call when a button is released
  107431. * @param callback defines the callback to use
  107432. */
  107433. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  107434. /**
  107435. * Defines the callback to call when a pad is pressed
  107436. * @param callback defines the callback to use
  107437. */
  107438. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  107439. /**
  107440. * Defines the callback to call when a pad is released
  107441. * @param callback defines the callback to use
  107442. */
  107443. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  107444. private _setButtonValue;
  107445. private _setDPadValue;
  107446. /**
  107447. * Gets the value of the `Cross` button
  107448. */
  107449. /**
  107450. * Sets the value of the `Cross` button
  107451. */
  107452. buttonCross: number;
  107453. /**
  107454. * Gets the value of the `Circle` button
  107455. */
  107456. /**
  107457. * Sets the value of the `Circle` button
  107458. */
  107459. buttonCircle: number;
  107460. /**
  107461. * Gets the value of the `Square` button
  107462. */
  107463. /**
  107464. * Sets the value of the `Square` button
  107465. */
  107466. buttonSquare: number;
  107467. /**
  107468. * Gets the value of the `Triangle` button
  107469. */
  107470. /**
  107471. * Sets the value of the `Triangle` button
  107472. */
  107473. buttonTriangle: number;
  107474. /**
  107475. * Gets the value of the `Options` button
  107476. */
  107477. /**
  107478. * Sets the value of the `Options` button
  107479. */
  107480. buttonOptions: number;
  107481. /**
  107482. * Gets the value of the `Share` button
  107483. */
  107484. /**
  107485. * Sets the value of the `Share` button
  107486. */
  107487. buttonShare: number;
  107488. /**
  107489. * Gets the value of the `L1` button
  107490. */
  107491. /**
  107492. * Sets the value of the `L1` button
  107493. */
  107494. buttonL1: number;
  107495. /**
  107496. * Gets the value of the `R1` button
  107497. */
  107498. /**
  107499. * Sets the value of the `R1` button
  107500. */
  107501. buttonR1: number;
  107502. /**
  107503. * Gets the value of the Left joystick
  107504. */
  107505. /**
  107506. * Sets the value of the Left joystick
  107507. */
  107508. buttonLeftStick: number;
  107509. /**
  107510. * Gets the value of the Right joystick
  107511. */
  107512. /**
  107513. * Sets the value of the Right joystick
  107514. */
  107515. buttonRightStick: number;
  107516. /**
  107517. * Gets the value of D-pad up
  107518. */
  107519. /**
  107520. * Sets the value of D-pad up
  107521. */
  107522. dPadUp: number;
  107523. /**
  107524. * Gets the value of D-pad down
  107525. */
  107526. /**
  107527. * Sets the value of D-pad down
  107528. */
  107529. dPadDown: number;
  107530. /**
  107531. * Gets the value of D-pad left
  107532. */
  107533. /**
  107534. * Sets the value of D-pad left
  107535. */
  107536. dPadLeft: number;
  107537. /**
  107538. * Gets the value of D-pad right
  107539. */
  107540. /**
  107541. * Sets the value of D-pad right
  107542. */
  107543. dPadRight: number;
  107544. /**
  107545. * Force the gamepad to synchronize with device values
  107546. */
  107547. update(): void;
  107548. /**
  107549. * Disposes the gamepad
  107550. */
  107551. dispose(): void;
  107552. }
  107553. }
  107554. declare module BABYLON {
  107555. /**
  107556. * Manager for handling gamepads
  107557. */
  107558. export class GamepadManager {
  107559. private _scene?;
  107560. private _babylonGamepads;
  107561. private _oneGamepadConnected;
  107562. /** @hidden */
  107563. _isMonitoring: boolean;
  107564. private _gamepadEventSupported;
  107565. private _gamepadSupport;
  107566. /**
  107567. * observable to be triggered when the gamepad controller has been connected
  107568. */
  107569. onGamepadConnectedObservable: Observable<Gamepad>;
  107570. /**
  107571. * observable to be triggered when the gamepad controller has been disconnected
  107572. */
  107573. onGamepadDisconnectedObservable: Observable<Gamepad>;
  107574. private _onGamepadConnectedEvent;
  107575. private _onGamepadDisconnectedEvent;
  107576. /**
  107577. * Initializes the gamepad manager
  107578. * @param _scene BabylonJS scene
  107579. */
  107580. constructor(_scene?: Scene | undefined);
  107581. /**
  107582. * The gamepads in the game pad manager
  107583. */
  107584. readonly gamepads: Gamepad[];
  107585. /**
  107586. * Get the gamepad controllers based on type
  107587. * @param type The type of gamepad controller
  107588. * @returns Nullable gamepad
  107589. */
  107590. getGamepadByType(type?: number): Nullable<Gamepad>;
  107591. /**
  107592. * Disposes the gamepad manager
  107593. */
  107594. dispose(): void;
  107595. private _addNewGamepad;
  107596. private _startMonitoringGamepads;
  107597. private _stopMonitoringGamepads;
  107598. /** @hidden */
  107599. _checkGamepadsStatus(): void;
  107600. private _updateGamepadObjects;
  107601. }
  107602. }
  107603. declare module BABYLON {
  107604. interface Scene {
  107605. /** @hidden */
  107606. _gamepadManager: Nullable<GamepadManager>;
  107607. /**
  107608. * Gets the gamepad manager associated with the scene
  107609. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  107610. */
  107611. gamepadManager: GamepadManager;
  107612. }
  107613. /**
  107614. * Interface representing a free camera inputs manager
  107615. */
  107616. interface FreeCameraInputsManager {
  107617. /**
  107618. * Adds gamepad input support to the FreeCameraInputsManager.
  107619. * @returns the FreeCameraInputsManager
  107620. */
  107621. addGamepad(): FreeCameraInputsManager;
  107622. }
  107623. /**
  107624. * Interface representing an arc rotate camera inputs manager
  107625. */
  107626. interface ArcRotateCameraInputsManager {
  107627. /**
  107628. * Adds gamepad input support to the ArcRotateCamera InputManager.
  107629. * @returns the camera inputs manager
  107630. */
  107631. addGamepad(): ArcRotateCameraInputsManager;
  107632. }
  107633. /**
  107634. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  107635. */
  107636. export class GamepadSystemSceneComponent implements ISceneComponent {
  107637. /**
  107638. * The component name helpfull to identify the component in the list of scene components.
  107639. */
  107640. readonly name: string;
  107641. /**
  107642. * The scene the component belongs to.
  107643. */
  107644. scene: Scene;
  107645. /**
  107646. * Creates a new instance of the component for the given scene
  107647. * @param scene Defines the scene to register the component in
  107648. */
  107649. constructor(scene: Scene);
  107650. /**
  107651. * Registers the component in a given scene
  107652. */
  107653. register(): void;
  107654. /**
  107655. * Rebuilds the elements related to this component in case of
  107656. * context lost for instance.
  107657. */
  107658. rebuild(): void;
  107659. /**
  107660. * Disposes the component and the associated ressources
  107661. */
  107662. dispose(): void;
  107663. private _beforeCameraUpdate;
  107664. }
  107665. }
  107666. declare module BABYLON {
  107667. /**
  107668. * 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,
  107669. * which still works and will still be found in many Playgrounds.
  107670. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107671. */
  107672. export class UniversalCamera extends TouchCamera {
  107673. /**
  107674. * Defines the gamepad rotation sensiblity.
  107675. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107676. */
  107677. gamepadAngularSensibility: number;
  107678. /**
  107679. * Defines the gamepad move sensiblity.
  107680. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107681. */
  107682. gamepadMoveSensibility: number;
  107683. /**
  107684. * 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,
  107685. * which still works and will still be found in many Playgrounds.
  107686. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107687. * @param name Define the name of the camera in the scene
  107688. * @param position Define the start position of the camera in the scene
  107689. * @param scene Define the scene the camera belongs to
  107690. */
  107691. constructor(name: string, position: Vector3, scene: Scene);
  107692. /**
  107693. * Gets the current object class name.
  107694. * @return the class name
  107695. */
  107696. getClassName(): string;
  107697. }
  107698. }
  107699. declare module BABYLON {
  107700. /**
  107701. * This represents a FPS type of camera. This is only here for back compat purpose.
  107702. * Please use the UniversalCamera instead as both are identical.
  107703. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107704. */
  107705. export class GamepadCamera extends UniversalCamera {
  107706. /**
  107707. * Instantiates a new Gamepad Camera
  107708. * This represents a FPS type of camera. This is only here for back compat purpose.
  107709. * Please use the UniversalCamera instead as both are identical.
  107710. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107711. * @param name Define the name of the camera in the scene
  107712. * @param position Define the start position of the camera in the scene
  107713. * @param scene Define the scene the camera belongs to
  107714. */
  107715. constructor(name: string, position: Vector3, scene: Scene);
  107716. /**
  107717. * Gets the current object class name.
  107718. * @return the class name
  107719. */
  107720. getClassName(): string;
  107721. }
  107722. }
  107723. declare module BABYLON {
  107724. /** @hidden */
  107725. export var passPixelShader: {
  107726. name: string;
  107727. shader: string;
  107728. };
  107729. }
  107730. declare module BABYLON {
  107731. /** @hidden */
  107732. export var passCubePixelShader: {
  107733. name: string;
  107734. shader: string;
  107735. };
  107736. }
  107737. declare module BABYLON {
  107738. /**
  107739. * PassPostProcess which produces an output the same as it's input
  107740. */
  107741. export class PassPostProcess extends PostProcess {
  107742. /**
  107743. * Creates the PassPostProcess
  107744. * @param name The name of the effect.
  107745. * @param options The required width/height ratio to downsize to before computing the render pass.
  107746. * @param camera The camera to apply the render pass to.
  107747. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107748. * @param engine The engine which the post process will be applied. (default: current engine)
  107749. * @param reusable If the post process can be reused on the same frame. (default: false)
  107750. * @param textureType The type of texture to be used when performing the post processing.
  107751. * @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)
  107752. */
  107753. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107754. }
  107755. /**
  107756. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  107757. */
  107758. export class PassCubePostProcess extends PostProcess {
  107759. private _face;
  107760. /**
  107761. * Gets or sets the cube face to display.
  107762. * * 0 is +X
  107763. * * 1 is -X
  107764. * * 2 is +Y
  107765. * * 3 is -Y
  107766. * * 4 is +Z
  107767. * * 5 is -Z
  107768. */
  107769. face: number;
  107770. /**
  107771. * Creates the PassCubePostProcess
  107772. * @param name The name of the effect.
  107773. * @param options The required width/height ratio to downsize to before computing the render pass.
  107774. * @param camera The camera to apply the render pass to.
  107775. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107776. * @param engine The engine which the post process will be applied. (default: current engine)
  107777. * @param reusable If the post process can be reused on the same frame. (default: false)
  107778. * @param textureType The type of texture to be used when performing the post processing.
  107779. * @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)
  107780. */
  107781. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107782. }
  107783. }
  107784. declare module BABYLON {
  107785. /** @hidden */
  107786. export var anaglyphPixelShader: {
  107787. name: string;
  107788. shader: string;
  107789. };
  107790. }
  107791. declare module BABYLON {
  107792. /**
  107793. * Postprocess used to generate anaglyphic rendering
  107794. */
  107795. export class AnaglyphPostProcess extends PostProcess {
  107796. private _passedProcess;
  107797. /**
  107798. * Creates a new AnaglyphPostProcess
  107799. * @param name defines postprocess name
  107800. * @param options defines creation options or target ratio scale
  107801. * @param rigCameras defines cameras using this postprocess
  107802. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  107803. * @param engine defines hosting engine
  107804. * @param reusable defines if the postprocess will be reused multiple times per frame
  107805. */
  107806. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  107807. }
  107808. }
  107809. declare module BABYLON {
  107810. /**
  107811. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  107812. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107813. */
  107814. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  107815. /**
  107816. * Creates a new AnaglyphArcRotateCamera
  107817. * @param name defines camera name
  107818. * @param alpha defines alpha angle (in radians)
  107819. * @param beta defines beta angle (in radians)
  107820. * @param radius defines radius
  107821. * @param target defines camera target
  107822. * @param interaxialDistance defines distance between each color axis
  107823. * @param scene defines the hosting scene
  107824. */
  107825. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  107826. /**
  107827. * Gets camera class name
  107828. * @returns AnaglyphArcRotateCamera
  107829. */
  107830. getClassName(): string;
  107831. }
  107832. }
  107833. declare module BABYLON {
  107834. /**
  107835. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  107836. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107837. */
  107838. export class AnaglyphFreeCamera extends FreeCamera {
  107839. /**
  107840. * Creates a new AnaglyphFreeCamera
  107841. * @param name defines camera name
  107842. * @param position defines initial position
  107843. * @param interaxialDistance defines distance between each color axis
  107844. * @param scene defines the hosting scene
  107845. */
  107846. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107847. /**
  107848. * Gets camera class name
  107849. * @returns AnaglyphFreeCamera
  107850. */
  107851. getClassName(): string;
  107852. }
  107853. }
  107854. declare module BABYLON {
  107855. /**
  107856. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  107857. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107858. */
  107859. export class AnaglyphGamepadCamera extends GamepadCamera {
  107860. /**
  107861. * Creates a new AnaglyphGamepadCamera
  107862. * @param name defines camera name
  107863. * @param position defines initial position
  107864. * @param interaxialDistance defines distance between each color axis
  107865. * @param scene defines the hosting scene
  107866. */
  107867. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107868. /**
  107869. * Gets camera class name
  107870. * @returns AnaglyphGamepadCamera
  107871. */
  107872. getClassName(): string;
  107873. }
  107874. }
  107875. declare module BABYLON {
  107876. /**
  107877. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  107878. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107879. */
  107880. export class AnaglyphUniversalCamera extends UniversalCamera {
  107881. /**
  107882. * Creates a new AnaglyphUniversalCamera
  107883. * @param name defines camera name
  107884. * @param position defines initial position
  107885. * @param interaxialDistance defines distance between each color axis
  107886. * @param scene defines the hosting scene
  107887. */
  107888. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107889. /**
  107890. * Gets camera class name
  107891. * @returns AnaglyphUniversalCamera
  107892. */
  107893. getClassName(): string;
  107894. }
  107895. }
  107896. declare module BABYLON {
  107897. /** @hidden */
  107898. export var stereoscopicInterlacePixelShader: {
  107899. name: string;
  107900. shader: string;
  107901. };
  107902. }
  107903. declare module BABYLON {
  107904. /**
  107905. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  107906. */
  107907. export class StereoscopicInterlacePostProcess extends PostProcess {
  107908. private _stepSize;
  107909. private _passedProcess;
  107910. /**
  107911. * Initializes a StereoscopicInterlacePostProcess
  107912. * @param name The name of the effect.
  107913. * @param rigCameras The rig cameras to be appled to the post process
  107914. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  107915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107916. * @param engine The engine which the post process will be applied. (default: current engine)
  107917. * @param reusable If the post process can be reused on the same frame. (default: false)
  107918. */
  107919. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107920. }
  107921. }
  107922. declare module BABYLON {
  107923. /**
  107924. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  107925. * @see http://doc.babylonjs.com/features/cameras
  107926. */
  107927. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  107928. /**
  107929. * Creates a new StereoscopicArcRotateCamera
  107930. * @param name defines camera name
  107931. * @param alpha defines alpha angle (in radians)
  107932. * @param beta defines beta angle (in radians)
  107933. * @param radius defines radius
  107934. * @param target defines camera target
  107935. * @param interaxialDistance defines distance between each color axis
  107936. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107937. * @param scene defines the hosting scene
  107938. */
  107939. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107940. /**
  107941. * Gets camera class name
  107942. * @returns StereoscopicArcRotateCamera
  107943. */
  107944. getClassName(): string;
  107945. }
  107946. }
  107947. declare module BABYLON {
  107948. /**
  107949. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  107950. * @see http://doc.babylonjs.com/features/cameras
  107951. */
  107952. export class StereoscopicFreeCamera extends FreeCamera {
  107953. /**
  107954. * Creates a new StereoscopicFreeCamera
  107955. * @param name defines camera name
  107956. * @param position defines initial position
  107957. * @param interaxialDistance defines distance between each color axis
  107958. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107959. * @param scene defines the hosting scene
  107960. */
  107961. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107962. /**
  107963. * Gets camera class name
  107964. * @returns StereoscopicFreeCamera
  107965. */
  107966. getClassName(): string;
  107967. }
  107968. }
  107969. declare module BABYLON {
  107970. /**
  107971. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  107972. * @see http://doc.babylonjs.com/features/cameras
  107973. */
  107974. export class StereoscopicGamepadCamera extends GamepadCamera {
  107975. /**
  107976. * Creates a new StereoscopicGamepadCamera
  107977. * @param name defines camera name
  107978. * @param position defines initial position
  107979. * @param interaxialDistance defines distance between each color axis
  107980. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107981. * @param scene defines the hosting scene
  107982. */
  107983. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107984. /**
  107985. * Gets camera class name
  107986. * @returns StereoscopicGamepadCamera
  107987. */
  107988. getClassName(): string;
  107989. }
  107990. }
  107991. declare module BABYLON {
  107992. /**
  107993. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  107994. * @see http://doc.babylonjs.com/features/cameras
  107995. */
  107996. export class StereoscopicUniversalCamera extends UniversalCamera {
  107997. /**
  107998. * Creates a new StereoscopicUniversalCamera
  107999. * @param name defines camera name
  108000. * @param position defines initial position
  108001. * @param interaxialDistance defines distance between each color axis
  108002. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108003. * @param scene defines the hosting scene
  108004. */
  108005. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108006. /**
  108007. * Gets camera class name
  108008. * @returns StereoscopicUniversalCamera
  108009. */
  108010. getClassName(): string;
  108011. }
  108012. }
  108013. declare module BABYLON {
  108014. /**
  108015. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  108016. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  108017. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  108018. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  108019. */
  108020. export class VirtualJoysticksCamera extends FreeCamera {
  108021. /**
  108022. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  108023. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  108024. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  108025. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  108026. * @param name Define the name of the camera in the scene
  108027. * @param position Define the start position of the camera in the scene
  108028. * @param scene Define the scene the camera belongs to
  108029. */
  108030. constructor(name: string, position: Vector3, scene: Scene);
  108031. /**
  108032. * Gets the current object class name.
  108033. * @return the class name
  108034. */
  108035. getClassName(): string;
  108036. }
  108037. }
  108038. declare module BABYLON {
  108039. /**
  108040. * This represents all the required metrics to create a VR camera.
  108041. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  108042. */
  108043. export class VRCameraMetrics {
  108044. /**
  108045. * Define the horizontal resolution off the screen.
  108046. */
  108047. hResolution: number;
  108048. /**
  108049. * Define the vertical resolution off the screen.
  108050. */
  108051. vResolution: number;
  108052. /**
  108053. * Define the horizontal screen size.
  108054. */
  108055. hScreenSize: number;
  108056. /**
  108057. * Define the vertical screen size.
  108058. */
  108059. vScreenSize: number;
  108060. /**
  108061. * Define the vertical screen center position.
  108062. */
  108063. vScreenCenter: number;
  108064. /**
  108065. * Define the distance of the eyes to the screen.
  108066. */
  108067. eyeToScreenDistance: number;
  108068. /**
  108069. * Define the distance between both lenses
  108070. */
  108071. lensSeparationDistance: number;
  108072. /**
  108073. * Define the distance between both viewer's eyes.
  108074. */
  108075. interpupillaryDistance: number;
  108076. /**
  108077. * Define the distortion factor of the VR postprocess.
  108078. * Please, touch with care.
  108079. */
  108080. distortionK: number[];
  108081. /**
  108082. * Define the chromatic aberration correction factors for the VR post process.
  108083. */
  108084. chromaAbCorrection: number[];
  108085. /**
  108086. * Define the scale factor of the post process.
  108087. * The smaller the better but the slower.
  108088. */
  108089. postProcessScaleFactor: number;
  108090. /**
  108091. * Define an offset for the lens center.
  108092. */
  108093. lensCenterOffset: number;
  108094. /**
  108095. * Define if the current vr camera should compensate the distortion of the lense or not.
  108096. */
  108097. compensateDistortion: boolean;
  108098. /**
  108099. * Defines if multiview should be enabled when rendering (Default: false)
  108100. */
  108101. multiviewEnabled: boolean;
  108102. /**
  108103. * Gets the rendering aspect ratio based on the provided resolutions.
  108104. */
  108105. readonly aspectRatio: number;
  108106. /**
  108107. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  108108. */
  108109. readonly aspectRatioFov: number;
  108110. /**
  108111. * @hidden
  108112. */
  108113. readonly leftHMatrix: Matrix;
  108114. /**
  108115. * @hidden
  108116. */
  108117. readonly rightHMatrix: Matrix;
  108118. /**
  108119. * @hidden
  108120. */
  108121. readonly leftPreViewMatrix: Matrix;
  108122. /**
  108123. * @hidden
  108124. */
  108125. readonly rightPreViewMatrix: Matrix;
  108126. /**
  108127. * Get the default VRMetrics based on the most generic setup.
  108128. * @returns the default vr metrics
  108129. */
  108130. static GetDefault(): VRCameraMetrics;
  108131. }
  108132. }
  108133. declare module BABYLON {
  108134. /** @hidden */
  108135. export var vrDistortionCorrectionPixelShader: {
  108136. name: string;
  108137. shader: string;
  108138. };
  108139. }
  108140. declare module BABYLON {
  108141. /**
  108142. * VRDistortionCorrectionPostProcess used for mobile VR
  108143. */
  108144. export class VRDistortionCorrectionPostProcess extends PostProcess {
  108145. private _isRightEye;
  108146. private _distortionFactors;
  108147. private _postProcessScaleFactor;
  108148. private _lensCenterOffset;
  108149. private _scaleIn;
  108150. private _scaleFactor;
  108151. private _lensCenter;
  108152. /**
  108153. * Initializes the VRDistortionCorrectionPostProcess
  108154. * @param name The name of the effect.
  108155. * @param camera The camera to apply the render pass to.
  108156. * @param isRightEye If this is for the right eye distortion
  108157. * @param vrMetrics All the required metrics for the VR camera
  108158. */
  108159. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  108160. }
  108161. }
  108162. declare module BABYLON {
  108163. /**
  108164. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  108165. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108166. */
  108167. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  108168. /**
  108169. * Creates a new VRDeviceOrientationArcRotateCamera
  108170. * @param name defines camera name
  108171. * @param alpha defines the camera rotation along the logitudinal axis
  108172. * @param beta defines the camera rotation along the latitudinal axis
  108173. * @param radius defines the camera distance from its target
  108174. * @param target defines the camera target
  108175. * @param scene defines the scene the camera belongs to
  108176. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108177. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108178. */
  108179. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108180. /**
  108181. * Gets camera class name
  108182. * @returns VRDeviceOrientationArcRotateCamera
  108183. */
  108184. getClassName(): string;
  108185. }
  108186. }
  108187. declare module BABYLON {
  108188. /**
  108189. * Camera used to simulate VR rendering (based on FreeCamera)
  108190. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108191. */
  108192. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  108193. /**
  108194. * Creates a new VRDeviceOrientationFreeCamera
  108195. * @param name defines camera name
  108196. * @param position defines the start position of the camera
  108197. * @param scene defines the scene the camera belongs to
  108198. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108199. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108200. */
  108201. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108202. /**
  108203. * Gets camera class name
  108204. * @returns VRDeviceOrientationFreeCamera
  108205. */
  108206. getClassName(): string;
  108207. }
  108208. }
  108209. declare module BABYLON {
  108210. /**
  108211. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  108212. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108213. */
  108214. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  108215. /**
  108216. * Creates a new VRDeviceOrientationGamepadCamera
  108217. * @param name defines camera name
  108218. * @param position defines the start position of the camera
  108219. * @param scene defines the scene the camera belongs to
  108220. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108221. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108222. */
  108223. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108224. /**
  108225. * Gets camera class name
  108226. * @returns VRDeviceOrientationGamepadCamera
  108227. */
  108228. getClassName(): string;
  108229. }
  108230. }
  108231. declare module BABYLON {
  108232. /**
  108233. * Base class of materials working in push mode in babylon JS
  108234. * @hidden
  108235. */
  108236. export class PushMaterial extends Material {
  108237. protected _activeEffect: Effect;
  108238. protected _normalMatrix: Matrix;
  108239. /**
  108240. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  108241. * This means that the material can keep using a previous shader while a new one is being compiled.
  108242. * This is mostly used when shader parallel compilation is supported (true by default)
  108243. */
  108244. allowShaderHotSwapping: boolean;
  108245. constructor(name: string, scene: Scene);
  108246. getEffect(): Effect;
  108247. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  108248. /**
  108249. * Binds the given world matrix to the active effect
  108250. *
  108251. * @param world the matrix to bind
  108252. */
  108253. bindOnlyWorldMatrix(world: Matrix): void;
  108254. /**
  108255. * Binds the given normal matrix to the active effect
  108256. *
  108257. * @param normalMatrix the matrix to bind
  108258. */
  108259. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  108260. bind(world: Matrix, mesh?: Mesh): void;
  108261. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  108262. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  108263. }
  108264. }
  108265. declare module BABYLON {
  108266. /**
  108267. * This groups all the flags used to control the materials channel.
  108268. */
  108269. export class MaterialFlags {
  108270. private static _DiffuseTextureEnabled;
  108271. /**
  108272. * Are diffuse textures enabled in the application.
  108273. */
  108274. static DiffuseTextureEnabled: boolean;
  108275. private static _AmbientTextureEnabled;
  108276. /**
  108277. * Are ambient textures enabled in the application.
  108278. */
  108279. static AmbientTextureEnabled: boolean;
  108280. private static _OpacityTextureEnabled;
  108281. /**
  108282. * Are opacity textures enabled in the application.
  108283. */
  108284. static OpacityTextureEnabled: boolean;
  108285. private static _ReflectionTextureEnabled;
  108286. /**
  108287. * Are reflection textures enabled in the application.
  108288. */
  108289. static ReflectionTextureEnabled: boolean;
  108290. private static _EmissiveTextureEnabled;
  108291. /**
  108292. * Are emissive textures enabled in the application.
  108293. */
  108294. static EmissiveTextureEnabled: boolean;
  108295. private static _SpecularTextureEnabled;
  108296. /**
  108297. * Are specular textures enabled in the application.
  108298. */
  108299. static SpecularTextureEnabled: boolean;
  108300. private static _BumpTextureEnabled;
  108301. /**
  108302. * Are bump textures enabled in the application.
  108303. */
  108304. static BumpTextureEnabled: boolean;
  108305. private static _LightmapTextureEnabled;
  108306. /**
  108307. * Are lightmap textures enabled in the application.
  108308. */
  108309. static LightmapTextureEnabled: boolean;
  108310. private static _RefractionTextureEnabled;
  108311. /**
  108312. * Are refraction textures enabled in the application.
  108313. */
  108314. static RefractionTextureEnabled: boolean;
  108315. private static _ColorGradingTextureEnabled;
  108316. /**
  108317. * Are color grading textures enabled in the application.
  108318. */
  108319. static ColorGradingTextureEnabled: boolean;
  108320. private static _FresnelEnabled;
  108321. /**
  108322. * Are fresnels enabled in the application.
  108323. */
  108324. static FresnelEnabled: boolean;
  108325. private static _ClearCoatTextureEnabled;
  108326. /**
  108327. * Are clear coat textures enabled in the application.
  108328. */
  108329. static ClearCoatTextureEnabled: boolean;
  108330. private static _ClearCoatBumpTextureEnabled;
  108331. /**
  108332. * Are clear coat bump textures enabled in the application.
  108333. */
  108334. static ClearCoatBumpTextureEnabled: boolean;
  108335. private static _ClearCoatTintTextureEnabled;
  108336. /**
  108337. * Are clear coat tint textures enabled in the application.
  108338. */
  108339. static ClearCoatTintTextureEnabled: boolean;
  108340. private static _SheenTextureEnabled;
  108341. /**
  108342. * Are sheen textures enabled in the application.
  108343. */
  108344. static SheenTextureEnabled: boolean;
  108345. private static _AnisotropicTextureEnabled;
  108346. /**
  108347. * Are anisotropic textures enabled in the application.
  108348. */
  108349. static AnisotropicTextureEnabled: boolean;
  108350. private static _ThicknessTextureEnabled;
  108351. /**
  108352. * Are thickness textures enabled in the application.
  108353. */
  108354. static ThicknessTextureEnabled: boolean;
  108355. }
  108356. }
  108357. declare module BABYLON {
  108358. /** @hidden */
  108359. export var defaultFragmentDeclaration: {
  108360. name: string;
  108361. shader: string;
  108362. };
  108363. }
  108364. declare module BABYLON {
  108365. /** @hidden */
  108366. export var defaultUboDeclaration: {
  108367. name: string;
  108368. shader: string;
  108369. };
  108370. }
  108371. declare module BABYLON {
  108372. /** @hidden */
  108373. export var lightFragmentDeclaration: {
  108374. name: string;
  108375. shader: string;
  108376. };
  108377. }
  108378. declare module BABYLON {
  108379. /** @hidden */
  108380. export var lightUboDeclaration: {
  108381. name: string;
  108382. shader: string;
  108383. };
  108384. }
  108385. declare module BABYLON {
  108386. /** @hidden */
  108387. export var lightsFragmentFunctions: {
  108388. name: string;
  108389. shader: string;
  108390. };
  108391. }
  108392. declare module BABYLON {
  108393. /** @hidden */
  108394. export var shadowsFragmentFunctions: {
  108395. name: string;
  108396. shader: string;
  108397. };
  108398. }
  108399. declare module BABYLON {
  108400. /** @hidden */
  108401. export var fresnelFunction: {
  108402. name: string;
  108403. shader: string;
  108404. };
  108405. }
  108406. declare module BABYLON {
  108407. /** @hidden */
  108408. export var reflectionFunction: {
  108409. name: string;
  108410. shader: string;
  108411. };
  108412. }
  108413. declare module BABYLON {
  108414. /** @hidden */
  108415. export var bumpFragmentFunctions: {
  108416. name: string;
  108417. shader: string;
  108418. };
  108419. }
  108420. declare module BABYLON {
  108421. /** @hidden */
  108422. export var logDepthDeclaration: {
  108423. name: string;
  108424. shader: string;
  108425. };
  108426. }
  108427. declare module BABYLON {
  108428. /** @hidden */
  108429. export var bumpFragment: {
  108430. name: string;
  108431. shader: string;
  108432. };
  108433. }
  108434. declare module BABYLON {
  108435. /** @hidden */
  108436. export var depthPrePass: {
  108437. name: string;
  108438. shader: string;
  108439. };
  108440. }
  108441. declare module BABYLON {
  108442. /** @hidden */
  108443. export var lightFragment: {
  108444. name: string;
  108445. shader: string;
  108446. };
  108447. }
  108448. declare module BABYLON {
  108449. /** @hidden */
  108450. export var logDepthFragment: {
  108451. name: string;
  108452. shader: string;
  108453. };
  108454. }
  108455. declare module BABYLON {
  108456. /** @hidden */
  108457. export var defaultPixelShader: {
  108458. name: string;
  108459. shader: string;
  108460. };
  108461. }
  108462. declare module BABYLON {
  108463. /** @hidden */
  108464. export var defaultVertexDeclaration: {
  108465. name: string;
  108466. shader: string;
  108467. };
  108468. }
  108469. declare module BABYLON {
  108470. /** @hidden */
  108471. export var bumpVertexDeclaration: {
  108472. name: string;
  108473. shader: string;
  108474. };
  108475. }
  108476. declare module BABYLON {
  108477. /** @hidden */
  108478. export var bumpVertex: {
  108479. name: string;
  108480. shader: string;
  108481. };
  108482. }
  108483. declare module BABYLON {
  108484. /** @hidden */
  108485. export var fogVertex: {
  108486. name: string;
  108487. shader: string;
  108488. };
  108489. }
  108490. declare module BABYLON {
  108491. /** @hidden */
  108492. export var shadowsVertex: {
  108493. name: string;
  108494. shader: string;
  108495. };
  108496. }
  108497. declare module BABYLON {
  108498. /** @hidden */
  108499. export var pointCloudVertex: {
  108500. name: string;
  108501. shader: string;
  108502. };
  108503. }
  108504. declare module BABYLON {
  108505. /** @hidden */
  108506. export var logDepthVertex: {
  108507. name: string;
  108508. shader: string;
  108509. };
  108510. }
  108511. declare module BABYLON {
  108512. /** @hidden */
  108513. export var defaultVertexShader: {
  108514. name: string;
  108515. shader: string;
  108516. };
  108517. }
  108518. declare module BABYLON {
  108519. /** @hidden */
  108520. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  108521. MAINUV1: boolean;
  108522. MAINUV2: boolean;
  108523. DIFFUSE: boolean;
  108524. DIFFUSEDIRECTUV: number;
  108525. AMBIENT: boolean;
  108526. AMBIENTDIRECTUV: number;
  108527. OPACITY: boolean;
  108528. OPACITYDIRECTUV: number;
  108529. OPACITYRGB: boolean;
  108530. REFLECTION: boolean;
  108531. EMISSIVE: boolean;
  108532. EMISSIVEDIRECTUV: number;
  108533. SPECULAR: boolean;
  108534. SPECULARDIRECTUV: number;
  108535. BUMP: boolean;
  108536. BUMPDIRECTUV: number;
  108537. PARALLAX: boolean;
  108538. PARALLAXOCCLUSION: boolean;
  108539. SPECULAROVERALPHA: boolean;
  108540. CLIPPLANE: boolean;
  108541. CLIPPLANE2: boolean;
  108542. CLIPPLANE3: boolean;
  108543. CLIPPLANE4: boolean;
  108544. ALPHATEST: boolean;
  108545. DEPTHPREPASS: boolean;
  108546. ALPHAFROMDIFFUSE: boolean;
  108547. POINTSIZE: boolean;
  108548. FOG: boolean;
  108549. SPECULARTERM: boolean;
  108550. DIFFUSEFRESNEL: boolean;
  108551. OPACITYFRESNEL: boolean;
  108552. REFLECTIONFRESNEL: boolean;
  108553. REFRACTIONFRESNEL: boolean;
  108554. EMISSIVEFRESNEL: boolean;
  108555. FRESNEL: boolean;
  108556. NORMAL: boolean;
  108557. UV1: boolean;
  108558. UV2: boolean;
  108559. VERTEXCOLOR: boolean;
  108560. VERTEXALPHA: boolean;
  108561. NUM_BONE_INFLUENCERS: number;
  108562. BonesPerMesh: number;
  108563. BONETEXTURE: boolean;
  108564. INSTANCES: boolean;
  108565. GLOSSINESS: boolean;
  108566. ROUGHNESS: boolean;
  108567. EMISSIVEASILLUMINATION: boolean;
  108568. LINKEMISSIVEWITHDIFFUSE: boolean;
  108569. REFLECTIONFRESNELFROMSPECULAR: boolean;
  108570. LIGHTMAP: boolean;
  108571. LIGHTMAPDIRECTUV: number;
  108572. OBJECTSPACE_NORMALMAP: boolean;
  108573. USELIGHTMAPASSHADOWMAP: boolean;
  108574. REFLECTIONMAP_3D: boolean;
  108575. REFLECTIONMAP_SPHERICAL: boolean;
  108576. REFLECTIONMAP_PLANAR: boolean;
  108577. REFLECTIONMAP_CUBIC: boolean;
  108578. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108579. REFLECTIONMAP_PROJECTION: boolean;
  108580. REFLECTIONMAP_SKYBOX: boolean;
  108581. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108582. REFLECTIONMAP_EXPLICIT: boolean;
  108583. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108584. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108585. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108586. INVERTCUBICMAP: boolean;
  108587. LOGARITHMICDEPTH: boolean;
  108588. REFRACTION: boolean;
  108589. REFRACTIONMAP_3D: boolean;
  108590. REFLECTIONOVERALPHA: boolean;
  108591. TWOSIDEDLIGHTING: boolean;
  108592. SHADOWFLOAT: boolean;
  108593. MORPHTARGETS: boolean;
  108594. MORPHTARGETS_NORMAL: boolean;
  108595. MORPHTARGETS_TANGENT: boolean;
  108596. MORPHTARGETS_UV: boolean;
  108597. NUM_MORPH_INFLUENCERS: number;
  108598. NONUNIFORMSCALING: boolean;
  108599. PREMULTIPLYALPHA: boolean;
  108600. IMAGEPROCESSING: boolean;
  108601. VIGNETTE: boolean;
  108602. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108603. VIGNETTEBLENDMODEOPAQUE: boolean;
  108604. TONEMAPPING: boolean;
  108605. TONEMAPPING_ACES: boolean;
  108606. CONTRAST: boolean;
  108607. COLORCURVES: boolean;
  108608. COLORGRADING: boolean;
  108609. COLORGRADING3D: boolean;
  108610. SAMPLER3DGREENDEPTH: boolean;
  108611. SAMPLER3DBGRMAP: boolean;
  108612. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108613. MULTIVIEW: boolean;
  108614. /**
  108615. * If the reflection texture on this material is in linear color space
  108616. * @hidden
  108617. */
  108618. IS_REFLECTION_LINEAR: boolean;
  108619. /**
  108620. * If the refraction texture on this material is in linear color space
  108621. * @hidden
  108622. */
  108623. IS_REFRACTION_LINEAR: boolean;
  108624. EXPOSURE: boolean;
  108625. constructor();
  108626. setReflectionMode(modeToEnable: string): void;
  108627. }
  108628. /**
  108629. * This is the default material used in Babylon. It is the best trade off between quality
  108630. * and performances.
  108631. * @see http://doc.babylonjs.com/babylon101/materials
  108632. */
  108633. export class StandardMaterial extends PushMaterial {
  108634. private _diffuseTexture;
  108635. /**
  108636. * The basic texture of the material as viewed under a light.
  108637. */
  108638. diffuseTexture: Nullable<BaseTexture>;
  108639. private _ambientTexture;
  108640. /**
  108641. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  108642. */
  108643. ambientTexture: Nullable<BaseTexture>;
  108644. private _opacityTexture;
  108645. /**
  108646. * Define the transparency of the material from a texture.
  108647. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  108648. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  108649. */
  108650. opacityTexture: Nullable<BaseTexture>;
  108651. private _reflectionTexture;
  108652. /**
  108653. * Define the texture used to display the reflection.
  108654. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108655. */
  108656. reflectionTexture: Nullable<BaseTexture>;
  108657. private _emissiveTexture;
  108658. /**
  108659. * Define texture of the material as if self lit.
  108660. * This will be mixed in the final result even in the absence of light.
  108661. */
  108662. emissiveTexture: Nullable<BaseTexture>;
  108663. private _specularTexture;
  108664. /**
  108665. * Define how the color and intensity of the highlight given by the light in the material.
  108666. */
  108667. specularTexture: Nullable<BaseTexture>;
  108668. private _bumpTexture;
  108669. /**
  108670. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  108671. * 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.
  108672. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  108673. */
  108674. bumpTexture: Nullable<BaseTexture>;
  108675. private _lightmapTexture;
  108676. /**
  108677. * Complex lighting can be computationally expensive to compute at runtime.
  108678. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  108679. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  108680. */
  108681. lightmapTexture: Nullable<BaseTexture>;
  108682. private _refractionTexture;
  108683. /**
  108684. * Define the texture used to display the refraction.
  108685. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108686. */
  108687. refractionTexture: Nullable<BaseTexture>;
  108688. /**
  108689. * The color of the material lit by the environmental background lighting.
  108690. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  108691. */
  108692. ambientColor: Color3;
  108693. /**
  108694. * The basic color of the material as viewed under a light.
  108695. */
  108696. diffuseColor: Color3;
  108697. /**
  108698. * Define how the color and intensity of the highlight given by the light in the material.
  108699. */
  108700. specularColor: Color3;
  108701. /**
  108702. * Define the color of the material as if self lit.
  108703. * This will be mixed in the final result even in the absence of light.
  108704. */
  108705. emissiveColor: Color3;
  108706. /**
  108707. * Defines how sharp are the highlights in the material.
  108708. * The bigger the value the sharper giving a more glossy feeling to the result.
  108709. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  108710. */
  108711. specularPower: number;
  108712. private _useAlphaFromDiffuseTexture;
  108713. /**
  108714. * Does the transparency come from the diffuse texture alpha channel.
  108715. */
  108716. useAlphaFromDiffuseTexture: boolean;
  108717. private _useEmissiveAsIllumination;
  108718. /**
  108719. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  108720. */
  108721. useEmissiveAsIllumination: boolean;
  108722. private _linkEmissiveWithDiffuse;
  108723. /**
  108724. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  108725. * the emissive level when the final color is close to one.
  108726. */
  108727. linkEmissiveWithDiffuse: boolean;
  108728. private _useSpecularOverAlpha;
  108729. /**
  108730. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108731. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108732. */
  108733. useSpecularOverAlpha: boolean;
  108734. private _useReflectionOverAlpha;
  108735. /**
  108736. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108737. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108738. */
  108739. useReflectionOverAlpha: boolean;
  108740. private _disableLighting;
  108741. /**
  108742. * Does lights from the scene impacts this material.
  108743. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  108744. */
  108745. disableLighting: boolean;
  108746. private _useObjectSpaceNormalMap;
  108747. /**
  108748. * Allows using an object space normal map (instead of tangent space).
  108749. */
  108750. useObjectSpaceNormalMap: boolean;
  108751. private _useParallax;
  108752. /**
  108753. * Is parallax enabled or not.
  108754. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  108755. */
  108756. useParallax: boolean;
  108757. private _useParallaxOcclusion;
  108758. /**
  108759. * Is parallax occlusion enabled or not.
  108760. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  108761. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  108762. */
  108763. useParallaxOcclusion: boolean;
  108764. /**
  108765. * 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.
  108766. */
  108767. parallaxScaleBias: number;
  108768. private _roughness;
  108769. /**
  108770. * Helps to define how blurry the reflections should appears in the material.
  108771. */
  108772. roughness: number;
  108773. /**
  108774. * In case of refraction, define the value of the index of refraction.
  108775. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108776. */
  108777. indexOfRefraction: number;
  108778. /**
  108779. * Invert the refraction texture alongside the y axis.
  108780. * It can be useful with procedural textures or probe for instance.
  108781. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108782. */
  108783. invertRefractionY: boolean;
  108784. /**
  108785. * Defines the alpha limits in alpha test mode.
  108786. */
  108787. alphaCutOff: number;
  108788. private _useLightmapAsShadowmap;
  108789. /**
  108790. * In case of light mapping, define whether the map contains light or shadow informations.
  108791. */
  108792. useLightmapAsShadowmap: boolean;
  108793. private _diffuseFresnelParameters;
  108794. /**
  108795. * Define the diffuse fresnel parameters of the material.
  108796. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108797. */
  108798. diffuseFresnelParameters: FresnelParameters;
  108799. private _opacityFresnelParameters;
  108800. /**
  108801. * Define the opacity fresnel parameters of the material.
  108802. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108803. */
  108804. opacityFresnelParameters: FresnelParameters;
  108805. private _reflectionFresnelParameters;
  108806. /**
  108807. * Define the reflection fresnel parameters of the material.
  108808. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108809. */
  108810. reflectionFresnelParameters: FresnelParameters;
  108811. private _refractionFresnelParameters;
  108812. /**
  108813. * Define the refraction fresnel parameters of the material.
  108814. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108815. */
  108816. refractionFresnelParameters: FresnelParameters;
  108817. private _emissiveFresnelParameters;
  108818. /**
  108819. * Define the emissive fresnel parameters of the material.
  108820. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108821. */
  108822. emissiveFresnelParameters: FresnelParameters;
  108823. private _useReflectionFresnelFromSpecular;
  108824. /**
  108825. * If true automatically deducts the fresnels values from the material specularity.
  108826. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108827. */
  108828. useReflectionFresnelFromSpecular: boolean;
  108829. private _useGlossinessFromSpecularMapAlpha;
  108830. /**
  108831. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  108832. */
  108833. useGlossinessFromSpecularMapAlpha: boolean;
  108834. private _maxSimultaneousLights;
  108835. /**
  108836. * Defines the maximum number of lights that can be used in the material
  108837. */
  108838. maxSimultaneousLights: number;
  108839. private _invertNormalMapX;
  108840. /**
  108841. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108842. */
  108843. invertNormalMapX: boolean;
  108844. private _invertNormalMapY;
  108845. /**
  108846. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108847. */
  108848. invertNormalMapY: boolean;
  108849. private _twoSidedLighting;
  108850. /**
  108851. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108852. */
  108853. twoSidedLighting: boolean;
  108854. /**
  108855. * Default configuration related to image processing available in the standard Material.
  108856. */
  108857. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108858. /**
  108859. * Gets the image processing configuration used either in this material.
  108860. */
  108861. /**
  108862. * Sets the Default image processing configuration used either in the this material.
  108863. *
  108864. * If sets to null, the scene one is in use.
  108865. */
  108866. imageProcessingConfiguration: ImageProcessingConfiguration;
  108867. /**
  108868. * Keep track of the image processing observer to allow dispose and replace.
  108869. */
  108870. private _imageProcessingObserver;
  108871. /**
  108872. * Attaches a new image processing configuration to the Standard Material.
  108873. * @param configuration
  108874. */
  108875. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108876. /**
  108877. * Gets wether the color curves effect is enabled.
  108878. */
  108879. /**
  108880. * Sets wether the color curves effect is enabled.
  108881. */
  108882. cameraColorCurvesEnabled: boolean;
  108883. /**
  108884. * Gets wether the color grading effect is enabled.
  108885. */
  108886. /**
  108887. * Gets wether the color grading effect is enabled.
  108888. */
  108889. cameraColorGradingEnabled: boolean;
  108890. /**
  108891. * Gets wether tonemapping is enabled or not.
  108892. */
  108893. /**
  108894. * Sets wether tonemapping is enabled or not
  108895. */
  108896. cameraToneMappingEnabled: boolean;
  108897. /**
  108898. * The camera exposure used on this material.
  108899. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108900. * This corresponds to a photographic exposure.
  108901. */
  108902. /**
  108903. * The camera exposure used on this material.
  108904. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108905. * This corresponds to a photographic exposure.
  108906. */
  108907. cameraExposure: number;
  108908. /**
  108909. * Gets The camera contrast used on this material.
  108910. */
  108911. /**
  108912. * Sets The camera contrast used on this material.
  108913. */
  108914. cameraContrast: number;
  108915. /**
  108916. * Gets the Color Grading 2D Lookup Texture.
  108917. */
  108918. /**
  108919. * Sets the Color Grading 2D Lookup Texture.
  108920. */
  108921. cameraColorGradingTexture: Nullable<BaseTexture>;
  108922. /**
  108923. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108924. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108925. * 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;
  108926. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108927. */
  108928. /**
  108929. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108930. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108931. * 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;
  108932. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108933. */
  108934. cameraColorCurves: Nullable<ColorCurves>;
  108935. /**
  108936. * Custom callback helping to override the default shader used in the material.
  108937. */
  108938. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  108939. protected _renderTargets: SmartArray<RenderTargetTexture>;
  108940. protected _worldViewProjectionMatrix: Matrix;
  108941. protected _globalAmbientColor: Color3;
  108942. protected _useLogarithmicDepth: boolean;
  108943. protected _rebuildInParallel: boolean;
  108944. /**
  108945. * Instantiates a new standard material.
  108946. * This is the default material used in Babylon. It is the best trade off between quality
  108947. * and performances.
  108948. * @see http://doc.babylonjs.com/babylon101/materials
  108949. * @param name Define the name of the material in the scene
  108950. * @param scene Define the scene the material belong to
  108951. */
  108952. constructor(name: string, scene: Scene);
  108953. /**
  108954. * Gets a boolean indicating that current material needs to register RTT
  108955. */
  108956. readonly hasRenderTargetTextures: boolean;
  108957. /**
  108958. * Gets the current class name of the material e.g. "StandardMaterial"
  108959. * Mainly use in serialization.
  108960. * @returns the class name
  108961. */
  108962. getClassName(): string;
  108963. /**
  108964. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  108965. * You can try switching to logarithmic depth.
  108966. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  108967. */
  108968. useLogarithmicDepth: boolean;
  108969. /**
  108970. * Specifies if the material will require alpha blending
  108971. * @returns a boolean specifying if alpha blending is needed
  108972. */
  108973. needAlphaBlending(): boolean;
  108974. /**
  108975. * Specifies if this material should be rendered in alpha test mode
  108976. * @returns a boolean specifying if an alpha test is needed.
  108977. */
  108978. needAlphaTesting(): boolean;
  108979. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  108980. /**
  108981. * Get the texture used for alpha test purpose.
  108982. * @returns the diffuse texture in case of the standard material.
  108983. */
  108984. getAlphaTestTexture(): Nullable<BaseTexture>;
  108985. /**
  108986. * Get if the submesh is ready to be used and all its information available.
  108987. * Child classes can use it to update shaders
  108988. * @param mesh defines the mesh to check
  108989. * @param subMesh defines which submesh to check
  108990. * @param useInstances specifies that instances should be used
  108991. * @returns a boolean indicating that the submesh is ready or not
  108992. */
  108993. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108994. /**
  108995. * Builds the material UBO layouts.
  108996. * Used internally during the effect preparation.
  108997. */
  108998. buildUniformLayout(): void;
  108999. /**
  109000. * Unbinds the material from the mesh
  109001. */
  109002. unbind(): void;
  109003. /**
  109004. * Binds the submesh to this material by preparing the effect and shader to draw
  109005. * @param world defines the world transformation matrix
  109006. * @param mesh defines the mesh containing the submesh
  109007. * @param subMesh defines the submesh to bind the material to
  109008. */
  109009. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109010. /**
  109011. * Get the list of animatables in the material.
  109012. * @returns the list of animatables object used in the material
  109013. */
  109014. getAnimatables(): IAnimatable[];
  109015. /**
  109016. * Gets the active textures from the material
  109017. * @returns an array of textures
  109018. */
  109019. getActiveTextures(): BaseTexture[];
  109020. /**
  109021. * Specifies if the material uses a texture
  109022. * @param texture defines the texture to check against the material
  109023. * @returns a boolean specifying if the material uses the texture
  109024. */
  109025. hasTexture(texture: BaseTexture): boolean;
  109026. /**
  109027. * Disposes the material
  109028. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109029. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109030. */
  109031. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109032. /**
  109033. * Makes a duplicate of the material, and gives it a new name
  109034. * @param name defines the new name for the duplicated material
  109035. * @returns the cloned material
  109036. */
  109037. clone(name: string): StandardMaterial;
  109038. /**
  109039. * Serializes this material in a JSON representation
  109040. * @returns the serialized material object
  109041. */
  109042. serialize(): any;
  109043. /**
  109044. * Creates a standard material from parsed material data
  109045. * @param source defines the JSON representation of the material
  109046. * @param scene defines the hosting scene
  109047. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109048. * @returns a new standard material
  109049. */
  109050. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  109051. /**
  109052. * Are diffuse textures enabled in the application.
  109053. */
  109054. static DiffuseTextureEnabled: boolean;
  109055. /**
  109056. * Are ambient textures enabled in the application.
  109057. */
  109058. static AmbientTextureEnabled: boolean;
  109059. /**
  109060. * Are opacity textures enabled in the application.
  109061. */
  109062. static OpacityTextureEnabled: boolean;
  109063. /**
  109064. * Are reflection textures enabled in the application.
  109065. */
  109066. static ReflectionTextureEnabled: boolean;
  109067. /**
  109068. * Are emissive textures enabled in the application.
  109069. */
  109070. static EmissiveTextureEnabled: boolean;
  109071. /**
  109072. * Are specular textures enabled in the application.
  109073. */
  109074. static SpecularTextureEnabled: boolean;
  109075. /**
  109076. * Are bump textures enabled in the application.
  109077. */
  109078. static BumpTextureEnabled: boolean;
  109079. /**
  109080. * Are lightmap textures enabled in the application.
  109081. */
  109082. static LightmapTextureEnabled: boolean;
  109083. /**
  109084. * Are refraction textures enabled in the application.
  109085. */
  109086. static RefractionTextureEnabled: boolean;
  109087. /**
  109088. * Are color grading textures enabled in the application.
  109089. */
  109090. static ColorGradingTextureEnabled: boolean;
  109091. /**
  109092. * Are fresnels enabled in the application.
  109093. */
  109094. static FresnelEnabled: boolean;
  109095. }
  109096. }
  109097. declare module BABYLON {
  109098. /** @hidden */
  109099. export var imageProcessingPixelShader: {
  109100. name: string;
  109101. shader: string;
  109102. };
  109103. }
  109104. declare module BABYLON {
  109105. /**
  109106. * ImageProcessingPostProcess
  109107. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  109108. */
  109109. export class ImageProcessingPostProcess extends PostProcess {
  109110. /**
  109111. * Default configuration related to image processing available in the PBR Material.
  109112. */
  109113. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109114. /**
  109115. * Gets the image processing configuration used either in this material.
  109116. */
  109117. /**
  109118. * Sets the Default image processing configuration used either in the this material.
  109119. *
  109120. * If sets to null, the scene one is in use.
  109121. */
  109122. imageProcessingConfiguration: ImageProcessingConfiguration;
  109123. /**
  109124. * Keep track of the image processing observer to allow dispose and replace.
  109125. */
  109126. private _imageProcessingObserver;
  109127. /**
  109128. * Attaches a new image processing configuration to the PBR Material.
  109129. * @param configuration
  109130. */
  109131. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  109132. /**
  109133. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109134. */
  109135. /**
  109136. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109137. */
  109138. colorCurves: Nullable<ColorCurves>;
  109139. /**
  109140. * Gets wether the color curves effect is enabled.
  109141. */
  109142. /**
  109143. * Sets wether the color curves effect is enabled.
  109144. */
  109145. colorCurvesEnabled: boolean;
  109146. /**
  109147. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109148. */
  109149. /**
  109150. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109151. */
  109152. colorGradingTexture: Nullable<BaseTexture>;
  109153. /**
  109154. * Gets wether the color grading effect is enabled.
  109155. */
  109156. /**
  109157. * Gets wether the color grading effect is enabled.
  109158. */
  109159. colorGradingEnabled: boolean;
  109160. /**
  109161. * Gets exposure used in the effect.
  109162. */
  109163. /**
  109164. * Sets exposure used in the effect.
  109165. */
  109166. exposure: number;
  109167. /**
  109168. * Gets wether tonemapping is enabled or not.
  109169. */
  109170. /**
  109171. * Sets wether tonemapping is enabled or not
  109172. */
  109173. toneMappingEnabled: boolean;
  109174. /**
  109175. * Gets the type of tone mapping effect.
  109176. */
  109177. /**
  109178. * Sets the type of tone mapping effect.
  109179. */
  109180. toneMappingType: number;
  109181. /**
  109182. * Gets contrast used in the effect.
  109183. */
  109184. /**
  109185. * Sets contrast used in the effect.
  109186. */
  109187. contrast: number;
  109188. /**
  109189. * Gets Vignette stretch size.
  109190. */
  109191. /**
  109192. * Sets Vignette stretch size.
  109193. */
  109194. vignetteStretch: number;
  109195. /**
  109196. * Gets Vignette centre X Offset.
  109197. */
  109198. /**
  109199. * Sets Vignette centre X Offset.
  109200. */
  109201. vignetteCentreX: number;
  109202. /**
  109203. * Gets Vignette centre Y Offset.
  109204. */
  109205. /**
  109206. * Sets Vignette centre Y Offset.
  109207. */
  109208. vignetteCentreY: number;
  109209. /**
  109210. * Gets Vignette weight or intensity of the vignette effect.
  109211. */
  109212. /**
  109213. * Sets Vignette weight or intensity of the vignette effect.
  109214. */
  109215. vignetteWeight: number;
  109216. /**
  109217. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  109218. * if vignetteEnabled is set to true.
  109219. */
  109220. /**
  109221. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  109222. * if vignetteEnabled is set to true.
  109223. */
  109224. vignetteColor: Color4;
  109225. /**
  109226. * Gets Camera field of view used by the Vignette effect.
  109227. */
  109228. /**
  109229. * Sets Camera field of view used by the Vignette effect.
  109230. */
  109231. vignetteCameraFov: number;
  109232. /**
  109233. * Gets the vignette blend mode allowing different kind of effect.
  109234. */
  109235. /**
  109236. * Sets the vignette blend mode allowing different kind of effect.
  109237. */
  109238. vignetteBlendMode: number;
  109239. /**
  109240. * Gets wether the vignette effect is enabled.
  109241. */
  109242. /**
  109243. * Sets wether the vignette effect is enabled.
  109244. */
  109245. vignetteEnabled: boolean;
  109246. private _fromLinearSpace;
  109247. /**
  109248. * Gets wether the input of the processing is in Gamma or Linear Space.
  109249. */
  109250. /**
  109251. * Sets wether the input of the processing is in Gamma or Linear Space.
  109252. */
  109253. fromLinearSpace: boolean;
  109254. /**
  109255. * Defines cache preventing GC.
  109256. */
  109257. private _defines;
  109258. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  109259. /**
  109260. * "ImageProcessingPostProcess"
  109261. * @returns "ImageProcessingPostProcess"
  109262. */
  109263. getClassName(): string;
  109264. protected _updateParameters(): void;
  109265. dispose(camera?: Camera): void;
  109266. }
  109267. }
  109268. declare module BABYLON {
  109269. /**
  109270. * Class containing static functions to help procedurally build meshes
  109271. */
  109272. export class GroundBuilder {
  109273. /**
  109274. * Creates a ground mesh
  109275. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  109276. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  109277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109278. * @param name defines the name of the mesh
  109279. * @param options defines the options used to create the mesh
  109280. * @param scene defines the hosting scene
  109281. * @returns the ground mesh
  109282. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  109283. */
  109284. static CreateGround(name: string, options: {
  109285. width?: number;
  109286. height?: number;
  109287. subdivisions?: number;
  109288. subdivisionsX?: number;
  109289. subdivisionsY?: number;
  109290. updatable?: boolean;
  109291. }, scene: any): Mesh;
  109292. /**
  109293. * Creates a tiled ground mesh
  109294. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  109295. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  109296. * * 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
  109297. * * 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
  109298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109299. * @param name defines the name of the mesh
  109300. * @param options defines the options used to create the mesh
  109301. * @param scene defines the hosting scene
  109302. * @returns the tiled ground mesh
  109303. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  109304. */
  109305. static CreateTiledGround(name: string, options: {
  109306. xmin: number;
  109307. zmin: number;
  109308. xmax: number;
  109309. zmax: number;
  109310. subdivisions?: {
  109311. w: number;
  109312. h: number;
  109313. };
  109314. precision?: {
  109315. w: number;
  109316. h: number;
  109317. };
  109318. updatable?: boolean;
  109319. }, scene?: Nullable<Scene>): Mesh;
  109320. /**
  109321. * Creates a ground mesh from a height map
  109322. * * The parameter `url` sets the URL of the height map image resource.
  109323. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  109324. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  109325. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  109326. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  109327. * * 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.
  109328. * * 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).
  109329. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109331. * @param name defines the name of the mesh
  109332. * @param url defines the url to the height map
  109333. * @param options defines the options used to create the mesh
  109334. * @param scene defines the hosting scene
  109335. * @returns the ground mesh
  109336. * @see https://doc.babylonjs.com/babylon101/height_map
  109337. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  109338. */
  109339. static CreateGroundFromHeightMap(name: string, url: string, options: {
  109340. width?: number;
  109341. height?: number;
  109342. subdivisions?: number;
  109343. minHeight?: number;
  109344. maxHeight?: number;
  109345. colorFilter?: Color3;
  109346. alphaFilter?: number;
  109347. updatable?: boolean;
  109348. onReady?: (mesh: GroundMesh) => void;
  109349. }, scene?: Nullable<Scene>): GroundMesh;
  109350. }
  109351. }
  109352. declare module BABYLON {
  109353. /**
  109354. * Class containing static functions to help procedurally build meshes
  109355. */
  109356. export class TorusBuilder {
  109357. /**
  109358. * Creates a torus mesh
  109359. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  109360. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  109361. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  109362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109363. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109365. * @param name defines the name of the mesh
  109366. * @param options defines the options used to create the mesh
  109367. * @param scene defines the hosting scene
  109368. * @returns the torus mesh
  109369. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  109370. */
  109371. static CreateTorus(name: string, options: {
  109372. diameter?: number;
  109373. thickness?: number;
  109374. tessellation?: number;
  109375. updatable?: boolean;
  109376. sideOrientation?: number;
  109377. frontUVs?: Vector4;
  109378. backUVs?: Vector4;
  109379. }, scene: any): Mesh;
  109380. }
  109381. }
  109382. declare module BABYLON {
  109383. /**
  109384. * Class containing static functions to help procedurally build meshes
  109385. */
  109386. export class CylinderBuilder {
  109387. /**
  109388. * Creates a cylinder or a cone mesh
  109389. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  109390. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  109391. * * 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.
  109392. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  109393. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  109394. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  109395. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  109396. * * 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).
  109397. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  109398. * * 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).
  109399. * * 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
  109400. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  109401. * * 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
  109402. * * 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.
  109403. * * If `enclose` is false, a ring surface is one element.
  109404. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  109405. * * 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
  109406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109407. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109409. * @param name defines the name of the mesh
  109410. * @param options defines the options used to create the mesh
  109411. * @param scene defines the hosting scene
  109412. * @returns the cylinder mesh
  109413. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  109414. */
  109415. static CreateCylinder(name: string, options: {
  109416. height?: number;
  109417. diameterTop?: number;
  109418. diameterBottom?: number;
  109419. diameter?: number;
  109420. tessellation?: number;
  109421. subdivisions?: number;
  109422. arc?: number;
  109423. faceColors?: Color4[];
  109424. faceUV?: Vector4[];
  109425. updatable?: boolean;
  109426. hasRings?: boolean;
  109427. enclose?: boolean;
  109428. cap?: number;
  109429. sideOrientation?: number;
  109430. frontUVs?: Vector4;
  109431. backUVs?: Vector4;
  109432. }, scene: any): Mesh;
  109433. }
  109434. }
  109435. declare module BABYLON {
  109436. /**
  109437. * Options to modify the vr teleportation behavior.
  109438. */
  109439. export interface VRTeleportationOptions {
  109440. /**
  109441. * The name of the mesh which should be used as the teleportation floor. (default: null)
  109442. */
  109443. floorMeshName?: string;
  109444. /**
  109445. * A list of meshes to be used as the teleportation floor. (default: empty)
  109446. */
  109447. floorMeshes?: Mesh[];
  109448. }
  109449. /**
  109450. * Options to modify the vr experience helper's behavior.
  109451. */
  109452. export interface VRExperienceHelperOptions extends WebVROptions {
  109453. /**
  109454. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  109455. */
  109456. createDeviceOrientationCamera?: boolean;
  109457. /**
  109458. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  109459. */
  109460. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  109461. /**
  109462. * Uses the main button on the controller to toggle the laser casted. (default: true)
  109463. */
  109464. laserToggle?: boolean;
  109465. /**
  109466. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  109467. */
  109468. floorMeshes?: Mesh[];
  109469. /**
  109470. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  109471. */
  109472. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  109473. }
  109474. /**
  109475. * Event containing information after VR has been entered
  109476. */
  109477. export class OnAfterEnteringVRObservableEvent {
  109478. /**
  109479. * If entering vr was successful
  109480. */
  109481. success: boolean;
  109482. }
  109483. /**
  109484. * Helps to quickly add VR support to an existing scene.
  109485. * See http://doc.babylonjs.com/how_to/webvr_helper
  109486. */
  109487. export class VRExperienceHelper {
  109488. /** Options to modify the vr experience helper's behavior. */
  109489. webVROptions: VRExperienceHelperOptions;
  109490. private _scene;
  109491. private _position;
  109492. private _btnVR;
  109493. private _btnVRDisplayed;
  109494. private _webVRsupported;
  109495. private _webVRready;
  109496. private _webVRrequesting;
  109497. private _webVRpresenting;
  109498. private _hasEnteredVR;
  109499. private _fullscreenVRpresenting;
  109500. private _inputElement;
  109501. private _webVRCamera;
  109502. private _vrDeviceOrientationCamera;
  109503. private _deviceOrientationCamera;
  109504. private _existingCamera;
  109505. private _onKeyDown;
  109506. private _onVrDisplayPresentChange;
  109507. private _onVRDisplayChanged;
  109508. private _onVRRequestPresentStart;
  109509. private _onVRRequestPresentComplete;
  109510. /**
  109511. * 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)
  109512. */
  109513. enableGazeEvenWhenNoPointerLock: boolean;
  109514. /**
  109515. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  109516. */
  109517. exitVROnDoubleTap: boolean;
  109518. /**
  109519. * Observable raised right before entering VR.
  109520. */
  109521. onEnteringVRObservable: Observable<VRExperienceHelper>;
  109522. /**
  109523. * Observable raised when entering VR has completed.
  109524. */
  109525. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  109526. /**
  109527. * Observable raised when exiting VR.
  109528. */
  109529. onExitingVRObservable: Observable<VRExperienceHelper>;
  109530. /**
  109531. * Observable raised when controller mesh is loaded.
  109532. */
  109533. onControllerMeshLoadedObservable: Observable<WebVRController>;
  109534. /** Return this.onEnteringVRObservable
  109535. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  109536. */
  109537. readonly onEnteringVR: Observable<VRExperienceHelper>;
  109538. /** Return this.onExitingVRObservable
  109539. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  109540. */
  109541. readonly onExitingVR: Observable<VRExperienceHelper>;
  109542. /** Return this.onControllerMeshLoadedObservable
  109543. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  109544. */
  109545. readonly onControllerMeshLoaded: Observable<WebVRController>;
  109546. private _rayLength;
  109547. private _useCustomVRButton;
  109548. private _teleportationRequested;
  109549. private _teleportActive;
  109550. private _floorMeshName;
  109551. private _floorMeshesCollection;
  109552. private _rotationAllowed;
  109553. private _teleportBackwardsVector;
  109554. private _teleportationTarget;
  109555. private _isDefaultTeleportationTarget;
  109556. private _postProcessMove;
  109557. private _teleportationFillColor;
  109558. private _teleportationBorderColor;
  109559. private _rotationAngle;
  109560. private _haloCenter;
  109561. private _cameraGazer;
  109562. private _padSensibilityUp;
  109563. private _padSensibilityDown;
  109564. private _leftController;
  109565. private _rightController;
  109566. /**
  109567. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  109568. */
  109569. onNewMeshSelected: Observable<AbstractMesh>;
  109570. /**
  109571. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  109572. * This observable will provide the mesh and the controller used to select the mesh
  109573. */
  109574. onMeshSelectedWithController: Observable<{
  109575. mesh: AbstractMesh;
  109576. controller: WebVRController;
  109577. }>;
  109578. /**
  109579. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  109580. */
  109581. onNewMeshPicked: Observable<PickingInfo>;
  109582. private _circleEase;
  109583. /**
  109584. * Observable raised before camera teleportation
  109585. */
  109586. onBeforeCameraTeleport: Observable<Vector3>;
  109587. /**
  109588. * Observable raised after camera teleportation
  109589. */
  109590. onAfterCameraTeleport: Observable<Vector3>;
  109591. /**
  109592. * Observable raised when current selected mesh gets unselected
  109593. */
  109594. onSelectedMeshUnselected: Observable<AbstractMesh>;
  109595. private _raySelectionPredicate;
  109596. /**
  109597. * To be optionaly changed by user to define custom ray selection
  109598. */
  109599. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  109600. /**
  109601. * To be optionaly changed by user to define custom selection logic (after ray selection)
  109602. */
  109603. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  109604. /**
  109605. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  109606. */
  109607. teleportationEnabled: boolean;
  109608. private _defaultHeight;
  109609. private _teleportationInitialized;
  109610. private _interactionsEnabled;
  109611. private _interactionsRequested;
  109612. private _displayGaze;
  109613. private _displayLaserPointer;
  109614. /**
  109615. * The mesh used to display where the user is going to teleport.
  109616. */
  109617. /**
  109618. * Sets the mesh to be used to display where the user is going to teleport.
  109619. */
  109620. teleportationTarget: Mesh;
  109621. /**
  109622. * 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
  109623. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  109624. * See http://doc.babylonjs.com/resources/baking_transformations
  109625. */
  109626. gazeTrackerMesh: Mesh;
  109627. /**
  109628. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  109629. */
  109630. updateGazeTrackerScale: boolean;
  109631. /**
  109632. * If the gaze trackers color should be updated when selecting meshes
  109633. */
  109634. updateGazeTrackerColor: boolean;
  109635. /**
  109636. * If the controller laser color should be updated when selecting meshes
  109637. */
  109638. updateControllerLaserColor: boolean;
  109639. /**
  109640. * The gaze tracking mesh corresponding to the left controller
  109641. */
  109642. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  109643. /**
  109644. * The gaze tracking mesh corresponding to the right controller
  109645. */
  109646. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  109647. /**
  109648. * If the ray of the gaze should be displayed.
  109649. */
  109650. /**
  109651. * Sets if the ray of the gaze should be displayed.
  109652. */
  109653. displayGaze: boolean;
  109654. /**
  109655. * If the ray of the LaserPointer should be displayed.
  109656. */
  109657. /**
  109658. * Sets if the ray of the LaserPointer should be displayed.
  109659. */
  109660. displayLaserPointer: boolean;
  109661. /**
  109662. * The deviceOrientationCamera used as the camera when not in VR.
  109663. */
  109664. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  109665. /**
  109666. * Based on the current WebVR support, returns the current VR camera used.
  109667. */
  109668. readonly currentVRCamera: Nullable<Camera>;
  109669. /**
  109670. * The webVRCamera which is used when in VR.
  109671. */
  109672. readonly webVRCamera: WebVRFreeCamera;
  109673. /**
  109674. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  109675. */
  109676. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  109677. /**
  109678. * The html button that is used to trigger entering into VR.
  109679. */
  109680. readonly vrButton: Nullable<HTMLButtonElement>;
  109681. private readonly _teleportationRequestInitiated;
  109682. /**
  109683. * Defines wether or not Pointer lock should be requested when switching to
  109684. * full screen.
  109685. */
  109686. requestPointerLockOnFullScreen: boolean;
  109687. /**
  109688. * Instantiates a VRExperienceHelper.
  109689. * Helps to quickly add VR support to an existing scene.
  109690. * @param scene The scene the VRExperienceHelper belongs to.
  109691. * @param webVROptions Options to modify the vr experience helper's behavior.
  109692. */
  109693. constructor(scene: Scene,
  109694. /** Options to modify the vr experience helper's behavior. */
  109695. webVROptions?: VRExperienceHelperOptions);
  109696. private _onDefaultMeshLoaded;
  109697. private _onResize;
  109698. private _onFullscreenChange;
  109699. /**
  109700. * Gets a value indicating if we are currently in VR mode.
  109701. */
  109702. readonly isInVRMode: boolean;
  109703. private onVrDisplayPresentChange;
  109704. private onVRDisplayChanged;
  109705. private moveButtonToBottomRight;
  109706. private displayVRButton;
  109707. private updateButtonVisibility;
  109708. private _cachedAngularSensibility;
  109709. /**
  109710. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  109711. * Otherwise, will use the fullscreen API.
  109712. */
  109713. enterVR(): void;
  109714. /**
  109715. * Attempt to exit VR, or fullscreen.
  109716. */
  109717. exitVR(): void;
  109718. /**
  109719. * The position of the vr experience helper.
  109720. */
  109721. /**
  109722. * Sets the position of the vr experience helper.
  109723. */
  109724. position: Vector3;
  109725. /**
  109726. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  109727. */
  109728. enableInteractions(): void;
  109729. private readonly _noControllerIsActive;
  109730. private beforeRender;
  109731. private _isTeleportationFloor;
  109732. /**
  109733. * Adds a floor mesh to be used for teleportation.
  109734. * @param floorMesh the mesh to be used for teleportation.
  109735. */
  109736. addFloorMesh(floorMesh: Mesh): void;
  109737. /**
  109738. * Removes a floor mesh from being used for teleportation.
  109739. * @param floorMesh the mesh to be removed.
  109740. */
  109741. removeFloorMesh(floorMesh: Mesh): void;
  109742. /**
  109743. * Enables interactions and teleportation using the VR controllers and gaze.
  109744. * @param vrTeleportationOptions options to modify teleportation behavior.
  109745. */
  109746. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  109747. private _onNewGamepadConnected;
  109748. private _tryEnableInteractionOnController;
  109749. private _onNewGamepadDisconnected;
  109750. private _enableInteractionOnController;
  109751. private _checkTeleportWithRay;
  109752. private _checkRotate;
  109753. private _checkTeleportBackwards;
  109754. private _enableTeleportationOnController;
  109755. private _createTeleportationCircles;
  109756. private _displayTeleportationTarget;
  109757. private _hideTeleportationTarget;
  109758. private _rotateCamera;
  109759. private _moveTeleportationSelectorTo;
  109760. private _workingVector;
  109761. private _workingQuaternion;
  109762. private _workingMatrix;
  109763. /**
  109764. * Teleports the users feet to the desired location
  109765. * @param location The location where the user's feet should be placed
  109766. */
  109767. teleportCamera(location: Vector3): void;
  109768. private _convertNormalToDirectionOfRay;
  109769. private _castRayAndSelectObject;
  109770. private _notifySelectedMeshUnselected;
  109771. /**
  109772. * Sets the color of the laser ray from the vr controllers.
  109773. * @param color new color for the ray.
  109774. */
  109775. changeLaserColor(color: Color3): void;
  109776. /**
  109777. * Sets the color of the ray from the vr headsets gaze.
  109778. * @param color new color for the ray.
  109779. */
  109780. changeGazeColor(color: Color3): void;
  109781. /**
  109782. * Exits VR and disposes of the vr experience helper
  109783. */
  109784. dispose(): void;
  109785. /**
  109786. * Gets the name of the VRExperienceHelper class
  109787. * @returns "VRExperienceHelper"
  109788. */
  109789. getClassName(): string;
  109790. }
  109791. }
  109792. declare module BABYLON {
  109793. /**
  109794. * States of the webXR experience
  109795. */
  109796. export enum WebXRState {
  109797. /**
  109798. * Transitioning to being in XR mode
  109799. */
  109800. ENTERING_XR = 0,
  109801. /**
  109802. * Transitioning to non XR mode
  109803. */
  109804. EXITING_XR = 1,
  109805. /**
  109806. * In XR mode and presenting
  109807. */
  109808. IN_XR = 2,
  109809. /**
  109810. * Not entered XR mode
  109811. */
  109812. NOT_IN_XR = 3
  109813. }
  109814. /**
  109815. * Abstraction of the XR render target
  109816. */
  109817. export interface WebXRRenderTarget extends IDisposable {
  109818. /**
  109819. * xrpresent context of the canvas which can be used to display/mirror xr content
  109820. */
  109821. canvasContext: WebGLRenderingContext;
  109822. /**
  109823. * xr layer for the canvas
  109824. */
  109825. xrLayer: Nullable<XRWebGLLayer>;
  109826. /**
  109827. * Initializes the xr layer for the session
  109828. * @param xrSession xr session
  109829. * @returns a promise that will resolve once the XR Layer has been created
  109830. */
  109831. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  109832. }
  109833. }
  109834. declare module BABYLON {
  109835. /**
  109836. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  109837. */
  109838. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  109839. private _engine;
  109840. private _canvas;
  109841. /**
  109842. * xrpresent context of the canvas which can be used to display/mirror xr content
  109843. */
  109844. canvasContext: WebGLRenderingContext;
  109845. /**
  109846. * xr layer for the canvas
  109847. */
  109848. xrLayer: Nullable<XRWebGLLayer>;
  109849. /**
  109850. * Initializes the xr layer for the session
  109851. * @param xrSession xr session
  109852. * @returns a promise that will resolve once the XR Layer has been created
  109853. */
  109854. initializeXRLayerAsync(xrSession: any): any;
  109855. /**
  109856. * Initializes the canvas to be added/removed upon entering/exiting xr
  109857. * @param engine the Babylon engine
  109858. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  109859. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  109860. */
  109861. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>);
  109862. /**
  109863. * Disposes of the object
  109864. */
  109865. dispose(): void;
  109866. private _setManagedOutputCanvas;
  109867. private _addCanvas;
  109868. private _removeCanvas;
  109869. }
  109870. }
  109871. declare module BABYLON {
  109872. /**
  109873. * Manages an XRSession to work with Babylon's engine
  109874. * @see https://doc.babylonjs.com/how_to/webxr
  109875. */
  109876. export class WebXRSessionManager implements IDisposable {
  109877. private scene;
  109878. /**
  109879. * Fires every time a new xrFrame arrives which can be used to update the camera
  109880. */
  109881. onXRFrameObservable: Observable<any>;
  109882. /**
  109883. * Fires when the xr session is ended either by the device or manually done
  109884. */
  109885. onXRSessionEnded: Observable<any>;
  109886. /**
  109887. * Underlying xr session
  109888. */
  109889. session: XRSession;
  109890. /**
  109891. * Type of reference space used when creating the session
  109892. */
  109893. referenceSpace: XRReferenceSpace;
  109894. /**
  109895. * Current XR frame
  109896. */
  109897. currentFrame: Nullable<XRFrame>;
  109898. private _xrNavigator;
  109899. private baseLayer;
  109900. private _rttProvider;
  109901. private _sessionEnded;
  109902. /**
  109903. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  109904. * @param scene The scene which the session should be created for
  109905. */
  109906. constructor(scene: Scene);
  109907. /**
  109908. * Initializes the manager
  109909. * After initialization enterXR can be called to start an XR session
  109910. * @returns Promise which resolves after it is initialized
  109911. */
  109912. initializeAsync(): Promise<void>;
  109913. /**
  109914. * Initializes an xr session
  109915. * @param xrSessionMode mode to initialize
  109916. * @param optionalFeatures defines optional values to pass to the session builder
  109917. * @returns a promise which will resolve once the session has been initialized
  109918. */
  109919. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  109920. /**
  109921. * Sets the reference space on the xr session
  109922. * @param referenceSpace space to set
  109923. * @returns a promise that will resolve once the reference space has been set
  109924. */
  109925. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  109926. /**
  109927. * Updates the render state of the session
  109928. * @param state state to set
  109929. * @returns a promise that resolves once the render state has been updated
  109930. */
  109931. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  109932. /**
  109933. * Starts rendering to the xr layer
  109934. * @returns a promise that will resolve once rendering has started
  109935. */
  109936. startRenderingToXRAsync(): Promise<void>;
  109937. /**
  109938. * Gets the correct render target texture to be rendered this frame for this eye
  109939. * @param eye the eye for which to get the render target
  109940. * @returns the render target for the specified eye
  109941. */
  109942. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  109943. /**
  109944. * Stops the xrSession and restores the renderloop
  109945. * @returns Promise which resolves after it exits XR
  109946. */
  109947. exitXRAsync(): Promise<void>;
  109948. /**
  109949. * Checks if a session would be supported for the creation options specified
  109950. * @param sessionMode session mode to check if supported eg. immersive-vr
  109951. * @returns true if supported
  109952. */
  109953. supportsSessionAsync(sessionMode: XRSessionMode): any;
  109954. /**
  109955. * Creates a WebXRRenderTarget object for the XR session
  109956. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  109957. * @returns a WebXR render target to which the session can render
  109958. */
  109959. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  109960. /**
  109961. * @hidden
  109962. * Converts the render layer of xrSession to a render target
  109963. * @param session session to create render target for
  109964. * @param scene scene the new render target should be created for
  109965. */
  109966. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  109967. /**
  109968. * Disposes of the session manager
  109969. */
  109970. dispose(): void;
  109971. }
  109972. }
  109973. declare module BABYLON {
  109974. /**
  109975. * WebXR Camera which holds the views for the xrSession
  109976. * @see https://doc.babylonjs.com/how_to/webxr
  109977. */
  109978. export class WebXRCamera extends FreeCamera {
  109979. private static _TmpMatrix;
  109980. /**
  109981. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  109982. * @param name the name of the camera
  109983. * @param scene the scene to add the camera to
  109984. */
  109985. constructor(name: string, scene: Scene);
  109986. private _updateNumberOfRigCameras;
  109987. /** @hidden */
  109988. _updateForDualEyeDebugging(): void;
  109989. /**
  109990. * Updates the cameras position from the current pose information of the XR session
  109991. * @param xrSessionManager the session containing pose information
  109992. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  109993. */
  109994. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  109995. }
  109996. }
  109997. declare module BABYLON {
  109998. /**
  109999. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  110000. * @see https://doc.babylonjs.com/how_to/webxr
  110001. */
  110002. export class WebXRExperienceHelper implements IDisposable {
  110003. private scene;
  110004. /**
  110005. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  110006. */
  110007. container: AbstractMesh;
  110008. /**
  110009. * Camera used to render xr content
  110010. */
  110011. camera: WebXRCamera;
  110012. /**
  110013. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  110014. */
  110015. state: WebXRState;
  110016. private _setState;
  110017. private static _TmpVector;
  110018. /**
  110019. * Fires when the state of the experience helper has changed
  110020. */
  110021. onStateChangedObservable: Observable<WebXRState>;
  110022. /** Session manager used to keep track of xr session */
  110023. sessionManager: WebXRSessionManager;
  110024. private _nonVRCamera;
  110025. private _originalSceneAutoClear;
  110026. private _supported;
  110027. /**
  110028. * Creates the experience helper
  110029. * @param scene the scene to attach the experience helper to
  110030. * @returns a promise for the experience helper
  110031. */
  110032. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  110033. /**
  110034. * Creates a WebXRExperienceHelper
  110035. * @param scene The scene the helper should be created in
  110036. */
  110037. private constructor();
  110038. /**
  110039. * Exits XR mode and returns the scene to its original state
  110040. * @returns promise that resolves after xr mode has exited
  110041. */
  110042. exitXRAsync(): Promise<void>;
  110043. /**
  110044. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  110045. * @param sessionMode options for the XR session
  110046. * @param referenceSpaceType frame of reference of the XR session
  110047. * @param renderTarget the output canvas that will be used to enter XR mode
  110048. * @returns promise that resolves after xr mode has entered
  110049. */
  110050. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  110051. /**
  110052. * Updates the global position of the camera by moving the camera's container
  110053. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  110054. * @param position The desired global position of the camera
  110055. */
  110056. setPositionOfCameraUsingContainer(position: Vector3): void;
  110057. /**
  110058. * Rotates the xr camera by rotating the camera's container around the camera's position
  110059. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  110060. * @param rotation the desired quaternion rotation to apply to the camera
  110061. */
  110062. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  110063. /**
  110064. * Disposes of the experience helper
  110065. */
  110066. dispose(): void;
  110067. }
  110068. }
  110069. declare module BABYLON {
  110070. /**
  110071. * Button which can be used to enter a different mode of XR
  110072. */
  110073. export class WebXREnterExitUIButton {
  110074. /** button element */
  110075. element: HTMLElement;
  110076. /** XR initialization options for the button */
  110077. sessionMode: XRSessionMode;
  110078. /** Reference space type */
  110079. referenceSpaceType: XRReferenceSpaceType;
  110080. /**
  110081. * Creates a WebXREnterExitUIButton
  110082. * @param element button element
  110083. * @param sessionMode XR initialization session mode
  110084. * @param referenceSpaceType the type of reference space to be used
  110085. */
  110086. constructor(
  110087. /** button element */
  110088. element: HTMLElement,
  110089. /** XR initialization options for the button */
  110090. sessionMode: XRSessionMode,
  110091. /** Reference space type */
  110092. referenceSpaceType: XRReferenceSpaceType);
  110093. /**
  110094. * Overwritable function which can be used to update the button's visuals when the state changes
  110095. * @param activeButton the current active button in the UI
  110096. */
  110097. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  110098. }
  110099. /**
  110100. * Options to create the webXR UI
  110101. */
  110102. export class WebXREnterExitUIOptions {
  110103. /**
  110104. * Context to enter xr with
  110105. */
  110106. renderTarget?: Nullable<WebXRRenderTarget>;
  110107. /**
  110108. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  110109. */
  110110. customButtons?: Array<WebXREnterExitUIButton>;
  110111. }
  110112. /**
  110113. * UI to allow the user to enter/exit XR mode
  110114. */
  110115. export class WebXREnterExitUI implements IDisposable {
  110116. private scene;
  110117. private _overlay;
  110118. private _buttons;
  110119. private _activeButton;
  110120. /**
  110121. * Fired every time the active button is changed.
  110122. *
  110123. * When xr is entered via a button that launches xr that button will be the callback parameter
  110124. *
  110125. * When exiting xr the callback parameter will be null)
  110126. */
  110127. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  110128. /**
  110129. * Creates UI to allow the user to enter/exit XR mode
  110130. * @param scene the scene to add the ui to
  110131. * @param helper the xr experience helper to enter/exit xr with
  110132. * @param options options to configure the UI
  110133. * @returns the created ui
  110134. */
  110135. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  110136. private constructor();
  110137. private _updateButtons;
  110138. /**
  110139. * Disposes of the object
  110140. */
  110141. dispose(): void;
  110142. }
  110143. }
  110144. declare module BABYLON {
  110145. /**
  110146. * Represents an XR input
  110147. */
  110148. export class WebXRController {
  110149. private scene;
  110150. /** The underlying input source for the controller */
  110151. inputSource: XRInputSource;
  110152. private parentContainer;
  110153. /**
  110154. * 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
  110155. */
  110156. grip?: AbstractMesh;
  110157. /**
  110158. * Pointer which can be used to select objects or attach a visible laser to
  110159. */
  110160. pointer: AbstractMesh;
  110161. private _gamepadMode;
  110162. /**
  110163. * If available, this is the gamepad object related to this controller.
  110164. * Using this object it is possible to get click events and trackpad changes of the
  110165. * webxr controller that is currently being used.
  110166. */
  110167. gamepadController?: WebVRController;
  110168. /**
  110169. * Event that fires when the controller is removed/disposed
  110170. */
  110171. onDisposeObservable: Observable<{}>;
  110172. private _tmpMatrix;
  110173. private _tmpQuaternion;
  110174. private _tmpVector;
  110175. /**
  110176. * Creates the controller
  110177. * @see https://doc.babylonjs.com/how_to/webxr
  110178. * @param scene the scene which the controller should be associated to
  110179. * @param inputSource the underlying input source for the controller
  110180. * @param parentContainer parent that the controller meshes should be children of
  110181. */
  110182. constructor(scene: Scene,
  110183. /** The underlying input source for the controller */
  110184. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  110185. /**
  110186. * Updates the controller pose based on the given XRFrame
  110187. * @param xrFrame xr frame to update the pose with
  110188. * @param referenceSpace reference space to use
  110189. */
  110190. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  110191. /**
  110192. * Gets a world space ray coming from the controller
  110193. * @param result the resulting ray
  110194. */
  110195. getWorldPointerRayToRef(result: Ray): void;
  110196. /**
  110197. * Get the scene associated with this controller
  110198. * @returns the scene object
  110199. */
  110200. getScene(): Scene;
  110201. /**
  110202. * Disposes of the object
  110203. */
  110204. dispose(): void;
  110205. }
  110206. }
  110207. declare module BABYLON {
  110208. /**
  110209. * XR input used to track XR inputs such as controllers/rays
  110210. */
  110211. export class WebXRInput implements IDisposable {
  110212. /**
  110213. * Base experience the input listens to
  110214. */
  110215. baseExperience: WebXRExperienceHelper;
  110216. /**
  110217. * XR controllers being tracked
  110218. */
  110219. controllers: Array<WebXRController>;
  110220. private _frameObserver;
  110221. private _stateObserver;
  110222. /**
  110223. * Event when a controller has been connected/added
  110224. */
  110225. onControllerAddedObservable: Observable<WebXRController>;
  110226. /**
  110227. * Event when a controller has been removed/disconnected
  110228. */
  110229. onControllerRemovedObservable: Observable<WebXRController>;
  110230. /**
  110231. * Initializes the WebXRInput
  110232. * @param baseExperience experience helper which the input should be created for
  110233. */
  110234. constructor(
  110235. /**
  110236. * Base experience the input listens to
  110237. */
  110238. baseExperience: WebXRExperienceHelper);
  110239. private _onInputSourcesChange;
  110240. private _addAndRemoveControllers;
  110241. /**
  110242. * Disposes of the object
  110243. */
  110244. dispose(): void;
  110245. }
  110246. }
  110247. declare module BABYLON {
  110248. /**
  110249. * Enables teleportation
  110250. */
  110251. export class WebXRControllerTeleportation {
  110252. private _teleportationFillColor;
  110253. private _teleportationBorderColor;
  110254. private _tmpRay;
  110255. private _tmpVector;
  110256. /**
  110257. * Creates a WebXRControllerTeleportation
  110258. * @param input input manager to add teleportation to
  110259. * @param floorMeshes floormeshes which can be teleported to
  110260. */
  110261. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  110262. }
  110263. }
  110264. declare module BABYLON {
  110265. /**
  110266. * Handles pointer input automatically for the pointer of XR controllers
  110267. */
  110268. export class WebXRControllerPointerSelection {
  110269. private static _idCounter;
  110270. private _tmpRay;
  110271. /**
  110272. * Creates a WebXRControllerPointerSelection
  110273. * @param input input manager to setup pointer selection
  110274. */
  110275. constructor(input: WebXRInput);
  110276. private _convertNormalToDirectionOfRay;
  110277. private _updatePointerDistance;
  110278. }
  110279. }
  110280. declare module BABYLON {
  110281. /**
  110282. * Class used to represent data loading progression
  110283. */
  110284. export class SceneLoaderProgressEvent {
  110285. /** defines if data length to load can be evaluated */
  110286. readonly lengthComputable: boolean;
  110287. /** defines the loaded data length */
  110288. readonly loaded: number;
  110289. /** defines the data length to load */
  110290. readonly total: number;
  110291. /**
  110292. * Create a new progress event
  110293. * @param lengthComputable defines if data length to load can be evaluated
  110294. * @param loaded defines the loaded data length
  110295. * @param total defines the data length to load
  110296. */
  110297. constructor(
  110298. /** defines if data length to load can be evaluated */
  110299. lengthComputable: boolean,
  110300. /** defines the loaded data length */
  110301. loaded: number,
  110302. /** defines the data length to load */
  110303. total: number);
  110304. /**
  110305. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  110306. * @param event defines the source event
  110307. * @returns a new SceneLoaderProgressEvent
  110308. */
  110309. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  110310. }
  110311. /**
  110312. * Interface used by SceneLoader plugins to define supported file extensions
  110313. */
  110314. export interface ISceneLoaderPluginExtensions {
  110315. /**
  110316. * Defines the list of supported extensions
  110317. */
  110318. [extension: string]: {
  110319. isBinary: boolean;
  110320. };
  110321. }
  110322. /**
  110323. * Interface used by SceneLoader plugin factory
  110324. */
  110325. export interface ISceneLoaderPluginFactory {
  110326. /**
  110327. * Defines the name of the factory
  110328. */
  110329. name: string;
  110330. /**
  110331. * Function called to create a new plugin
  110332. * @return the new plugin
  110333. */
  110334. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  110335. /**
  110336. * The callback that returns true if the data can be directly loaded.
  110337. * @param data string containing the file data
  110338. * @returns if the data can be loaded directly
  110339. */
  110340. canDirectLoad?(data: string): boolean;
  110341. }
  110342. /**
  110343. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  110344. */
  110345. export interface ISceneLoaderPluginBase {
  110346. /**
  110347. * The friendly name of this plugin.
  110348. */
  110349. name: string;
  110350. /**
  110351. * The file extensions supported by this plugin.
  110352. */
  110353. extensions: string | ISceneLoaderPluginExtensions;
  110354. /**
  110355. * The callback called when loading from a url.
  110356. * @param scene scene loading this url
  110357. * @param url url to load
  110358. * @param onSuccess callback called when the file successfully loads
  110359. * @param onProgress callback called while file is loading (if the server supports this mode)
  110360. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110361. * @param onError callback called when the file fails to load
  110362. * @returns a file request object
  110363. */
  110364. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110365. /**
  110366. * The callback called when loading from a file object.
  110367. * @param scene scene loading this file
  110368. * @param file defines the file to load
  110369. * @param onSuccess defines the callback to call when data is loaded
  110370. * @param onProgress defines the callback to call during loading process
  110371. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  110372. * @param onError defines the callback to call when an error occurs
  110373. * @returns a file request object
  110374. */
  110375. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110376. /**
  110377. * The callback that returns true if the data can be directly loaded.
  110378. * @param data string containing the file data
  110379. * @returns if the data can be loaded directly
  110380. */
  110381. canDirectLoad?(data: string): boolean;
  110382. /**
  110383. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  110384. * @param scene scene loading this data
  110385. * @param data string containing the data
  110386. * @returns data to pass to the plugin
  110387. */
  110388. directLoad?(scene: Scene, data: string): any;
  110389. /**
  110390. * The callback that allows custom handling of the root url based on the response url.
  110391. * @param rootUrl the original root url
  110392. * @param responseURL the response url if available
  110393. * @returns the new root url
  110394. */
  110395. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  110396. }
  110397. /**
  110398. * Interface used to define a SceneLoader plugin
  110399. */
  110400. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  110401. /**
  110402. * Import meshes into a scene.
  110403. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110404. * @param scene The scene to import into
  110405. * @param data The data to import
  110406. * @param rootUrl The root url for scene and resources
  110407. * @param meshes The meshes array to import into
  110408. * @param particleSystems The particle systems array to import into
  110409. * @param skeletons The skeletons array to import into
  110410. * @param onError The callback when import fails
  110411. * @returns True if successful or false otherwise
  110412. */
  110413. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  110414. /**
  110415. * Load into a scene.
  110416. * @param scene The scene to load into
  110417. * @param data The data to import
  110418. * @param rootUrl The root url for scene and resources
  110419. * @param onError The callback when import fails
  110420. * @returns True if successful or false otherwise
  110421. */
  110422. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  110423. /**
  110424. * Load into an asset container.
  110425. * @param scene The scene to load into
  110426. * @param data The data to import
  110427. * @param rootUrl The root url for scene and resources
  110428. * @param onError The callback when import fails
  110429. * @returns The loaded asset container
  110430. */
  110431. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  110432. }
  110433. /**
  110434. * Interface used to define an async SceneLoader plugin
  110435. */
  110436. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  110437. /**
  110438. * Import meshes into a scene.
  110439. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110440. * @param scene The scene to import into
  110441. * @param data The data to import
  110442. * @param rootUrl The root url for scene and resources
  110443. * @param onProgress The callback when the load progresses
  110444. * @param fileName Defines the name of the file to load
  110445. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  110446. */
  110447. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  110448. meshes: AbstractMesh[];
  110449. particleSystems: IParticleSystem[];
  110450. skeletons: Skeleton[];
  110451. animationGroups: AnimationGroup[];
  110452. }>;
  110453. /**
  110454. * Load into a scene.
  110455. * @param scene The scene to load into
  110456. * @param data The data to import
  110457. * @param rootUrl The root url for scene and resources
  110458. * @param onProgress The callback when the load progresses
  110459. * @param fileName Defines the name of the file to load
  110460. * @returns Nothing
  110461. */
  110462. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  110463. /**
  110464. * Load into an asset container.
  110465. * @param scene The scene to load into
  110466. * @param data The data to import
  110467. * @param rootUrl The root url for scene and resources
  110468. * @param onProgress The callback when the load progresses
  110469. * @param fileName Defines the name of the file to load
  110470. * @returns The loaded asset container
  110471. */
  110472. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  110473. }
  110474. /**
  110475. * Class used to load scene from various file formats using registered plugins
  110476. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  110477. */
  110478. export class SceneLoader {
  110479. /**
  110480. * No logging while loading
  110481. */
  110482. static readonly NO_LOGGING: number;
  110483. /**
  110484. * Minimal logging while loading
  110485. */
  110486. static readonly MINIMAL_LOGGING: number;
  110487. /**
  110488. * Summary logging while loading
  110489. */
  110490. static readonly SUMMARY_LOGGING: number;
  110491. /**
  110492. * Detailled logging while loading
  110493. */
  110494. static readonly DETAILED_LOGGING: number;
  110495. /**
  110496. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  110497. */
  110498. static ForceFullSceneLoadingForIncremental: boolean;
  110499. /**
  110500. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  110501. */
  110502. static ShowLoadingScreen: boolean;
  110503. /**
  110504. * Defines the current logging level (while loading the scene)
  110505. * @ignorenaming
  110506. */
  110507. static loggingLevel: number;
  110508. /**
  110509. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  110510. */
  110511. static CleanBoneMatrixWeights: boolean;
  110512. /**
  110513. * Event raised when a plugin is used to load a scene
  110514. */
  110515. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  110516. private static _registeredPlugins;
  110517. private static _getDefaultPlugin;
  110518. private static _getPluginForExtension;
  110519. private static _getPluginForDirectLoad;
  110520. private static _getPluginForFilename;
  110521. private static _getDirectLoad;
  110522. private static _loadData;
  110523. private static _getFileInfo;
  110524. /**
  110525. * Gets a plugin that can load the given extension
  110526. * @param extension defines the extension to load
  110527. * @returns a plugin or null if none works
  110528. */
  110529. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  110530. /**
  110531. * Gets a boolean indicating that the given extension can be loaded
  110532. * @param extension defines the extension to load
  110533. * @returns true if the extension is supported
  110534. */
  110535. static IsPluginForExtensionAvailable(extension: string): boolean;
  110536. /**
  110537. * Adds a new plugin to the list of registered plugins
  110538. * @param plugin defines the plugin to add
  110539. */
  110540. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  110541. /**
  110542. * Import meshes into a scene
  110543. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110544. * @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)
  110545. * @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)
  110546. * @param scene the instance of BABYLON.Scene to append to
  110547. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  110548. * @param onProgress a callback with a progress event for each file being loaded
  110549. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110550. * @param pluginExtension the extension used to determine the plugin
  110551. * @returns The loaded plugin
  110552. */
  110553. 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>;
  110554. /**
  110555. * Import meshes into a scene
  110556. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110557. * @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)
  110558. * @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)
  110559. * @param scene the instance of BABYLON.Scene to append to
  110560. * @param onProgress a callback with a progress event for each file being loaded
  110561. * @param pluginExtension the extension used to determine the plugin
  110562. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  110563. */
  110564. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  110565. meshes: AbstractMesh[];
  110566. particleSystems: IParticleSystem[];
  110567. skeletons: Skeleton[];
  110568. animationGroups: AnimationGroup[];
  110569. }>;
  110570. /**
  110571. * Load a scene
  110572. * @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)
  110573. * @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)
  110574. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110575. * @param onSuccess a callback with the scene when import succeeds
  110576. * @param onProgress a callback with a progress event for each file being loaded
  110577. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110578. * @param pluginExtension the extension used to determine the plugin
  110579. * @returns The loaded plugin
  110580. */
  110581. 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>;
  110582. /**
  110583. * Load a scene
  110584. * @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)
  110585. * @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)
  110586. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110587. * @param onProgress a callback with a progress event for each file being loaded
  110588. * @param pluginExtension the extension used to determine the plugin
  110589. * @returns The loaded scene
  110590. */
  110591. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110592. /**
  110593. * Append a scene
  110594. * @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)
  110595. * @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)
  110596. * @param scene is the instance of BABYLON.Scene to append to
  110597. * @param onSuccess a callback with the scene when import succeeds
  110598. * @param onProgress a callback with a progress event for each file being loaded
  110599. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110600. * @param pluginExtension the extension used to determine the plugin
  110601. * @returns The loaded plugin
  110602. */
  110603. 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>;
  110604. /**
  110605. * Append a scene
  110606. * @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)
  110607. * @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)
  110608. * @param scene is the instance of BABYLON.Scene to append to
  110609. * @param onProgress a callback with a progress event for each file being loaded
  110610. * @param pluginExtension the extension used to determine the plugin
  110611. * @returns The given scene
  110612. */
  110613. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110614. /**
  110615. * Load a scene into an asset container
  110616. * @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)
  110617. * @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)
  110618. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110619. * @param onSuccess a callback with the scene when import succeeds
  110620. * @param onProgress a callback with a progress event for each file being loaded
  110621. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110622. * @param pluginExtension the extension used to determine the plugin
  110623. * @returns The loaded plugin
  110624. */
  110625. 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>;
  110626. /**
  110627. * Load a scene into an asset container
  110628. * @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)
  110629. * @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)
  110630. * @param scene is the instance of Scene to append to
  110631. * @param onProgress a callback with a progress event for each file being loaded
  110632. * @param pluginExtension the extension used to determine the plugin
  110633. * @returns The loaded asset container
  110634. */
  110635. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  110636. }
  110637. }
  110638. declare module BABYLON {
  110639. /**
  110640. * Generic Controller
  110641. */
  110642. export class GenericController extends WebVRController {
  110643. /**
  110644. * Base Url for the controller model.
  110645. */
  110646. static readonly MODEL_BASE_URL: string;
  110647. /**
  110648. * File name for the controller model.
  110649. */
  110650. static readonly MODEL_FILENAME: string;
  110651. /**
  110652. * Creates a new GenericController from a gamepad
  110653. * @param vrGamepad the gamepad that the controller should be created from
  110654. */
  110655. constructor(vrGamepad: any);
  110656. /**
  110657. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110658. * @param scene scene in which to add meshes
  110659. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110660. */
  110661. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110662. /**
  110663. * Called once for each button that changed state since the last frame
  110664. * @param buttonIdx Which button index changed
  110665. * @param state New state of the button
  110666. * @param changes Which properties on the state changed since last frame
  110667. */
  110668. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110669. }
  110670. }
  110671. declare module BABYLON {
  110672. /**
  110673. * Defines the WindowsMotionController object that the state of the windows motion controller
  110674. */
  110675. export class WindowsMotionController extends WebVRController {
  110676. /**
  110677. * The base url used to load the left and right controller models
  110678. */
  110679. static MODEL_BASE_URL: string;
  110680. /**
  110681. * The name of the left controller model file
  110682. */
  110683. static MODEL_LEFT_FILENAME: string;
  110684. /**
  110685. * The name of the right controller model file
  110686. */
  110687. static MODEL_RIGHT_FILENAME: string;
  110688. /**
  110689. * The controller name prefix for this controller type
  110690. */
  110691. static readonly GAMEPAD_ID_PREFIX: string;
  110692. /**
  110693. * The controller id pattern for this controller type
  110694. */
  110695. private static readonly GAMEPAD_ID_PATTERN;
  110696. private _loadedMeshInfo;
  110697. private readonly _mapping;
  110698. /**
  110699. * Fired when the trackpad on this controller is clicked
  110700. */
  110701. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  110702. /**
  110703. * Fired when the trackpad on this controller is modified
  110704. */
  110705. onTrackpadValuesChangedObservable: Observable<StickValues>;
  110706. /**
  110707. * The current x and y values of this controller's trackpad
  110708. */
  110709. trackpad: StickValues;
  110710. /**
  110711. * Creates a new WindowsMotionController from a gamepad
  110712. * @param vrGamepad the gamepad that the controller should be created from
  110713. */
  110714. constructor(vrGamepad: any);
  110715. /**
  110716. * Fired when the trigger on this controller is modified
  110717. */
  110718. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110719. /**
  110720. * Fired when the menu button on this controller is modified
  110721. */
  110722. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110723. /**
  110724. * Fired when the grip button on this controller is modified
  110725. */
  110726. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110727. /**
  110728. * Fired when the thumbstick button on this controller is modified
  110729. */
  110730. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110731. /**
  110732. * Fired when the touchpad button on this controller is modified
  110733. */
  110734. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110735. /**
  110736. * Fired when the touchpad values on this controller are modified
  110737. */
  110738. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  110739. private _updateTrackpad;
  110740. /**
  110741. * Called once per frame by the engine.
  110742. */
  110743. update(): void;
  110744. /**
  110745. * Called once for each button that changed state since the last frame
  110746. * @param buttonIdx Which button index changed
  110747. * @param state New state of the button
  110748. * @param changes Which properties on the state changed since last frame
  110749. */
  110750. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110751. /**
  110752. * Moves the buttons on the controller mesh based on their current state
  110753. * @param buttonName the name of the button to move
  110754. * @param buttonValue the value of the button which determines the buttons new position
  110755. */
  110756. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  110757. /**
  110758. * Moves the axis on the controller mesh based on its current state
  110759. * @param axis the index of the axis
  110760. * @param axisValue the value of the axis which determines the meshes new position
  110761. * @hidden
  110762. */
  110763. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  110764. /**
  110765. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110766. * @param scene scene in which to add meshes
  110767. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110768. */
  110769. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  110770. /**
  110771. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  110772. * can be transformed by button presses and axes values, based on this._mapping.
  110773. *
  110774. * @param scene scene in which the meshes exist
  110775. * @param meshes list of meshes that make up the controller model to process
  110776. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  110777. */
  110778. private processModel;
  110779. private createMeshInfo;
  110780. /**
  110781. * Gets the ray of the controller in the direction the controller is pointing
  110782. * @param length the length the resulting ray should be
  110783. * @returns a ray in the direction the controller is pointing
  110784. */
  110785. getForwardRay(length?: number): Ray;
  110786. /**
  110787. * Disposes of the controller
  110788. */
  110789. dispose(): void;
  110790. }
  110791. }
  110792. declare module BABYLON {
  110793. /**
  110794. * Oculus Touch Controller
  110795. */
  110796. export class OculusTouchController extends WebVRController {
  110797. /**
  110798. * Base Url for the controller model.
  110799. */
  110800. static MODEL_BASE_URL: string;
  110801. /**
  110802. * File name for the left controller model.
  110803. */
  110804. static MODEL_LEFT_FILENAME: string;
  110805. /**
  110806. * File name for the right controller model.
  110807. */
  110808. static MODEL_RIGHT_FILENAME: string;
  110809. /**
  110810. * Base Url for the Quest controller model.
  110811. */
  110812. static QUEST_MODEL_BASE_URL: string;
  110813. /**
  110814. * @hidden
  110815. * If the controllers are running on a device that needs the updated Quest controller models
  110816. */
  110817. static _IsQuest: boolean;
  110818. /**
  110819. * Fired when the secondary trigger on this controller is modified
  110820. */
  110821. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  110822. /**
  110823. * Fired when the thumb rest on this controller is modified
  110824. */
  110825. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  110826. /**
  110827. * Creates a new OculusTouchController from a gamepad
  110828. * @param vrGamepad the gamepad that the controller should be created from
  110829. */
  110830. constructor(vrGamepad: any);
  110831. /**
  110832. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110833. * @param scene scene in which to add meshes
  110834. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110835. */
  110836. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110837. /**
  110838. * Fired when the A button on this controller is modified
  110839. */
  110840. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110841. /**
  110842. * Fired when the B button on this controller is modified
  110843. */
  110844. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110845. /**
  110846. * Fired when the X button on this controller is modified
  110847. */
  110848. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110849. /**
  110850. * Fired when the Y button on this controller is modified
  110851. */
  110852. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110853. /**
  110854. * Called once for each button that changed state since the last frame
  110855. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  110856. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  110857. * 2) secondary trigger (same)
  110858. * 3) A (right) X (left), touch, pressed = value
  110859. * 4) B / Y
  110860. * 5) thumb rest
  110861. * @param buttonIdx Which button index changed
  110862. * @param state New state of the button
  110863. * @param changes Which properties on the state changed since last frame
  110864. */
  110865. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110866. }
  110867. }
  110868. declare module BABYLON {
  110869. /**
  110870. * Vive Controller
  110871. */
  110872. export class ViveController extends WebVRController {
  110873. /**
  110874. * Base Url for the controller model.
  110875. */
  110876. static MODEL_BASE_URL: string;
  110877. /**
  110878. * File name for the controller model.
  110879. */
  110880. static MODEL_FILENAME: string;
  110881. /**
  110882. * Creates a new ViveController from a gamepad
  110883. * @param vrGamepad the gamepad that the controller should be created from
  110884. */
  110885. constructor(vrGamepad: any);
  110886. /**
  110887. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110888. * @param scene scene in which to add meshes
  110889. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110890. */
  110891. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110892. /**
  110893. * Fired when the left button on this controller is modified
  110894. */
  110895. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110896. /**
  110897. * Fired when the right button on this controller is modified
  110898. */
  110899. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110900. /**
  110901. * Fired when the menu button on this controller is modified
  110902. */
  110903. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110904. /**
  110905. * Called once for each button that changed state since the last frame
  110906. * Vive mapping:
  110907. * 0: touchpad
  110908. * 1: trigger
  110909. * 2: left AND right buttons
  110910. * 3: menu button
  110911. * @param buttonIdx Which button index changed
  110912. * @param state New state of the button
  110913. * @param changes Which properties on the state changed since last frame
  110914. */
  110915. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110916. }
  110917. }
  110918. declare module BABYLON {
  110919. /**
  110920. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  110921. */
  110922. export class WebXRControllerModelLoader {
  110923. /**
  110924. * Creates the WebXRControllerModelLoader
  110925. * @param input xr input that creates the controllers
  110926. */
  110927. constructor(input: WebXRInput);
  110928. }
  110929. }
  110930. declare module BABYLON {
  110931. /**
  110932. * Contains an array of blocks representing the octree
  110933. */
  110934. export interface IOctreeContainer<T> {
  110935. /**
  110936. * Blocks within the octree
  110937. */
  110938. blocks: Array<OctreeBlock<T>>;
  110939. }
  110940. /**
  110941. * Class used to store a cell in an octree
  110942. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110943. */
  110944. export class OctreeBlock<T> {
  110945. /**
  110946. * Gets the content of the current block
  110947. */
  110948. entries: T[];
  110949. /**
  110950. * Gets the list of block children
  110951. */
  110952. blocks: Array<OctreeBlock<T>>;
  110953. private _depth;
  110954. private _maxDepth;
  110955. private _capacity;
  110956. private _minPoint;
  110957. private _maxPoint;
  110958. private _boundingVectors;
  110959. private _creationFunc;
  110960. /**
  110961. * Creates a new block
  110962. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  110963. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  110964. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  110965. * @param depth defines the current depth of this block in the octree
  110966. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  110967. * @param creationFunc defines a callback to call when an element is added to the block
  110968. */
  110969. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  110970. /**
  110971. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  110972. */
  110973. readonly capacity: number;
  110974. /**
  110975. * Gets the minimum vector (in world space) of the block's bounding box
  110976. */
  110977. readonly minPoint: Vector3;
  110978. /**
  110979. * Gets the maximum vector (in world space) of the block's bounding box
  110980. */
  110981. readonly maxPoint: Vector3;
  110982. /**
  110983. * Add a new element to this block
  110984. * @param entry defines the element to add
  110985. */
  110986. addEntry(entry: T): void;
  110987. /**
  110988. * Remove an element from this block
  110989. * @param entry defines the element to remove
  110990. */
  110991. removeEntry(entry: T): void;
  110992. /**
  110993. * Add an array of elements to this block
  110994. * @param entries defines the array of elements to add
  110995. */
  110996. addEntries(entries: T[]): void;
  110997. /**
  110998. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  110999. * @param frustumPlanes defines the frustum planes to test
  111000. * @param selection defines the array to store current content if selection is positive
  111001. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111002. */
  111003. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  111004. /**
  111005. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  111006. * @param sphereCenter defines the bounding sphere center
  111007. * @param sphereRadius defines the bounding sphere radius
  111008. * @param selection defines the array to store current content if selection is positive
  111009. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111010. */
  111011. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  111012. /**
  111013. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  111014. * @param ray defines the ray to test with
  111015. * @param selection defines the array to store current content if selection is positive
  111016. */
  111017. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  111018. /**
  111019. * Subdivide the content into child blocks (this block will then be empty)
  111020. */
  111021. createInnerBlocks(): void;
  111022. /**
  111023. * @hidden
  111024. */
  111025. 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;
  111026. }
  111027. }
  111028. declare module BABYLON {
  111029. /**
  111030. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  111031. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111032. */
  111033. export class Octree<T> {
  111034. /** 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.) */
  111035. maxDepth: number;
  111036. /**
  111037. * Blocks within the octree containing objects
  111038. */
  111039. blocks: Array<OctreeBlock<T>>;
  111040. /**
  111041. * Content stored in the octree
  111042. */
  111043. dynamicContent: T[];
  111044. private _maxBlockCapacity;
  111045. private _selectionContent;
  111046. private _creationFunc;
  111047. /**
  111048. * Creates a octree
  111049. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111050. * @param creationFunc function to be used to instatiate the octree
  111051. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  111052. * @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.)
  111053. */
  111054. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  111055. /** 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.) */
  111056. maxDepth?: number);
  111057. /**
  111058. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  111059. * @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);
  111060. * @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);
  111061. * @param entries meshes to be added to the octree blocks
  111062. */
  111063. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  111064. /**
  111065. * Adds a mesh to the octree
  111066. * @param entry Mesh to add to the octree
  111067. */
  111068. addMesh(entry: T): void;
  111069. /**
  111070. * Remove an element from the octree
  111071. * @param entry defines the element to remove
  111072. */
  111073. removeMesh(entry: T): void;
  111074. /**
  111075. * Selects an array of meshes within the frustum
  111076. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  111077. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  111078. * @returns array of meshes within the frustum
  111079. */
  111080. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  111081. /**
  111082. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  111083. * @param sphereCenter defines the bounding sphere center
  111084. * @param sphereRadius defines the bounding sphere radius
  111085. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111086. * @returns an array of objects that intersect the sphere
  111087. */
  111088. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  111089. /**
  111090. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  111091. * @param ray defines the ray to test with
  111092. * @returns array of intersected objects
  111093. */
  111094. intersectsRay(ray: Ray): SmartArray<T>;
  111095. /**
  111096. * Adds a mesh into the octree block if it intersects the block
  111097. */
  111098. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  111099. /**
  111100. * Adds a submesh into the octree block if it intersects the block
  111101. */
  111102. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  111103. }
  111104. }
  111105. declare module BABYLON {
  111106. interface Scene {
  111107. /**
  111108. * @hidden
  111109. * Backing Filed
  111110. */
  111111. _selectionOctree: Octree<AbstractMesh>;
  111112. /**
  111113. * Gets the octree used to boost mesh selection (picking)
  111114. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111115. */
  111116. selectionOctree: Octree<AbstractMesh>;
  111117. /**
  111118. * Creates or updates the octree used to boost selection (picking)
  111119. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111120. * @param maxCapacity defines the maximum capacity per leaf
  111121. * @param maxDepth defines the maximum depth of the octree
  111122. * @returns an octree of AbstractMesh
  111123. */
  111124. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  111125. }
  111126. interface AbstractMesh {
  111127. /**
  111128. * @hidden
  111129. * Backing Field
  111130. */
  111131. _submeshesOctree: Octree<SubMesh>;
  111132. /**
  111133. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  111134. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  111135. * @param maxCapacity defines the maximum size of each block (64 by default)
  111136. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  111137. * @returns the new octree
  111138. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  111139. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111140. */
  111141. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  111142. }
  111143. /**
  111144. * Defines the octree scene component responsible to manage any octrees
  111145. * in a given scene.
  111146. */
  111147. export class OctreeSceneComponent {
  111148. /**
  111149. * The component name help to identify the component in the list of scene components.
  111150. */
  111151. readonly name: string;
  111152. /**
  111153. * The scene the component belongs to.
  111154. */
  111155. scene: Scene;
  111156. /**
  111157. * Indicates if the meshes have been checked to make sure they are isEnabled()
  111158. */
  111159. readonly checksIsEnabled: boolean;
  111160. /**
  111161. * Creates a new instance of the component for the given scene
  111162. * @param scene Defines the scene to register the component in
  111163. */
  111164. constructor(scene: Scene);
  111165. /**
  111166. * Registers the component in a given scene
  111167. */
  111168. register(): void;
  111169. /**
  111170. * Return the list of active meshes
  111171. * @returns the list of active meshes
  111172. */
  111173. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  111174. /**
  111175. * Return the list of active sub meshes
  111176. * @param mesh The mesh to get the candidates sub meshes from
  111177. * @returns the list of active sub meshes
  111178. */
  111179. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  111180. private _tempRay;
  111181. /**
  111182. * Return the list of sub meshes intersecting with a given local ray
  111183. * @param mesh defines the mesh to find the submesh for
  111184. * @param localRay defines the ray in local space
  111185. * @returns the list of intersecting sub meshes
  111186. */
  111187. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  111188. /**
  111189. * Return the list of sub meshes colliding with a collider
  111190. * @param mesh defines the mesh to find the submesh for
  111191. * @param collider defines the collider to evaluate the collision against
  111192. * @returns the list of colliding sub meshes
  111193. */
  111194. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  111195. /**
  111196. * Rebuilds the elements related to this component in case of
  111197. * context lost for instance.
  111198. */
  111199. rebuild(): void;
  111200. /**
  111201. * Disposes the component and the associated ressources.
  111202. */
  111203. dispose(): void;
  111204. }
  111205. }
  111206. declare module BABYLON {
  111207. /**
  111208. * Renders a layer on top of an existing scene
  111209. */
  111210. export class UtilityLayerRenderer implements IDisposable {
  111211. /** the original scene that will be rendered on top of */
  111212. originalScene: Scene;
  111213. private _pointerCaptures;
  111214. private _lastPointerEvents;
  111215. private static _DefaultUtilityLayer;
  111216. private static _DefaultKeepDepthUtilityLayer;
  111217. private _sharedGizmoLight;
  111218. private _renderCamera;
  111219. /**
  111220. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  111221. * @returns the camera that is used when rendering the utility layer
  111222. */
  111223. getRenderCamera(): Nullable<Camera>;
  111224. /**
  111225. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  111226. * @param cam the camera that should be used when rendering the utility layer
  111227. */
  111228. setRenderCamera(cam: Nullable<Camera>): void;
  111229. /**
  111230. * @hidden
  111231. * Light which used by gizmos to get light shading
  111232. */
  111233. _getSharedGizmoLight(): HemisphericLight;
  111234. /**
  111235. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  111236. */
  111237. pickUtilitySceneFirst: boolean;
  111238. /**
  111239. * 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)
  111240. */
  111241. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  111242. /**
  111243. * 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)
  111244. */
  111245. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  111246. /**
  111247. * The scene that is rendered on top of the original scene
  111248. */
  111249. utilityLayerScene: Scene;
  111250. /**
  111251. * If the utility layer should automatically be rendered on top of existing scene
  111252. */
  111253. shouldRender: boolean;
  111254. /**
  111255. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  111256. */
  111257. onlyCheckPointerDownEvents: boolean;
  111258. /**
  111259. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  111260. */
  111261. processAllEvents: boolean;
  111262. /**
  111263. * Observable raised when the pointer move from the utility layer scene to the main scene
  111264. */
  111265. onPointerOutObservable: Observable<number>;
  111266. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  111267. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  111268. private _afterRenderObserver;
  111269. private _sceneDisposeObserver;
  111270. private _originalPointerObserver;
  111271. /**
  111272. * Instantiates a UtilityLayerRenderer
  111273. * @param originalScene the original scene that will be rendered on top of
  111274. * @param handleEvents boolean indicating if the utility layer should handle events
  111275. */
  111276. constructor(
  111277. /** the original scene that will be rendered on top of */
  111278. originalScene: Scene, handleEvents?: boolean);
  111279. private _notifyObservers;
  111280. /**
  111281. * Renders the utility layers scene on top of the original scene
  111282. */
  111283. render(): void;
  111284. /**
  111285. * Disposes of the renderer
  111286. */
  111287. dispose(): void;
  111288. private _updateCamera;
  111289. }
  111290. }
  111291. declare module BABYLON {
  111292. /**
  111293. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  111294. */
  111295. export class Gizmo implements IDisposable {
  111296. /** The utility layer the gizmo will be added to */
  111297. gizmoLayer: UtilityLayerRenderer;
  111298. /**
  111299. * The root mesh of the gizmo
  111300. */
  111301. _rootMesh: Mesh;
  111302. private _attachedMesh;
  111303. /**
  111304. * Ratio for the scale of the gizmo (Default: 1)
  111305. */
  111306. scaleRatio: number;
  111307. /**
  111308. * If a custom mesh has been set (Default: false)
  111309. */
  111310. protected _customMeshSet: boolean;
  111311. /**
  111312. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  111313. * * When set, interactions will be enabled
  111314. */
  111315. attachedMesh: Nullable<AbstractMesh>;
  111316. /**
  111317. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111318. * @param mesh The mesh to replace the default mesh of the gizmo
  111319. */
  111320. setCustomMesh(mesh: Mesh): void;
  111321. /**
  111322. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  111323. */
  111324. updateGizmoRotationToMatchAttachedMesh: boolean;
  111325. /**
  111326. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  111327. */
  111328. updateGizmoPositionToMatchAttachedMesh: boolean;
  111329. /**
  111330. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  111331. */
  111332. updateScale: boolean;
  111333. protected _interactionsEnabled: boolean;
  111334. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111335. private _beforeRenderObserver;
  111336. private _tempVector;
  111337. /**
  111338. * Creates a gizmo
  111339. * @param gizmoLayer The utility layer the gizmo will be added to
  111340. */
  111341. constructor(
  111342. /** The utility layer the gizmo will be added to */
  111343. gizmoLayer?: UtilityLayerRenderer);
  111344. /**
  111345. * Updates the gizmo to match the attached mesh's position/rotation
  111346. */
  111347. protected _update(): void;
  111348. /**
  111349. * Disposes of the gizmo
  111350. */
  111351. dispose(): void;
  111352. }
  111353. }
  111354. declare module BABYLON {
  111355. /**
  111356. * Single plane drag gizmo
  111357. */
  111358. export class PlaneDragGizmo extends Gizmo {
  111359. /**
  111360. * Drag behavior responsible for the gizmos dragging interactions
  111361. */
  111362. dragBehavior: PointerDragBehavior;
  111363. private _pointerObserver;
  111364. /**
  111365. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111366. */
  111367. snapDistance: number;
  111368. /**
  111369. * Event that fires each time the gizmo snaps to a new location.
  111370. * * snapDistance is the the change in distance
  111371. */
  111372. onSnapObservable: Observable<{
  111373. snapDistance: number;
  111374. }>;
  111375. private _plane;
  111376. private _coloredMaterial;
  111377. private _hoverMaterial;
  111378. private _isEnabled;
  111379. private _parent;
  111380. /** @hidden */
  111381. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  111382. /** @hidden */
  111383. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  111384. /**
  111385. * Creates a PlaneDragGizmo
  111386. * @param gizmoLayer The utility layer the gizmo will be added to
  111387. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  111388. * @param color The color of the gizmo
  111389. */
  111390. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  111391. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111392. /**
  111393. * If the gizmo is enabled
  111394. */
  111395. isEnabled: boolean;
  111396. /**
  111397. * Disposes of the gizmo
  111398. */
  111399. dispose(): void;
  111400. }
  111401. }
  111402. declare module BABYLON {
  111403. /**
  111404. * Gizmo that enables dragging a mesh along 3 axis
  111405. */
  111406. export class PositionGizmo extends Gizmo {
  111407. /**
  111408. * Internal gizmo used for interactions on the x axis
  111409. */
  111410. xGizmo: AxisDragGizmo;
  111411. /**
  111412. * Internal gizmo used for interactions on the y axis
  111413. */
  111414. yGizmo: AxisDragGizmo;
  111415. /**
  111416. * Internal gizmo used for interactions on the z axis
  111417. */
  111418. zGizmo: AxisDragGizmo;
  111419. /**
  111420. * Internal gizmo used for interactions on the yz plane
  111421. */
  111422. xPlaneGizmo: PlaneDragGizmo;
  111423. /**
  111424. * Internal gizmo used for interactions on the xz plane
  111425. */
  111426. yPlaneGizmo: PlaneDragGizmo;
  111427. /**
  111428. * Internal gizmo used for interactions on the xy plane
  111429. */
  111430. zPlaneGizmo: PlaneDragGizmo;
  111431. /**
  111432. * private variables
  111433. */
  111434. private _meshAttached;
  111435. private _updateGizmoRotationToMatchAttachedMesh;
  111436. private _snapDistance;
  111437. private _scaleRatio;
  111438. /** Fires an event when any of it's sub gizmos are dragged */
  111439. onDragStartObservable: Observable<unknown>;
  111440. /** Fires an event when any of it's sub gizmos are released from dragging */
  111441. onDragEndObservable: Observable<unknown>;
  111442. /**
  111443. * If set to true, planar drag is enabled
  111444. */
  111445. private _planarGizmoEnabled;
  111446. attachedMesh: Nullable<AbstractMesh>;
  111447. /**
  111448. * Creates a PositionGizmo
  111449. * @param gizmoLayer The utility layer the gizmo will be added to
  111450. */
  111451. constructor(gizmoLayer?: UtilityLayerRenderer);
  111452. /**
  111453. * If the planar drag gizmo is enabled
  111454. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  111455. */
  111456. planarGizmoEnabled: boolean;
  111457. updateGizmoRotationToMatchAttachedMesh: boolean;
  111458. /**
  111459. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111460. */
  111461. snapDistance: number;
  111462. /**
  111463. * Ratio for the scale of the gizmo (Default: 1)
  111464. */
  111465. scaleRatio: number;
  111466. /**
  111467. * Disposes of the gizmo
  111468. */
  111469. dispose(): void;
  111470. /**
  111471. * CustomMeshes are not supported by this gizmo
  111472. * @param mesh The mesh to replace the default mesh of the gizmo
  111473. */
  111474. setCustomMesh(mesh: Mesh): void;
  111475. }
  111476. }
  111477. declare module BABYLON {
  111478. /**
  111479. * Single axis drag gizmo
  111480. */
  111481. export class AxisDragGizmo extends Gizmo {
  111482. /**
  111483. * Drag behavior responsible for the gizmos dragging interactions
  111484. */
  111485. dragBehavior: PointerDragBehavior;
  111486. private _pointerObserver;
  111487. /**
  111488. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111489. */
  111490. snapDistance: number;
  111491. /**
  111492. * Event that fires each time the gizmo snaps to a new location.
  111493. * * snapDistance is the the change in distance
  111494. */
  111495. onSnapObservable: Observable<{
  111496. snapDistance: number;
  111497. }>;
  111498. private _isEnabled;
  111499. private _parent;
  111500. private _arrow;
  111501. private _coloredMaterial;
  111502. private _hoverMaterial;
  111503. /** @hidden */
  111504. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  111505. /** @hidden */
  111506. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  111507. /**
  111508. * Creates an AxisDragGizmo
  111509. * @param gizmoLayer The utility layer the gizmo will be added to
  111510. * @param dragAxis The axis which the gizmo will be able to drag on
  111511. * @param color The color of the gizmo
  111512. */
  111513. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  111514. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111515. /**
  111516. * If the gizmo is enabled
  111517. */
  111518. isEnabled: boolean;
  111519. /**
  111520. * Disposes of the gizmo
  111521. */
  111522. dispose(): void;
  111523. }
  111524. }
  111525. declare module BABYLON.Debug {
  111526. /**
  111527. * The Axes viewer will show 3 axes in a specific point in space
  111528. */
  111529. export class AxesViewer {
  111530. private _xAxis;
  111531. private _yAxis;
  111532. private _zAxis;
  111533. private _scaleLinesFactor;
  111534. private _instanced;
  111535. /**
  111536. * Gets the hosting scene
  111537. */
  111538. scene: Scene;
  111539. /**
  111540. * Gets or sets a number used to scale line length
  111541. */
  111542. scaleLines: number;
  111543. /** Gets the node hierarchy used to render x-axis */
  111544. readonly xAxis: TransformNode;
  111545. /** Gets the node hierarchy used to render y-axis */
  111546. readonly yAxis: TransformNode;
  111547. /** Gets the node hierarchy used to render z-axis */
  111548. readonly zAxis: TransformNode;
  111549. /**
  111550. * Creates a new AxesViewer
  111551. * @param scene defines the hosting scene
  111552. * @param scaleLines defines a number used to scale line length (1 by default)
  111553. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  111554. * @param xAxis defines the node hierarchy used to render the x-axis
  111555. * @param yAxis defines the node hierarchy used to render the y-axis
  111556. * @param zAxis defines the node hierarchy used to render the z-axis
  111557. */
  111558. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  111559. /**
  111560. * Force the viewer to update
  111561. * @param position defines the position of the viewer
  111562. * @param xaxis defines the x axis of the viewer
  111563. * @param yaxis defines the y axis of the viewer
  111564. * @param zaxis defines the z axis of the viewer
  111565. */
  111566. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  111567. /**
  111568. * Creates an instance of this axes viewer.
  111569. * @returns a new axes viewer with instanced meshes
  111570. */
  111571. createInstance(): AxesViewer;
  111572. /** Releases resources */
  111573. dispose(): void;
  111574. private static _SetRenderingGroupId;
  111575. }
  111576. }
  111577. declare module BABYLON.Debug {
  111578. /**
  111579. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  111580. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  111581. */
  111582. export class BoneAxesViewer extends AxesViewer {
  111583. /**
  111584. * Gets or sets the target mesh where to display the axes viewer
  111585. */
  111586. mesh: Nullable<Mesh>;
  111587. /**
  111588. * Gets or sets the target bone where to display the axes viewer
  111589. */
  111590. bone: Nullable<Bone>;
  111591. /** Gets current position */
  111592. pos: Vector3;
  111593. /** Gets direction of X axis */
  111594. xaxis: Vector3;
  111595. /** Gets direction of Y axis */
  111596. yaxis: Vector3;
  111597. /** Gets direction of Z axis */
  111598. zaxis: Vector3;
  111599. /**
  111600. * Creates a new BoneAxesViewer
  111601. * @param scene defines the hosting scene
  111602. * @param bone defines the target bone
  111603. * @param mesh defines the target mesh
  111604. * @param scaleLines defines a scaling factor for line length (1 by default)
  111605. */
  111606. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  111607. /**
  111608. * Force the viewer to update
  111609. */
  111610. update(): void;
  111611. /** Releases resources */
  111612. dispose(): void;
  111613. }
  111614. }
  111615. declare module BABYLON {
  111616. /**
  111617. * Interface used to define scene explorer extensibility option
  111618. */
  111619. export interface IExplorerExtensibilityOption {
  111620. /**
  111621. * Define the option label
  111622. */
  111623. label: string;
  111624. /**
  111625. * Defines the action to execute on click
  111626. */
  111627. action: (entity: any) => void;
  111628. }
  111629. /**
  111630. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  111631. */
  111632. export interface IExplorerExtensibilityGroup {
  111633. /**
  111634. * Defines a predicate to test if a given type mut be extended
  111635. */
  111636. predicate: (entity: any) => boolean;
  111637. /**
  111638. * Gets the list of options added to a type
  111639. */
  111640. entries: IExplorerExtensibilityOption[];
  111641. }
  111642. /**
  111643. * Interface used to define the options to use to create the Inspector
  111644. */
  111645. export interface IInspectorOptions {
  111646. /**
  111647. * Display in overlay mode (default: false)
  111648. */
  111649. overlay?: boolean;
  111650. /**
  111651. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  111652. */
  111653. globalRoot?: HTMLElement;
  111654. /**
  111655. * Display the Scene explorer
  111656. */
  111657. showExplorer?: boolean;
  111658. /**
  111659. * Display the property inspector
  111660. */
  111661. showInspector?: boolean;
  111662. /**
  111663. * Display in embed mode (both panes on the right)
  111664. */
  111665. embedMode?: boolean;
  111666. /**
  111667. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  111668. */
  111669. handleResize?: boolean;
  111670. /**
  111671. * Allow the panes to popup (default: true)
  111672. */
  111673. enablePopup?: boolean;
  111674. /**
  111675. * Allow the panes to be closed by users (default: true)
  111676. */
  111677. enableClose?: boolean;
  111678. /**
  111679. * Optional list of extensibility entries
  111680. */
  111681. explorerExtensibility?: IExplorerExtensibilityGroup[];
  111682. /**
  111683. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  111684. */
  111685. inspectorURL?: string;
  111686. }
  111687. interface Scene {
  111688. /**
  111689. * @hidden
  111690. * Backing field
  111691. */
  111692. _debugLayer: DebugLayer;
  111693. /**
  111694. * Gets the debug layer (aka Inspector) associated with the scene
  111695. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111696. */
  111697. debugLayer: DebugLayer;
  111698. }
  111699. /**
  111700. * The debug layer (aka Inspector) is the go to tool in order to better understand
  111701. * what is happening in your scene
  111702. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111703. */
  111704. export class DebugLayer {
  111705. /**
  111706. * Define the url to get the inspector script from.
  111707. * By default it uses the babylonjs CDN.
  111708. * @ignoreNaming
  111709. */
  111710. static InspectorURL: string;
  111711. private _scene;
  111712. private BJSINSPECTOR;
  111713. private _onPropertyChangedObservable?;
  111714. /**
  111715. * Observable triggered when a property is changed through the inspector.
  111716. */
  111717. readonly onPropertyChangedObservable: any;
  111718. /**
  111719. * Instantiates a new debug layer.
  111720. * The debug layer (aka Inspector) is the go to tool in order to better understand
  111721. * what is happening in your scene
  111722. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111723. * @param scene Defines the scene to inspect
  111724. */
  111725. constructor(scene: Scene);
  111726. /** Creates the inspector window. */
  111727. private _createInspector;
  111728. /**
  111729. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  111730. * @param entity defines the entity to select
  111731. * @param lineContainerTitle defines the specific block to highlight
  111732. */
  111733. select(entity: any, lineContainerTitle?: string): void;
  111734. /** Get the inspector from bundle or global */
  111735. private _getGlobalInspector;
  111736. /**
  111737. * Get if the inspector is visible or not.
  111738. * @returns true if visible otherwise, false
  111739. */
  111740. isVisible(): boolean;
  111741. /**
  111742. * Hide the inspector and close its window.
  111743. */
  111744. hide(): void;
  111745. /**
  111746. * Launch the debugLayer.
  111747. * @param config Define the configuration of the inspector
  111748. * @return a promise fulfilled when the debug layer is visible
  111749. */
  111750. show(config?: IInspectorOptions): Promise<DebugLayer>;
  111751. }
  111752. }
  111753. declare module BABYLON {
  111754. /**
  111755. * Class containing static functions to help procedurally build meshes
  111756. */
  111757. export class BoxBuilder {
  111758. /**
  111759. * Creates a box mesh
  111760. * * The parameter `size` sets the size (float) of each box side (default 1)
  111761. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  111762. * * 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)
  111763. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  111764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111767. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  111768. * @param name defines the name of the mesh
  111769. * @param options defines the options used to create the mesh
  111770. * @param scene defines the hosting scene
  111771. * @returns the box mesh
  111772. */
  111773. static CreateBox(name: string, options: {
  111774. size?: number;
  111775. width?: number;
  111776. height?: number;
  111777. depth?: number;
  111778. faceUV?: Vector4[];
  111779. faceColors?: Color4[];
  111780. sideOrientation?: number;
  111781. frontUVs?: Vector4;
  111782. backUVs?: Vector4;
  111783. wrap?: boolean;
  111784. topBaseAt?: number;
  111785. bottomBaseAt?: number;
  111786. updatable?: boolean;
  111787. }, scene?: Nullable<Scene>): Mesh;
  111788. }
  111789. }
  111790. declare module BABYLON {
  111791. /**
  111792. * Class containing static functions to help procedurally build meshes
  111793. */
  111794. export class SphereBuilder {
  111795. /**
  111796. * Creates a sphere mesh
  111797. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  111798. * * 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`)
  111799. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  111800. * * 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
  111801. * * 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)
  111802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111803. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111805. * @param name defines the name of the mesh
  111806. * @param options defines the options used to create the mesh
  111807. * @param scene defines the hosting scene
  111808. * @returns the sphere mesh
  111809. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  111810. */
  111811. static CreateSphere(name: string, options: {
  111812. segments?: number;
  111813. diameter?: number;
  111814. diameterX?: number;
  111815. diameterY?: number;
  111816. diameterZ?: number;
  111817. arc?: number;
  111818. slice?: number;
  111819. sideOrientation?: number;
  111820. frontUVs?: Vector4;
  111821. backUVs?: Vector4;
  111822. updatable?: boolean;
  111823. }, scene?: Nullable<Scene>): Mesh;
  111824. }
  111825. }
  111826. declare module BABYLON.Debug {
  111827. /**
  111828. * Used to show the physics impostor around the specific mesh
  111829. */
  111830. export class PhysicsViewer {
  111831. /** @hidden */
  111832. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  111833. /** @hidden */
  111834. protected _meshes: Array<Nullable<AbstractMesh>>;
  111835. /** @hidden */
  111836. protected _scene: Nullable<Scene>;
  111837. /** @hidden */
  111838. protected _numMeshes: number;
  111839. /** @hidden */
  111840. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  111841. private _renderFunction;
  111842. private _utilityLayer;
  111843. private _debugBoxMesh;
  111844. private _debugSphereMesh;
  111845. private _debugCylinderMesh;
  111846. private _debugMaterial;
  111847. private _debugMeshMeshes;
  111848. /**
  111849. * Creates a new PhysicsViewer
  111850. * @param scene defines the hosting scene
  111851. */
  111852. constructor(scene: Scene);
  111853. /** @hidden */
  111854. protected _updateDebugMeshes(): void;
  111855. /**
  111856. * Renders a specified physic impostor
  111857. * @param impostor defines the impostor to render
  111858. * @param targetMesh defines the mesh represented by the impostor
  111859. * @returns the new debug mesh used to render the impostor
  111860. */
  111861. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  111862. /**
  111863. * Hides a specified physic impostor
  111864. * @param impostor defines the impostor to hide
  111865. */
  111866. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  111867. private _getDebugMaterial;
  111868. private _getDebugBoxMesh;
  111869. private _getDebugSphereMesh;
  111870. private _getDebugCylinderMesh;
  111871. private _getDebugMeshMesh;
  111872. private _getDebugMesh;
  111873. /** Releases all resources */
  111874. dispose(): void;
  111875. }
  111876. }
  111877. declare module BABYLON {
  111878. /**
  111879. * Class containing static functions to help procedurally build meshes
  111880. */
  111881. export class LinesBuilder {
  111882. /**
  111883. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  111884. * * 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
  111885. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  111886. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  111887. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  111888. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  111889. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  111890. * * 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
  111891. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  111892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111893. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  111894. * @param name defines the name of the new line system
  111895. * @param options defines the options used to create the line system
  111896. * @param scene defines the hosting scene
  111897. * @returns a new line system mesh
  111898. */
  111899. static CreateLineSystem(name: string, options: {
  111900. lines: Vector3[][];
  111901. updatable?: boolean;
  111902. instance?: Nullable<LinesMesh>;
  111903. colors?: Nullable<Color4[][]>;
  111904. useVertexAlpha?: boolean;
  111905. }, scene: Nullable<Scene>): LinesMesh;
  111906. /**
  111907. * Creates a line mesh
  111908. * 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
  111909. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  111910. * * The parameter `points` is an array successive Vector3
  111911. * * 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
  111912. * * The optional parameter `colors` is an array of successive Color4, one per line point
  111913. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  111914. * * When updating an instance, remember that only point positions can change, not the number of points
  111915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111916. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  111917. * @param name defines the name of the new line system
  111918. * @param options defines the options used to create the line system
  111919. * @param scene defines the hosting scene
  111920. * @returns a new line mesh
  111921. */
  111922. static CreateLines(name: string, options: {
  111923. points: Vector3[];
  111924. updatable?: boolean;
  111925. instance?: Nullable<LinesMesh>;
  111926. colors?: Color4[];
  111927. useVertexAlpha?: boolean;
  111928. }, scene?: Nullable<Scene>): LinesMesh;
  111929. /**
  111930. * Creates a dashed line mesh
  111931. * * 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
  111932. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  111933. * * The parameter `points` is an array successive Vector3
  111934. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  111935. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  111936. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  111937. * * 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
  111938. * * When updating an instance, remember that only point positions can change, not the number of points
  111939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111940. * @param name defines the name of the mesh
  111941. * @param options defines the options used to create the mesh
  111942. * @param scene defines the hosting scene
  111943. * @returns the dashed line mesh
  111944. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  111945. */
  111946. static CreateDashedLines(name: string, options: {
  111947. points: Vector3[];
  111948. dashSize?: number;
  111949. gapSize?: number;
  111950. dashNb?: number;
  111951. updatable?: boolean;
  111952. instance?: LinesMesh;
  111953. }, scene?: Nullable<Scene>): LinesMesh;
  111954. }
  111955. }
  111956. declare module BABYLON {
  111957. /**
  111958. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  111959. * in order to better appreciate the issue one might have.
  111960. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  111961. */
  111962. export class RayHelper {
  111963. /**
  111964. * Defines the ray we are currently tryin to visualize.
  111965. */
  111966. ray: Nullable<Ray>;
  111967. private _renderPoints;
  111968. private _renderLine;
  111969. private _renderFunction;
  111970. private _scene;
  111971. private _updateToMeshFunction;
  111972. private _attachedToMesh;
  111973. private _meshSpaceDirection;
  111974. private _meshSpaceOrigin;
  111975. /**
  111976. * Helper function to create a colored helper in a scene in one line.
  111977. * @param ray Defines the ray we are currently tryin to visualize
  111978. * @param scene Defines the scene the ray is used in
  111979. * @param color Defines the color we want to see the ray in
  111980. * @returns The newly created ray helper.
  111981. */
  111982. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  111983. /**
  111984. * Instantiate a new ray helper.
  111985. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  111986. * in order to better appreciate the issue one might have.
  111987. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  111988. * @param ray Defines the ray we are currently tryin to visualize
  111989. */
  111990. constructor(ray: Ray);
  111991. /**
  111992. * Shows the ray we are willing to debug.
  111993. * @param scene Defines the scene the ray needs to be rendered in
  111994. * @param color Defines the color the ray needs to be rendered in
  111995. */
  111996. show(scene: Scene, color?: Color3): void;
  111997. /**
  111998. * Hides the ray we are debugging.
  111999. */
  112000. hide(): void;
  112001. private _render;
  112002. /**
  112003. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  112004. * @param mesh Defines the mesh we want the helper attached to
  112005. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  112006. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  112007. * @param length Defines the length of the ray
  112008. */
  112009. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  112010. /**
  112011. * Detach the ray helper from the mesh it has previously been attached to.
  112012. */
  112013. detachFromMesh(): void;
  112014. private _updateToMesh;
  112015. /**
  112016. * Dispose the helper and release its associated resources.
  112017. */
  112018. dispose(): void;
  112019. }
  112020. }
  112021. declare module BABYLON.Debug {
  112022. /**
  112023. * Class used to render a debug view of a given skeleton
  112024. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  112025. */
  112026. export class SkeletonViewer {
  112027. /** defines the skeleton to render */
  112028. skeleton: Skeleton;
  112029. /** defines the mesh attached to the skeleton */
  112030. mesh: AbstractMesh;
  112031. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  112032. autoUpdateBonesMatrices: boolean;
  112033. /** defines the rendering group id to use with the viewer */
  112034. renderingGroupId: number;
  112035. /** Gets or sets the color used to render the skeleton */
  112036. color: Color3;
  112037. private _scene;
  112038. private _debugLines;
  112039. private _debugMesh;
  112040. private _isEnabled;
  112041. private _renderFunction;
  112042. private _utilityLayer;
  112043. /**
  112044. * Returns the mesh used to render the bones
  112045. */
  112046. readonly debugMesh: Nullable<LinesMesh>;
  112047. /**
  112048. * Creates a new SkeletonViewer
  112049. * @param skeleton defines the skeleton to render
  112050. * @param mesh defines the mesh attached to the skeleton
  112051. * @param scene defines the hosting scene
  112052. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  112053. * @param renderingGroupId defines the rendering group id to use with the viewer
  112054. */
  112055. constructor(
  112056. /** defines the skeleton to render */
  112057. skeleton: Skeleton,
  112058. /** defines the mesh attached to the skeleton */
  112059. mesh: AbstractMesh, scene: Scene,
  112060. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  112061. autoUpdateBonesMatrices?: boolean,
  112062. /** defines the rendering group id to use with the viewer */
  112063. renderingGroupId?: number);
  112064. /** Gets or sets a boolean indicating if the viewer is enabled */
  112065. isEnabled: boolean;
  112066. private _getBonePosition;
  112067. private _getLinesForBonesWithLength;
  112068. private _getLinesForBonesNoLength;
  112069. /** Update the viewer to sync with current skeleton state */
  112070. update(): void;
  112071. /** Release associated resources */
  112072. dispose(): void;
  112073. }
  112074. }
  112075. declare module BABYLON {
  112076. /**
  112077. * Options to create the null engine
  112078. */
  112079. export class NullEngineOptions {
  112080. /**
  112081. * Render width (Default: 512)
  112082. */
  112083. renderWidth: number;
  112084. /**
  112085. * Render height (Default: 256)
  112086. */
  112087. renderHeight: number;
  112088. /**
  112089. * Texture size (Default: 512)
  112090. */
  112091. textureSize: number;
  112092. /**
  112093. * If delta time between frames should be constant
  112094. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112095. */
  112096. deterministicLockstep: boolean;
  112097. /**
  112098. * Maximum about of steps between frames (Default: 4)
  112099. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112100. */
  112101. lockstepMaxSteps: number;
  112102. }
  112103. /**
  112104. * The null engine class provides support for headless version of babylon.js.
  112105. * This can be used in server side scenario or for testing purposes
  112106. */
  112107. export class NullEngine extends Engine {
  112108. private _options;
  112109. /**
  112110. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  112111. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112112. * @returns true if engine is in deterministic lock step mode
  112113. */
  112114. isDeterministicLockStep(): boolean;
  112115. /**
  112116. * Gets the max steps when engine is running in deterministic lock step
  112117. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112118. * @returns the max steps
  112119. */
  112120. getLockstepMaxSteps(): number;
  112121. /**
  112122. * Gets the current hardware scaling level.
  112123. * By default the hardware scaling level is computed from the window device ratio.
  112124. * 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.
  112125. * @returns a number indicating the current hardware scaling level
  112126. */
  112127. getHardwareScalingLevel(): number;
  112128. constructor(options?: NullEngineOptions);
  112129. /**
  112130. * Creates a vertex buffer
  112131. * @param vertices the data for the vertex buffer
  112132. * @returns the new WebGL static buffer
  112133. */
  112134. createVertexBuffer(vertices: FloatArray): DataBuffer;
  112135. /**
  112136. * Creates a new index buffer
  112137. * @param indices defines the content of the index buffer
  112138. * @param updatable defines if the index buffer must be updatable
  112139. * @returns a new webGL buffer
  112140. */
  112141. createIndexBuffer(indices: IndicesArray): DataBuffer;
  112142. /**
  112143. * Clear the current render buffer or the current render target (if any is set up)
  112144. * @param color defines the color to use
  112145. * @param backBuffer defines if the back buffer must be cleared
  112146. * @param depth defines if the depth buffer must be cleared
  112147. * @param stencil defines if the stencil buffer must be cleared
  112148. */
  112149. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112150. /**
  112151. * Gets the current render width
  112152. * @param useScreen defines if screen size must be used (or the current render target if any)
  112153. * @returns a number defining the current render width
  112154. */
  112155. getRenderWidth(useScreen?: boolean): number;
  112156. /**
  112157. * Gets the current render height
  112158. * @param useScreen defines if screen size must be used (or the current render target if any)
  112159. * @returns a number defining the current render height
  112160. */
  112161. getRenderHeight(useScreen?: boolean): number;
  112162. /**
  112163. * Set the WebGL's viewport
  112164. * @param viewport defines the viewport element to be used
  112165. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  112166. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  112167. */
  112168. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  112169. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  112170. /**
  112171. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  112172. * @param pipelineContext defines the pipeline context to use
  112173. * @param uniformsNames defines the list of uniform names
  112174. * @returns an array of webGL uniform locations
  112175. */
  112176. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  112177. /**
  112178. * Gets the lsit of active attributes for a given webGL program
  112179. * @param pipelineContext defines the pipeline context to use
  112180. * @param attributesNames defines the list of attribute names to get
  112181. * @returns an array of indices indicating the offset of each attribute
  112182. */
  112183. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112184. /**
  112185. * Binds an effect to the webGL context
  112186. * @param effect defines the effect to bind
  112187. */
  112188. bindSamplers(effect: Effect): void;
  112189. /**
  112190. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  112191. * @param effect defines the effect to activate
  112192. */
  112193. enableEffect(effect: Effect): void;
  112194. /**
  112195. * Set various states to the webGL context
  112196. * @param culling defines backface culling state
  112197. * @param zOffset defines the value to apply to zOffset (0 by default)
  112198. * @param force defines if states must be applied even if cache is up to date
  112199. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  112200. */
  112201. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  112202. /**
  112203. * Set the value of an uniform to an array of int32
  112204. * @param uniform defines the webGL uniform location where to store the value
  112205. * @param array defines the array of int32 to store
  112206. */
  112207. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  112208. /**
  112209. * Set the value of an uniform to an array of int32 (stored as vec2)
  112210. * @param uniform defines the webGL uniform location where to store the value
  112211. * @param array defines the array of int32 to store
  112212. */
  112213. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  112214. /**
  112215. * Set the value of an uniform to an array of int32 (stored as vec3)
  112216. * @param uniform defines the webGL uniform location where to store the value
  112217. * @param array defines the array of int32 to store
  112218. */
  112219. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  112220. /**
  112221. * Set the value of an uniform to an array of int32 (stored as vec4)
  112222. * @param uniform defines the webGL uniform location where to store the value
  112223. * @param array defines the array of int32 to store
  112224. */
  112225. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  112226. /**
  112227. * Set the value of an uniform to an array of float32
  112228. * @param uniform defines the webGL uniform location where to store the value
  112229. * @param array defines the array of float32 to store
  112230. */
  112231. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  112232. /**
  112233. * Set the value of an uniform to an array of float32 (stored as vec2)
  112234. * @param uniform defines the webGL uniform location where to store the value
  112235. * @param array defines the array of float32 to store
  112236. */
  112237. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  112238. /**
  112239. * Set the value of an uniform to an array of float32 (stored as vec3)
  112240. * @param uniform defines the webGL uniform location where to store the value
  112241. * @param array defines the array of float32 to store
  112242. */
  112243. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  112244. /**
  112245. * Set the value of an uniform to an array of float32 (stored as vec4)
  112246. * @param uniform defines the webGL uniform location where to store the value
  112247. * @param array defines the array of float32 to store
  112248. */
  112249. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  112250. /**
  112251. * Set the value of an uniform to an array of number
  112252. * @param uniform defines the webGL uniform location where to store the value
  112253. * @param array defines the array of number to store
  112254. */
  112255. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  112256. /**
  112257. * Set the value of an uniform to an array of number (stored as vec2)
  112258. * @param uniform defines the webGL uniform location where to store the value
  112259. * @param array defines the array of number to store
  112260. */
  112261. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  112262. /**
  112263. * Set the value of an uniform to an array of number (stored as vec3)
  112264. * @param uniform defines the webGL uniform location where to store the value
  112265. * @param array defines the array of number to store
  112266. */
  112267. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  112268. /**
  112269. * Set the value of an uniform to an array of number (stored as vec4)
  112270. * @param uniform defines the webGL uniform location where to store the value
  112271. * @param array defines the array of number to store
  112272. */
  112273. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  112274. /**
  112275. * Set the value of an uniform to an array of float32 (stored as matrices)
  112276. * @param uniform defines the webGL uniform location where to store the value
  112277. * @param matrices defines the array of float32 to store
  112278. */
  112279. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  112280. /**
  112281. * Set the value of an uniform to a matrix (3x3)
  112282. * @param uniform defines the webGL uniform location where to store the value
  112283. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  112284. */
  112285. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112286. /**
  112287. * Set the value of an uniform to a matrix (2x2)
  112288. * @param uniform defines the webGL uniform location where to store the value
  112289. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  112290. */
  112291. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112292. /**
  112293. * Set the value of an uniform to a number (float)
  112294. * @param uniform defines the webGL uniform location where to store the value
  112295. * @param value defines the float number to store
  112296. */
  112297. setFloat(uniform: WebGLUniformLocation, value: number): void;
  112298. /**
  112299. * Set the value of an uniform to a vec2
  112300. * @param uniform defines the webGL uniform location where to store the value
  112301. * @param x defines the 1st component of the value
  112302. * @param y defines the 2nd component of the value
  112303. */
  112304. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  112305. /**
  112306. * Set the value of an uniform to a vec3
  112307. * @param uniform defines the webGL uniform location where to store the value
  112308. * @param x defines the 1st component of the value
  112309. * @param y defines the 2nd component of the value
  112310. * @param z defines the 3rd component of the value
  112311. */
  112312. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  112313. /**
  112314. * Set the value of an uniform to a boolean
  112315. * @param uniform defines the webGL uniform location where to store the value
  112316. * @param bool defines the boolean to store
  112317. */
  112318. setBool(uniform: WebGLUniformLocation, bool: number): void;
  112319. /**
  112320. * Set the value of an uniform to a vec4
  112321. * @param uniform defines the webGL uniform location where to store the value
  112322. * @param x defines the 1st component of the value
  112323. * @param y defines the 2nd component of the value
  112324. * @param z defines the 3rd component of the value
  112325. * @param w defines the 4th component of the value
  112326. */
  112327. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  112328. /**
  112329. * Sets the current alpha mode
  112330. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  112331. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  112332. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112333. */
  112334. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  112335. /**
  112336. * Bind webGl buffers directly to the webGL context
  112337. * @param vertexBuffers defines the vertex buffer to bind
  112338. * @param indexBuffer defines the index buffer to bind
  112339. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  112340. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  112341. * @param effect defines the effect associated with the vertex buffer
  112342. */
  112343. bindBuffers(vertexBuffers: {
  112344. [key: string]: VertexBuffer;
  112345. }, indexBuffer: DataBuffer, effect: Effect): void;
  112346. /**
  112347. * Force the entire cache to be cleared
  112348. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  112349. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  112350. */
  112351. wipeCaches(bruteForce?: boolean): void;
  112352. /**
  112353. * Send a draw order
  112354. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112355. * @param indexStart defines the starting index
  112356. * @param indexCount defines the number of index to draw
  112357. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112358. */
  112359. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  112360. /**
  112361. * Draw a list of indexed primitives
  112362. * @param fillMode defines the primitive to use
  112363. * @param indexStart defines the starting index
  112364. * @param indexCount defines the number of index to draw
  112365. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112366. */
  112367. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112368. /**
  112369. * Draw a list of unindexed primitives
  112370. * @param fillMode defines the primitive to use
  112371. * @param verticesStart defines the index of first vertex to draw
  112372. * @param verticesCount defines the count of vertices to draw
  112373. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112374. */
  112375. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112376. /** @hidden */
  112377. _createTexture(): WebGLTexture;
  112378. /** @hidden */
  112379. _releaseTexture(texture: InternalTexture): void;
  112380. /**
  112381. * Usually called from Texture.ts.
  112382. * Passed information to create a WebGLTexture
  112383. * @param urlArg defines a value which contains one of the following:
  112384. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112385. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112386. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112387. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112388. * @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)
  112389. * @param scene needed for loading to the correct scene
  112390. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  112391. * @param onLoad optional callback to be called upon successful completion
  112392. * @param onError optional callback to be called upon failure
  112393. * @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
  112394. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112395. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112396. * @param forcedExtension defines the extension to use to pick the right loader
  112397. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  112398. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112399. */
  112400. 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;
  112401. /**
  112402. * Creates a new render target texture
  112403. * @param size defines the size of the texture
  112404. * @param options defines the options used to create the texture
  112405. * @returns a new render target texture stored in an InternalTexture
  112406. */
  112407. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  112408. /**
  112409. * Update the sampling mode of a given texture
  112410. * @param samplingMode defines the required sampling mode
  112411. * @param texture defines the texture to update
  112412. */
  112413. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  112414. /**
  112415. * Binds the frame buffer to the specified texture.
  112416. * @param texture The texture to render to or null for the default canvas
  112417. * @param faceIndex The face of the texture to render to in case of cube texture
  112418. * @param requiredWidth The width of the target to render to
  112419. * @param requiredHeight The height of the target to render to
  112420. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  112421. * @param depthStencilTexture The depth stencil texture to use to render
  112422. * @param lodLevel defines le lod level to bind to the frame buffer
  112423. */
  112424. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  112425. /**
  112426. * Unbind the current render target texture from the webGL context
  112427. * @param texture defines the render target texture to unbind
  112428. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112429. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112430. */
  112431. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112432. /**
  112433. * Creates a dynamic vertex buffer
  112434. * @param vertices the data for the dynamic vertex buffer
  112435. * @returns the new WebGL dynamic buffer
  112436. */
  112437. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  112438. /**
  112439. * Update the content of a dynamic texture
  112440. * @param texture defines the texture to update
  112441. * @param canvas defines the canvas containing the source
  112442. * @param invertY defines if data must be stored with Y axis inverted
  112443. * @param premulAlpha defines if alpha is stored as premultiplied
  112444. * @param format defines the format of the data
  112445. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  112446. */
  112447. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  112448. /**
  112449. * Gets a boolean indicating if all created effects are ready
  112450. * @returns true if all effects are ready
  112451. */
  112452. areAllEffectsReady(): boolean;
  112453. /**
  112454. * @hidden
  112455. * Get the current error code of the webGL context
  112456. * @returns the error code
  112457. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  112458. */
  112459. getError(): number;
  112460. /** @hidden */
  112461. _getUnpackAlignement(): number;
  112462. /** @hidden */
  112463. _unpackFlipY(value: boolean): void;
  112464. /**
  112465. * Update a dynamic index buffer
  112466. * @param indexBuffer defines the target index buffer
  112467. * @param indices defines the data to update
  112468. * @param offset defines the offset in the target index buffer where update should start
  112469. */
  112470. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  112471. /**
  112472. * Updates a dynamic vertex buffer.
  112473. * @param vertexBuffer the vertex buffer to update
  112474. * @param vertices the data used to update the vertex buffer
  112475. * @param byteOffset the byte offset of the data (optional)
  112476. * @param byteLength the byte length of the data (optional)
  112477. */
  112478. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  112479. /** @hidden */
  112480. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  112481. /** @hidden */
  112482. _bindTexture(channel: number, texture: InternalTexture): void;
  112483. protected _deleteBuffer(buffer: WebGLBuffer): void;
  112484. /**
  112485. * 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
  112486. */
  112487. releaseEffects(): void;
  112488. displayLoadingUI(): void;
  112489. hideLoadingUI(): void;
  112490. /** @hidden */
  112491. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112492. /** @hidden */
  112493. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112494. /** @hidden */
  112495. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112496. /** @hidden */
  112497. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  112498. }
  112499. }
  112500. declare module BABYLON {
  112501. /** @hidden */
  112502. export class _OcclusionDataStorage {
  112503. /** @hidden */
  112504. occlusionInternalRetryCounter: number;
  112505. /** @hidden */
  112506. isOcclusionQueryInProgress: boolean;
  112507. /** @hidden */
  112508. isOccluded: boolean;
  112509. /** @hidden */
  112510. occlusionRetryCount: number;
  112511. /** @hidden */
  112512. occlusionType: number;
  112513. /** @hidden */
  112514. occlusionQueryAlgorithmType: number;
  112515. }
  112516. interface Engine {
  112517. /**
  112518. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  112519. * @return the new query
  112520. */
  112521. createQuery(): WebGLQuery;
  112522. /**
  112523. * Delete and release a webGL query
  112524. * @param query defines the query to delete
  112525. * @return the current engine
  112526. */
  112527. deleteQuery(query: WebGLQuery): Engine;
  112528. /**
  112529. * Check if a given query has resolved and got its value
  112530. * @param query defines the query to check
  112531. * @returns true if the query got its value
  112532. */
  112533. isQueryResultAvailable(query: WebGLQuery): boolean;
  112534. /**
  112535. * Gets the value of a given query
  112536. * @param query defines the query to check
  112537. * @returns the value of the query
  112538. */
  112539. getQueryResult(query: WebGLQuery): number;
  112540. /**
  112541. * Initiates an occlusion query
  112542. * @param algorithmType defines the algorithm to use
  112543. * @param query defines the query to use
  112544. * @returns the current engine
  112545. * @see http://doc.babylonjs.com/features/occlusionquery
  112546. */
  112547. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  112548. /**
  112549. * Ends an occlusion query
  112550. * @see http://doc.babylonjs.com/features/occlusionquery
  112551. * @param algorithmType defines the algorithm to use
  112552. * @returns the current engine
  112553. */
  112554. endOcclusionQuery(algorithmType: number): Engine;
  112555. /**
  112556. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  112557. * Please note that only one query can be issued at a time
  112558. * @returns a time token used to track the time span
  112559. */
  112560. startTimeQuery(): Nullable<_TimeToken>;
  112561. /**
  112562. * Ends a time query
  112563. * @param token defines the token used to measure the time span
  112564. * @returns the time spent (in ns)
  112565. */
  112566. endTimeQuery(token: _TimeToken): int;
  112567. /** @hidden */
  112568. _currentNonTimestampToken: Nullable<_TimeToken>;
  112569. /** @hidden */
  112570. _createTimeQuery(): WebGLQuery;
  112571. /** @hidden */
  112572. _deleteTimeQuery(query: WebGLQuery): void;
  112573. /** @hidden */
  112574. _getGlAlgorithmType(algorithmType: number): number;
  112575. /** @hidden */
  112576. _getTimeQueryResult(query: WebGLQuery): any;
  112577. /** @hidden */
  112578. _getTimeQueryAvailability(query: WebGLQuery): any;
  112579. }
  112580. interface AbstractMesh {
  112581. /**
  112582. * Backing filed
  112583. * @hidden
  112584. */
  112585. __occlusionDataStorage: _OcclusionDataStorage;
  112586. /**
  112587. * Access property
  112588. * @hidden
  112589. */
  112590. _occlusionDataStorage: _OcclusionDataStorage;
  112591. /**
  112592. * 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.
  112593. * The default value is -1 which means don't break the query and wait till the result
  112594. * @see http://doc.babylonjs.com/features/occlusionquery
  112595. */
  112596. occlusionRetryCount: number;
  112597. /**
  112598. * 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:
  112599. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  112600. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  112601. * * 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.
  112602. * @see http://doc.babylonjs.com/features/occlusionquery
  112603. */
  112604. occlusionType: number;
  112605. /**
  112606. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  112607. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  112608. * * 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.
  112609. * @see http://doc.babylonjs.com/features/occlusionquery
  112610. */
  112611. occlusionQueryAlgorithmType: number;
  112612. /**
  112613. * 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
  112614. * @see http://doc.babylonjs.com/features/occlusionquery
  112615. */
  112616. isOccluded: boolean;
  112617. /**
  112618. * Flag to check the progress status of the query
  112619. * @see http://doc.babylonjs.com/features/occlusionquery
  112620. */
  112621. isOcclusionQueryInProgress: boolean;
  112622. }
  112623. }
  112624. declare module BABYLON {
  112625. /** @hidden */
  112626. export var _forceTransformFeedbackToBundle: boolean;
  112627. interface Engine {
  112628. /**
  112629. * Creates a webGL transform feedback object
  112630. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  112631. * @returns the webGL transform feedback object
  112632. */
  112633. createTransformFeedback(): WebGLTransformFeedback;
  112634. /**
  112635. * Delete a webGL transform feedback object
  112636. * @param value defines the webGL transform feedback object to delete
  112637. */
  112638. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  112639. /**
  112640. * Bind a webGL transform feedback object to the webgl context
  112641. * @param value defines the webGL transform feedback object to bind
  112642. */
  112643. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  112644. /**
  112645. * Begins a transform feedback operation
  112646. * @param usePoints defines if points or triangles must be used
  112647. */
  112648. beginTransformFeedback(usePoints: boolean): void;
  112649. /**
  112650. * Ends a transform feedback operation
  112651. */
  112652. endTransformFeedback(): void;
  112653. /**
  112654. * Specify the varyings to use with transform feedback
  112655. * @param program defines the associated webGL program
  112656. * @param value defines the list of strings representing the varying names
  112657. */
  112658. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  112659. /**
  112660. * Bind a webGL buffer for a transform feedback operation
  112661. * @param value defines the webGL buffer to bind
  112662. */
  112663. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  112664. }
  112665. }
  112666. declare module BABYLON {
  112667. /**
  112668. * Creation options of the multi render target texture.
  112669. */
  112670. export interface IMultiRenderTargetOptions {
  112671. /**
  112672. * Define if the texture needs to create mip maps after render.
  112673. */
  112674. generateMipMaps?: boolean;
  112675. /**
  112676. * Define the types of all the draw buffers we want to create
  112677. */
  112678. types?: number[];
  112679. /**
  112680. * Define the sampling modes of all the draw buffers we want to create
  112681. */
  112682. samplingModes?: number[];
  112683. /**
  112684. * Define if a depth buffer is required
  112685. */
  112686. generateDepthBuffer?: boolean;
  112687. /**
  112688. * Define if a stencil buffer is required
  112689. */
  112690. generateStencilBuffer?: boolean;
  112691. /**
  112692. * Define if a depth texture is required instead of a depth buffer
  112693. */
  112694. generateDepthTexture?: boolean;
  112695. /**
  112696. * Define the number of desired draw buffers
  112697. */
  112698. textureCount?: number;
  112699. /**
  112700. * Define if aspect ratio should be adapted to the texture or stay the scene one
  112701. */
  112702. doNotChangeAspectRatio?: boolean;
  112703. /**
  112704. * Define the default type of the buffers we are creating
  112705. */
  112706. defaultType?: number;
  112707. }
  112708. /**
  112709. * A multi render target, like a render target provides the ability to render to a texture.
  112710. * Unlike the render target, it can render to several draw buffers in one draw.
  112711. * This is specially interesting in deferred rendering or for any effects requiring more than
  112712. * just one color from a single pass.
  112713. */
  112714. export class MultiRenderTarget extends RenderTargetTexture {
  112715. private _internalTextures;
  112716. private _textures;
  112717. private _multiRenderTargetOptions;
  112718. /**
  112719. * Get if draw buffers are currently supported by the used hardware and browser.
  112720. */
  112721. readonly isSupported: boolean;
  112722. /**
  112723. * Get the list of textures generated by the multi render target.
  112724. */
  112725. readonly textures: Texture[];
  112726. /**
  112727. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  112728. */
  112729. readonly depthTexture: Texture;
  112730. /**
  112731. * Set the wrapping mode on U of all the textures we are rendering to.
  112732. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  112733. */
  112734. wrapU: number;
  112735. /**
  112736. * Set the wrapping mode on V of all the textures we are rendering to.
  112737. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  112738. */
  112739. wrapV: number;
  112740. /**
  112741. * Instantiate a new multi render target texture.
  112742. * A multi render target, like a render target provides the ability to render to a texture.
  112743. * Unlike the render target, it can render to several draw buffers in one draw.
  112744. * This is specially interesting in deferred rendering or for any effects requiring more than
  112745. * just one color from a single pass.
  112746. * @param name Define the name of the texture
  112747. * @param size Define the size of the buffers to render to
  112748. * @param count Define the number of target we are rendering into
  112749. * @param scene Define the scene the texture belongs to
  112750. * @param options Define the options used to create the multi render target
  112751. */
  112752. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  112753. /** @hidden */
  112754. _rebuild(): void;
  112755. private _createInternalTextures;
  112756. private _createTextures;
  112757. /**
  112758. * Define the number of samples used if MSAA is enabled.
  112759. */
  112760. samples: number;
  112761. /**
  112762. * Resize all the textures in the multi render target.
  112763. * Be carrefull as it will recreate all the data in the new texture.
  112764. * @param size Define the new size
  112765. */
  112766. resize(size: any): void;
  112767. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  112768. /**
  112769. * Dispose the render targets and their associated resources
  112770. */
  112771. dispose(): void;
  112772. /**
  112773. * Release all the underlying texture used as draw buffers.
  112774. */
  112775. releaseInternalTextures(): void;
  112776. }
  112777. }
  112778. declare module BABYLON {
  112779. interface ThinEngine {
  112780. /**
  112781. * Unbind a list of render target textures from the webGL context
  112782. * This is used only when drawBuffer extension or webGL2 are active
  112783. * @param textures defines the render target textures to unbind
  112784. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112785. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112786. */
  112787. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  112788. /**
  112789. * Create a multi render target texture
  112790. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  112791. * @param size defines the size of the texture
  112792. * @param options defines the creation options
  112793. * @returns the cube texture as an InternalTexture
  112794. */
  112795. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  112796. /**
  112797. * Update the sample count for a given multiple render target texture
  112798. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  112799. * @param textures defines the textures to update
  112800. * @param samples defines the sample count to set
  112801. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  112802. */
  112803. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  112804. }
  112805. }
  112806. declare module BABYLON {
  112807. /**
  112808. * Class used to define an additional view for the engine
  112809. * @see https://doc.babylonjs.com/how_to/multi_canvases
  112810. */
  112811. export class EngineView {
  112812. /** Defines the canvas where to render the view */
  112813. target: HTMLCanvasElement;
  112814. /** Defines an optional camera used to render the view (will use active camera else) */
  112815. camera?: Camera;
  112816. }
  112817. interface Engine {
  112818. /**
  112819. * Gets or sets the HTML element to use for attaching events
  112820. */
  112821. inputElement: Nullable<HTMLElement>;
  112822. /**
  112823. * Gets the current engine view
  112824. * @see https://doc.babylonjs.com/how_to/multi_canvases
  112825. */
  112826. activeView: Nullable<EngineView>;
  112827. /** Gets or sets the list of views */
  112828. views: EngineView[];
  112829. /**
  112830. * Register a new child canvas
  112831. * @param canvas defines the canvas to register
  112832. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  112833. * @returns the associated view
  112834. */
  112835. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  112836. /**
  112837. * Remove a registered child canvas
  112838. * @param canvas defines the canvas to remove
  112839. * @returns the current engine
  112840. */
  112841. unRegisterView(canvas: HTMLCanvasElement): Engine;
  112842. }
  112843. }
  112844. declare module BABYLON {
  112845. /**
  112846. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  112847. */
  112848. export interface CubeMapInfo {
  112849. /**
  112850. * The pixel array for the front face.
  112851. * This is stored in format, left to right, up to down format.
  112852. */
  112853. front: Nullable<ArrayBufferView>;
  112854. /**
  112855. * The pixel array for the back face.
  112856. * This is stored in format, left to right, up to down format.
  112857. */
  112858. back: Nullable<ArrayBufferView>;
  112859. /**
  112860. * The pixel array for the left face.
  112861. * This is stored in format, left to right, up to down format.
  112862. */
  112863. left: Nullable<ArrayBufferView>;
  112864. /**
  112865. * The pixel array for the right face.
  112866. * This is stored in format, left to right, up to down format.
  112867. */
  112868. right: Nullable<ArrayBufferView>;
  112869. /**
  112870. * The pixel array for the up face.
  112871. * This is stored in format, left to right, up to down format.
  112872. */
  112873. up: Nullable<ArrayBufferView>;
  112874. /**
  112875. * The pixel array for the down face.
  112876. * This is stored in format, left to right, up to down format.
  112877. */
  112878. down: Nullable<ArrayBufferView>;
  112879. /**
  112880. * The size of the cubemap stored.
  112881. *
  112882. * Each faces will be size * size pixels.
  112883. */
  112884. size: number;
  112885. /**
  112886. * The format of the texture.
  112887. *
  112888. * RGBA, RGB.
  112889. */
  112890. format: number;
  112891. /**
  112892. * The type of the texture data.
  112893. *
  112894. * UNSIGNED_INT, FLOAT.
  112895. */
  112896. type: number;
  112897. /**
  112898. * Specifies whether the texture is in gamma space.
  112899. */
  112900. gammaSpace: boolean;
  112901. }
  112902. /**
  112903. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  112904. */
  112905. export class PanoramaToCubeMapTools {
  112906. private static FACE_FRONT;
  112907. private static FACE_BACK;
  112908. private static FACE_RIGHT;
  112909. private static FACE_LEFT;
  112910. private static FACE_DOWN;
  112911. private static FACE_UP;
  112912. /**
  112913. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  112914. *
  112915. * @param float32Array The source data.
  112916. * @param inputWidth The width of the input panorama.
  112917. * @param inputHeight The height of the input panorama.
  112918. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  112919. * @return The cubemap data
  112920. */
  112921. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  112922. private static CreateCubemapTexture;
  112923. private static CalcProjectionSpherical;
  112924. }
  112925. }
  112926. declare module BABYLON {
  112927. /**
  112928. * Helper class dealing with the extraction of spherical polynomial dataArray
  112929. * from a cube map.
  112930. */
  112931. export class CubeMapToSphericalPolynomialTools {
  112932. private static FileFaces;
  112933. /**
  112934. * Converts a texture to the according Spherical Polynomial data.
  112935. * This extracts the first 3 orders only as they are the only one used in the lighting.
  112936. *
  112937. * @param texture The texture to extract the information from.
  112938. * @return The Spherical Polynomial data.
  112939. */
  112940. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  112941. /**
  112942. * Converts a cubemap to the according Spherical Polynomial data.
  112943. * This extracts the first 3 orders only as they are the only one used in the lighting.
  112944. *
  112945. * @param cubeInfo The Cube map to extract the information from.
  112946. * @return The Spherical Polynomial data.
  112947. */
  112948. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  112949. }
  112950. }
  112951. declare module BABYLON {
  112952. interface BaseTexture {
  112953. /**
  112954. * Get the polynomial representation of the texture data.
  112955. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  112956. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  112957. */
  112958. sphericalPolynomial: Nullable<SphericalPolynomial>;
  112959. }
  112960. }
  112961. declare module BABYLON {
  112962. /** @hidden */
  112963. export var rgbdEncodePixelShader: {
  112964. name: string;
  112965. shader: string;
  112966. };
  112967. }
  112968. declare module BABYLON {
  112969. /** @hidden */
  112970. export var rgbdDecodePixelShader: {
  112971. name: string;
  112972. shader: string;
  112973. };
  112974. }
  112975. declare module BABYLON {
  112976. /**
  112977. * Raw texture data and descriptor sufficient for WebGL texture upload
  112978. */
  112979. export interface EnvironmentTextureInfo {
  112980. /**
  112981. * Version of the environment map
  112982. */
  112983. version: number;
  112984. /**
  112985. * Width of image
  112986. */
  112987. width: number;
  112988. /**
  112989. * Irradiance information stored in the file.
  112990. */
  112991. irradiance: any;
  112992. /**
  112993. * Specular information stored in the file.
  112994. */
  112995. specular: any;
  112996. }
  112997. /**
  112998. * Defines One Image in the file. It requires only the position in the file
  112999. * as well as the length.
  113000. */
  113001. interface BufferImageData {
  113002. /**
  113003. * Length of the image data.
  113004. */
  113005. length: number;
  113006. /**
  113007. * Position of the data from the null terminator delimiting the end of the JSON.
  113008. */
  113009. position: number;
  113010. }
  113011. /**
  113012. * Defines the specular data enclosed in the file.
  113013. * This corresponds to the version 1 of the data.
  113014. */
  113015. export interface EnvironmentTextureSpecularInfoV1 {
  113016. /**
  113017. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  113018. */
  113019. specularDataPosition?: number;
  113020. /**
  113021. * This contains all the images data needed to reconstruct the cubemap.
  113022. */
  113023. mipmaps: Array<BufferImageData>;
  113024. /**
  113025. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  113026. */
  113027. lodGenerationScale: number;
  113028. }
  113029. /**
  113030. * Sets of helpers addressing the serialization and deserialization of environment texture
  113031. * stored in a BabylonJS env file.
  113032. * Those files are usually stored as .env files.
  113033. */
  113034. export class EnvironmentTextureTools {
  113035. /**
  113036. * Magic number identifying the env file.
  113037. */
  113038. private static _MagicBytes;
  113039. /**
  113040. * Gets the environment info from an env file.
  113041. * @param data The array buffer containing the .env bytes.
  113042. * @returns the environment file info (the json header) if successfully parsed.
  113043. */
  113044. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  113045. /**
  113046. * Creates an environment texture from a loaded cube texture.
  113047. * @param texture defines the cube texture to convert in env file
  113048. * @return a promise containing the environment data if succesfull.
  113049. */
  113050. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  113051. /**
  113052. * Creates a JSON representation of the spherical data.
  113053. * @param texture defines the texture containing the polynomials
  113054. * @return the JSON representation of the spherical info
  113055. */
  113056. private static _CreateEnvTextureIrradiance;
  113057. /**
  113058. * Creates the ArrayBufferViews used for initializing environment texture image data.
  113059. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  113060. * @param info parameters that determine what views will be created for accessing the underlying buffer
  113061. * @return the views described by info providing access to the underlying buffer
  113062. */
  113063. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  113064. /**
  113065. * Uploads the texture info contained in the env file to the GPU.
  113066. * @param texture defines the internal texture to upload to
  113067. * @param arrayBuffer defines the buffer cotaining the data to load
  113068. * @param info defines the texture info retrieved through the GetEnvInfo method
  113069. * @returns a promise
  113070. */
  113071. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  113072. private static _OnImageReadyAsync;
  113073. /**
  113074. * Uploads the levels of image data to the GPU.
  113075. * @param texture defines the internal texture to upload to
  113076. * @param imageData defines the array buffer views of image data [mipmap][face]
  113077. * @returns a promise
  113078. */
  113079. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  113080. /**
  113081. * Uploads spherical polynomials information to the texture.
  113082. * @param texture defines the texture we are trying to upload the information to
  113083. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  113084. */
  113085. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  113086. /** @hidden */
  113087. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  113088. }
  113089. }
  113090. declare module BABYLON {
  113091. /**
  113092. * Contains position and normal vectors for a vertex
  113093. */
  113094. export class PositionNormalVertex {
  113095. /** the position of the vertex (defaut: 0,0,0) */
  113096. position: Vector3;
  113097. /** the normal of the vertex (defaut: 0,1,0) */
  113098. normal: Vector3;
  113099. /**
  113100. * Creates a PositionNormalVertex
  113101. * @param position the position of the vertex (defaut: 0,0,0)
  113102. * @param normal the normal of the vertex (defaut: 0,1,0)
  113103. */
  113104. constructor(
  113105. /** the position of the vertex (defaut: 0,0,0) */
  113106. position?: Vector3,
  113107. /** the normal of the vertex (defaut: 0,1,0) */
  113108. normal?: Vector3);
  113109. /**
  113110. * Clones the PositionNormalVertex
  113111. * @returns the cloned PositionNormalVertex
  113112. */
  113113. clone(): PositionNormalVertex;
  113114. }
  113115. /**
  113116. * Contains position, normal and uv vectors for a vertex
  113117. */
  113118. export class PositionNormalTextureVertex {
  113119. /** the position of the vertex (defaut: 0,0,0) */
  113120. position: Vector3;
  113121. /** the normal of the vertex (defaut: 0,1,0) */
  113122. normal: Vector3;
  113123. /** the uv of the vertex (default: 0,0) */
  113124. uv: Vector2;
  113125. /**
  113126. * Creates a PositionNormalTextureVertex
  113127. * @param position the position of the vertex (defaut: 0,0,0)
  113128. * @param normal the normal of the vertex (defaut: 0,1,0)
  113129. * @param uv the uv of the vertex (default: 0,0)
  113130. */
  113131. constructor(
  113132. /** the position of the vertex (defaut: 0,0,0) */
  113133. position?: Vector3,
  113134. /** the normal of the vertex (defaut: 0,1,0) */
  113135. normal?: Vector3,
  113136. /** the uv of the vertex (default: 0,0) */
  113137. uv?: Vector2);
  113138. /**
  113139. * Clones the PositionNormalTextureVertex
  113140. * @returns the cloned PositionNormalTextureVertex
  113141. */
  113142. clone(): PositionNormalTextureVertex;
  113143. }
  113144. }
  113145. declare module BABYLON {
  113146. /** @hidden */
  113147. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  113148. private _genericAttributeLocation;
  113149. private _varyingLocationCount;
  113150. private _varyingLocationMap;
  113151. private _replacements;
  113152. private _textureCount;
  113153. private _uniforms;
  113154. lineProcessor(line: string): string;
  113155. attributeProcessor(attribute: string): string;
  113156. varyingProcessor(varying: string, isFragment: boolean): string;
  113157. uniformProcessor(uniform: string): string;
  113158. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  113159. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  113160. }
  113161. }
  113162. declare module BABYLON {
  113163. /**
  113164. * Container for accessors for natively-stored mesh data buffers.
  113165. */
  113166. class NativeDataBuffer extends DataBuffer {
  113167. /**
  113168. * Accessor value used to identify/retrieve a natively-stored index buffer.
  113169. */
  113170. nativeIndexBuffer?: any;
  113171. /**
  113172. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  113173. */
  113174. nativeVertexBuffer?: any;
  113175. }
  113176. /** @hidden */
  113177. class NativeTexture extends InternalTexture {
  113178. getInternalTexture(): InternalTexture;
  113179. getViewCount(): number;
  113180. }
  113181. /** @hidden */
  113182. export class NativeEngine extends Engine {
  113183. private readonly _native;
  113184. getHardwareScalingLevel(): number;
  113185. constructor();
  113186. /**
  113187. * Can be used to override the current requestAnimationFrame requester.
  113188. * @hidden
  113189. */
  113190. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  113191. /**
  113192. * Override default engine behavior.
  113193. * @param color
  113194. * @param backBuffer
  113195. * @param depth
  113196. * @param stencil
  113197. */
  113198. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  113199. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  113200. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  113201. createVertexBuffer(data: DataArray): NativeDataBuffer;
  113202. recordVertexArrayObject(vertexBuffers: {
  113203. [key: string]: VertexBuffer;
  113204. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  113205. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  113206. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  113207. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113208. /**
  113209. * Draw a list of indexed primitives
  113210. * @param fillMode defines the primitive to use
  113211. * @param indexStart defines the starting index
  113212. * @param indexCount defines the number of index to draw
  113213. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113214. */
  113215. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113216. /**
  113217. * Draw a list of unindexed primitives
  113218. * @param fillMode defines the primitive to use
  113219. * @param verticesStart defines the index of first vertex to draw
  113220. * @param verticesCount defines the count of vertices to draw
  113221. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113222. */
  113223. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113224. createPipelineContext(): IPipelineContext;
  113225. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  113226. /** @hidden */
  113227. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  113228. /** @hidden */
  113229. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  113230. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  113231. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  113232. protected _setProgram(program: WebGLProgram): void;
  113233. _releaseEffect(effect: Effect): void;
  113234. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  113235. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  113236. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  113237. bindSamplers(effect: Effect): void;
  113238. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  113239. getRenderWidth(useScreen?: boolean): number;
  113240. getRenderHeight(useScreen?: boolean): number;
  113241. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  113242. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113243. /**
  113244. * Set the z offset to apply to current rendering
  113245. * @param value defines the offset to apply
  113246. */
  113247. setZOffset(value: number): void;
  113248. /**
  113249. * Gets the current value of the zOffset
  113250. * @returns the current zOffset state
  113251. */
  113252. getZOffset(): number;
  113253. /**
  113254. * Enable or disable depth buffering
  113255. * @param enable defines the state to set
  113256. */
  113257. setDepthBuffer(enable: boolean): void;
  113258. /**
  113259. * Gets a boolean indicating if depth writing is enabled
  113260. * @returns the current depth writing state
  113261. */
  113262. getDepthWrite(): boolean;
  113263. /**
  113264. * Enable or disable depth writing
  113265. * @param enable defines the state to set
  113266. */
  113267. setDepthWrite(enable: boolean): void;
  113268. /**
  113269. * Enable or disable color writing
  113270. * @param enable defines the state to set
  113271. */
  113272. setColorWrite(enable: boolean): void;
  113273. /**
  113274. * Gets a boolean indicating if color writing is enabled
  113275. * @returns the current color writing state
  113276. */
  113277. getColorWrite(): boolean;
  113278. /**
  113279. * Sets alpha constants used by some alpha blending modes
  113280. * @param r defines the red component
  113281. * @param g defines the green component
  113282. * @param b defines the blue component
  113283. * @param a defines the alpha component
  113284. */
  113285. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  113286. /**
  113287. * Sets the current alpha mode
  113288. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  113289. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113290. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113291. */
  113292. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113293. /**
  113294. * Gets the current alpha mode
  113295. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113296. * @returns the current alpha mode
  113297. */
  113298. getAlphaMode(): number;
  113299. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  113300. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  113301. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  113302. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  113303. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  113304. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  113305. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  113306. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  113307. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  113308. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  113309. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  113310. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  113311. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  113312. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113313. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113314. setFloat(uniform: WebGLUniformLocation, value: number): void;
  113315. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  113316. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  113317. setBool(uniform: WebGLUniformLocation, bool: number): void;
  113318. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  113319. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  113320. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  113321. wipeCaches(bruteForce?: boolean): void;
  113322. _createTexture(): WebGLTexture;
  113323. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  113324. /**
  113325. * Usually called from BABYLON.Texture.ts.
  113326. * Passed information to create a WebGLTexture
  113327. * @param urlArg defines a value which contains one of the following:
  113328. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113329. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113330. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113331. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113332. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  113333. * @param scene needed for loading to the correct scene
  113334. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  113335. * @param onLoad optional callback to be called upon successful completion
  113336. * @param onError optional callback to be called upon failure
  113337. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  113338. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113339. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113340. * @param forcedExtension defines the extension to use to pick the right loader
  113341. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113342. */
  113343. 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;
  113344. /**
  113345. * Creates a cube texture
  113346. * @param rootUrl defines the url where the files to load is located
  113347. * @param scene defines the current scene
  113348. * @param files defines the list of files to load (1 per face)
  113349. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  113350. * @param onLoad defines an optional callback raised when the texture is loaded
  113351. * @param onError defines an optional callback raised if there is an issue to load the texture
  113352. * @param format defines the format of the data
  113353. * @param forcedExtension defines the extension to use to pick the right loader
  113354. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  113355. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  113356. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  113357. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  113358. * @returns the cube texture as an InternalTexture
  113359. */
  113360. 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;
  113361. private _getSamplingFilter;
  113362. private static _GetNativeTextureFormat;
  113363. createRenderTargetTexture(size: number | {
  113364. width: number;
  113365. height: number;
  113366. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  113367. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  113368. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  113369. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  113370. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  113371. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  113372. /**
  113373. * Updates a dynamic vertex buffer.
  113374. * @param vertexBuffer the vertex buffer to update
  113375. * @param data the data used to update the vertex buffer
  113376. * @param byteOffset the byte offset of the data (optional)
  113377. * @param byteLength the byte length of the data (optional)
  113378. */
  113379. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  113380. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  113381. private _updateAnisotropicLevel;
  113382. private _getAddressMode;
  113383. /** @hidden */
  113384. _bindTexture(channel: number, texture: InternalTexture): void;
  113385. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  113386. releaseEffects(): void;
  113387. /** @hidden */
  113388. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113389. /** @hidden */
  113390. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113391. /** @hidden */
  113392. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113393. /** @hidden */
  113394. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  113395. }
  113396. }
  113397. declare module BABYLON {
  113398. /**
  113399. * Gather the list of clipboard event types as constants.
  113400. */
  113401. export class ClipboardEventTypes {
  113402. /**
  113403. * The clipboard event is fired when a copy command is active (pressed).
  113404. */
  113405. static readonly COPY: number;
  113406. /**
  113407. * The clipboard event is fired when a cut command is active (pressed).
  113408. */
  113409. static readonly CUT: number;
  113410. /**
  113411. * The clipboard event is fired when a paste command is active (pressed).
  113412. */
  113413. static readonly PASTE: number;
  113414. }
  113415. /**
  113416. * This class is used to store clipboard related info for the onClipboardObservable event.
  113417. */
  113418. export class ClipboardInfo {
  113419. /**
  113420. * Defines the type of event (BABYLON.ClipboardEventTypes)
  113421. */
  113422. type: number;
  113423. /**
  113424. * Defines the related dom event
  113425. */
  113426. event: ClipboardEvent;
  113427. /**
  113428. *Creates an instance of ClipboardInfo.
  113429. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  113430. * @param event Defines the related dom event
  113431. */
  113432. constructor(
  113433. /**
  113434. * Defines the type of event (BABYLON.ClipboardEventTypes)
  113435. */
  113436. type: number,
  113437. /**
  113438. * Defines the related dom event
  113439. */
  113440. event: ClipboardEvent);
  113441. /**
  113442. * Get the clipboard event's type from the keycode.
  113443. * @param keyCode Defines the keyCode for the current keyboard event.
  113444. * @return {number}
  113445. */
  113446. static GetTypeFromCharacter(keyCode: number): number;
  113447. }
  113448. }
  113449. declare module BABYLON {
  113450. /**
  113451. * Google Daydream controller
  113452. */
  113453. export class DaydreamController extends WebVRController {
  113454. /**
  113455. * Base Url for the controller model.
  113456. */
  113457. static MODEL_BASE_URL: string;
  113458. /**
  113459. * File name for the controller model.
  113460. */
  113461. static MODEL_FILENAME: string;
  113462. /**
  113463. * Gamepad Id prefix used to identify Daydream Controller.
  113464. */
  113465. static readonly GAMEPAD_ID_PREFIX: string;
  113466. /**
  113467. * Creates a new DaydreamController from a gamepad
  113468. * @param vrGamepad the gamepad that the controller should be created from
  113469. */
  113470. constructor(vrGamepad: any);
  113471. /**
  113472. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113473. * @param scene scene in which to add meshes
  113474. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113475. */
  113476. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113477. /**
  113478. * Called once for each button that changed state since the last frame
  113479. * @param buttonIdx Which button index changed
  113480. * @param state New state of the button
  113481. * @param changes Which properties on the state changed since last frame
  113482. */
  113483. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113484. }
  113485. }
  113486. declare module BABYLON {
  113487. /**
  113488. * Gear VR Controller
  113489. */
  113490. export class GearVRController extends WebVRController {
  113491. /**
  113492. * Base Url for the controller model.
  113493. */
  113494. static MODEL_BASE_URL: string;
  113495. /**
  113496. * File name for the controller model.
  113497. */
  113498. static MODEL_FILENAME: string;
  113499. /**
  113500. * Gamepad Id prefix used to identify this controller.
  113501. */
  113502. static readonly GAMEPAD_ID_PREFIX: string;
  113503. private readonly _buttonIndexToObservableNameMap;
  113504. /**
  113505. * Creates a new GearVRController from a gamepad
  113506. * @param vrGamepad the gamepad that the controller should be created from
  113507. */
  113508. constructor(vrGamepad: any);
  113509. /**
  113510. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113511. * @param scene scene in which to add meshes
  113512. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113513. */
  113514. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113515. /**
  113516. * Called once for each button that changed state since the last frame
  113517. * @param buttonIdx Which button index changed
  113518. * @param state New state of the button
  113519. * @param changes Which properties on the state changed since last frame
  113520. */
  113521. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113522. }
  113523. }
  113524. declare module BABYLON {
  113525. /**
  113526. * Class containing static functions to help procedurally build meshes
  113527. */
  113528. export class PolyhedronBuilder {
  113529. /**
  113530. * Creates a polyhedron mesh
  113531. * * 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
  113532. * * The parameter `size` (positive float, default 1) sets the polygon size
  113533. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  113534. * * 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`
  113535. * * 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
  113536. * * 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)`)
  113537. * * 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
  113538. * * 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
  113539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113540. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113542. * @param name defines the name of the mesh
  113543. * @param options defines the options used to create the mesh
  113544. * @param scene defines the hosting scene
  113545. * @returns the polyhedron mesh
  113546. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  113547. */
  113548. static CreatePolyhedron(name: string, options: {
  113549. type?: number;
  113550. size?: number;
  113551. sizeX?: number;
  113552. sizeY?: number;
  113553. sizeZ?: number;
  113554. custom?: any;
  113555. faceUV?: Vector4[];
  113556. faceColors?: Color4[];
  113557. flat?: boolean;
  113558. updatable?: boolean;
  113559. sideOrientation?: number;
  113560. frontUVs?: Vector4;
  113561. backUVs?: Vector4;
  113562. }, scene?: Nullable<Scene>): Mesh;
  113563. }
  113564. }
  113565. declare module BABYLON {
  113566. /**
  113567. * Gizmo that enables scaling a mesh along 3 axis
  113568. */
  113569. export class ScaleGizmo extends Gizmo {
  113570. /**
  113571. * Internal gizmo used for interactions on the x axis
  113572. */
  113573. xGizmo: AxisScaleGizmo;
  113574. /**
  113575. * Internal gizmo used for interactions on the y axis
  113576. */
  113577. yGizmo: AxisScaleGizmo;
  113578. /**
  113579. * Internal gizmo used for interactions on the z axis
  113580. */
  113581. zGizmo: AxisScaleGizmo;
  113582. /**
  113583. * Internal gizmo used to scale all axis equally
  113584. */
  113585. uniformScaleGizmo: AxisScaleGizmo;
  113586. private _meshAttached;
  113587. private _updateGizmoRotationToMatchAttachedMesh;
  113588. private _snapDistance;
  113589. private _scaleRatio;
  113590. private _uniformScalingMesh;
  113591. private _octahedron;
  113592. /** Fires an event when any of it's sub gizmos are dragged */
  113593. onDragStartObservable: Observable<unknown>;
  113594. /** Fires an event when any of it's sub gizmos are released from dragging */
  113595. onDragEndObservable: Observable<unknown>;
  113596. attachedMesh: Nullable<AbstractMesh>;
  113597. /**
  113598. * Creates a ScaleGizmo
  113599. * @param gizmoLayer The utility layer the gizmo will be added to
  113600. */
  113601. constructor(gizmoLayer?: UtilityLayerRenderer);
  113602. updateGizmoRotationToMatchAttachedMesh: boolean;
  113603. /**
  113604. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113605. */
  113606. snapDistance: number;
  113607. /**
  113608. * Ratio for the scale of the gizmo (Default: 1)
  113609. */
  113610. scaleRatio: number;
  113611. /**
  113612. * Disposes of the gizmo
  113613. */
  113614. dispose(): void;
  113615. }
  113616. }
  113617. declare module BABYLON {
  113618. /**
  113619. * Single axis scale gizmo
  113620. */
  113621. export class AxisScaleGizmo extends Gizmo {
  113622. /**
  113623. * Drag behavior responsible for the gizmos dragging interactions
  113624. */
  113625. dragBehavior: PointerDragBehavior;
  113626. private _pointerObserver;
  113627. /**
  113628. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113629. */
  113630. snapDistance: number;
  113631. /**
  113632. * Event that fires each time the gizmo snaps to a new location.
  113633. * * snapDistance is the the change in distance
  113634. */
  113635. onSnapObservable: Observable<{
  113636. snapDistance: number;
  113637. }>;
  113638. /**
  113639. * If the scaling operation should be done on all axis (default: false)
  113640. */
  113641. uniformScaling: boolean;
  113642. private _isEnabled;
  113643. private _parent;
  113644. private _arrow;
  113645. private _coloredMaterial;
  113646. private _hoverMaterial;
  113647. /**
  113648. * Creates an AxisScaleGizmo
  113649. * @param gizmoLayer The utility layer the gizmo will be added to
  113650. * @param dragAxis The axis which the gizmo will be able to scale on
  113651. * @param color The color of the gizmo
  113652. */
  113653. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  113654. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113655. /**
  113656. * If the gizmo is enabled
  113657. */
  113658. isEnabled: boolean;
  113659. /**
  113660. * Disposes of the gizmo
  113661. */
  113662. dispose(): void;
  113663. /**
  113664. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  113665. * @param mesh The mesh to replace the default mesh of the gizmo
  113666. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  113667. */
  113668. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  113669. }
  113670. }
  113671. declare module BABYLON {
  113672. /**
  113673. * Bounding box gizmo
  113674. */
  113675. export class BoundingBoxGizmo extends Gizmo {
  113676. private _lineBoundingBox;
  113677. private _rotateSpheresParent;
  113678. private _scaleBoxesParent;
  113679. private _boundingDimensions;
  113680. private _renderObserver;
  113681. private _pointerObserver;
  113682. private _scaleDragSpeed;
  113683. private _tmpQuaternion;
  113684. private _tmpVector;
  113685. private _tmpRotationMatrix;
  113686. /**
  113687. * 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)
  113688. */
  113689. ignoreChildren: boolean;
  113690. /**
  113691. * 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)
  113692. */
  113693. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  113694. /**
  113695. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  113696. */
  113697. rotationSphereSize: number;
  113698. /**
  113699. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  113700. */
  113701. scaleBoxSize: number;
  113702. /**
  113703. * 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)
  113704. */
  113705. fixedDragMeshScreenSize: boolean;
  113706. /**
  113707. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  113708. */
  113709. fixedDragMeshScreenSizeDistanceFactor: number;
  113710. /**
  113711. * Fired when a rotation sphere or scale box is dragged
  113712. */
  113713. onDragStartObservable: Observable<{}>;
  113714. /**
  113715. * Fired when a scale box is dragged
  113716. */
  113717. onScaleBoxDragObservable: Observable<{}>;
  113718. /**
  113719. * Fired when a scale box drag is ended
  113720. */
  113721. onScaleBoxDragEndObservable: Observable<{}>;
  113722. /**
  113723. * Fired when a rotation sphere is dragged
  113724. */
  113725. onRotationSphereDragObservable: Observable<{}>;
  113726. /**
  113727. * Fired when a rotation sphere drag is ended
  113728. */
  113729. onRotationSphereDragEndObservable: Observable<{}>;
  113730. /**
  113731. * 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)
  113732. */
  113733. scalePivot: Nullable<Vector3>;
  113734. /**
  113735. * Mesh used as a pivot to rotate the attached mesh
  113736. */
  113737. private _anchorMesh;
  113738. private _existingMeshScale;
  113739. private _dragMesh;
  113740. private pointerDragBehavior;
  113741. private coloredMaterial;
  113742. private hoverColoredMaterial;
  113743. /**
  113744. * Sets the color of the bounding box gizmo
  113745. * @param color the color to set
  113746. */
  113747. setColor(color: Color3): void;
  113748. /**
  113749. * Creates an BoundingBoxGizmo
  113750. * @param gizmoLayer The utility layer the gizmo will be added to
  113751. * @param color The color of the gizmo
  113752. */
  113753. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  113754. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113755. private _selectNode;
  113756. /**
  113757. * Updates the bounding box information for the Gizmo
  113758. */
  113759. updateBoundingBox(): void;
  113760. private _updateRotationSpheres;
  113761. private _updateScaleBoxes;
  113762. /**
  113763. * Enables rotation on the specified axis and disables rotation on the others
  113764. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  113765. */
  113766. setEnabledRotationAxis(axis: string): void;
  113767. /**
  113768. * Enables/disables scaling
  113769. * @param enable if scaling should be enabled
  113770. */
  113771. setEnabledScaling(enable: boolean): void;
  113772. private _updateDummy;
  113773. /**
  113774. * Enables a pointer drag behavior on the bounding box of the gizmo
  113775. */
  113776. enableDragBehavior(): void;
  113777. /**
  113778. * Disposes of the gizmo
  113779. */
  113780. dispose(): void;
  113781. /**
  113782. * 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)
  113783. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  113784. * @returns the bounding box mesh with the passed in mesh as a child
  113785. */
  113786. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  113787. /**
  113788. * CustomMeshes are not supported by this gizmo
  113789. * @param mesh The mesh to replace the default mesh of the gizmo
  113790. */
  113791. setCustomMesh(mesh: Mesh): void;
  113792. }
  113793. }
  113794. declare module BABYLON {
  113795. /**
  113796. * Single plane rotation gizmo
  113797. */
  113798. export class PlaneRotationGizmo extends Gizmo {
  113799. /**
  113800. * Drag behavior responsible for the gizmos dragging interactions
  113801. */
  113802. dragBehavior: PointerDragBehavior;
  113803. private _pointerObserver;
  113804. /**
  113805. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  113806. */
  113807. snapDistance: number;
  113808. /**
  113809. * Event that fires each time the gizmo snaps to a new location.
  113810. * * snapDistance is the the change in distance
  113811. */
  113812. onSnapObservable: Observable<{
  113813. snapDistance: number;
  113814. }>;
  113815. private _isEnabled;
  113816. private _parent;
  113817. /**
  113818. * Creates a PlaneRotationGizmo
  113819. * @param gizmoLayer The utility layer the gizmo will be added to
  113820. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  113821. * @param color The color of the gizmo
  113822. * @param tessellation Amount of tessellation to be used when creating rotation circles
  113823. * @param useEulerRotation Use and update Euler angle instead of quaternion
  113824. */
  113825. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  113826. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113827. /**
  113828. * If the gizmo is enabled
  113829. */
  113830. isEnabled: boolean;
  113831. /**
  113832. * Disposes of the gizmo
  113833. */
  113834. dispose(): void;
  113835. }
  113836. }
  113837. declare module BABYLON {
  113838. /**
  113839. * Gizmo that enables rotating a mesh along 3 axis
  113840. */
  113841. export class RotationGizmo extends Gizmo {
  113842. /**
  113843. * Internal gizmo used for interactions on the x axis
  113844. */
  113845. xGizmo: PlaneRotationGizmo;
  113846. /**
  113847. * Internal gizmo used for interactions on the y axis
  113848. */
  113849. yGizmo: PlaneRotationGizmo;
  113850. /**
  113851. * Internal gizmo used for interactions on the z axis
  113852. */
  113853. zGizmo: PlaneRotationGizmo;
  113854. /** Fires an event when any of it's sub gizmos are dragged */
  113855. onDragStartObservable: Observable<unknown>;
  113856. /** Fires an event when any of it's sub gizmos are released from dragging */
  113857. onDragEndObservable: Observable<unknown>;
  113858. private _meshAttached;
  113859. attachedMesh: Nullable<AbstractMesh>;
  113860. /**
  113861. * Creates a RotationGizmo
  113862. * @param gizmoLayer The utility layer the gizmo will be added to
  113863. * @param tessellation Amount of tessellation to be used when creating rotation circles
  113864. * @param useEulerRotation Use and update Euler angle instead of quaternion
  113865. */
  113866. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  113867. updateGizmoRotationToMatchAttachedMesh: boolean;
  113868. /**
  113869. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113870. */
  113871. snapDistance: number;
  113872. /**
  113873. * Ratio for the scale of the gizmo (Default: 1)
  113874. */
  113875. scaleRatio: number;
  113876. /**
  113877. * Disposes of the gizmo
  113878. */
  113879. dispose(): void;
  113880. /**
  113881. * CustomMeshes are not supported by this gizmo
  113882. * @param mesh The mesh to replace the default mesh of the gizmo
  113883. */
  113884. setCustomMesh(mesh: Mesh): void;
  113885. }
  113886. }
  113887. declare module BABYLON {
  113888. /**
  113889. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  113890. */
  113891. export class GizmoManager implements IDisposable {
  113892. private scene;
  113893. /**
  113894. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  113895. */
  113896. gizmos: {
  113897. positionGizmo: Nullable<PositionGizmo>;
  113898. rotationGizmo: Nullable<RotationGizmo>;
  113899. scaleGizmo: Nullable<ScaleGizmo>;
  113900. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  113901. };
  113902. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  113903. clearGizmoOnEmptyPointerEvent: boolean;
  113904. /** Fires an event when the manager is attached to a mesh */
  113905. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  113906. private _gizmosEnabled;
  113907. private _pointerObserver;
  113908. private _attachedMesh;
  113909. private _boundingBoxColor;
  113910. private _defaultUtilityLayer;
  113911. private _defaultKeepDepthUtilityLayer;
  113912. /**
  113913. * When bounding box gizmo is enabled, this can be used to track drag/end events
  113914. */
  113915. boundingBoxDragBehavior: SixDofDragBehavior;
  113916. /**
  113917. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  113918. */
  113919. attachableMeshes: Nullable<Array<AbstractMesh>>;
  113920. /**
  113921. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  113922. */
  113923. usePointerToAttachGizmos: boolean;
  113924. /**
  113925. * Utility layer that the bounding box gizmo belongs to
  113926. */
  113927. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  113928. /**
  113929. * Utility layer that all gizmos besides bounding box belong to
  113930. */
  113931. readonly utilityLayer: UtilityLayerRenderer;
  113932. /**
  113933. * Instatiates a gizmo manager
  113934. * @param scene the scene to overlay the gizmos on top of
  113935. */
  113936. constructor(scene: Scene);
  113937. /**
  113938. * Attaches a set of gizmos to the specified mesh
  113939. * @param mesh The mesh the gizmo's should be attached to
  113940. */
  113941. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  113942. /**
  113943. * If the position gizmo is enabled
  113944. */
  113945. positionGizmoEnabled: boolean;
  113946. /**
  113947. * If the rotation gizmo is enabled
  113948. */
  113949. rotationGizmoEnabled: boolean;
  113950. /**
  113951. * If the scale gizmo is enabled
  113952. */
  113953. scaleGizmoEnabled: boolean;
  113954. /**
  113955. * If the boundingBox gizmo is enabled
  113956. */
  113957. boundingBoxGizmoEnabled: boolean;
  113958. /**
  113959. * Disposes of the gizmo manager
  113960. */
  113961. dispose(): void;
  113962. }
  113963. }
  113964. declare module BABYLON {
  113965. /**
  113966. * A directional light is defined by a direction (what a surprise!).
  113967. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  113968. * 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.
  113969. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113970. */
  113971. export class DirectionalLight extends ShadowLight {
  113972. private _shadowFrustumSize;
  113973. /**
  113974. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  113975. */
  113976. /**
  113977. * Specifies a fix frustum size for the shadow generation.
  113978. */
  113979. shadowFrustumSize: number;
  113980. private _shadowOrthoScale;
  113981. /**
  113982. * Gets the shadow projection scale against the optimal computed one.
  113983. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  113984. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  113985. */
  113986. /**
  113987. * Sets the shadow projection scale against the optimal computed one.
  113988. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  113989. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  113990. */
  113991. shadowOrthoScale: number;
  113992. /**
  113993. * Automatically compute the projection matrix to best fit (including all the casters)
  113994. * on each frame.
  113995. */
  113996. autoUpdateExtends: boolean;
  113997. private _orthoLeft;
  113998. private _orthoRight;
  113999. private _orthoTop;
  114000. private _orthoBottom;
  114001. /**
  114002. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  114003. * The directional light is emitted from everywhere in the given direction.
  114004. * It can cast shadows.
  114005. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114006. * @param name The friendly name of the light
  114007. * @param direction The direction of the light
  114008. * @param scene The scene the light belongs to
  114009. */
  114010. constructor(name: string, direction: Vector3, scene: Scene);
  114011. /**
  114012. * Returns the string "DirectionalLight".
  114013. * @return The class name
  114014. */
  114015. getClassName(): string;
  114016. /**
  114017. * Returns the integer 1.
  114018. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114019. */
  114020. getTypeID(): number;
  114021. /**
  114022. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  114023. * Returns the DirectionalLight Shadow projection matrix.
  114024. */
  114025. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114026. /**
  114027. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  114028. * Returns the DirectionalLight Shadow projection matrix.
  114029. */
  114030. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  114031. /**
  114032. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  114033. * Returns the DirectionalLight Shadow projection matrix.
  114034. */
  114035. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114036. protected _buildUniformLayout(): void;
  114037. /**
  114038. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  114039. * @param effect The effect to update
  114040. * @param lightIndex The index of the light in the effect to update
  114041. * @returns The directional light
  114042. */
  114043. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  114044. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  114045. /**
  114046. * Gets the minZ used for shadow according to both the scene and the light.
  114047. *
  114048. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114049. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114050. * @param activeCamera The camera we are returning the min for
  114051. * @returns the depth min z
  114052. */
  114053. getDepthMinZ(activeCamera: Camera): number;
  114054. /**
  114055. * Gets the maxZ used for shadow according to both the scene and the light.
  114056. *
  114057. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114058. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114059. * @param activeCamera The camera we are returning the max for
  114060. * @returns the depth max z
  114061. */
  114062. getDepthMaxZ(activeCamera: Camera): number;
  114063. /**
  114064. * Prepares the list of defines specific to the light type.
  114065. * @param defines the list of defines
  114066. * @param lightIndex defines the index of the light for the effect
  114067. */
  114068. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114069. }
  114070. }
  114071. declare module BABYLON {
  114072. /**
  114073. * Class containing static functions to help procedurally build meshes
  114074. */
  114075. export class HemisphereBuilder {
  114076. /**
  114077. * Creates a hemisphere mesh
  114078. * @param name defines the name of the mesh
  114079. * @param options defines the options used to create the mesh
  114080. * @param scene defines the hosting scene
  114081. * @returns the hemisphere mesh
  114082. */
  114083. static CreateHemisphere(name: string, options: {
  114084. segments?: number;
  114085. diameter?: number;
  114086. sideOrientation?: number;
  114087. }, scene: any): Mesh;
  114088. }
  114089. }
  114090. declare module BABYLON {
  114091. /**
  114092. * A spot light is defined by a position, a direction, an angle, and an exponent.
  114093. * These values define a cone of light starting from the position, emitting toward the direction.
  114094. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  114095. * and the exponent defines the speed of the decay of the light with distance (reach).
  114096. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114097. */
  114098. export class SpotLight extends ShadowLight {
  114099. private _angle;
  114100. private _innerAngle;
  114101. private _cosHalfAngle;
  114102. private _lightAngleScale;
  114103. private _lightAngleOffset;
  114104. /**
  114105. * Gets the cone angle of the spot light in Radians.
  114106. */
  114107. /**
  114108. * Sets the cone angle of the spot light in Radians.
  114109. */
  114110. angle: number;
  114111. /**
  114112. * Only used in gltf falloff mode, this defines the angle where
  114113. * the directional falloff will start before cutting at angle which could be seen
  114114. * as outer angle.
  114115. */
  114116. /**
  114117. * Only used in gltf falloff mode, this defines the angle where
  114118. * the directional falloff will start before cutting at angle which could be seen
  114119. * as outer angle.
  114120. */
  114121. innerAngle: number;
  114122. private _shadowAngleScale;
  114123. /**
  114124. * Allows scaling the angle of the light for shadow generation only.
  114125. */
  114126. /**
  114127. * Allows scaling the angle of the light for shadow generation only.
  114128. */
  114129. shadowAngleScale: number;
  114130. /**
  114131. * The light decay speed with the distance from the emission spot.
  114132. */
  114133. exponent: number;
  114134. private _projectionTextureMatrix;
  114135. /**
  114136. * Allows reading the projecton texture
  114137. */
  114138. readonly projectionTextureMatrix: Matrix;
  114139. protected _projectionTextureLightNear: number;
  114140. /**
  114141. * Gets the near clip of the Spotlight for texture projection.
  114142. */
  114143. /**
  114144. * Sets the near clip of the Spotlight for texture projection.
  114145. */
  114146. projectionTextureLightNear: number;
  114147. protected _projectionTextureLightFar: number;
  114148. /**
  114149. * Gets the far clip of the Spotlight for texture projection.
  114150. */
  114151. /**
  114152. * Sets the far clip of the Spotlight for texture projection.
  114153. */
  114154. projectionTextureLightFar: number;
  114155. protected _projectionTextureUpDirection: Vector3;
  114156. /**
  114157. * Gets the Up vector of the Spotlight for texture projection.
  114158. */
  114159. /**
  114160. * Sets the Up vector of the Spotlight for texture projection.
  114161. */
  114162. projectionTextureUpDirection: Vector3;
  114163. private _projectionTexture;
  114164. /**
  114165. * Gets the projection texture of the light.
  114166. */
  114167. /**
  114168. * Sets the projection texture of the light.
  114169. */
  114170. projectionTexture: Nullable<BaseTexture>;
  114171. private _projectionTextureViewLightDirty;
  114172. private _projectionTextureProjectionLightDirty;
  114173. private _projectionTextureDirty;
  114174. private _projectionTextureViewTargetVector;
  114175. private _projectionTextureViewLightMatrix;
  114176. private _projectionTextureProjectionLightMatrix;
  114177. private _projectionTextureScalingMatrix;
  114178. /**
  114179. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  114180. * It can cast shadows.
  114181. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114182. * @param name The light friendly name
  114183. * @param position The position of the spot light in the scene
  114184. * @param direction The direction of the light in the scene
  114185. * @param angle The cone angle of the light in Radians
  114186. * @param exponent The light decay speed with the distance from the emission spot
  114187. * @param scene The scene the lights belongs to
  114188. */
  114189. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  114190. /**
  114191. * Returns the string "SpotLight".
  114192. * @returns the class name
  114193. */
  114194. getClassName(): string;
  114195. /**
  114196. * Returns the integer 2.
  114197. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114198. */
  114199. getTypeID(): number;
  114200. /**
  114201. * Overrides the direction setter to recompute the projection texture view light Matrix.
  114202. */
  114203. protected _setDirection(value: Vector3): void;
  114204. /**
  114205. * Overrides the position setter to recompute the projection texture view light Matrix.
  114206. */
  114207. protected _setPosition(value: Vector3): void;
  114208. /**
  114209. * 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.
  114210. * Returns the SpotLight.
  114211. */
  114212. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114213. protected _computeProjectionTextureViewLightMatrix(): void;
  114214. protected _computeProjectionTextureProjectionLightMatrix(): void;
  114215. /**
  114216. * Main function for light texture projection matrix computing.
  114217. */
  114218. protected _computeProjectionTextureMatrix(): void;
  114219. protected _buildUniformLayout(): void;
  114220. private _computeAngleValues;
  114221. /**
  114222. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  114223. * @param effect The effect to update
  114224. * @param lightIndex The index of the light in the effect to update
  114225. * @returns The spot light
  114226. */
  114227. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  114228. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  114229. /**
  114230. * Disposes the light and the associated resources.
  114231. */
  114232. dispose(): void;
  114233. /**
  114234. * Prepares the list of defines specific to the light type.
  114235. * @param defines the list of defines
  114236. * @param lightIndex defines the index of the light for the effect
  114237. */
  114238. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114239. }
  114240. }
  114241. declare module BABYLON {
  114242. /**
  114243. * Gizmo that enables viewing a light
  114244. */
  114245. export class LightGizmo extends Gizmo {
  114246. private _lightMesh;
  114247. private _material;
  114248. private cachedPosition;
  114249. private cachedForward;
  114250. /**
  114251. * Creates a LightGizmo
  114252. * @param gizmoLayer The utility layer the gizmo will be added to
  114253. */
  114254. constructor(gizmoLayer?: UtilityLayerRenderer);
  114255. private _light;
  114256. /**
  114257. * The light that the gizmo is attached to
  114258. */
  114259. light: Nullable<Light>;
  114260. /**
  114261. * Gets the material used to render the light gizmo
  114262. */
  114263. readonly material: StandardMaterial;
  114264. /**
  114265. * @hidden
  114266. * Updates the gizmo to match the attached mesh's position/rotation
  114267. */
  114268. protected _update(): void;
  114269. private static _Scale;
  114270. /**
  114271. * Creates the lines for a light mesh
  114272. */
  114273. private static _createLightLines;
  114274. /**
  114275. * Disposes of the light gizmo
  114276. */
  114277. dispose(): void;
  114278. private static _CreateHemisphericLightMesh;
  114279. private static _CreatePointLightMesh;
  114280. private static _CreateSpotLightMesh;
  114281. private static _CreateDirectionalLightMesh;
  114282. }
  114283. }
  114284. declare module BABYLON {
  114285. /** @hidden */
  114286. export var backgroundFragmentDeclaration: {
  114287. name: string;
  114288. shader: string;
  114289. };
  114290. }
  114291. declare module BABYLON {
  114292. /** @hidden */
  114293. export var backgroundUboDeclaration: {
  114294. name: string;
  114295. shader: string;
  114296. };
  114297. }
  114298. declare module BABYLON {
  114299. /** @hidden */
  114300. export var backgroundPixelShader: {
  114301. name: string;
  114302. shader: string;
  114303. };
  114304. }
  114305. declare module BABYLON {
  114306. /** @hidden */
  114307. export var backgroundVertexDeclaration: {
  114308. name: string;
  114309. shader: string;
  114310. };
  114311. }
  114312. declare module BABYLON {
  114313. /** @hidden */
  114314. export var backgroundVertexShader: {
  114315. name: string;
  114316. shader: string;
  114317. };
  114318. }
  114319. declare module BABYLON {
  114320. /**
  114321. * Background material used to create an efficient environement around your scene.
  114322. */
  114323. export class BackgroundMaterial extends PushMaterial {
  114324. /**
  114325. * Standard reflectance value at parallel view angle.
  114326. */
  114327. static StandardReflectance0: number;
  114328. /**
  114329. * Standard reflectance value at grazing angle.
  114330. */
  114331. static StandardReflectance90: number;
  114332. protected _primaryColor: Color3;
  114333. /**
  114334. * Key light Color (multiply against the environement texture)
  114335. */
  114336. primaryColor: Color3;
  114337. protected __perceptualColor: Nullable<Color3>;
  114338. /**
  114339. * Experimental Internal Use Only.
  114340. *
  114341. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  114342. * This acts as a helper to set the primary color to a more "human friendly" value.
  114343. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  114344. * output color as close as possible from the chosen value.
  114345. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  114346. * part of lighting setup.)
  114347. */
  114348. _perceptualColor: Nullable<Color3>;
  114349. protected _primaryColorShadowLevel: float;
  114350. /**
  114351. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  114352. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  114353. */
  114354. primaryColorShadowLevel: float;
  114355. protected _primaryColorHighlightLevel: float;
  114356. /**
  114357. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  114358. * The primary color is used at the level chosen to define what the white area would look.
  114359. */
  114360. primaryColorHighlightLevel: float;
  114361. protected _reflectionTexture: Nullable<BaseTexture>;
  114362. /**
  114363. * Reflection Texture used in the material.
  114364. * Should be author in a specific way for the best result (refer to the documentation).
  114365. */
  114366. reflectionTexture: Nullable<BaseTexture>;
  114367. protected _reflectionBlur: float;
  114368. /**
  114369. * Reflection Texture level of blur.
  114370. *
  114371. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  114372. * texture twice.
  114373. */
  114374. reflectionBlur: float;
  114375. protected _diffuseTexture: Nullable<BaseTexture>;
  114376. /**
  114377. * Diffuse Texture used in the material.
  114378. * Should be author in a specific way for the best result (refer to the documentation).
  114379. */
  114380. diffuseTexture: Nullable<BaseTexture>;
  114381. protected _shadowLights: Nullable<IShadowLight[]>;
  114382. /**
  114383. * Specify the list of lights casting shadow on the material.
  114384. * All scene shadow lights will be included if null.
  114385. */
  114386. shadowLights: Nullable<IShadowLight[]>;
  114387. protected _shadowLevel: float;
  114388. /**
  114389. * Helps adjusting the shadow to a softer level if required.
  114390. * 0 means black shadows and 1 means no shadows.
  114391. */
  114392. shadowLevel: float;
  114393. protected _sceneCenter: Vector3;
  114394. /**
  114395. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  114396. * It is usually zero but might be interesting to modify according to your setup.
  114397. */
  114398. sceneCenter: Vector3;
  114399. protected _opacityFresnel: boolean;
  114400. /**
  114401. * This helps specifying that the material is falling off to the sky box at grazing angle.
  114402. * This helps ensuring a nice transition when the camera goes under the ground.
  114403. */
  114404. opacityFresnel: boolean;
  114405. protected _reflectionFresnel: boolean;
  114406. /**
  114407. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  114408. * This helps adding a mirror texture on the ground.
  114409. */
  114410. reflectionFresnel: boolean;
  114411. protected _reflectionFalloffDistance: number;
  114412. /**
  114413. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  114414. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  114415. */
  114416. reflectionFalloffDistance: number;
  114417. protected _reflectionAmount: number;
  114418. /**
  114419. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  114420. */
  114421. reflectionAmount: number;
  114422. protected _reflectionReflectance0: number;
  114423. /**
  114424. * This specifies the weight of the reflection at grazing angle.
  114425. */
  114426. reflectionReflectance0: number;
  114427. protected _reflectionReflectance90: number;
  114428. /**
  114429. * This specifies the weight of the reflection at a perpendicular point of view.
  114430. */
  114431. reflectionReflectance90: number;
  114432. /**
  114433. * Sets the reflection reflectance fresnel values according to the default standard
  114434. * empirically know to work well :-)
  114435. */
  114436. reflectionStandardFresnelWeight: number;
  114437. protected _useRGBColor: boolean;
  114438. /**
  114439. * Helps to directly use the maps channels instead of their level.
  114440. */
  114441. useRGBColor: boolean;
  114442. protected _enableNoise: boolean;
  114443. /**
  114444. * This helps reducing the banding effect that could occur on the background.
  114445. */
  114446. enableNoise: boolean;
  114447. /**
  114448. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114449. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  114450. * Recommended to be keep at 1.0 except for special cases.
  114451. */
  114452. fovMultiplier: number;
  114453. private _fovMultiplier;
  114454. /**
  114455. * Enable the FOV adjustment feature controlled by fovMultiplier.
  114456. */
  114457. useEquirectangularFOV: boolean;
  114458. private _maxSimultaneousLights;
  114459. /**
  114460. * Number of Simultaneous lights allowed on the material.
  114461. */
  114462. maxSimultaneousLights: int;
  114463. /**
  114464. * Default configuration related to image processing available in the Background Material.
  114465. */
  114466. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114467. /**
  114468. * Keep track of the image processing observer to allow dispose and replace.
  114469. */
  114470. private _imageProcessingObserver;
  114471. /**
  114472. * Attaches a new image processing configuration to the PBR Material.
  114473. * @param configuration (if null the scene configuration will be use)
  114474. */
  114475. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114476. /**
  114477. * Gets the image processing configuration used either in this material.
  114478. */
  114479. /**
  114480. * Sets the Default image processing configuration used either in the this material.
  114481. *
  114482. * If sets to null, the scene one is in use.
  114483. */
  114484. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  114485. /**
  114486. * Gets wether the color curves effect is enabled.
  114487. */
  114488. /**
  114489. * Sets wether the color curves effect is enabled.
  114490. */
  114491. cameraColorCurvesEnabled: boolean;
  114492. /**
  114493. * Gets wether the color grading effect is enabled.
  114494. */
  114495. /**
  114496. * Gets wether the color grading effect is enabled.
  114497. */
  114498. cameraColorGradingEnabled: boolean;
  114499. /**
  114500. * Gets wether tonemapping is enabled or not.
  114501. */
  114502. /**
  114503. * Sets wether tonemapping is enabled or not
  114504. */
  114505. cameraToneMappingEnabled: boolean;
  114506. /**
  114507. * The camera exposure used on this material.
  114508. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114509. * This corresponds to a photographic exposure.
  114510. */
  114511. /**
  114512. * The camera exposure used on this material.
  114513. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114514. * This corresponds to a photographic exposure.
  114515. */
  114516. cameraExposure: float;
  114517. /**
  114518. * Gets The camera contrast used on this material.
  114519. */
  114520. /**
  114521. * Sets The camera contrast used on this material.
  114522. */
  114523. cameraContrast: float;
  114524. /**
  114525. * Gets the Color Grading 2D Lookup Texture.
  114526. */
  114527. /**
  114528. * Sets the Color Grading 2D Lookup Texture.
  114529. */
  114530. cameraColorGradingTexture: Nullable<BaseTexture>;
  114531. /**
  114532. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114533. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114534. * 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;
  114535. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114536. */
  114537. /**
  114538. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114539. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114540. * 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;
  114541. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114542. */
  114543. cameraColorCurves: Nullable<ColorCurves>;
  114544. /**
  114545. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  114546. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  114547. */
  114548. switchToBGR: boolean;
  114549. private _renderTargets;
  114550. private _reflectionControls;
  114551. private _white;
  114552. private _primaryShadowColor;
  114553. private _primaryHighlightColor;
  114554. /**
  114555. * Instantiates a Background Material in the given scene
  114556. * @param name The friendly name of the material
  114557. * @param scene The scene to add the material to
  114558. */
  114559. constructor(name: string, scene: Scene);
  114560. /**
  114561. * Gets a boolean indicating that current material needs to register RTT
  114562. */
  114563. readonly hasRenderTargetTextures: boolean;
  114564. /**
  114565. * The entire material has been created in order to prevent overdraw.
  114566. * @returns false
  114567. */
  114568. needAlphaTesting(): boolean;
  114569. /**
  114570. * The entire material has been created in order to prevent overdraw.
  114571. * @returns true if blending is enable
  114572. */
  114573. needAlphaBlending(): boolean;
  114574. /**
  114575. * Checks wether the material is ready to be rendered for a given mesh.
  114576. * @param mesh The mesh to render
  114577. * @param subMesh The submesh to check against
  114578. * @param useInstances Specify wether or not the material is used with instances
  114579. * @returns true if all the dependencies are ready (Textures, Effects...)
  114580. */
  114581. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114582. /**
  114583. * Compute the primary color according to the chosen perceptual color.
  114584. */
  114585. private _computePrimaryColorFromPerceptualColor;
  114586. /**
  114587. * Compute the highlights and shadow colors according to their chosen levels.
  114588. */
  114589. private _computePrimaryColors;
  114590. /**
  114591. * Build the uniform buffer used in the material.
  114592. */
  114593. buildUniformLayout(): void;
  114594. /**
  114595. * Unbind the material.
  114596. */
  114597. unbind(): void;
  114598. /**
  114599. * Bind only the world matrix to the material.
  114600. * @param world The world matrix to bind.
  114601. */
  114602. bindOnlyWorldMatrix(world: Matrix): void;
  114603. /**
  114604. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  114605. * @param world The world matrix to bind.
  114606. * @param subMesh The submesh to bind for.
  114607. */
  114608. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114609. /**
  114610. * Checks to see if a texture is used in the material.
  114611. * @param texture - Base texture to use.
  114612. * @returns - Boolean specifying if a texture is used in the material.
  114613. */
  114614. hasTexture(texture: BaseTexture): boolean;
  114615. /**
  114616. * Dispose the material.
  114617. * @param forceDisposeEffect Force disposal of the associated effect.
  114618. * @param forceDisposeTextures Force disposal of the associated textures.
  114619. */
  114620. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114621. /**
  114622. * Clones the material.
  114623. * @param name The cloned name.
  114624. * @returns The cloned material.
  114625. */
  114626. clone(name: string): BackgroundMaterial;
  114627. /**
  114628. * Serializes the current material to its JSON representation.
  114629. * @returns The JSON representation.
  114630. */
  114631. serialize(): any;
  114632. /**
  114633. * Gets the class name of the material
  114634. * @returns "BackgroundMaterial"
  114635. */
  114636. getClassName(): string;
  114637. /**
  114638. * Parse a JSON input to create back a background material.
  114639. * @param source The JSON data to parse
  114640. * @param scene The scene to create the parsed material in
  114641. * @param rootUrl The root url of the assets the material depends upon
  114642. * @returns the instantiated BackgroundMaterial.
  114643. */
  114644. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  114645. }
  114646. }
  114647. declare module BABYLON {
  114648. /**
  114649. * Represents the different options available during the creation of
  114650. * a Environment helper.
  114651. *
  114652. * This can control the default ground, skybox and image processing setup of your scene.
  114653. */
  114654. export interface IEnvironmentHelperOptions {
  114655. /**
  114656. * Specifies wether or not to create a ground.
  114657. * True by default.
  114658. */
  114659. createGround: boolean;
  114660. /**
  114661. * Specifies the ground size.
  114662. * 15 by default.
  114663. */
  114664. groundSize: number;
  114665. /**
  114666. * The texture used on the ground for the main color.
  114667. * Comes from the BabylonJS CDN by default.
  114668. *
  114669. * Remarks: Can be either a texture or a url.
  114670. */
  114671. groundTexture: string | BaseTexture;
  114672. /**
  114673. * The color mixed in the ground texture by default.
  114674. * BabylonJS clearColor by default.
  114675. */
  114676. groundColor: Color3;
  114677. /**
  114678. * Specifies the ground opacity.
  114679. * 1 by default.
  114680. */
  114681. groundOpacity: number;
  114682. /**
  114683. * Enables the ground to receive shadows.
  114684. * True by default.
  114685. */
  114686. enableGroundShadow: boolean;
  114687. /**
  114688. * Helps preventing the shadow to be fully black on the ground.
  114689. * 0.5 by default.
  114690. */
  114691. groundShadowLevel: number;
  114692. /**
  114693. * Creates a mirror texture attach to the ground.
  114694. * false by default.
  114695. */
  114696. enableGroundMirror: boolean;
  114697. /**
  114698. * Specifies the ground mirror size ratio.
  114699. * 0.3 by default as the default kernel is 64.
  114700. */
  114701. groundMirrorSizeRatio: number;
  114702. /**
  114703. * Specifies the ground mirror blur kernel size.
  114704. * 64 by default.
  114705. */
  114706. groundMirrorBlurKernel: number;
  114707. /**
  114708. * Specifies the ground mirror visibility amount.
  114709. * 1 by default
  114710. */
  114711. groundMirrorAmount: number;
  114712. /**
  114713. * Specifies the ground mirror reflectance weight.
  114714. * This uses the standard weight of the background material to setup the fresnel effect
  114715. * of the mirror.
  114716. * 1 by default.
  114717. */
  114718. groundMirrorFresnelWeight: number;
  114719. /**
  114720. * Specifies the ground mirror Falloff distance.
  114721. * This can helps reducing the size of the reflection.
  114722. * 0 by Default.
  114723. */
  114724. groundMirrorFallOffDistance: number;
  114725. /**
  114726. * Specifies the ground mirror texture type.
  114727. * Unsigned Int by Default.
  114728. */
  114729. groundMirrorTextureType: number;
  114730. /**
  114731. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  114732. * the shown objects.
  114733. */
  114734. groundYBias: number;
  114735. /**
  114736. * Specifies wether or not to create a skybox.
  114737. * True by default.
  114738. */
  114739. createSkybox: boolean;
  114740. /**
  114741. * Specifies the skybox size.
  114742. * 20 by default.
  114743. */
  114744. skyboxSize: number;
  114745. /**
  114746. * The texture used on the skybox for the main color.
  114747. * Comes from the BabylonJS CDN by default.
  114748. *
  114749. * Remarks: Can be either a texture or a url.
  114750. */
  114751. skyboxTexture: string | BaseTexture;
  114752. /**
  114753. * The color mixed in the skybox texture by default.
  114754. * BabylonJS clearColor by default.
  114755. */
  114756. skyboxColor: Color3;
  114757. /**
  114758. * The background rotation around the Y axis of the scene.
  114759. * This helps aligning the key lights of your scene with the background.
  114760. * 0 by default.
  114761. */
  114762. backgroundYRotation: number;
  114763. /**
  114764. * Compute automatically the size of the elements to best fit with the scene.
  114765. */
  114766. sizeAuto: boolean;
  114767. /**
  114768. * Default position of the rootMesh if autoSize is not true.
  114769. */
  114770. rootPosition: Vector3;
  114771. /**
  114772. * Sets up the image processing in the scene.
  114773. * true by default.
  114774. */
  114775. setupImageProcessing: boolean;
  114776. /**
  114777. * The texture used as your environment texture in the scene.
  114778. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  114779. *
  114780. * Remarks: Can be either a texture or a url.
  114781. */
  114782. environmentTexture: string | BaseTexture;
  114783. /**
  114784. * The value of the exposure to apply to the scene.
  114785. * 0.6 by default if setupImageProcessing is true.
  114786. */
  114787. cameraExposure: number;
  114788. /**
  114789. * The value of the contrast to apply to the scene.
  114790. * 1.6 by default if setupImageProcessing is true.
  114791. */
  114792. cameraContrast: number;
  114793. /**
  114794. * Specifies wether or not tonemapping should be enabled in the scene.
  114795. * true by default if setupImageProcessing is true.
  114796. */
  114797. toneMappingEnabled: boolean;
  114798. }
  114799. /**
  114800. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  114801. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  114802. * It also helps with the default setup of your imageProcessing configuration.
  114803. */
  114804. export class EnvironmentHelper {
  114805. /**
  114806. * Default ground texture URL.
  114807. */
  114808. private static _groundTextureCDNUrl;
  114809. /**
  114810. * Default skybox texture URL.
  114811. */
  114812. private static _skyboxTextureCDNUrl;
  114813. /**
  114814. * Default environment texture URL.
  114815. */
  114816. private static _environmentTextureCDNUrl;
  114817. /**
  114818. * Creates the default options for the helper.
  114819. */
  114820. private static _getDefaultOptions;
  114821. private _rootMesh;
  114822. /**
  114823. * Gets the root mesh created by the helper.
  114824. */
  114825. readonly rootMesh: Mesh;
  114826. private _skybox;
  114827. /**
  114828. * Gets the skybox created by the helper.
  114829. */
  114830. readonly skybox: Nullable<Mesh>;
  114831. private _skyboxTexture;
  114832. /**
  114833. * Gets the skybox texture created by the helper.
  114834. */
  114835. readonly skyboxTexture: Nullable<BaseTexture>;
  114836. private _skyboxMaterial;
  114837. /**
  114838. * Gets the skybox material created by the helper.
  114839. */
  114840. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  114841. private _ground;
  114842. /**
  114843. * Gets the ground mesh created by the helper.
  114844. */
  114845. readonly ground: Nullable<Mesh>;
  114846. private _groundTexture;
  114847. /**
  114848. * Gets the ground texture created by the helper.
  114849. */
  114850. readonly groundTexture: Nullable<BaseTexture>;
  114851. private _groundMirror;
  114852. /**
  114853. * Gets the ground mirror created by the helper.
  114854. */
  114855. readonly groundMirror: Nullable<MirrorTexture>;
  114856. /**
  114857. * Gets the ground mirror render list to helps pushing the meshes
  114858. * you wish in the ground reflection.
  114859. */
  114860. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  114861. private _groundMaterial;
  114862. /**
  114863. * Gets the ground material created by the helper.
  114864. */
  114865. readonly groundMaterial: Nullable<BackgroundMaterial>;
  114866. /**
  114867. * Stores the creation options.
  114868. */
  114869. private readonly _scene;
  114870. private _options;
  114871. /**
  114872. * This observable will be notified with any error during the creation of the environment,
  114873. * mainly texture creation errors.
  114874. */
  114875. onErrorObservable: Observable<{
  114876. message?: string;
  114877. exception?: any;
  114878. }>;
  114879. /**
  114880. * constructor
  114881. * @param options Defines the options we want to customize the helper
  114882. * @param scene The scene to add the material to
  114883. */
  114884. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  114885. /**
  114886. * Updates the background according to the new options
  114887. * @param options
  114888. */
  114889. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  114890. /**
  114891. * Sets the primary color of all the available elements.
  114892. * @param color the main color to affect to the ground and the background
  114893. */
  114894. setMainColor(color: Color3): void;
  114895. /**
  114896. * Setup the image processing according to the specified options.
  114897. */
  114898. private _setupImageProcessing;
  114899. /**
  114900. * Setup the environment texture according to the specified options.
  114901. */
  114902. private _setupEnvironmentTexture;
  114903. /**
  114904. * Setup the background according to the specified options.
  114905. */
  114906. private _setupBackground;
  114907. /**
  114908. * Get the scene sizes according to the setup.
  114909. */
  114910. private _getSceneSize;
  114911. /**
  114912. * Setup the ground according to the specified options.
  114913. */
  114914. private _setupGround;
  114915. /**
  114916. * Setup the ground material according to the specified options.
  114917. */
  114918. private _setupGroundMaterial;
  114919. /**
  114920. * Setup the ground diffuse texture according to the specified options.
  114921. */
  114922. private _setupGroundDiffuseTexture;
  114923. /**
  114924. * Setup the ground mirror texture according to the specified options.
  114925. */
  114926. private _setupGroundMirrorTexture;
  114927. /**
  114928. * Setup the ground to receive the mirror texture.
  114929. */
  114930. private _setupMirrorInGroundMaterial;
  114931. /**
  114932. * Setup the skybox according to the specified options.
  114933. */
  114934. private _setupSkybox;
  114935. /**
  114936. * Setup the skybox material according to the specified options.
  114937. */
  114938. private _setupSkyboxMaterial;
  114939. /**
  114940. * Setup the skybox reflection texture according to the specified options.
  114941. */
  114942. private _setupSkyboxReflectionTexture;
  114943. private _errorHandler;
  114944. /**
  114945. * Dispose all the elements created by the Helper.
  114946. */
  114947. dispose(): void;
  114948. }
  114949. }
  114950. declare module BABYLON {
  114951. /**
  114952. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  114953. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  114954. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  114955. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  114956. */
  114957. export class PhotoDome extends TransformNode {
  114958. /**
  114959. * Define the image as a Monoscopic panoramic 360 image.
  114960. */
  114961. static readonly MODE_MONOSCOPIC: number;
  114962. /**
  114963. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  114964. */
  114965. static readonly MODE_TOPBOTTOM: number;
  114966. /**
  114967. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  114968. */
  114969. static readonly MODE_SIDEBYSIDE: number;
  114970. private _useDirectMapping;
  114971. /**
  114972. * The texture being displayed on the sphere
  114973. */
  114974. protected _photoTexture: Texture;
  114975. /**
  114976. * Gets or sets the texture being displayed on the sphere
  114977. */
  114978. photoTexture: Texture;
  114979. /**
  114980. * Observable raised when an error occured while loading the 360 image
  114981. */
  114982. onLoadErrorObservable: Observable<string>;
  114983. /**
  114984. * The skybox material
  114985. */
  114986. protected _material: BackgroundMaterial;
  114987. /**
  114988. * The surface used for the skybox
  114989. */
  114990. protected _mesh: Mesh;
  114991. /**
  114992. * Gets the mesh used for the skybox.
  114993. */
  114994. readonly mesh: Mesh;
  114995. /**
  114996. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114997. * Also see the options.resolution property.
  114998. */
  114999. fovMultiplier: number;
  115000. private _imageMode;
  115001. /**
  115002. * Gets or set the current video mode for the video. It can be:
  115003. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  115004. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  115005. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  115006. */
  115007. imageMode: number;
  115008. /**
  115009. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  115010. * @param name Element's name, child elements will append suffixes for their own names.
  115011. * @param urlsOfPhoto defines the url of the photo to display
  115012. * @param options defines an object containing optional or exposed sub element properties
  115013. * @param onError defines a callback called when an error occured while loading the texture
  115014. */
  115015. constructor(name: string, urlOfPhoto: string, options: {
  115016. resolution?: number;
  115017. size?: number;
  115018. useDirectMapping?: boolean;
  115019. faceForward?: boolean;
  115020. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  115021. private _onBeforeCameraRenderObserver;
  115022. private _changeImageMode;
  115023. /**
  115024. * Releases resources associated with this node.
  115025. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115026. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115027. */
  115028. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115029. }
  115030. }
  115031. declare module BABYLON {
  115032. /**
  115033. * Class used to host RGBD texture specific utilities
  115034. */
  115035. export class RGBDTextureTools {
  115036. /**
  115037. * Expand the RGBD Texture from RGBD to Half Float if possible.
  115038. * @param texture the texture to expand.
  115039. */
  115040. static ExpandRGBDTexture(texture: Texture): void;
  115041. }
  115042. }
  115043. declare module BABYLON {
  115044. /**
  115045. * Class used to host texture specific utilities
  115046. */
  115047. export class BRDFTextureTools {
  115048. /**
  115049. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  115050. * @param scene defines the hosting scene
  115051. * @returns the environment BRDF texture
  115052. */
  115053. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  115054. private static _environmentBRDFBase64Texture;
  115055. }
  115056. }
  115057. declare module BABYLON {
  115058. /**
  115059. * @hidden
  115060. */
  115061. export interface IMaterialClearCoatDefines {
  115062. CLEARCOAT: boolean;
  115063. CLEARCOAT_DEFAULTIOR: boolean;
  115064. CLEARCOAT_TEXTURE: boolean;
  115065. CLEARCOAT_TEXTUREDIRECTUV: number;
  115066. CLEARCOAT_BUMP: boolean;
  115067. CLEARCOAT_BUMPDIRECTUV: number;
  115068. CLEARCOAT_TINT: boolean;
  115069. CLEARCOAT_TINT_TEXTURE: boolean;
  115070. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  115071. /** @hidden */
  115072. _areTexturesDirty: boolean;
  115073. }
  115074. /**
  115075. * Define the code related to the clear coat parameters of the pbr material.
  115076. */
  115077. export class PBRClearCoatConfiguration {
  115078. /**
  115079. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  115080. * The default fits with a polyurethane material.
  115081. */
  115082. private static readonly _DefaultIndexOfRefraction;
  115083. private _isEnabled;
  115084. /**
  115085. * Defines if the clear coat is enabled in the material.
  115086. */
  115087. isEnabled: boolean;
  115088. /**
  115089. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  115090. */
  115091. intensity: number;
  115092. /**
  115093. * Defines the clear coat layer roughness.
  115094. */
  115095. roughness: number;
  115096. private _indexOfRefraction;
  115097. /**
  115098. * Defines the index of refraction of the clear coat.
  115099. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  115100. * The default fits with a polyurethane material.
  115101. * Changing the default value is more performance intensive.
  115102. */
  115103. indexOfRefraction: number;
  115104. private _texture;
  115105. /**
  115106. * Stores the clear coat values in a texture.
  115107. */
  115108. texture: Nullable<BaseTexture>;
  115109. private _bumpTexture;
  115110. /**
  115111. * Define the clear coat specific bump texture.
  115112. */
  115113. bumpTexture: Nullable<BaseTexture>;
  115114. private _isTintEnabled;
  115115. /**
  115116. * Defines if the clear coat tint is enabled in the material.
  115117. */
  115118. isTintEnabled: boolean;
  115119. /**
  115120. * Defines the clear coat tint of the material.
  115121. * This is only use if tint is enabled
  115122. */
  115123. tintColor: Color3;
  115124. /**
  115125. * Defines the distance at which the tint color should be found in the
  115126. * clear coat media.
  115127. * This is only use if tint is enabled
  115128. */
  115129. tintColorAtDistance: number;
  115130. /**
  115131. * Defines the clear coat layer thickness.
  115132. * This is only use if tint is enabled
  115133. */
  115134. tintThickness: number;
  115135. private _tintTexture;
  115136. /**
  115137. * Stores the clear tint values in a texture.
  115138. * rgb is tint
  115139. * a is a thickness factor
  115140. */
  115141. tintTexture: Nullable<BaseTexture>;
  115142. /** @hidden */
  115143. private _internalMarkAllSubMeshesAsTexturesDirty;
  115144. /** @hidden */
  115145. _markAllSubMeshesAsTexturesDirty(): void;
  115146. /**
  115147. * Instantiate a new istance of clear coat configuration.
  115148. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115149. */
  115150. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115151. /**
  115152. * Gets wehter the submesh is ready to be used or not.
  115153. * @param defines the list of "defines" to update.
  115154. * @param scene defines the scene the material belongs to.
  115155. * @param engine defines the engine the material belongs to.
  115156. * @param disableBumpMap defines wether the material disables bump or not.
  115157. * @returns - boolean indicating that the submesh is ready or not.
  115158. */
  115159. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  115160. /**
  115161. * Checks to see if a texture is used in the material.
  115162. * @param defines the list of "defines" to update.
  115163. * @param scene defines the scene to the material belongs to.
  115164. */
  115165. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  115166. /**
  115167. * Binds the material data.
  115168. * @param uniformBuffer defines the Uniform buffer to fill in.
  115169. * @param scene defines the scene the material belongs to.
  115170. * @param engine defines the engine the material belongs to.
  115171. * @param disableBumpMap defines wether the material disables bump or not.
  115172. * @param isFrozen defines wether the material is frozen or not.
  115173. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  115174. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  115175. */
  115176. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  115177. /**
  115178. * Checks to see if a texture is used in the material.
  115179. * @param texture - Base texture to use.
  115180. * @returns - Boolean specifying if a texture is used in the material.
  115181. */
  115182. hasTexture(texture: BaseTexture): boolean;
  115183. /**
  115184. * Returns an array of the actively used textures.
  115185. * @param activeTextures Array of BaseTextures
  115186. */
  115187. getActiveTextures(activeTextures: BaseTexture[]): void;
  115188. /**
  115189. * Returns the animatable textures.
  115190. * @param animatables Array of animatable textures.
  115191. */
  115192. getAnimatables(animatables: IAnimatable[]): void;
  115193. /**
  115194. * Disposes the resources of the material.
  115195. * @param forceDisposeTextures - Forces the disposal of all textures.
  115196. */
  115197. dispose(forceDisposeTextures?: boolean): void;
  115198. /**
  115199. * Get the current class name of the texture useful for serialization or dynamic coding.
  115200. * @returns "PBRClearCoatConfiguration"
  115201. */
  115202. getClassName(): string;
  115203. /**
  115204. * Add fallbacks to the effect fallbacks list.
  115205. * @param defines defines the Base texture to use.
  115206. * @param fallbacks defines the current fallback list.
  115207. * @param currentRank defines the current fallback rank.
  115208. * @returns the new fallback rank.
  115209. */
  115210. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115211. /**
  115212. * Add the required uniforms to the current list.
  115213. * @param uniforms defines the current uniform list.
  115214. */
  115215. static AddUniforms(uniforms: string[]): void;
  115216. /**
  115217. * Add the required samplers to the current list.
  115218. * @param samplers defines the current sampler list.
  115219. */
  115220. static AddSamplers(samplers: string[]): void;
  115221. /**
  115222. * Add the required uniforms to the current buffer.
  115223. * @param uniformBuffer defines the current uniform buffer.
  115224. */
  115225. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115226. /**
  115227. * Makes a duplicate of the current configuration into another one.
  115228. * @param clearCoatConfiguration define the config where to copy the info
  115229. */
  115230. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  115231. /**
  115232. * Serializes this clear coat configuration.
  115233. * @returns - An object with the serialized config.
  115234. */
  115235. serialize(): any;
  115236. /**
  115237. * Parses a anisotropy Configuration from a serialized object.
  115238. * @param source - Serialized object.
  115239. * @param scene Defines the scene we are parsing for
  115240. * @param rootUrl Defines the rootUrl to load from
  115241. */
  115242. parse(source: any, scene: Scene, rootUrl: string): void;
  115243. }
  115244. }
  115245. declare module BABYLON {
  115246. /**
  115247. * @hidden
  115248. */
  115249. export interface IMaterialAnisotropicDefines {
  115250. ANISOTROPIC: boolean;
  115251. ANISOTROPIC_TEXTURE: boolean;
  115252. ANISOTROPIC_TEXTUREDIRECTUV: number;
  115253. MAINUV1: boolean;
  115254. _areTexturesDirty: boolean;
  115255. _needUVs: boolean;
  115256. }
  115257. /**
  115258. * Define the code related to the anisotropic parameters of the pbr material.
  115259. */
  115260. export class PBRAnisotropicConfiguration {
  115261. private _isEnabled;
  115262. /**
  115263. * Defines if the anisotropy is enabled in the material.
  115264. */
  115265. isEnabled: boolean;
  115266. /**
  115267. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  115268. */
  115269. intensity: number;
  115270. /**
  115271. * Defines if the effect is along the tangents, bitangents or in between.
  115272. * By default, the effect is "strectching" the highlights along the tangents.
  115273. */
  115274. direction: Vector2;
  115275. private _texture;
  115276. /**
  115277. * Stores the anisotropy values in a texture.
  115278. * rg is direction (like normal from -1 to 1)
  115279. * b is a intensity
  115280. */
  115281. texture: Nullable<BaseTexture>;
  115282. /** @hidden */
  115283. private _internalMarkAllSubMeshesAsTexturesDirty;
  115284. /** @hidden */
  115285. _markAllSubMeshesAsTexturesDirty(): void;
  115286. /**
  115287. * Instantiate a new istance of anisotropy configuration.
  115288. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115289. */
  115290. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115291. /**
  115292. * Specifies that the submesh is ready to be used.
  115293. * @param defines the list of "defines" to update.
  115294. * @param scene defines the scene the material belongs to.
  115295. * @returns - boolean indicating that the submesh is ready or not.
  115296. */
  115297. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  115298. /**
  115299. * Checks to see if a texture is used in the material.
  115300. * @param defines the list of "defines" to update.
  115301. * @param mesh the mesh we are preparing the defines for.
  115302. * @param scene defines the scene the material belongs to.
  115303. */
  115304. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  115305. /**
  115306. * Binds the material data.
  115307. * @param uniformBuffer defines the Uniform buffer to fill in.
  115308. * @param scene defines the scene the material belongs to.
  115309. * @param isFrozen defines wether the material is frozen or not.
  115310. */
  115311. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  115312. /**
  115313. * Checks to see if a texture is used in the material.
  115314. * @param texture - Base texture to use.
  115315. * @returns - Boolean specifying if a texture is used in the material.
  115316. */
  115317. hasTexture(texture: BaseTexture): boolean;
  115318. /**
  115319. * Returns an array of the actively used textures.
  115320. * @param activeTextures Array of BaseTextures
  115321. */
  115322. getActiveTextures(activeTextures: BaseTexture[]): void;
  115323. /**
  115324. * Returns the animatable textures.
  115325. * @param animatables Array of animatable textures.
  115326. */
  115327. getAnimatables(animatables: IAnimatable[]): void;
  115328. /**
  115329. * Disposes the resources of the material.
  115330. * @param forceDisposeTextures - Forces the disposal of all textures.
  115331. */
  115332. dispose(forceDisposeTextures?: boolean): void;
  115333. /**
  115334. * Get the current class name of the texture useful for serialization or dynamic coding.
  115335. * @returns "PBRAnisotropicConfiguration"
  115336. */
  115337. getClassName(): string;
  115338. /**
  115339. * Add fallbacks to the effect fallbacks list.
  115340. * @param defines defines the Base texture to use.
  115341. * @param fallbacks defines the current fallback list.
  115342. * @param currentRank defines the current fallback rank.
  115343. * @returns the new fallback rank.
  115344. */
  115345. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115346. /**
  115347. * Add the required uniforms to the current list.
  115348. * @param uniforms defines the current uniform list.
  115349. */
  115350. static AddUniforms(uniforms: string[]): void;
  115351. /**
  115352. * Add the required uniforms to the current buffer.
  115353. * @param uniformBuffer defines the current uniform buffer.
  115354. */
  115355. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115356. /**
  115357. * Add the required samplers to the current list.
  115358. * @param samplers defines the current sampler list.
  115359. */
  115360. static AddSamplers(samplers: string[]): void;
  115361. /**
  115362. * Makes a duplicate of the current configuration into another one.
  115363. * @param anisotropicConfiguration define the config where to copy the info
  115364. */
  115365. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  115366. /**
  115367. * Serializes this anisotropy configuration.
  115368. * @returns - An object with the serialized config.
  115369. */
  115370. serialize(): any;
  115371. /**
  115372. * Parses a anisotropy Configuration from a serialized object.
  115373. * @param source - Serialized object.
  115374. * @param scene Defines the scene we are parsing for
  115375. * @param rootUrl Defines the rootUrl to load from
  115376. */
  115377. parse(source: any, scene: Scene, rootUrl: string): void;
  115378. }
  115379. }
  115380. declare module BABYLON {
  115381. /**
  115382. * @hidden
  115383. */
  115384. export interface IMaterialBRDFDefines {
  115385. BRDF_V_HEIGHT_CORRELATED: boolean;
  115386. MS_BRDF_ENERGY_CONSERVATION: boolean;
  115387. SPHERICAL_HARMONICS: boolean;
  115388. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  115389. /** @hidden */
  115390. _areMiscDirty: boolean;
  115391. }
  115392. /**
  115393. * Define the code related to the BRDF parameters of the pbr material.
  115394. */
  115395. export class PBRBRDFConfiguration {
  115396. /**
  115397. * Default value used for the energy conservation.
  115398. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  115399. */
  115400. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  115401. /**
  115402. * Default value used for the Smith Visibility Height Correlated mode.
  115403. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  115404. */
  115405. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  115406. /**
  115407. * Default value used for the IBL diffuse part.
  115408. * This can help switching back to the polynomials mode globally which is a tiny bit
  115409. * less GPU intensive at the drawback of a lower quality.
  115410. */
  115411. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  115412. /**
  115413. * Default value used for activating energy conservation for the specular workflow.
  115414. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  115415. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  115416. */
  115417. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  115418. private _useEnergyConservation;
  115419. /**
  115420. * Defines if the material uses energy conservation.
  115421. */
  115422. useEnergyConservation: boolean;
  115423. private _useSmithVisibilityHeightCorrelated;
  115424. /**
  115425. * LEGACY Mode set to false
  115426. * Defines if the material uses height smith correlated visibility term.
  115427. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  115428. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  115429. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  115430. * Not relying on height correlated will also disable energy conservation.
  115431. */
  115432. useSmithVisibilityHeightCorrelated: boolean;
  115433. private _useSphericalHarmonics;
  115434. /**
  115435. * LEGACY Mode set to false
  115436. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  115437. * diffuse part of the IBL.
  115438. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  115439. * to the ground truth.
  115440. */
  115441. useSphericalHarmonics: boolean;
  115442. private _useSpecularGlossinessInputEnergyConservation;
  115443. /**
  115444. * Defines if the material uses energy conservation, when the specular workflow is active.
  115445. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  115446. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  115447. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  115448. */
  115449. useSpecularGlossinessInputEnergyConservation: boolean;
  115450. /** @hidden */
  115451. private _internalMarkAllSubMeshesAsMiscDirty;
  115452. /** @hidden */
  115453. _markAllSubMeshesAsMiscDirty(): void;
  115454. /**
  115455. * Instantiate a new istance of clear coat configuration.
  115456. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  115457. */
  115458. constructor(markAllSubMeshesAsMiscDirty: () => void);
  115459. /**
  115460. * Checks to see if a texture is used in the material.
  115461. * @param defines the list of "defines" to update.
  115462. */
  115463. prepareDefines(defines: IMaterialBRDFDefines): void;
  115464. /**
  115465. * Get the current class name of the texture useful for serialization or dynamic coding.
  115466. * @returns "PBRClearCoatConfiguration"
  115467. */
  115468. getClassName(): string;
  115469. /**
  115470. * Makes a duplicate of the current configuration into another one.
  115471. * @param brdfConfiguration define the config where to copy the info
  115472. */
  115473. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  115474. /**
  115475. * Serializes this BRDF configuration.
  115476. * @returns - An object with the serialized config.
  115477. */
  115478. serialize(): any;
  115479. /**
  115480. * Parses a anisotropy Configuration from a serialized object.
  115481. * @param source - Serialized object.
  115482. * @param scene Defines the scene we are parsing for
  115483. * @param rootUrl Defines the rootUrl to load from
  115484. */
  115485. parse(source: any, scene: Scene, rootUrl: string): void;
  115486. }
  115487. }
  115488. declare module BABYLON {
  115489. /**
  115490. * @hidden
  115491. */
  115492. export interface IMaterialSheenDefines {
  115493. SHEEN: boolean;
  115494. SHEEN_TEXTURE: boolean;
  115495. SHEEN_TEXTUREDIRECTUV: number;
  115496. SHEEN_LINKWITHALBEDO: boolean;
  115497. /** @hidden */
  115498. _areTexturesDirty: boolean;
  115499. }
  115500. /**
  115501. * Define the code related to the Sheen parameters of the pbr material.
  115502. */
  115503. export class PBRSheenConfiguration {
  115504. private _isEnabled;
  115505. /**
  115506. * Defines if the material uses sheen.
  115507. */
  115508. isEnabled: boolean;
  115509. private _linkSheenWithAlbedo;
  115510. /**
  115511. * Defines if the sheen is linked to the sheen color.
  115512. */
  115513. linkSheenWithAlbedo: boolean;
  115514. /**
  115515. * Defines the sheen intensity.
  115516. */
  115517. intensity: number;
  115518. /**
  115519. * Defines the sheen color.
  115520. */
  115521. color: Color3;
  115522. private _texture;
  115523. /**
  115524. * Stores the sheen tint values in a texture.
  115525. * rgb is tint
  115526. * a is a intensity
  115527. */
  115528. texture: Nullable<BaseTexture>;
  115529. /** @hidden */
  115530. private _internalMarkAllSubMeshesAsTexturesDirty;
  115531. /** @hidden */
  115532. _markAllSubMeshesAsTexturesDirty(): void;
  115533. /**
  115534. * Instantiate a new istance of clear coat configuration.
  115535. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115536. */
  115537. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115538. /**
  115539. * Specifies that the submesh is ready to be used.
  115540. * @param defines the list of "defines" to update.
  115541. * @param scene defines the scene the material belongs to.
  115542. * @returns - boolean indicating that the submesh is ready or not.
  115543. */
  115544. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  115545. /**
  115546. * Checks to see if a texture is used in the material.
  115547. * @param defines the list of "defines" to update.
  115548. * @param scene defines the scene the material belongs to.
  115549. */
  115550. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  115551. /**
  115552. * Binds the material data.
  115553. * @param uniformBuffer defines the Uniform buffer to fill in.
  115554. * @param scene defines the scene the material belongs to.
  115555. * @param isFrozen defines wether the material is frozen or not.
  115556. */
  115557. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  115558. /**
  115559. * Checks to see if a texture is used in the material.
  115560. * @param texture - Base texture to use.
  115561. * @returns - Boolean specifying if a texture is used in the material.
  115562. */
  115563. hasTexture(texture: BaseTexture): boolean;
  115564. /**
  115565. * Returns an array of the actively used textures.
  115566. * @param activeTextures Array of BaseTextures
  115567. */
  115568. getActiveTextures(activeTextures: BaseTexture[]): void;
  115569. /**
  115570. * Returns the animatable textures.
  115571. * @param animatables Array of animatable textures.
  115572. */
  115573. getAnimatables(animatables: IAnimatable[]): void;
  115574. /**
  115575. * Disposes the resources of the material.
  115576. * @param forceDisposeTextures - Forces the disposal of all textures.
  115577. */
  115578. dispose(forceDisposeTextures?: boolean): void;
  115579. /**
  115580. * Get the current class name of the texture useful for serialization or dynamic coding.
  115581. * @returns "PBRSheenConfiguration"
  115582. */
  115583. getClassName(): string;
  115584. /**
  115585. * Add fallbacks to the effect fallbacks list.
  115586. * @param defines defines the Base texture to use.
  115587. * @param fallbacks defines the current fallback list.
  115588. * @param currentRank defines the current fallback rank.
  115589. * @returns the new fallback rank.
  115590. */
  115591. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115592. /**
  115593. * Add the required uniforms to the current list.
  115594. * @param uniforms defines the current uniform list.
  115595. */
  115596. static AddUniforms(uniforms: string[]): void;
  115597. /**
  115598. * Add the required uniforms to the current buffer.
  115599. * @param uniformBuffer defines the current uniform buffer.
  115600. */
  115601. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115602. /**
  115603. * Add the required samplers to the current list.
  115604. * @param samplers defines the current sampler list.
  115605. */
  115606. static AddSamplers(samplers: string[]): void;
  115607. /**
  115608. * Makes a duplicate of the current configuration into another one.
  115609. * @param sheenConfiguration define the config where to copy the info
  115610. */
  115611. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  115612. /**
  115613. * Serializes this BRDF configuration.
  115614. * @returns - An object with the serialized config.
  115615. */
  115616. serialize(): any;
  115617. /**
  115618. * Parses a anisotropy Configuration from a serialized object.
  115619. * @param source - Serialized object.
  115620. * @param scene Defines the scene we are parsing for
  115621. * @param rootUrl Defines the rootUrl to load from
  115622. */
  115623. parse(source: any, scene: Scene, rootUrl: string): void;
  115624. }
  115625. }
  115626. declare module BABYLON {
  115627. /**
  115628. * @hidden
  115629. */
  115630. export interface IMaterialSubSurfaceDefines {
  115631. SUBSURFACE: boolean;
  115632. SS_REFRACTION: boolean;
  115633. SS_TRANSLUCENCY: boolean;
  115634. SS_SCATERRING: boolean;
  115635. SS_THICKNESSANDMASK_TEXTURE: boolean;
  115636. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  115637. SS_REFRACTIONMAP_3D: boolean;
  115638. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  115639. SS_LODINREFRACTIONALPHA: boolean;
  115640. SS_GAMMAREFRACTION: boolean;
  115641. SS_RGBDREFRACTION: boolean;
  115642. SS_LINEARSPECULARREFRACTION: boolean;
  115643. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  115644. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  115645. /** @hidden */
  115646. _areTexturesDirty: boolean;
  115647. }
  115648. /**
  115649. * Define the code related to the sub surface parameters of the pbr material.
  115650. */
  115651. export class PBRSubSurfaceConfiguration {
  115652. private _isRefractionEnabled;
  115653. /**
  115654. * Defines if the refraction is enabled in the material.
  115655. */
  115656. isRefractionEnabled: boolean;
  115657. private _isTranslucencyEnabled;
  115658. /**
  115659. * Defines if the translucency is enabled in the material.
  115660. */
  115661. isTranslucencyEnabled: boolean;
  115662. private _isScatteringEnabled;
  115663. /**
  115664. * Defines the refraction intensity of the material.
  115665. * The refraction when enabled replaces the Diffuse part of the material.
  115666. * The intensity helps transitionning between diffuse and refraction.
  115667. */
  115668. refractionIntensity: number;
  115669. /**
  115670. * Defines the translucency intensity of the material.
  115671. * When translucency has been enabled, this defines how much of the "translucency"
  115672. * is addded to the diffuse part of the material.
  115673. */
  115674. translucencyIntensity: number;
  115675. /**
  115676. * Defines the scattering intensity of the material.
  115677. * When scattering has been enabled, this defines how much of the "scattered light"
  115678. * is addded to the diffuse part of the material.
  115679. */
  115680. scatteringIntensity: number;
  115681. private _thicknessTexture;
  115682. /**
  115683. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  115684. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  115685. * 0 would mean minimumThickness
  115686. * 1 would mean maximumThickness
  115687. * The other channels might be use as a mask to vary the different effects intensity.
  115688. */
  115689. thicknessTexture: Nullable<BaseTexture>;
  115690. private _refractionTexture;
  115691. /**
  115692. * Defines the texture to use for refraction.
  115693. */
  115694. refractionTexture: Nullable<BaseTexture>;
  115695. private _indexOfRefraction;
  115696. /**
  115697. * Defines the index of refraction used in the material.
  115698. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  115699. */
  115700. indexOfRefraction: number;
  115701. private _invertRefractionY;
  115702. /**
  115703. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  115704. */
  115705. invertRefractionY: boolean;
  115706. private _linkRefractionWithTransparency;
  115707. /**
  115708. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  115709. * Materials half opaque for instance using refraction could benefit from this control.
  115710. */
  115711. linkRefractionWithTransparency: boolean;
  115712. /**
  115713. * Defines the minimum thickness stored in the thickness map.
  115714. * If no thickness map is defined, this value will be used to simulate thickness.
  115715. */
  115716. minimumThickness: number;
  115717. /**
  115718. * Defines the maximum thickness stored in the thickness map.
  115719. */
  115720. maximumThickness: number;
  115721. /**
  115722. * Defines the volume tint of the material.
  115723. * This is used for both translucency and scattering.
  115724. */
  115725. tintColor: Color3;
  115726. /**
  115727. * Defines the distance at which the tint color should be found in the media.
  115728. * This is used for refraction only.
  115729. */
  115730. tintColorAtDistance: number;
  115731. /**
  115732. * Defines how far each channel transmit through the media.
  115733. * It is defined as a color to simplify it selection.
  115734. */
  115735. diffusionDistance: Color3;
  115736. private _useMaskFromThicknessTexture;
  115737. /**
  115738. * Stores the intensity of the different subsurface effects in the thickness texture.
  115739. * * the green channel is the translucency intensity.
  115740. * * the blue channel is the scattering intensity.
  115741. * * the alpha channel is the refraction intensity.
  115742. */
  115743. useMaskFromThicknessTexture: boolean;
  115744. /** @hidden */
  115745. private _internalMarkAllSubMeshesAsTexturesDirty;
  115746. /** @hidden */
  115747. _markAllSubMeshesAsTexturesDirty(): void;
  115748. /**
  115749. * Instantiate a new istance of sub surface configuration.
  115750. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115751. */
  115752. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115753. /**
  115754. * Gets wehter the submesh is ready to be used or not.
  115755. * @param defines the list of "defines" to update.
  115756. * @param scene defines the scene the material belongs to.
  115757. * @returns - boolean indicating that the submesh is ready or not.
  115758. */
  115759. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  115760. /**
  115761. * Checks to see if a texture is used in the material.
  115762. * @param defines the list of "defines" to update.
  115763. * @param scene defines the scene to the material belongs to.
  115764. */
  115765. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  115766. /**
  115767. * Binds the material data.
  115768. * @param uniformBuffer defines the Uniform buffer to fill in.
  115769. * @param scene defines the scene the material belongs to.
  115770. * @param engine defines the engine the material belongs to.
  115771. * @param isFrozen defines wether the material is frozen or not.
  115772. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  115773. */
  115774. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  115775. /**
  115776. * Unbinds the material from the mesh.
  115777. * @param activeEffect defines the effect that should be unbound from.
  115778. * @returns true if unbound, otherwise false
  115779. */
  115780. unbind(activeEffect: Effect): boolean;
  115781. /**
  115782. * Returns the texture used for refraction or null if none is used.
  115783. * @param scene defines the scene the material belongs to.
  115784. * @returns - Refraction texture if present. If no refraction texture and refraction
  115785. * is linked with transparency, returns environment texture. Otherwise, returns null.
  115786. */
  115787. private _getRefractionTexture;
  115788. /**
  115789. * Returns true if alpha blending should be disabled.
  115790. */
  115791. readonly disableAlphaBlending: boolean;
  115792. /**
  115793. * Fills the list of render target textures.
  115794. * @param renderTargets the list of render targets to update
  115795. */
  115796. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  115797. /**
  115798. * Checks to see if a texture is used in the material.
  115799. * @param texture - Base texture to use.
  115800. * @returns - Boolean specifying if a texture is used in the material.
  115801. */
  115802. hasTexture(texture: BaseTexture): boolean;
  115803. /**
  115804. * Gets a boolean indicating that current material needs to register RTT
  115805. * @returns true if this uses a render target otherwise false.
  115806. */
  115807. hasRenderTargetTextures(): boolean;
  115808. /**
  115809. * Returns an array of the actively used textures.
  115810. * @param activeTextures Array of BaseTextures
  115811. */
  115812. getActiveTextures(activeTextures: BaseTexture[]): void;
  115813. /**
  115814. * Returns the animatable textures.
  115815. * @param animatables Array of animatable textures.
  115816. */
  115817. getAnimatables(animatables: IAnimatable[]): void;
  115818. /**
  115819. * Disposes the resources of the material.
  115820. * @param forceDisposeTextures - Forces the disposal of all textures.
  115821. */
  115822. dispose(forceDisposeTextures?: boolean): void;
  115823. /**
  115824. * Get the current class name of the texture useful for serialization or dynamic coding.
  115825. * @returns "PBRSubSurfaceConfiguration"
  115826. */
  115827. getClassName(): string;
  115828. /**
  115829. * Add fallbacks to the effect fallbacks list.
  115830. * @param defines defines the Base texture to use.
  115831. * @param fallbacks defines the current fallback list.
  115832. * @param currentRank defines the current fallback rank.
  115833. * @returns the new fallback rank.
  115834. */
  115835. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115836. /**
  115837. * Add the required uniforms to the current list.
  115838. * @param uniforms defines the current uniform list.
  115839. */
  115840. static AddUniforms(uniforms: string[]): void;
  115841. /**
  115842. * Add the required samplers to the current list.
  115843. * @param samplers defines the current sampler list.
  115844. */
  115845. static AddSamplers(samplers: string[]): void;
  115846. /**
  115847. * Add the required uniforms to the current buffer.
  115848. * @param uniformBuffer defines the current uniform buffer.
  115849. */
  115850. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115851. /**
  115852. * Makes a duplicate of the current configuration into another one.
  115853. * @param configuration define the config where to copy the info
  115854. */
  115855. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  115856. /**
  115857. * Serializes this Sub Surface configuration.
  115858. * @returns - An object with the serialized config.
  115859. */
  115860. serialize(): any;
  115861. /**
  115862. * Parses a anisotropy Configuration from a serialized object.
  115863. * @param source - Serialized object.
  115864. * @param scene Defines the scene we are parsing for
  115865. * @param rootUrl Defines the rootUrl to load from
  115866. */
  115867. parse(source: any, scene: Scene, rootUrl: string): void;
  115868. }
  115869. }
  115870. declare module BABYLON {
  115871. /** @hidden */
  115872. export var pbrFragmentDeclaration: {
  115873. name: string;
  115874. shader: string;
  115875. };
  115876. }
  115877. declare module BABYLON {
  115878. /** @hidden */
  115879. export var pbrUboDeclaration: {
  115880. name: string;
  115881. shader: string;
  115882. };
  115883. }
  115884. declare module BABYLON {
  115885. /** @hidden */
  115886. export var pbrFragmentExtraDeclaration: {
  115887. name: string;
  115888. shader: string;
  115889. };
  115890. }
  115891. declare module BABYLON {
  115892. /** @hidden */
  115893. export var pbrFragmentSamplersDeclaration: {
  115894. name: string;
  115895. shader: string;
  115896. };
  115897. }
  115898. declare module BABYLON {
  115899. /** @hidden */
  115900. export var pbrHelperFunctions: {
  115901. name: string;
  115902. shader: string;
  115903. };
  115904. }
  115905. declare module BABYLON {
  115906. /** @hidden */
  115907. export var harmonicsFunctions: {
  115908. name: string;
  115909. shader: string;
  115910. };
  115911. }
  115912. declare module BABYLON {
  115913. /** @hidden */
  115914. export var pbrDirectLightingSetupFunctions: {
  115915. name: string;
  115916. shader: string;
  115917. };
  115918. }
  115919. declare module BABYLON {
  115920. /** @hidden */
  115921. export var pbrDirectLightingFalloffFunctions: {
  115922. name: string;
  115923. shader: string;
  115924. };
  115925. }
  115926. declare module BABYLON {
  115927. /** @hidden */
  115928. export var pbrBRDFFunctions: {
  115929. name: string;
  115930. shader: string;
  115931. };
  115932. }
  115933. declare module BABYLON {
  115934. /** @hidden */
  115935. export var pbrDirectLightingFunctions: {
  115936. name: string;
  115937. shader: string;
  115938. };
  115939. }
  115940. declare module BABYLON {
  115941. /** @hidden */
  115942. export var pbrIBLFunctions: {
  115943. name: string;
  115944. shader: string;
  115945. };
  115946. }
  115947. declare module BABYLON {
  115948. /** @hidden */
  115949. export var pbrDebug: {
  115950. name: string;
  115951. shader: string;
  115952. };
  115953. }
  115954. declare module BABYLON {
  115955. /** @hidden */
  115956. export var pbrPixelShader: {
  115957. name: string;
  115958. shader: string;
  115959. };
  115960. }
  115961. declare module BABYLON {
  115962. /** @hidden */
  115963. export var pbrVertexDeclaration: {
  115964. name: string;
  115965. shader: string;
  115966. };
  115967. }
  115968. declare module BABYLON {
  115969. /** @hidden */
  115970. export var pbrVertexShader: {
  115971. name: string;
  115972. shader: string;
  115973. };
  115974. }
  115975. declare module BABYLON {
  115976. /**
  115977. * Manages the defines for the PBR Material.
  115978. * @hidden
  115979. */
  115980. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  115981. PBR: boolean;
  115982. MAINUV1: boolean;
  115983. MAINUV2: boolean;
  115984. UV1: boolean;
  115985. UV2: boolean;
  115986. ALBEDO: boolean;
  115987. ALBEDODIRECTUV: number;
  115988. VERTEXCOLOR: boolean;
  115989. AMBIENT: boolean;
  115990. AMBIENTDIRECTUV: number;
  115991. AMBIENTINGRAYSCALE: boolean;
  115992. OPACITY: boolean;
  115993. VERTEXALPHA: boolean;
  115994. OPACITYDIRECTUV: number;
  115995. OPACITYRGB: boolean;
  115996. ALPHATEST: boolean;
  115997. DEPTHPREPASS: boolean;
  115998. ALPHABLEND: boolean;
  115999. ALPHAFROMALBEDO: boolean;
  116000. ALPHATESTVALUE: string;
  116001. SPECULAROVERALPHA: boolean;
  116002. RADIANCEOVERALPHA: boolean;
  116003. ALPHAFRESNEL: boolean;
  116004. LINEARALPHAFRESNEL: boolean;
  116005. PREMULTIPLYALPHA: boolean;
  116006. EMISSIVE: boolean;
  116007. EMISSIVEDIRECTUV: number;
  116008. REFLECTIVITY: boolean;
  116009. REFLECTIVITYDIRECTUV: number;
  116010. SPECULARTERM: boolean;
  116011. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  116012. MICROSURFACEAUTOMATIC: boolean;
  116013. LODBASEDMICROSFURACE: boolean;
  116014. MICROSURFACEMAP: boolean;
  116015. MICROSURFACEMAPDIRECTUV: number;
  116016. METALLICWORKFLOW: boolean;
  116017. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  116018. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  116019. METALLNESSSTOREINMETALMAPBLUE: boolean;
  116020. AOSTOREINMETALMAPRED: boolean;
  116021. METALLICF0FACTORFROMMETALLICMAP: boolean;
  116022. ENVIRONMENTBRDF: boolean;
  116023. ENVIRONMENTBRDF_RGBD: boolean;
  116024. NORMAL: boolean;
  116025. TANGENT: boolean;
  116026. BUMP: boolean;
  116027. BUMPDIRECTUV: number;
  116028. OBJECTSPACE_NORMALMAP: boolean;
  116029. PARALLAX: boolean;
  116030. PARALLAXOCCLUSION: boolean;
  116031. NORMALXYSCALE: boolean;
  116032. LIGHTMAP: boolean;
  116033. LIGHTMAPDIRECTUV: number;
  116034. USELIGHTMAPASSHADOWMAP: boolean;
  116035. GAMMALIGHTMAP: boolean;
  116036. RGBDLIGHTMAP: boolean;
  116037. REFLECTION: boolean;
  116038. REFLECTIONMAP_3D: boolean;
  116039. REFLECTIONMAP_SPHERICAL: boolean;
  116040. REFLECTIONMAP_PLANAR: boolean;
  116041. REFLECTIONMAP_CUBIC: boolean;
  116042. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  116043. REFLECTIONMAP_PROJECTION: boolean;
  116044. REFLECTIONMAP_SKYBOX: boolean;
  116045. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  116046. REFLECTIONMAP_EXPLICIT: boolean;
  116047. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  116048. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  116049. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  116050. INVERTCUBICMAP: boolean;
  116051. USESPHERICALFROMREFLECTIONMAP: boolean;
  116052. USEIRRADIANCEMAP: boolean;
  116053. SPHERICAL_HARMONICS: boolean;
  116054. USESPHERICALINVERTEX: boolean;
  116055. REFLECTIONMAP_OPPOSITEZ: boolean;
  116056. LODINREFLECTIONALPHA: boolean;
  116057. GAMMAREFLECTION: boolean;
  116058. RGBDREFLECTION: boolean;
  116059. LINEARSPECULARREFLECTION: boolean;
  116060. RADIANCEOCCLUSION: boolean;
  116061. HORIZONOCCLUSION: boolean;
  116062. INSTANCES: boolean;
  116063. NUM_BONE_INFLUENCERS: number;
  116064. BonesPerMesh: number;
  116065. BONETEXTURE: boolean;
  116066. NONUNIFORMSCALING: boolean;
  116067. MORPHTARGETS: boolean;
  116068. MORPHTARGETS_NORMAL: boolean;
  116069. MORPHTARGETS_TANGENT: boolean;
  116070. MORPHTARGETS_UV: boolean;
  116071. NUM_MORPH_INFLUENCERS: number;
  116072. IMAGEPROCESSING: boolean;
  116073. VIGNETTE: boolean;
  116074. VIGNETTEBLENDMODEMULTIPLY: boolean;
  116075. VIGNETTEBLENDMODEOPAQUE: boolean;
  116076. TONEMAPPING: boolean;
  116077. TONEMAPPING_ACES: boolean;
  116078. CONTRAST: boolean;
  116079. COLORCURVES: boolean;
  116080. COLORGRADING: boolean;
  116081. COLORGRADING3D: boolean;
  116082. SAMPLER3DGREENDEPTH: boolean;
  116083. SAMPLER3DBGRMAP: boolean;
  116084. IMAGEPROCESSINGPOSTPROCESS: boolean;
  116085. EXPOSURE: boolean;
  116086. MULTIVIEW: boolean;
  116087. USEPHYSICALLIGHTFALLOFF: boolean;
  116088. USEGLTFLIGHTFALLOFF: boolean;
  116089. TWOSIDEDLIGHTING: boolean;
  116090. SHADOWFLOAT: boolean;
  116091. CLIPPLANE: boolean;
  116092. CLIPPLANE2: boolean;
  116093. CLIPPLANE3: boolean;
  116094. CLIPPLANE4: boolean;
  116095. POINTSIZE: boolean;
  116096. FOG: boolean;
  116097. LOGARITHMICDEPTH: boolean;
  116098. FORCENORMALFORWARD: boolean;
  116099. SPECULARAA: boolean;
  116100. CLEARCOAT: boolean;
  116101. CLEARCOAT_DEFAULTIOR: boolean;
  116102. CLEARCOAT_TEXTURE: boolean;
  116103. CLEARCOAT_TEXTUREDIRECTUV: number;
  116104. CLEARCOAT_BUMP: boolean;
  116105. CLEARCOAT_BUMPDIRECTUV: number;
  116106. CLEARCOAT_TINT: boolean;
  116107. CLEARCOAT_TINT_TEXTURE: boolean;
  116108. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  116109. ANISOTROPIC: boolean;
  116110. ANISOTROPIC_TEXTURE: boolean;
  116111. ANISOTROPIC_TEXTUREDIRECTUV: number;
  116112. BRDF_V_HEIGHT_CORRELATED: boolean;
  116113. MS_BRDF_ENERGY_CONSERVATION: boolean;
  116114. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  116115. SHEEN: boolean;
  116116. SHEEN_TEXTURE: boolean;
  116117. SHEEN_TEXTUREDIRECTUV: number;
  116118. SHEEN_LINKWITHALBEDO: boolean;
  116119. SUBSURFACE: boolean;
  116120. SS_REFRACTION: boolean;
  116121. SS_TRANSLUCENCY: boolean;
  116122. SS_SCATERRING: boolean;
  116123. SS_THICKNESSANDMASK_TEXTURE: boolean;
  116124. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  116125. SS_REFRACTIONMAP_3D: boolean;
  116126. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  116127. SS_LODINREFRACTIONALPHA: boolean;
  116128. SS_GAMMAREFRACTION: boolean;
  116129. SS_RGBDREFRACTION: boolean;
  116130. SS_LINEARSPECULARREFRACTION: boolean;
  116131. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  116132. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  116133. UNLIT: boolean;
  116134. DEBUGMODE: number;
  116135. /**
  116136. * Initializes the PBR Material defines.
  116137. */
  116138. constructor();
  116139. /**
  116140. * Resets the PBR Material defines.
  116141. */
  116142. reset(): void;
  116143. }
  116144. /**
  116145. * The Physically based material base class of BJS.
  116146. *
  116147. * This offers the main features of a standard PBR material.
  116148. * For more information, please refer to the documentation :
  116149. * https://doc.babylonjs.com/how_to/physically_based_rendering
  116150. */
  116151. export abstract class PBRBaseMaterial extends PushMaterial {
  116152. /**
  116153. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  116154. */
  116155. static readonly PBRMATERIAL_OPAQUE: number;
  116156. /**
  116157. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  116158. */
  116159. static readonly PBRMATERIAL_ALPHATEST: number;
  116160. /**
  116161. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116162. */
  116163. static readonly PBRMATERIAL_ALPHABLEND: number;
  116164. /**
  116165. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116166. * They are also discarded below the alpha cutoff threshold to improve performances.
  116167. */
  116168. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  116169. /**
  116170. * Defines the default value of how much AO map is occluding the analytical lights
  116171. * (point spot...).
  116172. */
  116173. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  116174. /**
  116175. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  116176. */
  116177. static readonly LIGHTFALLOFF_PHYSICAL: number;
  116178. /**
  116179. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  116180. * to enhance interoperability with other engines.
  116181. */
  116182. static readonly LIGHTFALLOFF_GLTF: number;
  116183. /**
  116184. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  116185. * to enhance interoperability with other materials.
  116186. */
  116187. static readonly LIGHTFALLOFF_STANDARD: number;
  116188. /**
  116189. * Intensity of the direct lights e.g. the four lights available in your scene.
  116190. * This impacts both the direct diffuse and specular highlights.
  116191. */
  116192. protected _directIntensity: number;
  116193. /**
  116194. * Intensity of the emissive part of the material.
  116195. * This helps controlling the emissive effect without modifying the emissive color.
  116196. */
  116197. protected _emissiveIntensity: number;
  116198. /**
  116199. * Intensity of the environment e.g. how much the environment will light the object
  116200. * either through harmonics for rough material or through the refelction for shiny ones.
  116201. */
  116202. protected _environmentIntensity: number;
  116203. /**
  116204. * This is a special control allowing the reduction of the specular highlights coming from the
  116205. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  116206. */
  116207. protected _specularIntensity: number;
  116208. /**
  116209. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  116210. */
  116211. private _lightingInfos;
  116212. /**
  116213. * Debug Control allowing disabling the bump map on this material.
  116214. */
  116215. protected _disableBumpMap: boolean;
  116216. /**
  116217. * AKA Diffuse Texture in standard nomenclature.
  116218. */
  116219. protected _albedoTexture: Nullable<BaseTexture>;
  116220. /**
  116221. * AKA Occlusion Texture in other nomenclature.
  116222. */
  116223. protected _ambientTexture: Nullable<BaseTexture>;
  116224. /**
  116225. * AKA Occlusion Texture Intensity in other nomenclature.
  116226. */
  116227. protected _ambientTextureStrength: number;
  116228. /**
  116229. * Defines how much the AO map is occluding the analytical lights (point spot...).
  116230. * 1 means it completely occludes it
  116231. * 0 mean it has no impact
  116232. */
  116233. protected _ambientTextureImpactOnAnalyticalLights: number;
  116234. /**
  116235. * Stores the alpha values in a texture.
  116236. */
  116237. protected _opacityTexture: Nullable<BaseTexture>;
  116238. /**
  116239. * Stores the reflection values in a texture.
  116240. */
  116241. protected _reflectionTexture: Nullable<BaseTexture>;
  116242. /**
  116243. * Stores the emissive values in a texture.
  116244. */
  116245. protected _emissiveTexture: Nullable<BaseTexture>;
  116246. /**
  116247. * AKA Specular texture in other nomenclature.
  116248. */
  116249. protected _reflectivityTexture: Nullable<BaseTexture>;
  116250. /**
  116251. * Used to switch from specular/glossiness to metallic/roughness workflow.
  116252. */
  116253. protected _metallicTexture: Nullable<BaseTexture>;
  116254. /**
  116255. * Specifies the metallic scalar of the metallic/roughness workflow.
  116256. * Can also be used to scale the metalness values of the metallic texture.
  116257. */
  116258. protected _metallic: Nullable<number>;
  116259. /**
  116260. * Specifies the roughness scalar of the metallic/roughness workflow.
  116261. * Can also be used to scale the roughness values of the metallic texture.
  116262. */
  116263. protected _roughness: Nullable<number>;
  116264. /**
  116265. * Specifies the an F0 factor to help configuring the material F0.
  116266. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  116267. * to 0.5 the previously hard coded value stays the same.
  116268. * Can also be used to scale the F0 values of the metallic texture.
  116269. */
  116270. protected _metallicF0Factor: number;
  116271. /**
  116272. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  116273. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  116274. * your expectation as it multiplies with the texture data.
  116275. */
  116276. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  116277. /**
  116278. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  116279. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  116280. */
  116281. protected _microSurfaceTexture: Nullable<BaseTexture>;
  116282. /**
  116283. * Stores surface normal data used to displace a mesh in a texture.
  116284. */
  116285. protected _bumpTexture: Nullable<BaseTexture>;
  116286. /**
  116287. * Stores the pre-calculated light information of a mesh in a texture.
  116288. */
  116289. protected _lightmapTexture: Nullable<BaseTexture>;
  116290. /**
  116291. * The color of a material in ambient lighting.
  116292. */
  116293. protected _ambientColor: Color3;
  116294. /**
  116295. * AKA Diffuse Color in other nomenclature.
  116296. */
  116297. protected _albedoColor: Color3;
  116298. /**
  116299. * AKA Specular Color in other nomenclature.
  116300. */
  116301. protected _reflectivityColor: Color3;
  116302. /**
  116303. * The color applied when light is reflected from a material.
  116304. */
  116305. protected _reflectionColor: Color3;
  116306. /**
  116307. * The color applied when light is emitted from a material.
  116308. */
  116309. protected _emissiveColor: Color3;
  116310. /**
  116311. * AKA Glossiness in other nomenclature.
  116312. */
  116313. protected _microSurface: number;
  116314. /**
  116315. * Specifies that the material will use the light map as a show map.
  116316. */
  116317. protected _useLightmapAsShadowmap: boolean;
  116318. /**
  116319. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  116320. * makes the reflect vector face the model (under horizon).
  116321. */
  116322. protected _useHorizonOcclusion: boolean;
  116323. /**
  116324. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  116325. * too much the area relying on ambient texture to define their ambient occlusion.
  116326. */
  116327. protected _useRadianceOcclusion: boolean;
  116328. /**
  116329. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  116330. */
  116331. protected _useAlphaFromAlbedoTexture: boolean;
  116332. /**
  116333. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  116334. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  116335. */
  116336. protected _useSpecularOverAlpha: boolean;
  116337. /**
  116338. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  116339. */
  116340. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  116341. /**
  116342. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  116343. */
  116344. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  116345. /**
  116346. * Specifies if the metallic texture contains the roughness information in its green channel.
  116347. */
  116348. protected _useRoughnessFromMetallicTextureGreen: boolean;
  116349. /**
  116350. * Specifies if the metallic texture contains the metallness information in its blue channel.
  116351. */
  116352. protected _useMetallnessFromMetallicTextureBlue: boolean;
  116353. /**
  116354. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  116355. */
  116356. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  116357. /**
  116358. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  116359. */
  116360. protected _useAmbientInGrayScale: boolean;
  116361. /**
  116362. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  116363. * The material will try to infer what glossiness each pixel should be.
  116364. */
  116365. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  116366. /**
  116367. * Defines the falloff type used in this material.
  116368. * It by default is Physical.
  116369. */
  116370. protected _lightFalloff: number;
  116371. /**
  116372. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  116373. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  116374. */
  116375. protected _useRadianceOverAlpha: boolean;
  116376. /**
  116377. * Allows using an object space normal map (instead of tangent space).
  116378. */
  116379. protected _useObjectSpaceNormalMap: boolean;
  116380. /**
  116381. * Allows using the bump map in parallax mode.
  116382. */
  116383. protected _useParallax: boolean;
  116384. /**
  116385. * Allows using the bump map in parallax occlusion mode.
  116386. */
  116387. protected _useParallaxOcclusion: boolean;
  116388. /**
  116389. * Controls the scale bias of the parallax mode.
  116390. */
  116391. protected _parallaxScaleBias: number;
  116392. /**
  116393. * If sets to true, disables all the lights affecting the material.
  116394. */
  116395. protected _disableLighting: boolean;
  116396. /**
  116397. * Number of Simultaneous lights allowed on the material.
  116398. */
  116399. protected _maxSimultaneousLights: number;
  116400. /**
  116401. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  116402. */
  116403. protected _invertNormalMapX: boolean;
  116404. /**
  116405. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  116406. */
  116407. protected _invertNormalMapY: boolean;
  116408. /**
  116409. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116410. */
  116411. protected _twoSidedLighting: boolean;
  116412. /**
  116413. * Defines the alpha limits in alpha test mode.
  116414. */
  116415. protected _alphaCutOff: number;
  116416. /**
  116417. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  116418. */
  116419. protected _forceAlphaTest: boolean;
  116420. /**
  116421. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116422. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  116423. */
  116424. protected _useAlphaFresnel: boolean;
  116425. /**
  116426. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116427. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  116428. */
  116429. protected _useLinearAlphaFresnel: boolean;
  116430. /**
  116431. * The transparency mode of the material.
  116432. */
  116433. protected _transparencyMode: Nullable<number>;
  116434. /**
  116435. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  116436. * from cos thetav and roughness:
  116437. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  116438. */
  116439. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  116440. /**
  116441. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  116442. */
  116443. protected _forceIrradianceInFragment: boolean;
  116444. /**
  116445. * Force normal to face away from face.
  116446. */
  116447. protected _forceNormalForward: boolean;
  116448. /**
  116449. * Enables specular anti aliasing in the PBR shader.
  116450. * It will both interacts on the Geometry for analytical and IBL lighting.
  116451. * It also prefilter the roughness map based on the bump values.
  116452. */
  116453. protected _enableSpecularAntiAliasing: boolean;
  116454. /**
  116455. * Default configuration related to image processing available in the PBR Material.
  116456. */
  116457. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116458. /**
  116459. * Keep track of the image processing observer to allow dispose and replace.
  116460. */
  116461. private _imageProcessingObserver;
  116462. /**
  116463. * Attaches a new image processing configuration to the PBR Material.
  116464. * @param configuration
  116465. */
  116466. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  116467. /**
  116468. * Stores the available render targets.
  116469. */
  116470. private _renderTargets;
  116471. /**
  116472. * Sets the global ambient color for the material used in lighting calculations.
  116473. */
  116474. private _globalAmbientColor;
  116475. /**
  116476. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  116477. */
  116478. private _useLogarithmicDepth;
  116479. /**
  116480. * If set to true, no lighting calculations will be applied.
  116481. */
  116482. private _unlit;
  116483. private _debugMode;
  116484. /**
  116485. * @hidden
  116486. * This is reserved for the inspector.
  116487. * Defines the material debug mode.
  116488. * It helps seeing only some components of the material while troubleshooting.
  116489. */
  116490. debugMode: number;
  116491. /**
  116492. * @hidden
  116493. * This is reserved for the inspector.
  116494. * Specify from where on screen the debug mode should start.
  116495. * The value goes from -1 (full screen) to 1 (not visible)
  116496. * It helps with side by side comparison against the final render
  116497. * This defaults to -1
  116498. */
  116499. private debugLimit;
  116500. /**
  116501. * @hidden
  116502. * This is reserved for the inspector.
  116503. * As the default viewing range might not be enough (if the ambient is really small for instance)
  116504. * You can use the factor to better multiply the final value.
  116505. */
  116506. private debugFactor;
  116507. /**
  116508. * Defines the clear coat layer parameters for the material.
  116509. */
  116510. readonly clearCoat: PBRClearCoatConfiguration;
  116511. /**
  116512. * Defines the anisotropic parameters for the material.
  116513. */
  116514. readonly anisotropy: PBRAnisotropicConfiguration;
  116515. /**
  116516. * Defines the BRDF parameters for the material.
  116517. */
  116518. readonly brdf: PBRBRDFConfiguration;
  116519. /**
  116520. * Defines the Sheen parameters for the material.
  116521. */
  116522. readonly sheen: PBRSheenConfiguration;
  116523. /**
  116524. * Defines the SubSurface parameters for the material.
  116525. */
  116526. readonly subSurface: PBRSubSurfaceConfiguration;
  116527. /**
  116528. * Custom callback helping to override the default shader used in the material.
  116529. */
  116530. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  116531. protected _rebuildInParallel: boolean;
  116532. /**
  116533. * Instantiates a new PBRMaterial instance.
  116534. *
  116535. * @param name The material name
  116536. * @param scene The scene the material will be use in.
  116537. */
  116538. constructor(name: string, scene: Scene);
  116539. /**
  116540. * Gets a boolean indicating that current material needs to register RTT
  116541. */
  116542. readonly hasRenderTargetTextures: boolean;
  116543. /**
  116544. * Gets the name of the material class.
  116545. */
  116546. getClassName(): string;
  116547. /**
  116548. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  116549. */
  116550. /**
  116551. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  116552. */
  116553. useLogarithmicDepth: boolean;
  116554. /**
  116555. * Gets the current transparency mode.
  116556. */
  116557. /**
  116558. * Sets the transparency mode of the material.
  116559. *
  116560. * | Value | Type | Description |
  116561. * | ----- | ----------------------------------- | ----------- |
  116562. * | 0 | OPAQUE | |
  116563. * | 1 | ALPHATEST | |
  116564. * | 2 | ALPHABLEND | |
  116565. * | 3 | ALPHATESTANDBLEND | |
  116566. *
  116567. */
  116568. transparencyMode: Nullable<number>;
  116569. /**
  116570. * Returns true if alpha blending should be disabled.
  116571. */
  116572. private readonly _disableAlphaBlending;
  116573. /**
  116574. * Specifies whether or not this material should be rendered in alpha blend mode.
  116575. */
  116576. needAlphaBlending(): boolean;
  116577. /**
  116578. * Specifies if the mesh will require alpha blending.
  116579. * @param mesh - BJS mesh.
  116580. */
  116581. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  116582. /**
  116583. * Specifies whether or not this material should be rendered in alpha test mode.
  116584. */
  116585. needAlphaTesting(): boolean;
  116586. /**
  116587. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  116588. */
  116589. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  116590. /**
  116591. * Gets the texture used for the alpha test.
  116592. */
  116593. getAlphaTestTexture(): Nullable<BaseTexture>;
  116594. /**
  116595. * Specifies that the submesh is ready to be used.
  116596. * @param mesh - BJS mesh.
  116597. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  116598. * @param useInstances - Specifies that instances should be used.
  116599. * @returns - boolean indicating that the submesh is ready or not.
  116600. */
  116601. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  116602. /**
  116603. * Specifies if the material uses metallic roughness workflow.
  116604. * @returns boolean specifiying if the material uses metallic roughness workflow.
  116605. */
  116606. isMetallicWorkflow(): boolean;
  116607. private _prepareEffect;
  116608. private _prepareDefines;
  116609. /**
  116610. * Force shader compilation
  116611. */
  116612. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  116613. /**
  116614. * Initializes the uniform buffer layout for the shader.
  116615. */
  116616. buildUniformLayout(): void;
  116617. /**
  116618. * Unbinds the material from the mesh
  116619. */
  116620. unbind(): void;
  116621. /**
  116622. * Binds the submesh data.
  116623. * @param world - The world matrix.
  116624. * @param mesh - The BJS mesh.
  116625. * @param subMesh - A submesh of the BJS mesh.
  116626. */
  116627. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  116628. /**
  116629. * Returns the animatable textures.
  116630. * @returns - Array of animatable textures.
  116631. */
  116632. getAnimatables(): IAnimatable[];
  116633. /**
  116634. * Returns the texture used for reflections.
  116635. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  116636. */
  116637. private _getReflectionTexture;
  116638. /**
  116639. * Returns an array of the actively used textures.
  116640. * @returns - Array of BaseTextures
  116641. */
  116642. getActiveTextures(): BaseTexture[];
  116643. /**
  116644. * Checks to see if a texture is used in the material.
  116645. * @param texture - Base texture to use.
  116646. * @returns - Boolean specifying if a texture is used in the material.
  116647. */
  116648. hasTexture(texture: BaseTexture): boolean;
  116649. /**
  116650. * Disposes the resources of the material.
  116651. * @param forceDisposeEffect - Forces the disposal of effects.
  116652. * @param forceDisposeTextures - Forces the disposal of all textures.
  116653. */
  116654. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  116655. }
  116656. }
  116657. declare module BABYLON {
  116658. /**
  116659. * The Physically based material of BJS.
  116660. *
  116661. * This offers the main features of a standard PBR material.
  116662. * For more information, please refer to the documentation :
  116663. * https://doc.babylonjs.com/how_to/physically_based_rendering
  116664. */
  116665. export class PBRMaterial extends PBRBaseMaterial {
  116666. /**
  116667. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  116668. */
  116669. static readonly PBRMATERIAL_OPAQUE: number;
  116670. /**
  116671. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  116672. */
  116673. static readonly PBRMATERIAL_ALPHATEST: number;
  116674. /**
  116675. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116676. */
  116677. static readonly PBRMATERIAL_ALPHABLEND: number;
  116678. /**
  116679. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116680. * They are also discarded below the alpha cutoff threshold to improve performances.
  116681. */
  116682. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  116683. /**
  116684. * Defines the default value of how much AO map is occluding the analytical lights
  116685. * (point spot...).
  116686. */
  116687. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  116688. /**
  116689. * Intensity of the direct lights e.g. the four lights available in your scene.
  116690. * This impacts both the direct diffuse and specular highlights.
  116691. */
  116692. directIntensity: number;
  116693. /**
  116694. * Intensity of the emissive part of the material.
  116695. * This helps controlling the emissive effect without modifying the emissive color.
  116696. */
  116697. emissiveIntensity: number;
  116698. /**
  116699. * Intensity of the environment e.g. how much the environment will light the object
  116700. * either through harmonics for rough material or through the refelction for shiny ones.
  116701. */
  116702. environmentIntensity: number;
  116703. /**
  116704. * This is a special control allowing the reduction of the specular highlights coming from the
  116705. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  116706. */
  116707. specularIntensity: number;
  116708. /**
  116709. * Debug Control allowing disabling the bump map on this material.
  116710. */
  116711. disableBumpMap: boolean;
  116712. /**
  116713. * AKA Diffuse Texture in standard nomenclature.
  116714. */
  116715. albedoTexture: BaseTexture;
  116716. /**
  116717. * AKA Occlusion Texture in other nomenclature.
  116718. */
  116719. ambientTexture: BaseTexture;
  116720. /**
  116721. * AKA Occlusion Texture Intensity in other nomenclature.
  116722. */
  116723. ambientTextureStrength: number;
  116724. /**
  116725. * Defines how much the AO map is occluding the analytical lights (point spot...).
  116726. * 1 means it completely occludes it
  116727. * 0 mean it has no impact
  116728. */
  116729. ambientTextureImpactOnAnalyticalLights: number;
  116730. /**
  116731. * Stores the alpha values in a texture.
  116732. */
  116733. opacityTexture: BaseTexture;
  116734. /**
  116735. * Stores the reflection values in a texture.
  116736. */
  116737. reflectionTexture: Nullable<BaseTexture>;
  116738. /**
  116739. * Stores the emissive values in a texture.
  116740. */
  116741. emissiveTexture: BaseTexture;
  116742. /**
  116743. * AKA Specular texture in other nomenclature.
  116744. */
  116745. reflectivityTexture: BaseTexture;
  116746. /**
  116747. * Used to switch from specular/glossiness to metallic/roughness workflow.
  116748. */
  116749. metallicTexture: BaseTexture;
  116750. /**
  116751. * Specifies the metallic scalar of the metallic/roughness workflow.
  116752. * Can also be used to scale the metalness values of the metallic texture.
  116753. */
  116754. metallic: Nullable<number>;
  116755. /**
  116756. * Specifies the roughness scalar of the metallic/roughness workflow.
  116757. * Can also be used to scale the roughness values of the metallic texture.
  116758. */
  116759. roughness: Nullable<number>;
  116760. /**
  116761. * Specifies the an F0 factor to help configuring the material F0.
  116762. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  116763. * to 0.5 the previously hard coded value stays the same.
  116764. * Can also be used to scale the F0 values of the metallic texture.
  116765. */
  116766. metallicF0Factor: number;
  116767. /**
  116768. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  116769. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  116770. * your expectation as it multiplies with the texture data.
  116771. */
  116772. useMetallicF0FactorFromMetallicTexture: boolean;
  116773. /**
  116774. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  116775. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  116776. */
  116777. microSurfaceTexture: BaseTexture;
  116778. /**
  116779. * Stores surface normal data used to displace a mesh in a texture.
  116780. */
  116781. bumpTexture: BaseTexture;
  116782. /**
  116783. * Stores the pre-calculated light information of a mesh in a texture.
  116784. */
  116785. lightmapTexture: BaseTexture;
  116786. /**
  116787. * Stores the refracted light information in a texture.
  116788. */
  116789. refractionTexture: Nullable<BaseTexture>;
  116790. /**
  116791. * The color of a material in ambient lighting.
  116792. */
  116793. ambientColor: Color3;
  116794. /**
  116795. * AKA Diffuse Color in other nomenclature.
  116796. */
  116797. albedoColor: Color3;
  116798. /**
  116799. * AKA Specular Color in other nomenclature.
  116800. */
  116801. reflectivityColor: Color3;
  116802. /**
  116803. * The color reflected from the material.
  116804. */
  116805. reflectionColor: Color3;
  116806. /**
  116807. * The color emitted from the material.
  116808. */
  116809. emissiveColor: Color3;
  116810. /**
  116811. * AKA Glossiness in other nomenclature.
  116812. */
  116813. microSurface: number;
  116814. /**
  116815. * source material index of refraction (IOR)' / 'destination material IOR.
  116816. */
  116817. indexOfRefraction: number;
  116818. /**
  116819. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  116820. */
  116821. invertRefractionY: boolean;
  116822. /**
  116823. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  116824. * Materials half opaque for instance using refraction could benefit from this control.
  116825. */
  116826. linkRefractionWithTransparency: boolean;
  116827. /**
  116828. * If true, the light map contains occlusion information instead of lighting info.
  116829. */
  116830. useLightmapAsShadowmap: boolean;
  116831. /**
  116832. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  116833. */
  116834. useAlphaFromAlbedoTexture: boolean;
  116835. /**
  116836. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  116837. */
  116838. forceAlphaTest: boolean;
  116839. /**
  116840. * Defines the alpha limits in alpha test mode.
  116841. */
  116842. alphaCutOff: number;
  116843. /**
  116844. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  116845. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  116846. */
  116847. useSpecularOverAlpha: boolean;
  116848. /**
  116849. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  116850. */
  116851. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  116852. /**
  116853. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  116854. */
  116855. useRoughnessFromMetallicTextureAlpha: boolean;
  116856. /**
  116857. * Specifies if the metallic texture contains the roughness information in its green channel.
  116858. */
  116859. useRoughnessFromMetallicTextureGreen: boolean;
  116860. /**
  116861. * Specifies if the metallic texture contains the metallness information in its blue channel.
  116862. */
  116863. useMetallnessFromMetallicTextureBlue: boolean;
  116864. /**
  116865. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  116866. */
  116867. useAmbientOcclusionFromMetallicTextureRed: boolean;
  116868. /**
  116869. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  116870. */
  116871. useAmbientInGrayScale: boolean;
  116872. /**
  116873. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  116874. * The material will try to infer what glossiness each pixel should be.
  116875. */
  116876. useAutoMicroSurfaceFromReflectivityMap: boolean;
  116877. /**
  116878. * BJS is using an harcoded light falloff based on a manually sets up range.
  116879. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  116880. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  116881. */
  116882. /**
  116883. * BJS is using an harcoded light falloff based on a manually sets up range.
  116884. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  116885. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  116886. */
  116887. usePhysicalLightFalloff: boolean;
  116888. /**
  116889. * In order to support the falloff compatibility with gltf, a special mode has been added
  116890. * to reproduce the gltf light falloff.
  116891. */
  116892. /**
  116893. * In order to support the falloff compatibility with gltf, a special mode has been added
  116894. * to reproduce the gltf light falloff.
  116895. */
  116896. useGLTFLightFalloff: boolean;
  116897. /**
  116898. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  116899. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  116900. */
  116901. useRadianceOverAlpha: boolean;
  116902. /**
  116903. * Allows using an object space normal map (instead of tangent space).
  116904. */
  116905. useObjectSpaceNormalMap: boolean;
  116906. /**
  116907. * Allows using the bump map in parallax mode.
  116908. */
  116909. useParallax: boolean;
  116910. /**
  116911. * Allows using the bump map in parallax occlusion mode.
  116912. */
  116913. useParallaxOcclusion: boolean;
  116914. /**
  116915. * Controls the scale bias of the parallax mode.
  116916. */
  116917. parallaxScaleBias: number;
  116918. /**
  116919. * If sets to true, disables all the lights affecting the material.
  116920. */
  116921. disableLighting: boolean;
  116922. /**
  116923. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  116924. */
  116925. forceIrradianceInFragment: boolean;
  116926. /**
  116927. * Number of Simultaneous lights allowed on the material.
  116928. */
  116929. maxSimultaneousLights: number;
  116930. /**
  116931. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  116932. */
  116933. invertNormalMapX: boolean;
  116934. /**
  116935. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  116936. */
  116937. invertNormalMapY: boolean;
  116938. /**
  116939. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116940. */
  116941. twoSidedLighting: boolean;
  116942. /**
  116943. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116944. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  116945. */
  116946. useAlphaFresnel: boolean;
  116947. /**
  116948. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116949. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  116950. */
  116951. useLinearAlphaFresnel: boolean;
  116952. /**
  116953. * Let user defines the brdf lookup texture used for IBL.
  116954. * A default 8bit version is embedded but you could point at :
  116955. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  116956. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  116957. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  116958. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  116959. */
  116960. environmentBRDFTexture: Nullable<BaseTexture>;
  116961. /**
  116962. * Force normal to face away from face.
  116963. */
  116964. forceNormalForward: boolean;
  116965. /**
  116966. * Enables specular anti aliasing in the PBR shader.
  116967. * It will both interacts on the Geometry for analytical and IBL lighting.
  116968. * It also prefilter the roughness map based on the bump values.
  116969. */
  116970. enableSpecularAntiAliasing: boolean;
  116971. /**
  116972. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  116973. * makes the reflect vector face the model (under horizon).
  116974. */
  116975. useHorizonOcclusion: boolean;
  116976. /**
  116977. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  116978. * too much the area relying on ambient texture to define their ambient occlusion.
  116979. */
  116980. useRadianceOcclusion: boolean;
  116981. /**
  116982. * If set to true, no lighting calculations will be applied.
  116983. */
  116984. unlit: boolean;
  116985. /**
  116986. * Gets the image processing configuration used either in this material.
  116987. */
  116988. /**
  116989. * Sets the Default image processing configuration used either in the this material.
  116990. *
  116991. * If sets to null, the scene one is in use.
  116992. */
  116993. imageProcessingConfiguration: ImageProcessingConfiguration;
  116994. /**
  116995. * Gets wether the color curves effect is enabled.
  116996. */
  116997. /**
  116998. * Sets wether the color curves effect is enabled.
  116999. */
  117000. cameraColorCurvesEnabled: boolean;
  117001. /**
  117002. * Gets wether the color grading effect is enabled.
  117003. */
  117004. /**
  117005. * Gets wether the color grading effect is enabled.
  117006. */
  117007. cameraColorGradingEnabled: boolean;
  117008. /**
  117009. * Gets wether tonemapping is enabled or not.
  117010. */
  117011. /**
  117012. * Sets wether tonemapping is enabled or not
  117013. */
  117014. cameraToneMappingEnabled: boolean;
  117015. /**
  117016. * The camera exposure used on this material.
  117017. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  117018. * This corresponds to a photographic exposure.
  117019. */
  117020. /**
  117021. * The camera exposure used on this material.
  117022. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  117023. * This corresponds to a photographic exposure.
  117024. */
  117025. cameraExposure: number;
  117026. /**
  117027. * Gets The camera contrast used on this material.
  117028. */
  117029. /**
  117030. * Sets The camera contrast used on this material.
  117031. */
  117032. cameraContrast: number;
  117033. /**
  117034. * Gets the Color Grading 2D Lookup Texture.
  117035. */
  117036. /**
  117037. * Sets the Color Grading 2D Lookup Texture.
  117038. */
  117039. cameraColorGradingTexture: Nullable<BaseTexture>;
  117040. /**
  117041. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117042. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117043. * 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;
  117044. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117045. */
  117046. /**
  117047. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117048. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117049. * 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;
  117050. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117051. */
  117052. cameraColorCurves: Nullable<ColorCurves>;
  117053. /**
  117054. * Instantiates a new PBRMaterial instance.
  117055. *
  117056. * @param name The material name
  117057. * @param scene The scene the material will be use in.
  117058. */
  117059. constructor(name: string, scene: Scene);
  117060. /**
  117061. * Returns the name of this material class.
  117062. */
  117063. getClassName(): string;
  117064. /**
  117065. * Makes a duplicate of the current material.
  117066. * @param name - name to use for the new material.
  117067. */
  117068. clone(name: string): PBRMaterial;
  117069. /**
  117070. * Serializes this PBR Material.
  117071. * @returns - An object with the serialized material.
  117072. */
  117073. serialize(): any;
  117074. /**
  117075. * Parses a PBR Material from a serialized object.
  117076. * @param source - Serialized object.
  117077. * @param scene - BJS scene instance.
  117078. * @param rootUrl - url for the scene object
  117079. * @returns - PBRMaterial
  117080. */
  117081. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  117082. }
  117083. }
  117084. declare module BABYLON {
  117085. /**
  117086. * Direct draw surface info
  117087. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  117088. */
  117089. export interface DDSInfo {
  117090. /**
  117091. * Width of the texture
  117092. */
  117093. width: number;
  117094. /**
  117095. * Width of the texture
  117096. */
  117097. height: number;
  117098. /**
  117099. * Number of Mipmaps for the texture
  117100. * @see https://en.wikipedia.org/wiki/Mipmap
  117101. */
  117102. mipmapCount: number;
  117103. /**
  117104. * If the textures format is a known fourCC format
  117105. * @see https://www.fourcc.org/
  117106. */
  117107. isFourCC: boolean;
  117108. /**
  117109. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  117110. */
  117111. isRGB: boolean;
  117112. /**
  117113. * If the texture is a lumincance format
  117114. */
  117115. isLuminance: boolean;
  117116. /**
  117117. * If this is a cube texture
  117118. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  117119. */
  117120. isCube: boolean;
  117121. /**
  117122. * If the texture is a compressed format eg. FOURCC_DXT1
  117123. */
  117124. isCompressed: boolean;
  117125. /**
  117126. * The dxgiFormat of the texture
  117127. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  117128. */
  117129. dxgiFormat: number;
  117130. /**
  117131. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  117132. */
  117133. textureType: number;
  117134. /**
  117135. * Sphericle polynomial created for the dds texture
  117136. */
  117137. sphericalPolynomial?: SphericalPolynomial;
  117138. }
  117139. /**
  117140. * Class used to provide DDS decompression tools
  117141. */
  117142. export class DDSTools {
  117143. /**
  117144. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  117145. */
  117146. static StoreLODInAlphaChannel: boolean;
  117147. /**
  117148. * Gets DDS information from an array buffer
  117149. * @param arrayBuffer defines the array buffer to read data from
  117150. * @returns the DDS information
  117151. */
  117152. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  117153. private static _FloatView;
  117154. private static _Int32View;
  117155. private static _ToHalfFloat;
  117156. private static _FromHalfFloat;
  117157. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  117158. private static _GetHalfFloatRGBAArrayBuffer;
  117159. private static _GetFloatRGBAArrayBuffer;
  117160. private static _GetFloatAsUIntRGBAArrayBuffer;
  117161. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  117162. private static _GetRGBAArrayBuffer;
  117163. private static _ExtractLongWordOrder;
  117164. private static _GetRGBArrayBuffer;
  117165. private static _GetLuminanceArrayBuffer;
  117166. /**
  117167. * Uploads DDS Levels to a Babylon Texture
  117168. * @hidden
  117169. */
  117170. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  117171. }
  117172. interface ThinEngine {
  117173. /**
  117174. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  117175. * @param rootUrl defines the url where the file to load is located
  117176. * @param scene defines the current scene
  117177. * @param lodScale defines scale to apply to the mip map selection
  117178. * @param lodOffset defines offset to apply to the mip map selection
  117179. * @param onLoad defines an optional callback raised when the texture is loaded
  117180. * @param onError defines an optional callback raised if there is an issue to load the texture
  117181. * @param format defines the format of the data
  117182. * @param forcedExtension defines the extension to use to pick the right loader
  117183. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  117184. * @returns the cube texture as an InternalTexture
  117185. */
  117186. 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;
  117187. }
  117188. }
  117189. declare module BABYLON {
  117190. /**
  117191. * Implementation of the DDS Texture Loader.
  117192. * @hidden
  117193. */
  117194. export class _DDSTextureLoader implements IInternalTextureLoader {
  117195. /**
  117196. * Defines wether the loader supports cascade loading the different faces.
  117197. */
  117198. readonly supportCascades: boolean;
  117199. /**
  117200. * This returns if the loader support the current file information.
  117201. * @param extension defines the file extension of the file being loaded
  117202. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117203. * @param fallback defines the fallback internal texture if any
  117204. * @param isBase64 defines whether the texture is encoded as a base64
  117205. * @param isBuffer defines whether the texture data are stored as a buffer
  117206. * @returns true if the loader can load the specified file
  117207. */
  117208. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117209. /**
  117210. * Transform the url before loading if required.
  117211. * @param rootUrl the url of the texture
  117212. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117213. * @returns the transformed texture
  117214. */
  117215. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117216. /**
  117217. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117218. * @param rootUrl the url of the texture
  117219. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117220. * @returns the fallback texture
  117221. */
  117222. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117223. /**
  117224. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117225. * @param data contains the texture data
  117226. * @param texture defines the BabylonJS internal texture
  117227. * @param createPolynomials will be true if polynomials have been requested
  117228. * @param onLoad defines the callback to trigger once the texture is ready
  117229. * @param onError defines the callback to trigger in case of error
  117230. */
  117231. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117232. /**
  117233. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117234. * @param data contains the texture data
  117235. * @param texture defines the BabylonJS internal texture
  117236. * @param callback defines the method to call once ready to upload
  117237. */
  117238. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117239. }
  117240. }
  117241. declare module BABYLON {
  117242. /**
  117243. * Implementation of the ENV Texture Loader.
  117244. * @hidden
  117245. */
  117246. export class _ENVTextureLoader implements IInternalTextureLoader {
  117247. /**
  117248. * Defines wether the loader supports cascade loading the different faces.
  117249. */
  117250. readonly supportCascades: boolean;
  117251. /**
  117252. * This returns if the loader support the current file information.
  117253. * @param extension defines the file extension of the file being loaded
  117254. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117255. * @param fallback defines the fallback internal texture if any
  117256. * @param isBase64 defines whether the texture is encoded as a base64
  117257. * @param isBuffer defines whether the texture data are stored as a buffer
  117258. * @returns true if the loader can load the specified file
  117259. */
  117260. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117261. /**
  117262. * Transform the url before loading if required.
  117263. * @param rootUrl the url of the texture
  117264. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117265. * @returns the transformed texture
  117266. */
  117267. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117268. /**
  117269. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117270. * @param rootUrl the url of the texture
  117271. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117272. * @returns the fallback texture
  117273. */
  117274. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117275. /**
  117276. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117277. * @param data contains the texture data
  117278. * @param texture defines the BabylonJS internal texture
  117279. * @param createPolynomials will be true if polynomials have been requested
  117280. * @param onLoad defines the callback to trigger once the texture is ready
  117281. * @param onError defines the callback to trigger in case of error
  117282. */
  117283. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117284. /**
  117285. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117286. * @param data contains the texture data
  117287. * @param texture defines the BabylonJS internal texture
  117288. * @param callback defines the method to call once ready to upload
  117289. */
  117290. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117291. }
  117292. }
  117293. declare module BABYLON {
  117294. /**
  117295. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  117296. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  117297. */
  117298. export class KhronosTextureContainer {
  117299. /** contents of the KTX container file */
  117300. arrayBuffer: any;
  117301. private static HEADER_LEN;
  117302. private static COMPRESSED_2D;
  117303. private static COMPRESSED_3D;
  117304. private static TEX_2D;
  117305. private static TEX_3D;
  117306. /**
  117307. * Gets the openGL type
  117308. */
  117309. glType: number;
  117310. /**
  117311. * Gets the openGL type size
  117312. */
  117313. glTypeSize: number;
  117314. /**
  117315. * Gets the openGL format
  117316. */
  117317. glFormat: number;
  117318. /**
  117319. * Gets the openGL internal format
  117320. */
  117321. glInternalFormat: number;
  117322. /**
  117323. * Gets the base internal format
  117324. */
  117325. glBaseInternalFormat: number;
  117326. /**
  117327. * Gets image width in pixel
  117328. */
  117329. pixelWidth: number;
  117330. /**
  117331. * Gets image height in pixel
  117332. */
  117333. pixelHeight: number;
  117334. /**
  117335. * Gets image depth in pixels
  117336. */
  117337. pixelDepth: number;
  117338. /**
  117339. * Gets the number of array elements
  117340. */
  117341. numberOfArrayElements: number;
  117342. /**
  117343. * Gets the number of faces
  117344. */
  117345. numberOfFaces: number;
  117346. /**
  117347. * Gets the number of mipmap levels
  117348. */
  117349. numberOfMipmapLevels: number;
  117350. /**
  117351. * Gets the bytes of key value data
  117352. */
  117353. bytesOfKeyValueData: number;
  117354. /**
  117355. * Gets the load type
  117356. */
  117357. loadType: number;
  117358. /**
  117359. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  117360. */
  117361. isInvalid: boolean;
  117362. /**
  117363. * Creates a new KhronosTextureContainer
  117364. * @param arrayBuffer contents of the KTX container file
  117365. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  117366. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  117367. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  117368. */
  117369. constructor(
  117370. /** contents of the KTX container file */
  117371. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  117372. /**
  117373. * Uploads KTX content to a Babylon Texture.
  117374. * It is assumed that the texture has already been created & is currently bound
  117375. * @hidden
  117376. */
  117377. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  117378. private _upload2DCompressedLevels;
  117379. }
  117380. }
  117381. declare module BABYLON {
  117382. /**
  117383. * Implementation of the KTX Texture Loader.
  117384. * @hidden
  117385. */
  117386. export class _KTXTextureLoader implements IInternalTextureLoader {
  117387. /**
  117388. * Defines wether the loader supports cascade loading the different faces.
  117389. */
  117390. readonly supportCascades: boolean;
  117391. /**
  117392. * This returns if the loader support the current file information.
  117393. * @param extension defines the file extension of the file being loaded
  117394. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117395. * @param fallback defines the fallback internal texture if any
  117396. * @param isBase64 defines whether the texture is encoded as a base64
  117397. * @param isBuffer defines whether the texture data are stored as a buffer
  117398. * @returns true if the loader can load the specified file
  117399. */
  117400. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117401. /**
  117402. * Transform the url before loading if required.
  117403. * @param rootUrl the url of the texture
  117404. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117405. * @returns the transformed texture
  117406. */
  117407. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117408. /**
  117409. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117410. * @param rootUrl the url of the texture
  117411. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117412. * @returns the fallback texture
  117413. */
  117414. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117415. /**
  117416. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117417. * @param data contains the texture data
  117418. * @param texture defines the BabylonJS internal texture
  117419. * @param createPolynomials will be true if polynomials have been requested
  117420. * @param onLoad defines the callback to trigger once the texture is ready
  117421. * @param onError defines the callback to trigger in case of error
  117422. */
  117423. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117424. /**
  117425. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117426. * @param data contains the texture data
  117427. * @param texture defines the BabylonJS internal texture
  117428. * @param callback defines the method to call once ready to upload
  117429. */
  117430. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  117431. }
  117432. }
  117433. declare module BABYLON {
  117434. /**
  117435. * Options for the default xr helper
  117436. */
  117437. export class WebXRDefaultExperienceOptions {
  117438. /**
  117439. * Floor meshes that should be used for teleporting
  117440. */
  117441. floorMeshes: Array<AbstractMesh>;
  117442. /**
  117443. * Enable or disable default UI to enter XR
  117444. */
  117445. disableDefaultUI: boolean;
  117446. }
  117447. /**
  117448. * Default experience which provides a similar setup to the previous webVRExperience
  117449. */
  117450. export class WebXRDefaultExperience {
  117451. /**
  117452. * Base experience
  117453. */
  117454. baseExperience: WebXRExperienceHelper;
  117455. /**
  117456. * Input experience extension
  117457. */
  117458. input: WebXRInput;
  117459. /**
  117460. * Loads the controller models
  117461. */
  117462. controllerModelLoader: WebXRControllerModelLoader;
  117463. /**
  117464. * Enables laser pointer and selection
  117465. */
  117466. pointerSelection: WebXRControllerPointerSelection;
  117467. /**
  117468. * Enables teleportation
  117469. */
  117470. teleportation: WebXRControllerTeleportation;
  117471. /**
  117472. * Enables ui for enetering/exiting xr
  117473. */
  117474. enterExitUI: WebXREnterExitUI;
  117475. /**
  117476. * Default target xr should render to
  117477. */
  117478. renderTarget: WebXRRenderTarget;
  117479. /**
  117480. * Creates the default xr experience
  117481. * @param scene scene
  117482. * @param options options for basic configuration
  117483. * @returns resulting WebXRDefaultExperience
  117484. */
  117485. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117486. private constructor();
  117487. /**
  117488. * DIsposes of the experience helper
  117489. */
  117490. dispose(): void;
  117491. }
  117492. }
  117493. declare module BABYLON {
  117494. /** @hidden */
  117495. export var _forceSceneHelpersToBundle: boolean;
  117496. interface Scene {
  117497. /**
  117498. * Creates a default light for the scene.
  117499. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  117500. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  117501. */
  117502. createDefaultLight(replace?: boolean): void;
  117503. /**
  117504. * Creates a default camera for the scene.
  117505. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  117506. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  117507. * @param replace has default false, when true replaces the active camera in the scene
  117508. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  117509. */
  117510. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  117511. /**
  117512. * Creates a default camera and a default light.
  117513. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  117514. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  117515. * @param replace has the default false, when true replaces the active camera/light in the scene
  117516. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  117517. */
  117518. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  117519. /**
  117520. * Creates a new sky box
  117521. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  117522. * @param environmentTexture defines the texture to use as environment texture
  117523. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  117524. * @param scale defines the overall scale of the skybox
  117525. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  117526. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  117527. * @returns a new mesh holding the sky box
  117528. */
  117529. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  117530. /**
  117531. * Creates a new environment
  117532. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  117533. * @param options defines the options you can use to configure the environment
  117534. * @returns the new EnvironmentHelper
  117535. */
  117536. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  117537. /**
  117538. * Creates a new VREXperienceHelper
  117539. * @see http://doc.babylonjs.com/how_to/webvr_helper
  117540. * @param webVROptions defines the options used to create the new VREXperienceHelper
  117541. * @returns a new VREXperienceHelper
  117542. */
  117543. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  117544. /**
  117545. * Creates a new WebXRDefaultExperience
  117546. * @see http://doc.babylonjs.com/how_to/webxr
  117547. * @param options experience options
  117548. * @returns a promise for a new WebXRDefaultExperience
  117549. */
  117550. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117551. }
  117552. }
  117553. declare module BABYLON {
  117554. /**
  117555. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  117556. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  117557. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  117558. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  117559. */
  117560. export class VideoDome extends TransformNode {
  117561. /**
  117562. * Define the video source as a Monoscopic panoramic 360 video.
  117563. */
  117564. static readonly MODE_MONOSCOPIC: number;
  117565. /**
  117566. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  117567. */
  117568. static readonly MODE_TOPBOTTOM: number;
  117569. /**
  117570. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  117571. */
  117572. static readonly MODE_SIDEBYSIDE: number;
  117573. private _halfDome;
  117574. private _useDirectMapping;
  117575. /**
  117576. * The video texture being displayed on the sphere
  117577. */
  117578. protected _videoTexture: VideoTexture;
  117579. /**
  117580. * Gets the video texture being displayed on the sphere
  117581. */
  117582. readonly videoTexture: VideoTexture;
  117583. /**
  117584. * The skybox material
  117585. */
  117586. protected _material: BackgroundMaterial;
  117587. /**
  117588. * The surface used for the skybox
  117589. */
  117590. protected _mesh: Mesh;
  117591. /**
  117592. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  117593. */
  117594. private _halfDomeMask;
  117595. /**
  117596. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  117597. * Also see the options.resolution property.
  117598. */
  117599. fovMultiplier: number;
  117600. private _videoMode;
  117601. /**
  117602. * Gets or set the current video mode for the video. It can be:
  117603. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  117604. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  117605. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  117606. */
  117607. videoMode: number;
  117608. /**
  117609. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  117610. *
  117611. */
  117612. /**
  117613. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  117614. */
  117615. halfDome: boolean;
  117616. /**
  117617. * Oberserver used in Stereoscopic VR Mode.
  117618. */
  117619. private _onBeforeCameraRenderObserver;
  117620. /**
  117621. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  117622. * @param name Element's name, child elements will append suffixes for their own names.
  117623. * @param urlsOrVideo defines the url(s) or the video element to use
  117624. * @param options An object containing optional or exposed sub element properties
  117625. */
  117626. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  117627. resolution?: number;
  117628. clickToPlay?: boolean;
  117629. autoPlay?: boolean;
  117630. loop?: boolean;
  117631. size?: number;
  117632. poster?: string;
  117633. faceForward?: boolean;
  117634. useDirectMapping?: boolean;
  117635. halfDomeMode?: boolean;
  117636. }, scene: Scene);
  117637. private _changeVideoMode;
  117638. /**
  117639. * Releases resources associated with this node.
  117640. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117641. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117642. */
  117643. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117644. }
  117645. }
  117646. declare module BABYLON {
  117647. /**
  117648. * This class can be used to get instrumentation data from a Babylon engine
  117649. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117650. */
  117651. export class EngineInstrumentation implements IDisposable {
  117652. /**
  117653. * Define the instrumented engine.
  117654. */
  117655. engine: Engine;
  117656. private _captureGPUFrameTime;
  117657. private _gpuFrameTimeToken;
  117658. private _gpuFrameTime;
  117659. private _captureShaderCompilationTime;
  117660. private _shaderCompilationTime;
  117661. private _onBeginFrameObserver;
  117662. private _onEndFrameObserver;
  117663. private _onBeforeShaderCompilationObserver;
  117664. private _onAfterShaderCompilationObserver;
  117665. /**
  117666. * Gets the perf counter used for GPU frame time
  117667. */
  117668. readonly gpuFrameTimeCounter: PerfCounter;
  117669. /**
  117670. * Gets the GPU frame time capture status
  117671. */
  117672. /**
  117673. * Enable or disable the GPU frame time capture
  117674. */
  117675. captureGPUFrameTime: boolean;
  117676. /**
  117677. * Gets the perf counter used for shader compilation time
  117678. */
  117679. readonly shaderCompilationTimeCounter: PerfCounter;
  117680. /**
  117681. * Gets the shader compilation time capture status
  117682. */
  117683. /**
  117684. * Enable or disable the shader compilation time capture
  117685. */
  117686. captureShaderCompilationTime: boolean;
  117687. /**
  117688. * Instantiates a new engine instrumentation.
  117689. * This class can be used to get instrumentation data from a Babylon engine
  117690. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117691. * @param engine Defines the engine to instrument
  117692. */
  117693. constructor(
  117694. /**
  117695. * Define the instrumented engine.
  117696. */
  117697. engine: Engine);
  117698. /**
  117699. * Dispose and release associated resources.
  117700. */
  117701. dispose(): void;
  117702. }
  117703. }
  117704. declare module BABYLON {
  117705. /**
  117706. * This class can be used to get instrumentation data from a Babylon engine
  117707. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  117708. */
  117709. export class SceneInstrumentation implements IDisposable {
  117710. /**
  117711. * Defines the scene to instrument
  117712. */
  117713. scene: Scene;
  117714. private _captureActiveMeshesEvaluationTime;
  117715. private _activeMeshesEvaluationTime;
  117716. private _captureRenderTargetsRenderTime;
  117717. private _renderTargetsRenderTime;
  117718. private _captureFrameTime;
  117719. private _frameTime;
  117720. private _captureRenderTime;
  117721. private _renderTime;
  117722. private _captureInterFrameTime;
  117723. private _interFrameTime;
  117724. private _captureParticlesRenderTime;
  117725. private _particlesRenderTime;
  117726. private _captureSpritesRenderTime;
  117727. private _spritesRenderTime;
  117728. private _capturePhysicsTime;
  117729. private _physicsTime;
  117730. private _captureAnimationsTime;
  117731. private _animationsTime;
  117732. private _captureCameraRenderTime;
  117733. private _cameraRenderTime;
  117734. private _onBeforeActiveMeshesEvaluationObserver;
  117735. private _onAfterActiveMeshesEvaluationObserver;
  117736. private _onBeforeRenderTargetsRenderObserver;
  117737. private _onAfterRenderTargetsRenderObserver;
  117738. private _onAfterRenderObserver;
  117739. private _onBeforeDrawPhaseObserver;
  117740. private _onAfterDrawPhaseObserver;
  117741. private _onBeforeAnimationsObserver;
  117742. private _onBeforeParticlesRenderingObserver;
  117743. private _onAfterParticlesRenderingObserver;
  117744. private _onBeforeSpritesRenderingObserver;
  117745. private _onAfterSpritesRenderingObserver;
  117746. private _onBeforePhysicsObserver;
  117747. private _onAfterPhysicsObserver;
  117748. private _onAfterAnimationsObserver;
  117749. private _onBeforeCameraRenderObserver;
  117750. private _onAfterCameraRenderObserver;
  117751. /**
  117752. * Gets the perf counter used for active meshes evaluation time
  117753. */
  117754. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  117755. /**
  117756. * Gets the active meshes evaluation time capture status
  117757. */
  117758. /**
  117759. * Enable or disable the active meshes evaluation time capture
  117760. */
  117761. captureActiveMeshesEvaluationTime: boolean;
  117762. /**
  117763. * Gets the perf counter used for render targets render time
  117764. */
  117765. readonly renderTargetsRenderTimeCounter: PerfCounter;
  117766. /**
  117767. * Gets the render targets render time capture status
  117768. */
  117769. /**
  117770. * Enable or disable the render targets render time capture
  117771. */
  117772. captureRenderTargetsRenderTime: boolean;
  117773. /**
  117774. * Gets the perf counter used for particles render time
  117775. */
  117776. readonly particlesRenderTimeCounter: PerfCounter;
  117777. /**
  117778. * Gets the particles render time capture status
  117779. */
  117780. /**
  117781. * Enable or disable the particles render time capture
  117782. */
  117783. captureParticlesRenderTime: boolean;
  117784. /**
  117785. * Gets the perf counter used for sprites render time
  117786. */
  117787. readonly spritesRenderTimeCounter: PerfCounter;
  117788. /**
  117789. * Gets the sprites render time capture status
  117790. */
  117791. /**
  117792. * Enable or disable the sprites render time capture
  117793. */
  117794. captureSpritesRenderTime: boolean;
  117795. /**
  117796. * Gets the perf counter used for physics time
  117797. */
  117798. readonly physicsTimeCounter: PerfCounter;
  117799. /**
  117800. * Gets the physics time capture status
  117801. */
  117802. /**
  117803. * Enable or disable the physics time capture
  117804. */
  117805. capturePhysicsTime: boolean;
  117806. /**
  117807. * Gets the perf counter used for animations time
  117808. */
  117809. readonly animationsTimeCounter: PerfCounter;
  117810. /**
  117811. * Gets the animations time capture status
  117812. */
  117813. /**
  117814. * Enable or disable the animations time capture
  117815. */
  117816. captureAnimationsTime: boolean;
  117817. /**
  117818. * Gets the perf counter used for frame time capture
  117819. */
  117820. readonly frameTimeCounter: PerfCounter;
  117821. /**
  117822. * Gets the frame time capture status
  117823. */
  117824. /**
  117825. * Enable or disable the frame time capture
  117826. */
  117827. captureFrameTime: boolean;
  117828. /**
  117829. * Gets the perf counter used for inter-frames time capture
  117830. */
  117831. readonly interFrameTimeCounter: PerfCounter;
  117832. /**
  117833. * Gets the inter-frames time capture status
  117834. */
  117835. /**
  117836. * Enable or disable the inter-frames time capture
  117837. */
  117838. captureInterFrameTime: boolean;
  117839. /**
  117840. * Gets the perf counter used for render time capture
  117841. */
  117842. readonly renderTimeCounter: PerfCounter;
  117843. /**
  117844. * Gets the render time capture status
  117845. */
  117846. /**
  117847. * Enable or disable the render time capture
  117848. */
  117849. captureRenderTime: boolean;
  117850. /**
  117851. * Gets the perf counter used for camera render time capture
  117852. */
  117853. readonly cameraRenderTimeCounter: PerfCounter;
  117854. /**
  117855. * Gets the camera render time capture status
  117856. */
  117857. /**
  117858. * Enable or disable the camera render time capture
  117859. */
  117860. captureCameraRenderTime: boolean;
  117861. /**
  117862. * Gets the perf counter used for draw calls
  117863. */
  117864. readonly drawCallsCounter: PerfCounter;
  117865. /**
  117866. * Instantiates a new scene instrumentation.
  117867. * This class can be used to get instrumentation data from a Babylon engine
  117868. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  117869. * @param scene Defines the scene to instrument
  117870. */
  117871. constructor(
  117872. /**
  117873. * Defines the scene to instrument
  117874. */
  117875. scene: Scene);
  117876. /**
  117877. * Dispose and release associated resources.
  117878. */
  117879. dispose(): void;
  117880. }
  117881. }
  117882. declare module BABYLON {
  117883. /** @hidden */
  117884. export var glowMapGenerationPixelShader: {
  117885. name: string;
  117886. shader: string;
  117887. };
  117888. }
  117889. declare module BABYLON {
  117890. /** @hidden */
  117891. export var glowMapGenerationVertexShader: {
  117892. name: string;
  117893. shader: string;
  117894. };
  117895. }
  117896. declare module BABYLON {
  117897. /**
  117898. * Effect layer options. This helps customizing the behaviour
  117899. * of the effect layer.
  117900. */
  117901. export interface IEffectLayerOptions {
  117902. /**
  117903. * Multiplication factor apply to the canvas size to compute the render target size
  117904. * used to generated the objects (the smaller the faster).
  117905. */
  117906. mainTextureRatio: number;
  117907. /**
  117908. * Enforces a fixed size texture to ensure effect stability across devices.
  117909. */
  117910. mainTextureFixedSize?: number;
  117911. /**
  117912. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  117913. */
  117914. alphaBlendingMode: number;
  117915. /**
  117916. * The camera attached to the layer.
  117917. */
  117918. camera: Nullable<Camera>;
  117919. /**
  117920. * The rendering group to draw the layer in.
  117921. */
  117922. renderingGroupId: number;
  117923. }
  117924. /**
  117925. * The effect layer Helps adding post process effect blended with the main pass.
  117926. *
  117927. * This can be for instance use to generate glow or higlight effects on the scene.
  117928. *
  117929. * The effect layer class can not be used directly and is intented to inherited from to be
  117930. * customized per effects.
  117931. */
  117932. export abstract class EffectLayer {
  117933. private _vertexBuffers;
  117934. private _indexBuffer;
  117935. private _cachedDefines;
  117936. private _effectLayerMapGenerationEffect;
  117937. private _effectLayerOptions;
  117938. private _mergeEffect;
  117939. protected _scene: Scene;
  117940. protected _engine: Engine;
  117941. protected _maxSize: number;
  117942. protected _mainTextureDesiredSize: ISize;
  117943. protected _mainTexture: RenderTargetTexture;
  117944. protected _shouldRender: boolean;
  117945. protected _postProcesses: PostProcess[];
  117946. protected _textures: BaseTexture[];
  117947. protected _emissiveTextureAndColor: {
  117948. texture: Nullable<BaseTexture>;
  117949. color: Color4;
  117950. };
  117951. /**
  117952. * The name of the layer
  117953. */
  117954. name: string;
  117955. /**
  117956. * The clear color of the texture used to generate the glow map.
  117957. */
  117958. neutralColor: Color4;
  117959. /**
  117960. * Specifies wether the highlight layer is enabled or not.
  117961. */
  117962. isEnabled: boolean;
  117963. /**
  117964. * Gets the camera attached to the layer.
  117965. */
  117966. readonly camera: Nullable<Camera>;
  117967. /**
  117968. * Gets the rendering group id the layer should render in.
  117969. */
  117970. renderingGroupId: number;
  117971. /**
  117972. * An event triggered when the effect layer has been disposed.
  117973. */
  117974. onDisposeObservable: Observable<EffectLayer>;
  117975. /**
  117976. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  117977. */
  117978. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  117979. /**
  117980. * An event triggered when the generated texture is being merged in the scene.
  117981. */
  117982. onBeforeComposeObservable: Observable<EffectLayer>;
  117983. /**
  117984. * An event triggered when the mesh is rendered into the effect render target.
  117985. */
  117986. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  117987. /**
  117988. * An event triggered after the mesh has been rendered into the effect render target.
  117989. */
  117990. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  117991. /**
  117992. * An event triggered when the generated texture has been merged in the scene.
  117993. */
  117994. onAfterComposeObservable: Observable<EffectLayer>;
  117995. /**
  117996. * An event triggered when the efffect layer changes its size.
  117997. */
  117998. onSizeChangedObservable: Observable<EffectLayer>;
  117999. /** @hidden */
  118000. static _SceneComponentInitialization: (scene: Scene) => void;
  118001. /**
  118002. * Instantiates a new effect Layer and references it in the scene.
  118003. * @param name The name of the layer
  118004. * @param scene The scene to use the layer in
  118005. */
  118006. constructor(
  118007. /** The Friendly of the effect in the scene */
  118008. name: string, scene: Scene);
  118009. /**
  118010. * Get the effect name of the layer.
  118011. * @return The effect name
  118012. */
  118013. abstract getEffectName(): string;
  118014. /**
  118015. * Checks for the readiness of the element composing the layer.
  118016. * @param subMesh the mesh to check for
  118017. * @param useInstances specify wether or not to use instances to render the mesh
  118018. * @return true if ready otherwise, false
  118019. */
  118020. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118021. /**
  118022. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118023. * @returns true if the effect requires stencil during the main canvas render pass.
  118024. */
  118025. abstract needStencil(): boolean;
  118026. /**
  118027. * Create the merge effect. This is the shader use to blit the information back
  118028. * to the main canvas at the end of the scene rendering.
  118029. * @returns The effect containing the shader used to merge the effect on the main canvas
  118030. */
  118031. protected abstract _createMergeEffect(): Effect;
  118032. /**
  118033. * Creates the render target textures and post processes used in the effect layer.
  118034. */
  118035. protected abstract _createTextureAndPostProcesses(): void;
  118036. /**
  118037. * Implementation specific of rendering the generating effect on the main canvas.
  118038. * @param effect The effect used to render through
  118039. */
  118040. protected abstract _internalRender(effect: Effect): void;
  118041. /**
  118042. * Sets the required values for both the emissive texture and and the main color.
  118043. */
  118044. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118045. /**
  118046. * Free any resources and references associated to a mesh.
  118047. * Internal use
  118048. * @param mesh The mesh to free.
  118049. */
  118050. abstract _disposeMesh(mesh: Mesh): void;
  118051. /**
  118052. * Serializes this layer (Glow or Highlight for example)
  118053. * @returns a serialized layer object
  118054. */
  118055. abstract serialize?(): any;
  118056. /**
  118057. * Initializes the effect layer with the required options.
  118058. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  118059. */
  118060. protected _init(options: Partial<IEffectLayerOptions>): void;
  118061. /**
  118062. * Generates the index buffer of the full screen quad blending to the main canvas.
  118063. */
  118064. private _generateIndexBuffer;
  118065. /**
  118066. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  118067. */
  118068. private _generateVertexBuffer;
  118069. /**
  118070. * Sets the main texture desired size which is the closest power of two
  118071. * of the engine canvas size.
  118072. */
  118073. private _setMainTextureSize;
  118074. /**
  118075. * Creates the main texture for the effect layer.
  118076. */
  118077. protected _createMainTexture(): void;
  118078. /**
  118079. * Adds specific effects defines.
  118080. * @param defines The defines to add specifics to.
  118081. */
  118082. protected _addCustomEffectDefines(defines: string[]): void;
  118083. /**
  118084. * Checks for the readiness of the element composing the layer.
  118085. * @param subMesh the mesh to check for
  118086. * @param useInstances specify wether or not to use instances to render the mesh
  118087. * @param emissiveTexture the associated emissive texture used to generate the glow
  118088. * @return true if ready otherwise, false
  118089. */
  118090. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  118091. /**
  118092. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  118093. */
  118094. render(): void;
  118095. /**
  118096. * Determine if a given mesh will be used in the current effect.
  118097. * @param mesh mesh to test
  118098. * @returns true if the mesh will be used
  118099. */
  118100. hasMesh(mesh: AbstractMesh): boolean;
  118101. /**
  118102. * Returns true if the layer contains information to display, otherwise false.
  118103. * @returns true if the glow layer should be rendered
  118104. */
  118105. shouldRender(): boolean;
  118106. /**
  118107. * Returns true if the mesh should render, otherwise false.
  118108. * @param mesh The mesh to render
  118109. * @returns true if it should render otherwise false
  118110. */
  118111. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  118112. /**
  118113. * Returns true if the mesh can be rendered, otherwise false.
  118114. * @param mesh The mesh to render
  118115. * @param material The material used on the mesh
  118116. * @returns true if it can be rendered otherwise false
  118117. */
  118118. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  118119. /**
  118120. * Returns true if the mesh should render, otherwise false.
  118121. * @param mesh The mesh to render
  118122. * @returns true if it should render otherwise false
  118123. */
  118124. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  118125. /**
  118126. * Renders the submesh passed in parameter to the generation map.
  118127. */
  118128. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  118129. /**
  118130. * Defines wether the current material of the mesh should be use to render the effect.
  118131. * @param mesh defines the current mesh to render
  118132. */
  118133. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  118134. /**
  118135. * Rebuild the required buffers.
  118136. * @hidden Internal use only.
  118137. */
  118138. _rebuild(): void;
  118139. /**
  118140. * Dispose only the render target textures and post process.
  118141. */
  118142. private _disposeTextureAndPostProcesses;
  118143. /**
  118144. * Dispose the highlight layer and free resources.
  118145. */
  118146. dispose(): void;
  118147. /**
  118148. * Gets the class name of the effect layer
  118149. * @returns the string with the class name of the effect layer
  118150. */
  118151. getClassName(): string;
  118152. /**
  118153. * Creates an effect layer from parsed effect layer data
  118154. * @param parsedEffectLayer defines effect layer data
  118155. * @param scene defines the current scene
  118156. * @param rootUrl defines the root URL containing the effect layer information
  118157. * @returns a parsed effect Layer
  118158. */
  118159. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  118160. }
  118161. }
  118162. declare module BABYLON {
  118163. interface AbstractScene {
  118164. /**
  118165. * The list of effect layers (highlights/glow) added to the scene
  118166. * @see http://doc.babylonjs.com/how_to/highlight_layer
  118167. * @see http://doc.babylonjs.com/how_to/glow_layer
  118168. */
  118169. effectLayers: Array<EffectLayer>;
  118170. /**
  118171. * Removes the given effect layer from this scene.
  118172. * @param toRemove defines the effect layer to remove
  118173. * @returns the index of the removed effect layer
  118174. */
  118175. removeEffectLayer(toRemove: EffectLayer): number;
  118176. /**
  118177. * Adds the given effect layer to this scene
  118178. * @param newEffectLayer defines the effect layer to add
  118179. */
  118180. addEffectLayer(newEffectLayer: EffectLayer): void;
  118181. }
  118182. /**
  118183. * Defines the layer scene component responsible to manage any effect layers
  118184. * in a given scene.
  118185. */
  118186. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  118187. /**
  118188. * The component name helpfull to identify the component in the list of scene components.
  118189. */
  118190. readonly name: string;
  118191. /**
  118192. * The scene the component belongs to.
  118193. */
  118194. scene: Scene;
  118195. private _engine;
  118196. private _renderEffects;
  118197. private _needStencil;
  118198. private _previousStencilState;
  118199. /**
  118200. * Creates a new instance of the component for the given scene
  118201. * @param scene Defines the scene to register the component in
  118202. */
  118203. constructor(scene: Scene);
  118204. /**
  118205. * Registers the component in a given scene
  118206. */
  118207. register(): void;
  118208. /**
  118209. * Rebuilds the elements related to this component in case of
  118210. * context lost for instance.
  118211. */
  118212. rebuild(): void;
  118213. /**
  118214. * Serializes the component data to the specified json object
  118215. * @param serializationObject The object to serialize to
  118216. */
  118217. serialize(serializationObject: any): void;
  118218. /**
  118219. * Adds all the elements from the container to the scene
  118220. * @param container the container holding the elements
  118221. */
  118222. addFromContainer(container: AbstractScene): void;
  118223. /**
  118224. * Removes all the elements in the container from the scene
  118225. * @param container contains the elements to remove
  118226. * @param dispose if the removed element should be disposed (default: false)
  118227. */
  118228. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118229. /**
  118230. * Disposes the component and the associated ressources.
  118231. */
  118232. dispose(): void;
  118233. private _isReadyForMesh;
  118234. private _renderMainTexture;
  118235. private _setStencil;
  118236. private _setStencilBack;
  118237. private _draw;
  118238. private _drawCamera;
  118239. private _drawRenderingGroup;
  118240. }
  118241. }
  118242. declare module BABYLON {
  118243. /** @hidden */
  118244. export var glowMapMergePixelShader: {
  118245. name: string;
  118246. shader: string;
  118247. };
  118248. }
  118249. declare module BABYLON {
  118250. /** @hidden */
  118251. export var glowMapMergeVertexShader: {
  118252. name: string;
  118253. shader: string;
  118254. };
  118255. }
  118256. declare module BABYLON {
  118257. interface AbstractScene {
  118258. /**
  118259. * Return a the first highlight layer of the scene with a given name.
  118260. * @param name The name of the highlight layer to look for.
  118261. * @return The highlight layer if found otherwise null.
  118262. */
  118263. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  118264. }
  118265. /**
  118266. * Glow layer options. This helps customizing the behaviour
  118267. * of the glow layer.
  118268. */
  118269. export interface IGlowLayerOptions {
  118270. /**
  118271. * Multiplication factor apply to the canvas size to compute the render target size
  118272. * used to generated the glowing objects (the smaller the faster).
  118273. */
  118274. mainTextureRatio: number;
  118275. /**
  118276. * Enforces a fixed size texture to ensure resize independant blur.
  118277. */
  118278. mainTextureFixedSize?: number;
  118279. /**
  118280. * How big is the kernel of the blur texture.
  118281. */
  118282. blurKernelSize: number;
  118283. /**
  118284. * The camera attached to the layer.
  118285. */
  118286. camera: Nullable<Camera>;
  118287. /**
  118288. * Enable MSAA by chosing the number of samples.
  118289. */
  118290. mainTextureSamples?: number;
  118291. /**
  118292. * The rendering group to draw the layer in.
  118293. */
  118294. renderingGroupId: number;
  118295. }
  118296. /**
  118297. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  118298. *
  118299. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  118300. *
  118301. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  118302. */
  118303. export class GlowLayer extends EffectLayer {
  118304. /**
  118305. * Effect Name of the layer.
  118306. */
  118307. static readonly EffectName: string;
  118308. /**
  118309. * The default blur kernel size used for the glow.
  118310. */
  118311. static DefaultBlurKernelSize: number;
  118312. /**
  118313. * The default texture size ratio used for the glow.
  118314. */
  118315. static DefaultTextureRatio: number;
  118316. /**
  118317. * Sets the kernel size of the blur.
  118318. */
  118319. /**
  118320. * Gets the kernel size of the blur.
  118321. */
  118322. blurKernelSize: number;
  118323. /**
  118324. * Sets the glow intensity.
  118325. */
  118326. /**
  118327. * Gets the glow intensity.
  118328. */
  118329. intensity: number;
  118330. private _options;
  118331. private _intensity;
  118332. private _horizontalBlurPostprocess1;
  118333. private _verticalBlurPostprocess1;
  118334. private _horizontalBlurPostprocess2;
  118335. private _verticalBlurPostprocess2;
  118336. private _blurTexture1;
  118337. private _blurTexture2;
  118338. private _postProcesses1;
  118339. private _postProcesses2;
  118340. private _includedOnlyMeshes;
  118341. private _excludedMeshes;
  118342. private _meshesUsingTheirOwnMaterials;
  118343. /**
  118344. * Callback used to let the user override the color selection on a per mesh basis
  118345. */
  118346. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  118347. /**
  118348. * Callback used to let the user override the texture selection on a per mesh basis
  118349. */
  118350. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  118351. /**
  118352. * Instantiates a new glow Layer and references it to the scene.
  118353. * @param name The name of the layer
  118354. * @param scene The scene to use the layer in
  118355. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  118356. */
  118357. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  118358. /**
  118359. * Get the effect name of the layer.
  118360. * @return The effect name
  118361. */
  118362. getEffectName(): string;
  118363. /**
  118364. * Create the merge effect. This is the shader use to blit the information back
  118365. * to the main canvas at the end of the scene rendering.
  118366. */
  118367. protected _createMergeEffect(): Effect;
  118368. /**
  118369. * Creates the render target textures and post processes used in the glow layer.
  118370. */
  118371. protected _createTextureAndPostProcesses(): void;
  118372. /**
  118373. * Checks for the readiness of the element composing the layer.
  118374. * @param subMesh the mesh to check for
  118375. * @param useInstances specify wether or not to use instances to render the mesh
  118376. * @param emissiveTexture the associated emissive texture used to generate the glow
  118377. * @return true if ready otherwise, false
  118378. */
  118379. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118380. /**
  118381. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118382. */
  118383. needStencil(): boolean;
  118384. /**
  118385. * Returns true if the mesh can be rendered, otherwise false.
  118386. * @param mesh The mesh to render
  118387. * @param material The material used on the mesh
  118388. * @returns true if it can be rendered otherwise false
  118389. */
  118390. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  118391. /**
  118392. * Implementation specific of rendering the generating effect on the main canvas.
  118393. * @param effect The effect used to render through
  118394. */
  118395. protected _internalRender(effect: Effect): void;
  118396. /**
  118397. * Sets the required values for both the emissive texture and and the main color.
  118398. */
  118399. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118400. /**
  118401. * Returns true if the mesh should render, otherwise false.
  118402. * @param mesh The mesh to render
  118403. * @returns true if it should render otherwise false
  118404. */
  118405. protected _shouldRenderMesh(mesh: Mesh): boolean;
  118406. /**
  118407. * Adds specific effects defines.
  118408. * @param defines The defines to add specifics to.
  118409. */
  118410. protected _addCustomEffectDefines(defines: string[]): void;
  118411. /**
  118412. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  118413. * @param mesh The mesh to exclude from the glow layer
  118414. */
  118415. addExcludedMesh(mesh: Mesh): void;
  118416. /**
  118417. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  118418. * @param mesh The mesh to remove
  118419. */
  118420. removeExcludedMesh(mesh: Mesh): void;
  118421. /**
  118422. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  118423. * @param mesh The mesh to include in the glow layer
  118424. */
  118425. addIncludedOnlyMesh(mesh: Mesh): void;
  118426. /**
  118427. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  118428. * @param mesh The mesh to remove
  118429. */
  118430. removeIncludedOnlyMesh(mesh: Mesh): void;
  118431. /**
  118432. * Determine if a given mesh will be used in the glow layer
  118433. * @param mesh The mesh to test
  118434. * @returns true if the mesh will be highlighted by the current glow layer
  118435. */
  118436. hasMesh(mesh: AbstractMesh): boolean;
  118437. /**
  118438. * Defines wether the current material of the mesh should be use to render the effect.
  118439. * @param mesh defines the current mesh to render
  118440. */
  118441. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  118442. /**
  118443. * Add a mesh to be rendered through its own material and not with emissive only.
  118444. * @param mesh The mesh for which we need to use its material
  118445. */
  118446. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  118447. /**
  118448. * Remove a mesh from being rendered through its own material and not with emissive only.
  118449. * @param mesh The mesh for which we need to not use its material
  118450. */
  118451. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  118452. /**
  118453. * Free any resources and references associated to a mesh.
  118454. * Internal use
  118455. * @param mesh The mesh to free.
  118456. * @hidden
  118457. */
  118458. _disposeMesh(mesh: Mesh): void;
  118459. /**
  118460. * Gets the class name of the effect layer
  118461. * @returns the string with the class name of the effect layer
  118462. */
  118463. getClassName(): string;
  118464. /**
  118465. * Serializes this glow layer
  118466. * @returns a serialized glow layer object
  118467. */
  118468. serialize(): any;
  118469. /**
  118470. * Creates a Glow Layer from parsed glow layer data
  118471. * @param parsedGlowLayer defines glow layer data
  118472. * @param scene defines the current scene
  118473. * @param rootUrl defines the root URL containing the glow layer information
  118474. * @returns a parsed Glow Layer
  118475. */
  118476. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  118477. }
  118478. }
  118479. declare module BABYLON {
  118480. /** @hidden */
  118481. export var glowBlurPostProcessPixelShader: {
  118482. name: string;
  118483. shader: string;
  118484. };
  118485. }
  118486. declare module BABYLON {
  118487. interface AbstractScene {
  118488. /**
  118489. * Return a the first highlight layer of the scene with a given name.
  118490. * @param name The name of the highlight layer to look for.
  118491. * @return The highlight layer if found otherwise null.
  118492. */
  118493. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  118494. }
  118495. /**
  118496. * Highlight layer options. This helps customizing the behaviour
  118497. * of the highlight layer.
  118498. */
  118499. export interface IHighlightLayerOptions {
  118500. /**
  118501. * Multiplication factor apply to the canvas size to compute the render target size
  118502. * used to generated the glowing objects (the smaller the faster).
  118503. */
  118504. mainTextureRatio: number;
  118505. /**
  118506. * Enforces a fixed size texture to ensure resize independant blur.
  118507. */
  118508. mainTextureFixedSize?: number;
  118509. /**
  118510. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  118511. * of the picture to blur (the smaller the faster).
  118512. */
  118513. blurTextureSizeRatio: number;
  118514. /**
  118515. * How big in texel of the blur texture is the vertical blur.
  118516. */
  118517. blurVerticalSize: number;
  118518. /**
  118519. * How big in texel of the blur texture is the horizontal blur.
  118520. */
  118521. blurHorizontalSize: number;
  118522. /**
  118523. * Alpha blending mode used to apply the blur. Default is combine.
  118524. */
  118525. alphaBlendingMode: number;
  118526. /**
  118527. * The camera attached to the layer.
  118528. */
  118529. camera: Nullable<Camera>;
  118530. /**
  118531. * Should we display highlight as a solid stroke?
  118532. */
  118533. isStroke?: boolean;
  118534. /**
  118535. * The rendering group to draw the layer in.
  118536. */
  118537. renderingGroupId: number;
  118538. }
  118539. /**
  118540. * The highlight layer Helps adding a glow effect around a mesh.
  118541. *
  118542. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  118543. * glowy meshes to your scene.
  118544. *
  118545. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  118546. */
  118547. export class HighlightLayer extends EffectLayer {
  118548. name: string;
  118549. /**
  118550. * Effect Name of the highlight layer.
  118551. */
  118552. static readonly EffectName: string;
  118553. /**
  118554. * The neutral color used during the preparation of the glow effect.
  118555. * This is black by default as the blend operation is a blend operation.
  118556. */
  118557. static NeutralColor: Color4;
  118558. /**
  118559. * Stencil value used for glowing meshes.
  118560. */
  118561. static GlowingMeshStencilReference: number;
  118562. /**
  118563. * Stencil value used for the other meshes in the scene.
  118564. */
  118565. static NormalMeshStencilReference: number;
  118566. /**
  118567. * Specifies whether or not the inner glow is ACTIVE in the layer.
  118568. */
  118569. innerGlow: boolean;
  118570. /**
  118571. * Specifies whether or not the outer glow is ACTIVE in the layer.
  118572. */
  118573. outerGlow: boolean;
  118574. /**
  118575. * Specifies the horizontal size of the blur.
  118576. */
  118577. /**
  118578. * Gets the horizontal size of the blur.
  118579. */
  118580. blurHorizontalSize: number;
  118581. /**
  118582. * Specifies the vertical size of the blur.
  118583. */
  118584. /**
  118585. * Gets the vertical size of the blur.
  118586. */
  118587. blurVerticalSize: number;
  118588. /**
  118589. * An event triggered when the highlight layer is being blurred.
  118590. */
  118591. onBeforeBlurObservable: Observable<HighlightLayer>;
  118592. /**
  118593. * An event triggered when the highlight layer has been blurred.
  118594. */
  118595. onAfterBlurObservable: Observable<HighlightLayer>;
  118596. private _instanceGlowingMeshStencilReference;
  118597. private _options;
  118598. private _downSamplePostprocess;
  118599. private _horizontalBlurPostprocess;
  118600. private _verticalBlurPostprocess;
  118601. private _blurTexture;
  118602. private _meshes;
  118603. private _excludedMeshes;
  118604. /**
  118605. * Instantiates a new highlight Layer and references it to the scene..
  118606. * @param name The name of the layer
  118607. * @param scene The scene to use the layer in
  118608. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  118609. */
  118610. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  118611. /**
  118612. * Get the effect name of the layer.
  118613. * @return The effect name
  118614. */
  118615. getEffectName(): string;
  118616. /**
  118617. * Create the merge effect. This is the shader use to blit the information back
  118618. * to the main canvas at the end of the scene rendering.
  118619. */
  118620. protected _createMergeEffect(): Effect;
  118621. /**
  118622. * Creates the render target textures and post processes used in the highlight layer.
  118623. */
  118624. protected _createTextureAndPostProcesses(): void;
  118625. /**
  118626. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118627. */
  118628. needStencil(): boolean;
  118629. /**
  118630. * Checks for the readiness of the element composing the layer.
  118631. * @param subMesh the mesh to check for
  118632. * @param useInstances specify wether or not to use instances to render the mesh
  118633. * @param emissiveTexture the associated emissive texture used to generate the glow
  118634. * @return true if ready otherwise, false
  118635. */
  118636. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118637. /**
  118638. * Implementation specific of rendering the generating effect on the main canvas.
  118639. * @param effect The effect used to render through
  118640. */
  118641. protected _internalRender(effect: Effect): void;
  118642. /**
  118643. * Returns true if the layer contains information to display, otherwise false.
  118644. */
  118645. shouldRender(): boolean;
  118646. /**
  118647. * Returns true if the mesh should render, otherwise false.
  118648. * @param mesh The mesh to render
  118649. * @returns true if it should render otherwise false
  118650. */
  118651. protected _shouldRenderMesh(mesh: Mesh): boolean;
  118652. /**
  118653. * Sets the required values for both the emissive texture and and the main color.
  118654. */
  118655. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118656. /**
  118657. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  118658. * @param mesh The mesh to exclude from the highlight layer
  118659. */
  118660. addExcludedMesh(mesh: Mesh): void;
  118661. /**
  118662. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  118663. * @param mesh The mesh to highlight
  118664. */
  118665. removeExcludedMesh(mesh: Mesh): void;
  118666. /**
  118667. * Determine if a given mesh will be highlighted by the current HighlightLayer
  118668. * @param mesh mesh to test
  118669. * @returns true if the mesh will be highlighted by the current HighlightLayer
  118670. */
  118671. hasMesh(mesh: AbstractMesh): boolean;
  118672. /**
  118673. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  118674. * @param mesh The mesh to highlight
  118675. * @param color The color of the highlight
  118676. * @param glowEmissiveOnly Extract the glow from the emissive texture
  118677. */
  118678. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  118679. /**
  118680. * Remove a mesh from the highlight layer in order to make it stop glowing.
  118681. * @param mesh The mesh to highlight
  118682. */
  118683. removeMesh(mesh: Mesh): void;
  118684. /**
  118685. * Force the stencil to the normal expected value for none glowing parts
  118686. */
  118687. private _defaultStencilReference;
  118688. /**
  118689. * Free any resources and references associated to a mesh.
  118690. * Internal use
  118691. * @param mesh The mesh to free.
  118692. * @hidden
  118693. */
  118694. _disposeMesh(mesh: Mesh): void;
  118695. /**
  118696. * Dispose the highlight layer and free resources.
  118697. */
  118698. dispose(): void;
  118699. /**
  118700. * Gets the class name of the effect layer
  118701. * @returns the string with the class name of the effect layer
  118702. */
  118703. getClassName(): string;
  118704. /**
  118705. * Serializes this Highlight layer
  118706. * @returns a serialized Highlight layer object
  118707. */
  118708. serialize(): any;
  118709. /**
  118710. * Creates a Highlight layer from parsed Highlight layer data
  118711. * @param parsedHightlightLayer defines the Highlight layer data
  118712. * @param scene defines the current scene
  118713. * @param rootUrl defines the root URL containing the Highlight layer information
  118714. * @returns a parsed Highlight layer
  118715. */
  118716. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  118717. }
  118718. }
  118719. declare module BABYLON {
  118720. interface AbstractScene {
  118721. /**
  118722. * The list of layers (background and foreground) of the scene
  118723. */
  118724. layers: Array<Layer>;
  118725. }
  118726. /**
  118727. * Defines the layer scene component responsible to manage any layers
  118728. * in a given scene.
  118729. */
  118730. export class LayerSceneComponent implements ISceneComponent {
  118731. /**
  118732. * The component name helpfull to identify the component in the list of scene components.
  118733. */
  118734. readonly name: string;
  118735. /**
  118736. * The scene the component belongs to.
  118737. */
  118738. scene: Scene;
  118739. private _engine;
  118740. /**
  118741. * Creates a new instance of the component for the given scene
  118742. * @param scene Defines the scene to register the component in
  118743. */
  118744. constructor(scene: Scene);
  118745. /**
  118746. * Registers the component in a given scene
  118747. */
  118748. register(): void;
  118749. /**
  118750. * Rebuilds the elements related to this component in case of
  118751. * context lost for instance.
  118752. */
  118753. rebuild(): void;
  118754. /**
  118755. * Disposes the component and the associated ressources.
  118756. */
  118757. dispose(): void;
  118758. private _draw;
  118759. private _drawCameraPredicate;
  118760. private _drawCameraBackground;
  118761. private _drawCameraForeground;
  118762. private _drawRenderTargetPredicate;
  118763. private _drawRenderTargetBackground;
  118764. private _drawRenderTargetForeground;
  118765. /**
  118766. * Adds all the elements from the container to the scene
  118767. * @param container the container holding the elements
  118768. */
  118769. addFromContainer(container: AbstractScene): void;
  118770. /**
  118771. * Removes all the elements in the container from the scene
  118772. * @param container contains the elements to remove
  118773. * @param dispose if the removed element should be disposed (default: false)
  118774. */
  118775. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118776. }
  118777. }
  118778. declare module BABYLON {
  118779. /** @hidden */
  118780. export var layerPixelShader: {
  118781. name: string;
  118782. shader: string;
  118783. };
  118784. }
  118785. declare module BABYLON {
  118786. /** @hidden */
  118787. export var layerVertexShader: {
  118788. name: string;
  118789. shader: string;
  118790. };
  118791. }
  118792. declare module BABYLON {
  118793. /**
  118794. * This represents a full screen 2d layer.
  118795. * This can be useful to display a picture in the background of your scene for instance.
  118796. * @see https://www.babylonjs-playground.com/#08A2BS#1
  118797. */
  118798. export class Layer {
  118799. /**
  118800. * Define the name of the layer.
  118801. */
  118802. name: string;
  118803. /**
  118804. * Define the texture the layer should display.
  118805. */
  118806. texture: Nullable<Texture>;
  118807. /**
  118808. * Is the layer in background or foreground.
  118809. */
  118810. isBackground: boolean;
  118811. /**
  118812. * Define the color of the layer (instead of texture).
  118813. */
  118814. color: Color4;
  118815. /**
  118816. * Define the scale of the layer in order to zoom in out of the texture.
  118817. */
  118818. scale: Vector2;
  118819. /**
  118820. * Define an offset for the layer in order to shift the texture.
  118821. */
  118822. offset: Vector2;
  118823. /**
  118824. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  118825. */
  118826. alphaBlendingMode: number;
  118827. /**
  118828. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  118829. * Alpha test will not mix with the background color in case of transparency.
  118830. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  118831. */
  118832. alphaTest: boolean;
  118833. /**
  118834. * Define a mask to restrict the layer to only some of the scene cameras.
  118835. */
  118836. layerMask: number;
  118837. /**
  118838. * Define the list of render target the layer is visible into.
  118839. */
  118840. renderTargetTextures: RenderTargetTexture[];
  118841. /**
  118842. * Define if the layer is only used in renderTarget or if it also
  118843. * renders in the main frame buffer of the canvas.
  118844. */
  118845. renderOnlyInRenderTargetTextures: boolean;
  118846. private _scene;
  118847. private _vertexBuffers;
  118848. private _indexBuffer;
  118849. private _effect;
  118850. private _alphaTestEffect;
  118851. /**
  118852. * An event triggered when the layer is disposed.
  118853. */
  118854. onDisposeObservable: Observable<Layer>;
  118855. private _onDisposeObserver;
  118856. /**
  118857. * Back compatibility with callback before the onDisposeObservable existed.
  118858. * The set callback will be triggered when the layer has been disposed.
  118859. */
  118860. onDispose: () => void;
  118861. /**
  118862. * An event triggered before rendering the scene
  118863. */
  118864. onBeforeRenderObservable: Observable<Layer>;
  118865. private _onBeforeRenderObserver;
  118866. /**
  118867. * Back compatibility with callback before the onBeforeRenderObservable existed.
  118868. * The set callback will be triggered just before rendering the layer.
  118869. */
  118870. onBeforeRender: () => void;
  118871. /**
  118872. * An event triggered after rendering the scene
  118873. */
  118874. onAfterRenderObservable: Observable<Layer>;
  118875. private _onAfterRenderObserver;
  118876. /**
  118877. * Back compatibility with callback before the onAfterRenderObservable existed.
  118878. * The set callback will be triggered just after rendering the layer.
  118879. */
  118880. onAfterRender: () => void;
  118881. /**
  118882. * Instantiates a new layer.
  118883. * This represents a full screen 2d layer.
  118884. * This can be useful to display a picture in the background of your scene for instance.
  118885. * @see https://www.babylonjs-playground.com/#08A2BS#1
  118886. * @param name Define the name of the layer in the scene
  118887. * @param imgUrl Define the url of the texture to display in the layer
  118888. * @param scene Define the scene the layer belongs to
  118889. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  118890. * @param color Defines a color for the layer
  118891. */
  118892. constructor(
  118893. /**
  118894. * Define the name of the layer.
  118895. */
  118896. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  118897. private _createIndexBuffer;
  118898. /** @hidden */
  118899. _rebuild(): void;
  118900. /**
  118901. * Renders the layer in the scene.
  118902. */
  118903. render(): void;
  118904. /**
  118905. * Disposes and releases the associated ressources.
  118906. */
  118907. dispose(): void;
  118908. }
  118909. }
  118910. declare module BABYLON {
  118911. /** @hidden */
  118912. export var lensFlarePixelShader: {
  118913. name: string;
  118914. shader: string;
  118915. };
  118916. }
  118917. declare module BABYLON {
  118918. /** @hidden */
  118919. export var lensFlareVertexShader: {
  118920. name: string;
  118921. shader: string;
  118922. };
  118923. }
  118924. declare module BABYLON {
  118925. /**
  118926. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  118927. * It is usually composed of several `lensFlare`.
  118928. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118929. */
  118930. export class LensFlareSystem {
  118931. /**
  118932. * Define the name of the lens flare system
  118933. */
  118934. name: string;
  118935. /**
  118936. * List of lens flares used in this system.
  118937. */
  118938. lensFlares: LensFlare[];
  118939. /**
  118940. * Define a limit from the border the lens flare can be visible.
  118941. */
  118942. borderLimit: number;
  118943. /**
  118944. * Define a viewport border we do not want to see the lens flare in.
  118945. */
  118946. viewportBorder: number;
  118947. /**
  118948. * Define a predicate which could limit the list of meshes able to occlude the effect.
  118949. */
  118950. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118951. /**
  118952. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  118953. */
  118954. layerMask: number;
  118955. /**
  118956. * Define the id of the lens flare system in the scene.
  118957. * (equal to name by default)
  118958. */
  118959. id: string;
  118960. private _scene;
  118961. private _emitter;
  118962. private _vertexBuffers;
  118963. private _indexBuffer;
  118964. private _effect;
  118965. private _positionX;
  118966. private _positionY;
  118967. private _isEnabled;
  118968. /** @hidden */
  118969. static _SceneComponentInitialization: (scene: Scene) => void;
  118970. /**
  118971. * Instantiates a lens flare system.
  118972. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  118973. * It is usually composed of several `lensFlare`.
  118974. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118975. * @param name Define the name of the lens flare system in the scene
  118976. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  118977. * @param scene Define the scene the lens flare system belongs to
  118978. */
  118979. constructor(
  118980. /**
  118981. * Define the name of the lens flare system
  118982. */
  118983. name: string, emitter: any, scene: Scene);
  118984. /**
  118985. * Define if the lens flare system is enabled.
  118986. */
  118987. isEnabled: boolean;
  118988. /**
  118989. * Get the scene the effects belongs to.
  118990. * @returns the scene holding the lens flare system
  118991. */
  118992. getScene(): Scene;
  118993. /**
  118994. * Get the emitter of the lens flare system.
  118995. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  118996. * @returns the emitter of the lens flare system
  118997. */
  118998. getEmitter(): any;
  118999. /**
  119000. * Set the emitter of the lens flare system.
  119001. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  119002. * @param newEmitter Define the new emitter of the system
  119003. */
  119004. setEmitter(newEmitter: any): void;
  119005. /**
  119006. * Get the lens flare system emitter position.
  119007. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  119008. * @returns the position
  119009. */
  119010. getEmitterPosition(): Vector3;
  119011. /**
  119012. * @hidden
  119013. */
  119014. computeEffectivePosition(globalViewport: Viewport): boolean;
  119015. /** @hidden */
  119016. _isVisible(): boolean;
  119017. /**
  119018. * @hidden
  119019. */
  119020. render(): boolean;
  119021. /**
  119022. * Dispose and release the lens flare with its associated resources.
  119023. */
  119024. dispose(): void;
  119025. /**
  119026. * Parse a lens flare system from a JSON repressentation
  119027. * @param parsedLensFlareSystem Define the JSON to parse
  119028. * @param scene Define the scene the parsed system should be instantiated in
  119029. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  119030. * @returns the parsed system
  119031. */
  119032. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  119033. /**
  119034. * Serialize the current Lens Flare System into a JSON representation.
  119035. * @returns the serialized JSON
  119036. */
  119037. serialize(): any;
  119038. }
  119039. }
  119040. declare module BABYLON {
  119041. /**
  119042. * This represents one of the lens effect in a `lensFlareSystem`.
  119043. * It controls one of the indiviual texture used in the effect.
  119044. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119045. */
  119046. export class LensFlare {
  119047. /**
  119048. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119049. */
  119050. size: number;
  119051. /**
  119052. * 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.
  119053. */
  119054. position: number;
  119055. /**
  119056. * Define the lens color.
  119057. */
  119058. color: Color3;
  119059. /**
  119060. * Define the lens texture.
  119061. */
  119062. texture: Nullable<Texture>;
  119063. /**
  119064. * Define the alpha mode to render this particular lens.
  119065. */
  119066. alphaMode: number;
  119067. private _system;
  119068. /**
  119069. * Creates a new Lens Flare.
  119070. * This represents one of the lens effect in a `lensFlareSystem`.
  119071. * It controls one of the indiviual texture used in the effect.
  119072. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119073. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  119074. * @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.
  119075. * @param color Define the lens color
  119076. * @param imgUrl Define the lens texture url
  119077. * @param system Define the `lensFlareSystem` this flare is part of
  119078. * @returns The newly created Lens Flare
  119079. */
  119080. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  119081. /**
  119082. * Instantiates a new Lens Flare.
  119083. * This represents one of the lens effect in a `lensFlareSystem`.
  119084. * It controls one of the indiviual texture used in the effect.
  119085. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119086. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  119087. * @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.
  119088. * @param color Define the lens color
  119089. * @param imgUrl Define the lens texture url
  119090. * @param system Define the `lensFlareSystem` this flare is part of
  119091. */
  119092. constructor(
  119093. /**
  119094. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119095. */
  119096. size: number,
  119097. /**
  119098. * 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.
  119099. */
  119100. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  119101. /**
  119102. * Dispose and release the lens flare with its associated resources.
  119103. */
  119104. dispose(): void;
  119105. }
  119106. }
  119107. declare module BABYLON {
  119108. interface AbstractScene {
  119109. /**
  119110. * The list of lens flare system added to the scene
  119111. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119112. */
  119113. lensFlareSystems: Array<LensFlareSystem>;
  119114. /**
  119115. * Removes the given lens flare system from this scene.
  119116. * @param toRemove The lens flare system to remove
  119117. * @returns The index of the removed lens flare system
  119118. */
  119119. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  119120. /**
  119121. * Adds the given lens flare system to this scene
  119122. * @param newLensFlareSystem The lens flare system to add
  119123. */
  119124. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  119125. /**
  119126. * Gets a lens flare system using its name
  119127. * @param name defines the name to look for
  119128. * @returns the lens flare system or null if not found
  119129. */
  119130. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  119131. /**
  119132. * Gets a lens flare system using its id
  119133. * @param id defines the id to look for
  119134. * @returns the lens flare system or null if not found
  119135. */
  119136. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  119137. }
  119138. /**
  119139. * Defines the lens flare scene component responsible to manage any lens flares
  119140. * in a given scene.
  119141. */
  119142. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  119143. /**
  119144. * The component name helpfull to identify the component in the list of scene components.
  119145. */
  119146. readonly name: string;
  119147. /**
  119148. * The scene the component belongs to.
  119149. */
  119150. scene: Scene;
  119151. /**
  119152. * Creates a new instance of the component for the given scene
  119153. * @param scene Defines the scene to register the component in
  119154. */
  119155. constructor(scene: Scene);
  119156. /**
  119157. * Registers the component in a given scene
  119158. */
  119159. register(): void;
  119160. /**
  119161. * Rebuilds the elements related to this component in case of
  119162. * context lost for instance.
  119163. */
  119164. rebuild(): void;
  119165. /**
  119166. * Adds all the elements from the container to the scene
  119167. * @param container the container holding the elements
  119168. */
  119169. addFromContainer(container: AbstractScene): void;
  119170. /**
  119171. * Removes all the elements in the container from the scene
  119172. * @param container contains the elements to remove
  119173. * @param dispose if the removed element should be disposed (default: false)
  119174. */
  119175. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119176. /**
  119177. * Serializes the component data to the specified json object
  119178. * @param serializationObject The object to serialize to
  119179. */
  119180. serialize(serializationObject: any): void;
  119181. /**
  119182. * Disposes the component and the associated ressources.
  119183. */
  119184. dispose(): void;
  119185. private _draw;
  119186. }
  119187. }
  119188. declare module BABYLON {
  119189. /**
  119190. * Defines the shadow generator component responsible to manage any shadow generators
  119191. * in a given scene.
  119192. */
  119193. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  119194. /**
  119195. * The component name helpfull to identify the component in the list of scene components.
  119196. */
  119197. readonly name: string;
  119198. /**
  119199. * The scene the component belongs to.
  119200. */
  119201. scene: Scene;
  119202. /**
  119203. * Creates a new instance of the component for the given scene
  119204. * @param scene Defines the scene to register the component in
  119205. */
  119206. constructor(scene: Scene);
  119207. /**
  119208. * Registers the component in a given scene
  119209. */
  119210. register(): void;
  119211. /**
  119212. * Rebuilds the elements related to this component in case of
  119213. * context lost for instance.
  119214. */
  119215. rebuild(): void;
  119216. /**
  119217. * Serializes the component data to the specified json object
  119218. * @param serializationObject The object to serialize to
  119219. */
  119220. serialize(serializationObject: any): void;
  119221. /**
  119222. * Adds all the elements from the container to the scene
  119223. * @param container the container holding the elements
  119224. */
  119225. addFromContainer(container: AbstractScene): void;
  119226. /**
  119227. * Removes all the elements in the container from the scene
  119228. * @param container contains the elements to remove
  119229. * @param dispose if the removed element should be disposed (default: false)
  119230. */
  119231. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119232. /**
  119233. * Rebuilds the elements related to this component in case of
  119234. * context lost for instance.
  119235. */
  119236. dispose(): void;
  119237. private _gatherRenderTargets;
  119238. }
  119239. }
  119240. declare module BABYLON {
  119241. /**
  119242. * A point light is a light defined by an unique point in world space.
  119243. * The light is emitted in every direction from this point.
  119244. * A good example of a point light is a standard light bulb.
  119245. * Documentation: https://doc.babylonjs.com/babylon101/lights
  119246. */
  119247. export class PointLight extends ShadowLight {
  119248. private _shadowAngle;
  119249. /**
  119250. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119251. * This specifies what angle the shadow will use to be created.
  119252. *
  119253. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  119254. */
  119255. /**
  119256. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119257. * This specifies what angle the shadow will use to be created.
  119258. *
  119259. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  119260. */
  119261. shadowAngle: number;
  119262. /**
  119263. * Gets the direction if it has been set.
  119264. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119265. */
  119266. /**
  119267. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119268. */
  119269. direction: Vector3;
  119270. /**
  119271. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  119272. * A PointLight emits the light in every direction.
  119273. * It can cast shadows.
  119274. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  119275. * ```javascript
  119276. * var pointLight = new PointLight("pl", camera.position, scene);
  119277. * ```
  119278. * Documentation : https://doc.babylonjs.com/babylon101/lights
  119279. * @param name The light friendly name
  119280. * @param position The position of the point light in the scene
  119281. * @param scene The scene the lights belongs to
  119282. */
  119283. constructor(name: string, position: Vector3, scene: Scene);
  119284. /**
  119285. * Returns the string "PointLight"
  119286. * @returns the class name
  119287. */
  119288. getClassName(): string;
  119289. /**
  119290. * Returns the integer 0.
  119291. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  119292. */
  119293. getTypeID(): number;
  119294. /**
  119295. * Specifies wether or not the shadowmap should be a cube texture.
  119296. * @returns true if the shadowmap needs to be a cube texture.
  119297. */
  119298. needCube(): boolean;
  119299. /**
  119300. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  119301. * @param faceIndex The index of the face we are computed the direction to generate shadow
  119302. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  119303. */
  119304. getShadowDirection(faceIndex?: number): Vector3;
  119305. /**
  119306. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  119307. * - fov = PI / 2
  119308. * - aspect ratio : 1.0
  119309. * - z-near and far equal to the active camera minZ and maxZ.
  119310. * Returns the PointLight.
  119311. */
  119312. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  119313. protected _buildUniformLayout(): void;
  119314. /**
  119315. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  119316. * @param effect The effect to update
  119317. * @param lightIndex The index of the light in the effect to update
  119318. * @returns The point light
  119319. */
  119320. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  119321. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  119322. /**
  119323. * Prepares the list of defines specific to the light type.
  119324. * @param defines the list of defines
  119325. * @param lightIndex defines the index of the light for the effect
  119326. */
  119327. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  119328. }
  119329. }
  119330. declare module BABYLON {
  119331. /**
  119332. * Header information of HDR texture files.
  119333. */
  119334. export interface HDRInfo {
  119335. /**
  119336. * The height of the texture in pixels.
  119337. */
  119338. height: number;
  119339. /**
  119340. * The width of the texture in pixels.
  119341. */
  119342. width: number;
  119343. /**
  119344. * The index of the beginning of the data in the binary file.
  119345. */
  119346. dataPosition: number;
  119347. }
  119348. /**
  119349. * This groups tools to convert HDR texture to native colors array.
  119350. */
  119351. export class HDRTools {
  119352. private static Ldexp;
  119353. private static Rgbe2float;
  119354. private static readStringLine;
  119355. /**
  119356. * Reads header information from an RGBE texture stored in a native array.
  119357. * More information on this format are available here:
  119358. * https://en.wikipedia.org/wiki/RGBE_image_format
  119359. *
  119360. * @param uint8array The binary file stored in native array.
  119361. * @return The header information.
  119362. */
  119363. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  119364. /**
  119365. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  119366. * This RGBE texture needs to store the information as a panorama.
  119367. *
  119368. * More information on this format are available here:
  119369. * https://en.wikipedia.org/wiki/RGBE_image_format
  119370. *
  119371. * @param buffer The binary file stored in an array buffer.
  119372. * @param size The expected size of the extracted cubemap.
  119373. * @return The Cube Map information.
  119374. */
  119375. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  119376. /**
  119377. * Returns the pixels data extracted from an RGBE texture.
  119378. * This pixels will be stored left to right up to down in the R G B order in one array.
  119379. *
  119380. * More information on this format are available here:
  119381. * https://en.wikipedia.org/wiki/RGBE_image_format
  119382. *
  119383. * @param uint8array The binary file stored in an array buffer.
  119384. * @param hdrInfo The header information of the file.
  119385. * @return The pixels data in RGB right to left up to down order.
  119386. */
  119387. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  119388. private static RGBE_ReadPixels_RLE;
  119389. }
  119390. }
  119391. declare module BABYLON {
  119392. /**
  119393. * This represents a texture coming from an HDR input.
  119394. *
  119395. * The only supported format is currently panorama picture stored in RGBE format.
  119396. * Example of such files can be found on HDRLib: http://hdrlib.com/
  119397. */
  119398. export class HDRCubeTexture extends BaseTexture {
  119399. private static _facesMapping;
  119400. private _generateHarmonics;
  119401. private _noMipmap;
  119402. private _textureMatrix;
  119403. private _size;
  119404. private _onLoad;
  119405. private _onError;
  119406. /**
  119407. * The texture URL.
  119408. */
  119409. url: string;
  119410. /**
  119411. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  119412. */
  119413. coordinatesMode: number;
  119414. protected _isBlocking: boolean;
  119415. /**
  119416. * Sets wether or not the texture is blocking during loading.
  119417. */
  119418. /**
  119419. * Gets wether or not the texture is blocking during loading.
  119420. */
  119421. isBlocking: boolean;
  119422. protected _rotationY: number;
  119423. /**
  119424. * Sets texture matrix rotation angle around Y axis in radians.
  119425. */
  119426. /**
  119427. * Gets texture matrix rotation angle around Y axis radians.
  119428. */
  119429. rotationY: number;
  119430. /**
  119431. * Gets or sets the center of the bounding box associated with the cube texture
  119432. * It must define where the camera used to render the texture was set
  119433. */
  119434. boundingBoxPosition: Vector3;
  119435. private _boundingBoxSize;
  119436. /**
  119437. * Gets or sets the size of the bounding box associated with the cube texture
  119438. * When defined, the cubemap will switch to local mode
  119439. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  119440. * @example https://www.babylonjs-playground.com/#RNASML
  119441. */
  119442. boundingBoxSize: Vector3;
  119443. /**
  119444. * Instantiates an HDRTexture from the following parameters.
  119445. *
  119446. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  119447. * @param scene The scene the texture will be used in
  119448. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  119449. * @param noMipmap Forces to not generate the mipmap if true
  119450. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  119451. * @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)
  119452. * @param reserved Reserved flag for internal use.
  119453. */
  119454. 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>);
  119455. /**
  119456. * Get the current class name of the texture useful for serialization or dynamic coding.
  119457. * @returns "HDRCubeTexture"
  119458. */
  119459. getClassName(): string;
  119460. /**
  119461. * Occurs when the file is raw .hdr file.
  119462. */
  119463. private loadTexture;
  119464. clone(): HDRCubeTexture;
  119465. delayLoad(): void;
  119466. /**
  119467. * Get the texture reflection matrix used to rotate/transform the reflection.
  119468. * @returns the reflection matrix
  119469. */
  119470. getReflectionTextureMatrix(): Matrix;
  119471. /**
  119472. * Set the texture reflection matrix used to rotate/transform the reflection.
  119473. * @param value Define the reflection matrix to set
  119474. */
  119475. setReflectionTextureMatrix(value: Matrix): void;
  119476. /**
  119477. * Parses a JSON representation of an HDR Texture in order to create the texture
  119478. * @param parsedTexture Define the JSON representation
  119479. * @param scene Define the scene the texture should be created in
  119480. * @param rootUrl Define the root url in case we need to load relative dependencies
  119481. * @returns the newly created texture after parsing
  119482. */
  119483. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  119484. serialize(): any;
  119485. }
  119486. }
  119487. declare module BABYLON {
  119488. /**
  119489. * Class used to control physics engine
  119490. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  119491. */
  119492. export class PhysicsEngine implements IPhysicsEngine {
  119493. private _physicsPlugin;
  119494. /**
  119495. * Global value used to control the smallest number supported by the simulation
  119496. */
  119497. static Epsilon: number;
  119498. private _impostors;
  119499. private _joints;
  119500. /**
  119501. * Gets the gravity vector used by the simulation
  119502. */
  119503. gravity: Vector3;
  119504. /**
  119505. * Factory used to create the default physics plugin.
  119506. * @returns The default physics plugin
  119507. */
  119508. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  119509. /**
  119510. * Creates a new Physics Engine
  119511. * @param gravity defines the gravity vector used by the simulation
  119512. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  119513. */
  119514. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  119515. /**
  119516. * Sets the gravity vector used by the simulation
  119517. * @param gravity defines the gravity vector to use
  119518. */
  119519. setGravity(gravity: Vector3): void;
  119520. /**
  119521. * Set the time step of the physics engine.
  119522. * Default is 1/60.
  119523. * To slow it down, enter 1/600 for example.
  119524. * To speed it up, 1/30
  119525. * @param newTimeStep defines the new timestep to apply to this world.
  119526. */
  119527. setTimeStep(newTimeStep?: number): void;
  119528. /**
  119529. * Get the time step of the physics engine.
  119530. * @returns the current time step
  119531. */
  119532. getTimeStep(): number;
  119533. /**
  119534. * Release all resources
  119535. */
  119536. dispose(): void;
  119537. /**
  119538. * Gets the name of the current physics plugin
  119539. * @returns the name of the plugin
  119540. */
  119541. getPhysicsPluginName(): string;
  119542. /**
  119543. * Adding a new impostor for the impostor tracking.
  119544. * This will be done by the impostor itself.
  119545. * @param impostor the impostor to add
  119546. */
  119547. addImpostor(impostor: PhysicsImpostor): void;
  119548. /**
  119549. * Remove an impostor from the engine.
  119550. * This impostor and its mesh will not longer be updated by the physics engine.
  119551. * @param impostor the impostor to remove
  119552. */
  119553. removeImpostor(impostor: PhysicsImpostor): void;
  119554. /**
  119555. * Add a joint to the physics engine
  119556. * @param mainImpostor defines the main impostor to which the joint is added.
  119557. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  119558. * @param joint defines the joint that will connect both impostors.
  119559. */
  119560. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  119561. /**
  119562. * Removes a joint from the simulation
  119563. * @param mainImpostor defines the impostor used with the joint
  119564. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  119565. * @param joint defines the joint to remove
  119566. */
  119567. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  119568. /**
  119569. * Called by the scene. No need to call it.
  119570. * @param delta defines the timespam between frames
  119571. */
  119572. _step(delta: number): void;
  119573. /**
  119574. * Gets the current plugin used to run the simulation
  119575. * @returns current plugin
  119576. */
  119577. getPhysicsPlugin(): IPhysicsEnginePlugin;
  119578. /**
  119579. * Gets the list of physic impostors
  119580. * @returns an array of PhysicsImpostor
  119581. */
  119582. getImpostors(): Array<PhysicsImpostor>;
  119583. /**
  119584. * Gets the impostor for a physics enabled object
  119585. * @param object defines the object impersonated by the impostor
  119586. * @returns the PhysicsImpostor or null if not found
  119587. */
  119588. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  119589. /**
  119590. * Gets the impostor for a physics body object
  119591. * @param body defines physics body used by the impostor
  119592. * @returns the PhysicsImpostor or null if not found
  119593. */
  119594. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  119595. /**
  119596. * Does a raycast in the physics world
  119597. * @param from when should the ray start?
  119598. * @param to when should the ray end?
  119599. * @returns PhysicsRaycastResult
  119600. */
  119601. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119602. }
  119603. }
  119604. declare module BABYLON {
  119605. /** @hidden */
  119606. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  119607. private _useDeltaForWorldStep;
  119608. world: any;
  119609. name: string;
  119610. private _physicsMaterials;
  119611. private _fixedTimeStep;
  119612. private _cannonRaycastResult;
  119613. private _raycastResult;
  119614. private _physicsBodysToRemoveAfterStep;
  119615. BJSCANNON: any;
  119616. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  119617. setGravity(gravity: Vector3): void;
  119618. setTimeStep(timeStep: number): void;
  119619. getTimeStep(): number;
  119620. executeStep(delta: number): void;
  119621. private _removeMarkedPhysicsBodiesFromWorld;
  119622. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119623. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119624. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119625. private _processChildMeshes;
  119626. removePhysicsBody(impostor: PhysicsImpostor): void;
  119627. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119628. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119629. private _addMaterial;
  119630. private _checkWithEpsilon;
  119631. private _createShape;
  119632. private _createHeightmap;
  119633. private _minus90X;
  119634. private _plus90X;
  119635. private _tmpPosition;
  119636. private _tmpDeltaPosition;
  119637. private _tmpUnityRotation;
  119638. private _updatePhysicsBodyTransformation;
  119639. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119640. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119641. isSupported(): boolean;
  119642. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119643. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119644. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119645. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119646. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119647. getBodyMass(impostor: PhysicsImpostor): number;
  119648. getBodyFriction(impostor: PhysicsImpostor): number;
  119649. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119650. getBodyRestitution(impostor: PhysicsImpostor): number;
  119651. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119652. sleepBody(impostor: PhysicsImpostor): void;
  119653. wakeUpBody(impostor: PhysicsImpostor): void;
  119654. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  119655. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  119656. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  119657. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119658. getRadius(impostor: PhysicsImpostor): number;
  119659. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119660. dispose(): void;
  119661. private _extendNamespace;
  119662. /**
  119663. * Does a raycast in the physics world
  119664. * @param from when should the ray start?
  119665. * @param to when should the ray end?
  119666. * @returns PhysicsRaycastResult
  119667. */
  119668. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119669. }
  119670. }
  119671. declare module BABYLON {
  119672. /** @hidden */
  119673. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  119674. world: any;
  119675. name: string;
  119676. BJSOIMO: any;
  119677. private _raycastResult;
  119678. constructor(iterations?: number, oimoInjection?: any);
  119679. setGravity(gravity: Vector3): void;
  119680. setTimeStep(timeStep: number): void;
  119681. getTimeStep(): number;
  119682. private _tmpImpostorsArray;
  119683. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  119684. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119685. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119686. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119687. private _tmpPositionVector;
  119688. removePhysicsBody(impostor: PhysicsImpostor): void;
  119689. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119690. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119691. isSupported(): boolean;
  119692. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119693. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119694. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119695. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119696. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119697. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119698. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119699. getBodyMass(impostor: PhysicsImpostor): number;
  119700. getBodyFriction(impostor: PhysicsImpostor): number;
  119701. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119702. getBodyRestitution(impostor: PhysicsImpostor): number;
  119703. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119704. sleepBody(impostor: PhysicsImpostor): void;
  119705. wakeUpBody(impostor: PhysicsImpostor): void;
  119706. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  119707. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  119708. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  119709. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119710. getRadius(impostor: PhysicsImpostor): number;
  119711. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119712. dispose(): void;
  119713. /**
  119714. * Does a raycast in the physics world
  119715. * @param from when should the ray start?
  119716. * @param to when should the ray end?
  119717. * @returns PhysicsRaycastResult
  119718. */
  119719. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119720. }
  119721. }
  119722. declare module BABYLON {
  119723. /**
  119724. * Class containing static functions to help procedurally build meshes
  119725. */
  119726. export class RibbonBuilder {
  119727. /**
  119728. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119729. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  119730. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  119731. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  119732. * * 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
  119733. * * 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
  119734. * * 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
  119735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119736. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119737. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119738. * * 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
  119739. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  119740. * * 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
  119741. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  119742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119743. * @param name defines the name of the mesh
  119744. * @param options defines the options used to create the mesh
  119745. * @param scene defines the hosting scene
  119746. * @returns the ribbon mesh
  119747. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  119748. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119749. */
  119750. static CreateRibbon(name: string, options: {
  119751. pathArray: Vector3[][];
  119752. closeArray?: boolean;
  119753. closePath?: boolean;
  119754. offset?: number;
  119755. updatable?: boolean;
  119756. sideOrientation?: number;
  119757. frontUVs?: Vector4;
  119758. backUVs?: Vector4;
  119759. instance?: Mesh;
  119760. invertUV?: boolean;
  119761. uvs?: Vector2[];
  119762. colors?: Color4[];
  119763. }, scene?: Nullable<Scene>): Mesh;
  119764. }
  119765. }
  119766. declare module BABYLON {
  119767. /**
  119768. * Class containing static functions to help procedurally build meshes
  119769. */
  119770. export class ShapeBuilder {
  119771. /**
  119772. * 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.
  119773. * * 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.
  119774. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119775. * * 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.
  119776. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  119777. * * 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
  119778. * * 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
  119779. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  119780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119781. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119782. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  119783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119784. * @param name defines the name of the mesh
  119785. * @param options defines the options used to create the mesh
  119786. * @param scene defines the hosting scene
  119787. * @returns the extruded shape mesh
  119788. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119789. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119790. */
  119791. static ExtrudeShape(name: string, options: {
  119792. shape: Vector3[];
  119793. path: Vector3[];
  119794. scale?: number;
  119795. rotation?: number;
  119796. cap?: number;
  119797. updatable?: boolean;
  119798. sideOrientation?: number;
  119799. frontUVs?: Vector4;
  119800. backUVs?: Vector4;
  119801. instance?: Mesh;
  119802. invertUV?: boolean;
  119803. }, scene?: Nullable<Scene>): Mesh;
  119804. /**
  119805. * Creates an custom extruded shape mesh.
  119806. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  119807. * * 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.
  119808. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119809. * * 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
  119810. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  119811. * * 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
  119812. * * It must returns a float value that will be the scale value applied to the shape on each path point
  119813. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  119814. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  119815. * * 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
  119816. * * 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
  119817. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  119818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119819. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119820. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119822. * @param name defines the name of the mesh
  119823. * @param options defines the options used to create the mesh
  119824. * @param scene defines the hosting scene
  119825. * @returns the custom extruded shape mesh
  119826. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  119827. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119828. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119829. */
  119830. static ExtrudeShapeCustom(name: string, options: {
  119831. shape: Vector3[];
  119832. path: Vector3[];
  119833. scaleFunction?: any;
  119834. rotationFunction?: any;
  119835. ribbonCloseArray?: boolean;
  119836. ribbonClosePath?: boolean;
  119837. cap?: number;
  119838. updatable?: boolean;
  119839. sideOrientation?: number;
  119840. frontUVs?: Vector4;
  119841. backUVs?: Vector4;
  119842. instance?: Mesh;
  119843. invertUV?: boolean;
  119844. }, scene?: Nullable<Scene>): Mesh;
  119845. private static _ExtrudeShapeGeneric;
  119846. }
  119847. }
  119848. declare module BABYLON {
  119849. /**
  119850. * AmmoJS Physics plugin
  119851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  119852. * @see https://github.com/kripken/ammo.js/
  119853. */
  119854. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  119855. private _useDeltaForWorldStep;
  119856. /**
  119857. * Reference to the Ammo library
  119858. */
  119859. bjsAMMO: any;
  119860. /**
  119861. * Created ammoJS world which physics bodies are added to
  119862. */
  119863. world: any;
  119864. /**
  119865. * Name of the plugin
  119866. */
  119867. name: string;
  119868. private _timeStep;
  119869. private _fixedTimeStep;
  119870. private _maxSteps;
  119871. private _tmpQuaternion;
  119872. private _tmpAmmoTransform;
  119873. private _tmpAmmoQuaternion;
  119874. private _tmpAmmoConcreteContactResultCallback;
  119875. private _collisionConfiguration;
  119876. private _dispatcher;
  119877. private _overlappingPairCache;
  119878. private _solver;
  119879. private _softBodySolver;
  119880. private _tmpAmmoVectorA;
  119881. private _tmpAmmoVectorB;
  119882. private _tmpAmmoVectorC;
  119883. private _tmpAmmoVectorD;
  119884. private _tmpContactCallbackResult;
  119885. private _tmpAmmoVectorRCA;
  119886. private _tmpAmmoVectorRCB;
  119887. private _raycastResult;
  119888. private static readonly DISABLE_COLLISION_FLAG;
  119889. private static readonly KINEMATIC_FLAG;
  119890. private static readonly DISABLE_DEACTIVATION_FLAG;
  119891. /**
  119892. * Initializes the ammoJS plugin
  119893. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  119894. * @param ammoInjection can be used to inject your own ammo reference
  119895. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  119896. */
  119897. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  119898. /**
  119899. * Sets the gravity of the physics world (m/(s^2))
  119900. * @param gravity Gravity to set
  119901. */
  119902. setGravity(gravity: Vector3): void;
  119903. /**
  119904. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  119905. * @param timeStep timestep to use in seconds
  119906. */
  119907. setTimeStep(timeStep: number): void;
  119908. /**
  119909. * 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)
  119910. * @param fixedTimeStep fixedTimeStep to use in seconds
  119911. */
  119912. setFixedTimeStep(fixedTimeStep: number): void;
  119913. /**
  119914. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  119915. * @param maxSteps the maximum number of steps by the physics engine per frame
  119916. */
  119917. setMaxSteps(maxSteps: number): void;
  119918. /**
  119919. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  119920. * @returns the current timestep in seconds
  119921. */
  119922. getTimeStep(): number;
  119923. private _isImpostorInContact;
  119924. private _isImpostorPairInContact;
  119925. private _stepSimulation;
  119926. /**
  119927. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  119928. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  119929. * After the step the babylon meshes are set to the position of the physics imposters
  119930. * @param delta amount of time to step forward
  119931. * @param impostors array of imposters to update before/after the step
  119932. */
  119933. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  119934. /**
  119935. * Update babylon mesh to match physics world object
  119936. * @param impostor imposter to match
  119937. */
  119938. private _afterSoftStep;
  119939. /**
  119940. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  119941. * @param impostor imposter to match
  119942. */
  119943. private _ropeStep;
  119944. /**
  119945. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  119946. * @param impostor imposter to match
  119947. */
  119948. private _softbodyOrClothStep;
  119949. private _tmpVector;
  119950. private _tmpMatrix;
  119951. /**
  119952. * Applies an impulse on the imposter
  119953. * @param impostor imposter to apply impulse to
  119954. * @param force amount of force to be applied to the imposter
  119955. * @param contactPoint the location to apply the impulse on the imposter
  119956. */
  119957. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119958. /**
  119959. * Applies a force on the imposter
  119960. * @param impostor imposter to apply force
  119961. * @param force amount of force to be applied to the imposter
  119962. * @param contactPoint the location to apply the force on the imposter
  119963. */
  119964. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119965. /**
  119966. * Creates a physics body using the plugin
  119967. * @param impostor the imposter to create the physics body on
  119968. */
  119969. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119970. /**
  119971. * Removes the physics body from the imposter and disposes of the body's memory
  119972. * @param impostor imposter to remove the physics body from
  119973. */
  119974. removePhysicsBody(impostor: PhysicsImpostor): void;
  119975. /**
  119976. * Generates a joint
  119977. * @param impostorJoint the imposter joint to create the joint with
  119978. */
  119979. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119980. /**
  119981. * Removes a joint
  119982. * @param impostorJoint the imposter joint to remove the joint from
  119983. */
  119984. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119985. private _addMeshVerts;
  119986. /**
  119987. * Initialise the soft body vertices to match its object's (mesh) vertices
  119988. * Softbody vertices (nodes) are in world space and to match this
  119989. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  119990. * @param impostor to create the softbody for
  119991. */
  119992. private _softVertexData;
  119993. /**
  119994. * Create an impostor's soft body
  119995. * @param impostor to create the softbody for
  119996. */
  119997. private _createSoftbody;
  119998. /**
  119999. * Create cloth for an impostor
  120000. * @param impostor to create the softbody for
  120001. */
  120002. private _createCloth;
  120003. /**
  120004. * Create rope for an impostor
  120005. * @param impostor to create the softbody for
  120006. */
  120007. private _createRope;
  120008. private _addHullVerts;
  120009. private _createShape;
  120010. /**
  120011. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  120012. * @param impostor imposter containing the physics body and babylon object
  120013. */
  120014. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  120015. /**
  120016. * Sets the babylon object's position/rotation from the physics body's position/rotation
  120017. * @param impostor imposter containing the physics body and babylon object
  120018. * @param newPosition new position
  120019. * @param newRotation new rotation
  120020. */
  120021. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  120022. /**
  120023. * If this plugin is supported
  120024. * @returns true if its supported
  120025. */
  120026. isSupported(): boolean;
  120027. /**
  120028. * Sets the linear velocity of the physics body
  120029. * @param impostor imposter to set the velocity on
  120030. * @param velocity velocity to set
  120031. */
  120032. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120033. /**
  120034. * Sets the angular velocity of the physics body
  120035. * @param impostor imposter to set the velocity on
  120036. * @param velocity velocity to set
  120037. */
  120038. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120039. /**
  120040. * gets the linear velocity
  120041. * @param impostor imposter to get linear velocity from
  120042. * @returns linear velocity
  120043. */
  120044. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120045. /**
  120046. * gets the angular velocity
  120047. * @param impostor imposter to get angular velocity from
  120048. * @returns angular velocity
  120049. */
  120050. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120051. /**
  120052. * Sets the mass of physics body
  120053. * @param impostor imposter to set the mass on
  120054. * @param mass mass to set
  120055. */
  120056. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120057. /**
  120058. * Gets the mass of the physics body
  120059. * @param impostor imposter to get the mass from
  120060. * @returns mass
  120061. */
  120062. getBodyMass(impostor: PhysicsImpostor): number;
  120063. /**
  120064. * Gets friction of the impostor
  120065. * @param impostor impostor to get friction from
  120066. * @returns friction value
  120067. */
  120068. getBodyFriction(impostor: PhysicsImpostor): number;
  120069. /**
  120070. * Sets friction of the impostor
  120071. * @param impostor impostor to set friction on
  120072. * @param friction friction value
  120073. */
  120074. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120075. /**
  120076. * Gets restitution of the impostor
  120077. * @param impostor impostor to get restitution from
  120078. * @returns restitution value
  120079. */
  120080. getBodyRestitution(impostor: PhysicsImpostor): number;
  120081. /**
  120082. * Sets resitution of the impostor
  120083. * @param impostor impostor to set resitution on
  120084. * @param restitution resitution value
  120085. */
  120086. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120087. /**
  120088. * Gets pressure inside the impostor
  120089. * @param impostor impostor to get pressure from
  120090. * @returns pressure value
  120091. */
  120092. getBodyPressure(impostor: PhysicsImpostor): number;
  120093. /**
  120094. * Sets pressure inside a soft body impostor
  120095. * Cloth and rope must remain 0 pressure
  120096. * @param impostor impostor to set pressure on
  120097. * @param pressure pressure value
  120098. */
  120099. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  120100. /**
  120101. * Gets stiffness of the impostor
  120102. * @param impostor impostor to get stiffness from
  120103. * @returns pressure value
  120104. */
  120105. getBodyStiffness(impostor: PhysicsImpostor): number;
  120106. /**
  120107. * Sets stiffness of the impostor
  120108. * @param impostor impostor to set stiffness on
  120109. * @param stiffness stiffness value from 0 to 1
  120110. */
  120111. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  120112. /**
  120113. * Gets velocityIterations of the impostor
  120114. * @param impostor impostor to get velocity iterations from
  120115. * @returns velocityIterations value
  120116. */
  120117. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  120118. /**
  120119. * Sets velocityIterations of the impostor
  120120. * @param impostor impostor to set velocity iterations on
  120121. * @param velocityIterations velocityIterations value
  120122. */
  120123. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  120124. /**
  120125. * Gets positionIterations of the impostor
  120126. * @param impostor impostor to get position iterations from
  120127. * @returns positionIterations value
  120128. */
  120129. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  120130. /**
  120131. * Sets positionIterations of the impostor
  120132. * @param impostor impostor to set position on
  120133. * @param positionIterations positionIterations value
  120134. */
  120135. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  120136. /**
  120137. * Append an anchor to a cloth object
  120138. * @param impostor is the cloth impostor to add anchor to
  120139. * @param otherImpostor is the rigid impostor to anchor to
  120140. * @param width ratio across width from 0 to 1
  120141. * @param height ratio up height from 0 to 1
  120142. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  120143. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120144. */
  120145. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  120146. /**
  120147. * Append an hook to a rope object
  120148. * @param impostor is the rope impostor to add hook to
  120149. * @param otherImpostor is the rigid impostor to hook to
  120150. * @param length ratio along the rope from 0 to 1
  120151. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  120152. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120153. */
  120154. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  120155. /**
  120156. * Sleeps the physics body and stops it from being active
  120157. * @param impostor impostor to sleep
  120158. */
  120159. sleepBody(impostor: PhysicsImpostor): void;
  120160. /**
  120161. * Activates the physics body
  120162. * @param impostor impostor to activate
  120163. */
  120164. wakeUpBody(impostor: PhysicsImpostor): void;
  120165. /**
  120166. * Updates the distance parameters of the joint
  120167. * @param joint joint to update
  120168. * @param maxDistance maximum distance of the joint
  120169. * @param minDistance minimum distance of the joint
  120170. */
  120171. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  120172. /**
  120173. * Sets a motor on the joint
  120174. * @param joint joint to set motor on
  120175. * @param speed speed of the motor
  120176. * @param maxForce maximum force of the motor
  120177. * @param motorIndex index of the motor
  120178. */
  120179. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  120180. /**
  120181. * Sets the motors limit
  120182. * @param joint joint to set limit on
  120183. * @param upperLimit upper limit
  120184. * @param lowerLimit lower limit
  120185. */
  120186. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  120187. /**
  120188. * Syncs the position and rotation of a mesh with the impostor
  120189. * @param mesh mesh to sync
  120190. * @param impostor impostor to update the mesh with
  120191. */
  120192. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120193. /**
  120194. * Gets the radius of the impostor
  120195. * @param impostor impostor to get radius from
  120196. * @returns the radius
  120197. */
  120198. getRadius(impostor: PhysicsImpostor): number;
  120199. /**
  120200. * Gets the box size of the impostor
  120201. * @param impostor impostor to get box size from
  120202. * @param result the resulting box size
  120203. */
  120204. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120205. /**
  120206. * Disposes of the impostor
  120207. */
  120208. dispose(): void;
  120209. /**
  120210. * Does a raycast in the physics world
  120211. * @param from when should the ray start?
  120212. * @param to when should the ray end?
  120213. * @returns PhysicsRaycastResult
  120214. */
  120215. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120216. }
  120217. }
  120218. declare module BABYLON {
  120219. interface AbstractScene {
  120220. /**
  120221. * The list of reflection probes added to the scene
  120222. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120223. */
  120224. reflectionProbes: Array<ReflectionProbe>;
  120225. /**
  120226. * Removes the given reflection probe from this scene.
  120227. * @param toRemove The reflection probe to remove
  120228. * @returns The index of the removed reflection probe
  120229. */
  120230. removeReflectionProbe(toRemove: ReflectionProbe): number;
  120231. /**
  120232. * Adds the given reflection probe to this scene.
  120233. * @param newReflectionProbe The reflection probe to add
  120234. */
  120235. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  120236. }
  120237. /**
  120238. * Class used to generate realtime reflection / refraction cube textures
  120239. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120240. */
  120241. export class ReflectionProbe {
  120242. /** defines the name of the probe */
  120243. name: string;
  120244. private _scene;
  120245. private _renderTargetTexture;
  120246. private _projectionMatrix;
  120247. private _viewMatrix;
  120248. private _target;
  120249. private _add;
  120250. private _attachedMesh;
  120251. private _invertYAxis;
  120252. /** Gets or sets probe position (center of the cube map) */
  120253. position: Vector3;
  120254. /**
  120255. * Creates a new reflection probe
  120256. * @param name defines the name of the probe
  120257. * @param size defines the texture resolution (for each face)
  120258. * @param scene defines the hosting scene
  120259. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  120260. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  120261. */
  120262. constructor(
  120263. /** defines the name of the probe */
  120264. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  120265. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  120266. samples: number;
  120267. /** Gets or sets the refresh rate to use (on every frame by default) */
  120268. refreshRate: number;
  120269. /**
  120270. * Gets the hosting scene
  120271. * @returns a Scene
  120272. */
  120273. getScene(): Scene;
  120274. /** Gets the internal CubeTexture used to render to */
  120275. readonly cubeTexture: RenderTargetTexture;
  120276. /** Gets the list of meshes to render */
  120277. readonly renderList: Nullable<AbstractMesh[]>;
  120278. /**
  120279. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  120280. * @param mesh defines the mesh to attach to
  120281. */
  120282. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  120283. /**
  120284. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  120285. * @param renderingGroupId The rendering group id corresponding to its index
  120286. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120287. */
  120288. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  120289. /**
  120290. * Clean all associated resources
  120291. */
  120292. dispose(): void;
  120293. /**
  120294. * Converts the reflection probe information to a readable string for debug purpose.
  120295. * @param fullDetails Supports for multiple levels of logging within scene loading
  120296. * @returns the human readable reflection probe info
  120297. */
  120298. toString(fullDetails?: boolean): string;
  120299. /**
  120300. * Get the class name of the relfection probe.
  120301. * @returns "ReflectionProbe"
  120302. */
  120303. getClassName(): string;
  120304. /**
  120305. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  120306. * @returns The JSON representation of the texture
  120307. */
  120308. serialize(): any;
  120309. /**
  120310. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  120311. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  120312. * @param scene Define the scene the parsed reflection probe should be instantiated in
  120313. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  120314. * @returns The parsed reflection probe if successful
  120315. */
  120316. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  120317. }
  120318. }
  120319. declare module BABYLON {
  120320. /** @hidden */
  120321. export var _BabylonLoaderRegistered: boolean;
  120322. /**
  120323. * Helps setting up some configuration for the babylon file loader.
  120324. */
  120325. export class BabylonFileLoaderConfiguration {
  120326. /**
  120327. * The loader does not allow injecting custom physix engine into the plugins.
  120328. * Unfortunately in ES6, we need to manually inject them into the plugin.
  120329. * So you could set this variable to your engine import to make it work.
  120330. */
  120331. static LoaderInjectedPhysicsEngine: any;
  120332. }
  120333. }
  120334. declare module BABYLON {
  120335. /**
  120336. * The Physically based simple base material of BJS.
  120337. *
  120338. * This enables better naming and convention enforcements on top of the pbrMaterial.
  120339. * It is used as the base class for both the specGloss and metalRough conventions.
  120340. */
  120341. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  120342. /**
  120343. * Number of Simultaneous lights allowed on the material.
  120344. */
  120345. maxSimultaneousLights: number;
  120346. /**
  120347. * If sets to true, disables all the lights affecting the material.
  120348. */
  120349. disableLighting: boolean;
  120350. /**
  120351. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  120352. */
  120353. environmentTexture: BaseTexture;
  120354. /**
  120355. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  120356. */
  120357. invertNormalMapX: boolean;
  120358. /**
  120359. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  120360. */
  120361. invertNormalMapY: boolean;
  120362. /**
  120363. * Normal map used in the model.
  120364. */
  120365. normalTexture: BaseTexture;
  120366. /**
  120367. * Emissivie color used to self-illuminate the model.
  120368. */
  120369. emissiveColor: Color3;
  120370. /**
  120371. * Emissivie texture used to self-illuminate the model.
  120372. */
  120373. emissiveTexture: BaseTexture;
  120374. /**
  120375. * Occlusion Channel Strenght.
  120376. */
  120377. occlusionStrength: number;
  120378. /**
  120379. * Occlusion Texture of the material (adding extra occlusion effects).
  120380. */
  120381. occlusionTexture: BaseTexture;
  120382. /**
  120383. * Defines the alpha limits in alpha test mode.
  120384. */
  120385. alphaCutOff: number;
  120386. /**
  120387. * Gets the current double sided mode.
  120388. */
  120389. /**
  120390. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  120391. */
  120392. doubleSided: boolean;
  120393. /**
  120394. * Stores the pre-calculated light information of a mesh in a texture.
  120395. */
  120396. lightmapTexture: BaseTexture;
  120397. /**
  120398. * If true, the light map contains occlusion information instead of lighting info.
  120399. */
  120400. useLightmapAsShadowmap: boolean;
  120401. /**
  120402. * Instantiates a new PBRMaterial instance.
  120403. *
  120404. * @param name The material name
  120405. * @param scene The scene the material will be use in.
  120406. */
  120407. constructor(name: string, scene: Scene);
  120408. getClassName(): string;
  120409. }
  120410. }
  120411. declare module BABYLON {
  120412. /**
  120413. * The PBR material of BJS following the metal roughness convention.
  120414. *
  120415. * This fits to the PBR convention in the GLTF definition:
  120416. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  120417. */
  120418. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  120419. /**
  120420. * The base color has two different interpretations depending on the value of metalness.
  120421. * When the material is a metal, the base color is the specific measured reflectance value
  120422. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  120423. * of the material.
  120424. */
  120425. baseColor: Color3;
  120426. /**
  120427. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  120428. * well as opacity information in the alpha channel.
  120429. */
  120430. baseTexture: BaseTexture;
  120431. /**
  120432. * Specifies the metallic scalar value of the material.
  120433. * Can also be used to scale the metalness values of the metallic texture.
  120434. */
  120435. metallic: number;
  120436. /**
  120437. * Specifies the roughness scalar value of the material.
  120438. * Can also be used to scale the roughness values of the metallic texture.
  120439. */
  120440. roughness: number;
  120441. /**
  120442. * Texture containing both the metallic value in the B channel and the
  120443. * roughness value in the G channel to keep better precision.
  120444. */
  120445. metallicRoughnessTexture: BaseTexture;
  120446. /**
  120447. * Instantiates a new PBRMetalRoughnessMaterial instance.
  120448. *
  120449. * @param name The material name
  120450. * @param scene The scene the material will be use in.
  120451. */
  120452. constructor(name: string, scene: Scene);
  120453. /**
  120454. * Return the currrent class name of the material.
  120455. */
  120456. getClassName(): string;
  120457. /**
  120458. * Makes a duplicate of the current material.
  120459. * @param name - name to use for the new material.
  120460. */
  120461. clone(name: string): PBRMetallicRoughnessMaterial;
  120462. /**
  120463. * Serialize the material to a parsable JSON object.
  120464. */
  120465. serialize(): any;
  120466. /**
  120467. * Parses a JSON object correponding to the serialize function.
  120468. */
  120469. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  120470. }
  120471. }
  120472. declare module BABYLON {
  120473. /**
  120474. * The PBR material of BJS following the specular glossiness convention.
  120475. *
  120476. * This fits to the PBR convention in the GLTF definition:
  120477. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  120478. */
  120479. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  120480. /**
  120481. * Specifies the diffuse color of the material.
  120482. */
  120483. diffuseColor: Color3;
  120484. /**
  120485. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  120486. * channel.
  120487. */
  120488. diffuseTexture: BaseTexture;
  120489. /**
  120490. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  120491. */
  120492. specularColor: Color3;
  120493. /**
  120494. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  120495. */
  120496. glossiness: number;
  120497. /**
  120498. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  120499. */
  120500. specularGlossinessTexture: BaseTexture;
  120501. /**
  120502. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  120503. *
  120504. * @param name The material name
  120505. * @param scene The scene the material will be use in.
  120506. */
  120507. constructor(name: string, scene: Scene);
  120508. /**
  120509. * Return the currrent class name of the material.
  120510. */
  120511. getClassName(): string;
  120512. /**
  120513. * Makes a duplicate of the current material.
  120514. * @param name - name to use for the new material.
  120515. */
  120516. clone(name: string): PBRSpecularGlossinessMaterial;
  120517. /**
  120518. * Serialize the material to a parsable JSON object.
  120519. */
  120520. serialize(): any;
  120521. /**
  120522. * Parses a JSON object correponding to the serialize function.
  120523. */
  120524. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  120525. }
  120526. }
  120527. declare module BABYLON {
  120528. /**
  120529. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  120530. * It can help converting any input color in a desired output one. This can then be used to create effects
  120531. * from sepia, black and white to sixties or futuristic rendering...
  120532. *
  120533. * The only supported format is currently 3dl.
  120534. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  120535. */
  120536. export class ColorGradingTexture extends BaseTexture {
  120537. /**
  120538. * The current texture matrix. (will always be identity in color grading texture)
  120539. */
  120540. private _textureMatrix;
  120541. /**
  120542. * The texture URL.
  120543. */
  120544. url: string;
  120545. /**
  120546. * Empty line regex stored for GC.
  120547. */
  120548. private static _noneEmptyLineRegex;
  120549. private _engine;
  120550. /**
  120551. * Instantiates a ColorGradingTexture from the following parameters.
  120552. *
  120553. * @param url The location of the color gradind data (currently only supporting 3dl)
  120554. * @param scene The scene the texture will be used in
  120555. */
  120556. constructor(url: string, scene: Scene);
  120557. /**
  120558. * Returns the texture matrix used in most of the material.
  120559. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  120560. */
  120561. getTextureMatrix(): Matrix;
  120562. /**
  120563. * Occurs when the file being loaded is a .3dl LUT file.
  120564. */
  120565. private load3dlTexture;
  120566. /**
  120567. * Starts the loading process of the texture.
  120568. */
  120569. private loadTexture;
  120570. /**
  120571. * Clones the color gradind texture.
  120572. */
  120573. clone(): ColorGradingTexture;
  120574. /**
  120575. * Called during delayed load for textures.
  120576. */
  120577. delayLoad(): void;
  120578. /**
  120579. * Parses a color grading texture serialized by Babylon.
  120580. * @param parsedTexture The texture information being parsedTexture
  120581. * @param scene The scene to load the texture in
  120582. * @param rootUrl The root url of the data assets to load
  120583. * @return A color gradind texture
  120584. */
  120585. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  120586. /**
  120587. * Serializes the LUT texture to json format.
  120588. */
  120589. serialize(): any;
  120590. }
  120591. }
  120592. declare module BABYLON {
  120593. /**
  120594. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  120595. */
  120596. export class EquiRectangularCubeTexture extends BaseTexture {
  120597. /** The six faces of the cube. */
  120598. private static _FacesMapping;
  120599. private _noMipmap;
  120600. private _onLoad;
  120601. private _onError;
  120602. /** The size of the cubemap. */
  120603. private _size;
  120604. /** The buffer of the image. */
  120605. private _buffer;
  120606. /** The width of the input image. */
  120607. private _width;
  120608. /** The height of the input image. */
  120609. private _height;
  120610. /** The URL to the image. */
  120611. url: string;
  120612. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  120613. coordinatesMode: number;
  120614. /**
  120615. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  120616. * @param url The location of the image
  120617. * @param scene The scene the texture will be used in
  120618. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  120619. * @param noMipmap Forces to not generate the mipmap if true
  120620. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  120621. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  120622. * @param onLoad — defines a callback called when texture is loaded
  120623. * @param onError — defines a callback called if there is an error
  120624. */
  120625. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  120626. /**
  120627. * Load the image data, by putting the image on a canvas and extracting its buffer.
  120628. */
  120629. private loadImage;
  120630. /**
  120631. * Convert the image buffer into a cubemap and create a CubeTexture.
  120632. */
  120633. private loadTexture;
  120634. /**
  120635. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  120636. * @param buffer The ArrayBuffer that should be converted.
  120637. * @returns The buffer as Float32Array.
  120638. */
  120639. private getFloat32ArrayFromArrayBuffer;
  120640. /**
  120641. * Get the current class name of the texture useful for serialization or dynamic coding.
  120642. * @returns "EquiRectangularCubeTexture"
  120643. */
  120644. getClassName(): string;
  120645. /**
  120646. * Create a clone of the current EquiRectangularCubeTexture and return it.
  120647. * @returns A clone of the current EquiRectangularCubeTexture.
  120648. */
  120649. clone(): EquiRectangularCubeTexture;
  120650. }
  120651. }
  120652. declare module BABYLON {
  120653. /**
  120654. * Based on jsTGALoader - Javascript loader for TGA file
  120655. * By Vincent Thibault
  120656. * @see http://blog.robrowser.com/javascript-tga-loader.html
  120657. */
  120658. export class TGATools {
  120659. private static _TYPE_INDEXED;
  120660. private static _TYPE_RGB;
  120661. private static _TYPE_GREY;
  120662. private static _TYPE_RLE_INDEXED;
  120663. private static _TYPE_RLE_RGB;
  120664. private static _TYPE_RLE_GREY;
  120665. private static _ORIGIN_MASK;
  120666. private static _ORIGIN_SHIFT;
  120667. private static _ORIGIN_BL;
  120668. private static _ORIGIN_BR;
  120669. private static _ORIGIN_UL;
  120670. private static _ORIGIN_UR;
  120671. /**
  120672. * Gets the header of a TGA file
  120673. * @param data defines the TGA data
  120674. * @returns the header
  120675. */
  120676. static GetTGAHeader(data: Uint8Array): any;
  120677. /**
  120678. * Uploads TGA content to a Babylon Texture
  120679. * @hidden
  120680. */
  120681. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  120682. /** @hidden */
  120683. 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;
  120684. /** @hidden */
  120685. 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;
  120686. /** @hidden */
  120687. 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;
  120688. /** @hidden */
  120689. 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;
  120690. /** @hidden */
  120691. 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;
  120692. /** @hidden */
  120693. 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;
  120694. }
  120695. }
  120696. declare module BABYLON {
  120697. /**
  120698. * Implementation of the TGA Texture Loader.
  120699. * @hidden
  120700. */
  120701. export class _TGATextureLoader implements IInternalTextureLoader {
  120702. /**
  120703. * Defines wether the loader supports cascade loading the different faces.
  120704. */
  120705. readonly supportCascades: boolean;
  120706. /**
  120707. * This returns if the loader support the current file information.
  120708. * @param extension defines the file extension of the file being loaded
  120709. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120710. * @param fallback defines the fallback internal texture if any
  120711. * @param isBase64 defines whether the texture is encoded as a base64
  120712. * @param isBuffer defines whether the texture data are stored as a buffer
  120713. * @returns true if the loader can load the specified file
  120714. */
  120715. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  120716. /**
  120717. * Transform the url before loading if required.
  120718. * @param rootUrl the url of the texture
  120719. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120720. * @returns the transformed texture
  120721. */
  120722. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  120723. /**
  120724. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  120725. * @param rootUrl the url of the texture
  120726. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120727. * @returns the fallback texture
  120728. */
  120729. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  120730. /**
  120731. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  120732. * @param data contains the texture data
  120733. * @param texture defines the BabylonJS internal texture
  120734. * @param createPolynomials will be true if polynomials have been requested
  120735. * @param onLoad defines the callback to trigger once the texture is ready
  120736. * @param onError defines the callback to trigger in case of error
  120737. */
  120738. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  120739. /**
  120740. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  120741. * @param data contains the texture data
  120742. * @param texture defines the BabylonJS internal texture
  120743. * @param callback defines the method to call once ready to upload
  120744. */
  120745. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  120746. }
  120747. }
  120748. declare module BABYLON {
  120749. /**
  120750. * Info about the .basis files
  120751. */
  120752. class BasisFileInfo {
  120753. /**
  120754. * If the file has alpha
  120755. */
  120756. hasAlpha: boolean;
  120757. /**
  120758. * Info about each image of the basis file
  120759. */
  120760. images: Array<{
  120761. levels: Array<{
  120762. width: number;
  120763. height: number;
  120764. transcodedPixels: ArrayBufferView;
  120765. }>;
  120766. }>;
  120767. }
  120768. /**
  120769. * Result of transcoding a basis file
  120770. */
  120771. class TranscodeResult {
  120772. /**
  120773. * Info about the .basis file
  120774. */
  120775. fileInfo: BasisFileInfo;
  120776. /**
  120777. * Format to use when loading the file
  120778. */
  120779. format: number;
  120780. }
  120781. /**
  120782. * Configuration options for the Basis transcoder
  120783. */
  120784. export class BasisTranscodeConfiguration {
  120785. /**
  120786. * Supported compression formats used to determine the supported output format of the transcoder
  120787. */
  120788. supportedCompressionFormats?: {
  120789. /**
  120790. * etc1 compression format
  120791. */
  120792. etc1?: boolean;
  120793. /**
  120794. * s3tc compression format
  120795. */
  120796. s3tc?: boolean;
  120797. /**
  120798. * pvrtc compression format
  120799. */
  120800. pvrtc?: boolean;
  120801. /**
  120802. * etc2 compression format
  120803. */
  120804. etc2?: boolean;
  120805. };
  120806. /**
  120807. * If mipmap levels should be loaded for transcoded images (Default: true)
  120808. */
  120809. loadMipmapLevels?: boolean;
  120810. /**
  120811. * Index of a single image to load (Default: all images)
  120812. */
  120813. loadSingleImage?: number;
  120814. }
  120815. /**
  120816. * Used to load .Basis files
  120817. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  120818. */
  120819. export class BasisTools {
  120820. private static _IgnoreSupportedFormats;
  120821. /**
  120822. * URL to use when loading the basis transcoder
  120823. */
  120824. static JSModuleURL: string;
  120825. /**
  120826. * URL to use when loading the wasm module for the transcoder
  120827. */
  120828. static WasmModuleURL: string;
  120829. /**
  120830. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  120831. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  120832. * @returns internal format corresponding to the Basis format
  120833. */
  120834. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  120835. private static _WorkerPromise;
  120836. private static _Worker;
  120837. private static _actionId;
  120838. private static _CreateWorkerAsync;
  120839. /**
  120840. * Transcodes a loaded image file to compressed pixel data
  120841. * @param imageData image data to transcode
  120842. * @param config configuration options for the transcoding
  120843. * @returns a promise resulting in the transcoded image
  120844. */
  120845. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  120846. /**
  120847. * Loads a texture from the transcode result
  120848. * @param texture texture load to
  120849. * @param transcodeResult the result of transcoding the basis file to load from
  120850. */
  120851. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  120852. }
  120853. }
  120854. declare module BABYLON {
  120855. /**
  120856. * Loader for .basis file format
  120857. */
  120858. export class _BasisTextureLoader implements IInternalTextureLoader {
  120859. /**
  120860. * Defines whether the loader supports cascade loading the different faces.
  120861. */
  120862. readonly supportCascades: boolean;
  120863. /**
  120864. * This returns if the loader support the current file information.
  120865. * @param extension defines the file extension of the file being loaded
  120866. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120867. * @param fallback defines the fallback internal texture if any
  120868. * @param isBase64 defines whether the texture is encoded as a base64
  120869. * @param isBuffer defines whether the texture data are stored as a buffer
  120870. * @returns true if the loader can load the specified file
  120871. */
  120872. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  120873. /**
  120874. * Transform the url before loading if required.
  120875. * @param rootUrl the url of the texture
  120876. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120877. * @returns the transformed texture
  120878. */
  120879. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  120880. /**
  120881. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  120882. * @param rootUrl the url of the texture
  120883. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120884. * @returns the fallback texture
  120885. */
  120886. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  120887. /**
  120888. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  120889. * @param data contains the texture data
  120890. * @param texture defines the BabylonJS internal texture
  120891. * @param createPolynomials will be true if polynomials have been requested
  120892. * @param onLoad defines the callback to trigger once the texture is ready
  120893. * @param onError defines the callback to trigger in case of error
  120894. */
  120895. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  120896. /**
  120897. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  120898. * @param data contains the texture data
  120899. * @param texture defines the BabylonJS internal texture
  120900. * @param callback defines the method to call once ready to upload
  120901. */
  120902. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  120903. }
  120904. }
  120905. declare module BABYLON {
  120906. /**
  120907. * 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.
  120908. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  120909. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  120910. */
  120911. export class CustomProceduralTexture extends ProceduralTexture {
  120912. private _animate;
  120913. private _time;
  120914. private _config;
  120915. private _texturePath;
  120916. /**
  120917. * Instantiates a new Custom Procedural Texture.
  120918. * 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.
  120919. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  120920. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  120921. * @param name Define the name of the texture
  120922. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  120923. * @param size Define the size of the texture to create
  120924. * @param scene Define the scene the texture belongs to
  120925. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  120926. * @param generateMipMaps Define if the texture should creates mip maps or not
  120927. */
  120928. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  120929. private _loadJson;
  120930. /**
  120931. * Is the texture ready to be used ? (rendered at least once)
  120932. * @returns true if ready, otherwise, false.
  120933. */
  120934. isReady(): boolean;
  120935. /**
  120936. * Render the texture to its associated render target.
  120937. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  120938. */
  120939. render(useCameraPostProcess?: boolean): void;
  120940. /**
  120941. * Update the list of dependant textures samplers in the shader.
  120942. */
  120943. updateTextures(): void;
  120944. /**
  120945. * Update the uniform values of the procedural texture in the shader.
  120946. */
  120947. updateShaderUniforms(): void;
  120948. /**
  120949. * Define if the texture animates or not.
  120950. */
  120951. animate: boolean;
  120952. }
  120953. }
  120954. declare module BABYLON {
  120955. /** @hidden */
  120956. export var noisePixelShader: {
  120957. name: string;
  120958. shader: string;
  120959. };
  120960. }
  120961. declare module BABYLON {
  120962. /**
  120963. * Class used to generate noise procedural textures
  120964. */
  120965. export class NoiseProceduralTexture extends ProceduralTexture {
  120966. private _time;
  120967. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  120968. brightness: number;
  120969. /** Defines the number of octaves to process */
  120970. octaves: number;
  120971. /** Defines the level of persistence (0.8 by default) */
  120972. persistence: number;
  120973. /** Gets or sets animation speed factor (default is 1) */
  120974. animationSpeedFactor: number;
  120975. /**
  120976. * Creates a new NoiseProceduralTexture
  120977. * @param name defines the name fo the texture
  120978. * @param size defines the size of the texture (default is 256)
  120979. * @param scene defines the hosting scene
  120980. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  120981. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  120982. */
  120983. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  120984. private _updateShaderUniforms;
  120985. protected _getDefines(): string;
  120986. /** Generate the current state of the procedural texture */
  120987. render(useCameraPostProcess?: boolean): void;
  120988. /**
  120989. * Serializes this noise procedural texture
  120990. * @returns a serialized noise procedural texture object
  120991. */
  120992. serialize(): any;
  120993. /**
  120994. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  120995. * @param parsedTexture defines parsed texture data
  120996. * @param scene defines the current scene
  120997. * @param rootUrl defines the root URL containing noise procedural texture information
  120998. * @returns a parsed NoiseProceduralTexture
  120999. */
  121000. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  121001. }
  121002. }
  121003. declare module BABYLON {
  121004. /**
  121005. * Raw cube texture where the raw buffers are passed in
  121006. */
  121007. export class RawCubeTexture extends CubeTexture {
  121008. /**
  121009. * Creates a cube texture where the raw buffers are passed in.
  121010. * @param scene defines the scene the texture is attached to
  121011. * @param data defines the array of data to use to create each face
  121012. * @param size defines the size of the textures
  121013. * @param format defines the format of the data
  121014. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  121015. * @param generateMipMaps defines if the engine should generate the mip levels
  121016. * @param invertY defines if data must be stored with Y axis inverted
  121017. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  121018. * @param compression defines the compression used (null by default)
  121019. */
  121020. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  121021. /**
  121022. * Updates the raw cube texture.
  121023. * @param data defines the data to store
  121024. * @param format defines the data format
  121025. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  121026. * @param invertY defines if data must be stored with Y axis inverted
  121027. * @param compression defines the compression used (null by default)
  121028. * @param level defines which level of the texture to update
  121029. */
  121030. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  121031. /**
  121032. * Updates a raw cube texture with RGBD encoded data.
  121033. * @param data defines the array of data [mipmap][face] to use to create each face
  121034. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  121035. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  121036. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  121037. * @returns a promsie that resolves when the operation is complete
  121038. */
  121039. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  121040. /**
  121041. * Clones the raw cube texture.
  121042. * @return a new cube texture
  121043. */
  121044. clone(): CubeTexture;
  121045. /** @hidden */
  121046. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  121047. }
  121048. }
  121049. declare module BABYLON {
  121050. /**
  121051. * Class used to store 3D textures containing user data
  121052. */
  121053. export class RawTexture3D extends Texture {
  121054. /** Gets or sets the texture format to use */
  121055. format: number;
  121056. private _engine;
  121057. /**
  121058. * Create a new RawTexture3D
  121059. * @param data defines the data of the texture
  121060. * @param width defines the width of the texture
  121061. * @param height defines the height of the texture
  121062. * @param depth defines the depth of the texture
  121063. * @param format defines the texture format to use
  121064. * @param scene defines the hosting scene
  121065. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121066. * @param invertY defines if texture must be stored with Y axis inverted
  121067. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121068. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121069. */
  121070. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121071. /** Gets or sets the texture format to use */
  121072. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121073. /**
  121074. * Update the texture with new data
  121075. * @param data defines the data to store in the texture
  121076. */
  121077. update(data: ArrayBufferView): void;
  121078. }
  121079. }
  121080. declare module BABYLON {
  121081. /**
  121082. * Class used to store 2D array textures containing user data
  121083. */
  121084. export class RawTexture2DArray extends Texture {
  121085. /** Gets or sets the texture format to use */
  121086. format: number;
  121087. private _engine;
  121088. /**
  121089. * Create a new RawTexture2DArray
  121090. * @param data defines the data of the texture
  121091. * @param width defines the width of the texture
  121092. * @param height defines the height of the texture
  121093. * @param depth defines the number of layers of the texture
  121094. * @param format defines the texture format to use
  121095. * @param scene defines the hosting scene
  121096. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121097. * @param invertY defines if texture must be stored with Y axis inverted
  121098. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121099. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121100. */
  121101. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121102. /** Gets or sets the texture format to use */
  121103. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121104. /**
  121105. * Update the texture with new data
  121106. * @param data defines the data to store in the texture
  121107. */
  121108. update(data: ArrayBufferView): void;
  121109. }
  121110. }
  121111. declare module BABYLON {
  121112. /**
  121113. * Creates a refraction texture used by refraction channel of the standard material.
  121114. * It is like a mirror but to see through a material.
  121115. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121116. */
  121117. export class RefractionTexture extends RenderTargetTexture {
  121118. /**
  121119. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  121120. * 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.
  121121. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121122. */
  121123. refractionPlane: Plane;
  121124. /**
  121125. * Define how deep under the surface we should see.
  121126. */
  121127. depth: number;
  121128. /**
  121129. * Creates a refraction texture used by refraction channel of the standard material.
  121130. * It is like a mirror but to see through a material.
  121131. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121132. * @param name Define the texture name
  121133. * @param size Define the size of the underlying texture
  121134. * @param scene Define the scene the refraction belongs to
  121135. * @param generateMipMaps Define if we need to generate mips level for the refraction
  121136. */
  121137. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  121138. /**
  121139. * Clone the refraction texture.
  121140. * @returns the cloned texture
  121141. */
  121142. clone(): RefractionTexture;
  121143. /**
  121144. * Serialize the texture to a JSON representation you could use in Parse later on
  121145. * @returns the serialized JSON representation
  121146. */
  121147. serialize(): any;
  121148. }
  121149. }
  121150. declare module BABYLON {
  121151. /**
  121152. * Defines the options related to the creation of an HtmlElementTexture
  121153. */
  121154. export interface IHtmlElementTextureOptions {
  121155. /**
  121156. * Defines wether mip maps should be created or not.
  121157. */
  121158. generateMipMaps?: boolean;
  121159. /**
  121160. * Defines the sampling mode of the texture.
  121161. */
  121162. samplingMode?: number;
  121163. /**
  121164. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  121165. */
  121166. engine: Nullable<ThinEngine>;
  121167. /**
  121168. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  121169. */
  121170. scene: Nullable<Scene>;
  121171. }
  121172. /**
  121173. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  121174. * To be as efficient as possible depending on your constraints nothing aside the first upload
  121175. * is automatically managed.
  121176. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  121177. * in your application.
  121178. *
  121179. * As the update is not automatic, you need to call them manually.
  121180. */
  121181. export class HtmlElementTexture extends BaseTexture {
  121182. /**
  121183. * The texture URL.
  121184. */
  121185. element: HTMLVideoElement | HTMLCanvasElement;
  121186. private static readonly DefaultOptions;
  121187. private _textureMatrix;
  121188. private _engine;
  121189. private _isVideo;
  121190. private _generateMipMaps;
  121191. private _samplingMode;
  121192. /**
  121193. * Instantiates a HtmlElementTexture from the following parameters.
  121194. *
  121195. * @param name Defines the name of the texture
  121196. * @param element Defines the video or canvas the texture is filled with
  121197. * @param options Defines the other none mandatory texture creation options
  121198. */
  121199. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  121200. private _createInternalTexture;
  121201. /**
  121202. * Returns the texture matrix used in most of the material.
  121203. */
  121204. getTextureMatrix(): Matrix;
  121205. /**
  121206. * Updates the content of the texture.
  121207. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  121208. */
  121209. update(invertY?: Nullable<boolean>): void;
  121210. }
  121211. }
  121212. declare module BABYLON {
  121213. /**
  121214. * Enum used to define the target of a block
  121215. */
  121216. export enum NodeMaterialBlockTargets {
  121217. /** Vertex shader */
  121218. Vertex = 1,
  121219. /** Fragment shader */
  121220. Fragment = 2,
  121221. /** Neutral */
  121222. Neutral = 4,
  121223. /** Vertex and Fragment */
  121224. VertexAndFragment = 3
  121225. }
  121226. }
  121227. declare module BABYLON {
  121228. /**
  121229. * Defines the kind of connection point for node based material
  121230. */
  121231. export enum NodeMaterialBlockConnectionPointTypes {
  121232. /** Float */
  121233. Float = 1,
  121234. /** Int */
  121235. Int = 2,
  121236. /** Vector2 */
  121237. Vector2 = 4,
  121238. /** Vector3 */
  121239. Vector3 = 8,
  121240. /** Vector4 */
  121241. Vector4 = 16,
  121242. /** Color3 */
  121243. Color3 = 32,
  121244. /** Color4 */
  121245. Color4 = 64,
  121246. /** Matrix */
  121247. Matrix = 128,
  121248. /** Detect type based on connection */
  121249. AutoDetect = 1024,
  121250. /** Output type that will be defined by input type */
  121251. BasedOnInput = 2048
  121252. }
  121253. }
  121254. declare module BABYLON {
  121255. /**
  121256. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  121257. */
  121258. export enum NodeMaterialBlockConnectionPointMode {
  121259. /** Value is an uniform */
  121260. Uniform = 0,
  121261. /** Value is a mesh attribute */
  121262. Attribute = 1,
  121263. /** Value is a varying between vertex and fragment shaders */
  121264. Varying = 2,
  121265. /** Mode is undefined */
  121266. Undefined = 3
  121267. }
  121268. }
  121269. declare module BABYLON {
  121270. /**
  121271. * Enum used to define system values e.g. values automatically provided by the system
  121272. */
  121273. export enum NodeMaterialSystemValues {
  121274. /** World */
  121275. World = 1,
  121276. /** View */
  121277. View = 2,
  121278. /** Projection */
  121279. Projection = 3,
  121280. /** ViewProjection */
  121281. ViewProjection = 4,
  121282. /** WorldView */
  121283. WorldView = 5,
  121284. /** WorldViewProjection */
  121285. WorldViewProjection = 6,
  121286. /** CameraPosition */
  121287. CameraPosition = 7,
  121288. /** Fog Color */
  121289. FogColor = 8,
  121290. /** Delta time */
  121291. DeltaTime = 9
  121292. }
  121293. }
  121294. declare module BABYLON {
  121295. /**
  121296. * Root class for all node material optimizers
  121297. */
  121298. export class NodeMaterialOptimizer {
  121299. /**
  121300. * Function used to optimize a NodeMaterial graph
  121301. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  121302. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  121303. */
  121304. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  121305. }
  121306. }
  121307. declare module BABYLON {
  121308. /**
  121309. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  121310. */
  121311. export class TransformBlock extends NodeMaterialBlock {
  121312. /**
  121313. * Defines the value to use to complement W value to transform it to a Vector4
  121314. */
  121315. complementW: number;
  121316. /**
  121317. * Defines the value to use to complement z value to transform it to a Vector4
  121318. */
  121319. complementZ: number;
  121320. /**
  121321. * Creates a new TransformBlock
  121322. * @param name defines the block name
  121323. */
  121324. constructor(name: string);
  121325. /**
  121326. * Gets the current class name
  121327. * @returns the class name
  121328. */
  121329. getClassName(): string;
  121330. /**
  121331. * Gets the vector input
  121332. */
  121333. readonly vector: NodeMaterialConnectionPoint;
  121334. /**
  121335. * Gets the output component
  121336. */
  121337. readonly output: NodeMaterialConnectionPoint;
  121338. /**
  121339. * Gets the matrix transform input
  121340. */
  121341. readonly transform: NodeMaterialConnectionPoint;
  121342. protected _buildBlock(state: NodeMaterialBuildState): this;
  121343. serialize(): any;
  121344. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121345. protected _dumpPropertiesCode(): string;
  121346. }
  121347. }
  121348. declare module BABYLON {
  121349. /**
  121350. * Block used to output the vertex position
  121351. */
  121352. export class VertexOutputBlock extends NodeMaterialBlock {
  121353. /**
  121354. * Creates a new VertexOutputBlock
  121355. * @param name defines the block name
  121356. */
  121357. constructor(name: string);
  121358. /**
  121359. * Gets the current class name
  121360. * @returns the class name
  121361. */
  121362. getClassName(): string;
  121363. /**
  121364. * Gets the vector input component
  121365. */
  121366. readonly vector: NodeMaterialConnectionPoint;
  121367. protected _buildBlock(state: NodeMaterialBuildState): this;
  121368. }
  121369. }
  121370. declare module BABYLON {
  121371. /**
  121372. * Block used to output the final color
  121373. */
  121374. export class FragmentOutputBlock extends NodeMaterialBlock {
  121375. /**
  121376. * Create a new FragmentOutputBlock
  121377. * @param name defines the block name
  121378. */
  121379. constructor(name: string);
  121380. /**
  121381. * Gets the current class name
  121382. * @returns the class name
  121383. */
  121384. getClassName(): string;
  121385. /**
  121386. * Gets the rgba input component
  121387. */
  121388. readonly rgba: NodeMaterialConnectionPoint;
  121389. /**
  121390. * Gets the rgb input component
  121391. */
  121392. readonly rgb: NodeMaterialConnectionPoint;
  121393. /**
  121394. * Gets the a input component
  121395. */
  121396. readonly a: NodeMaterialConnectionPoint;
  121397. protected _buildBlock(state: NodeMaterialBuildState): this;
  121398. }
  121399. }
  121400. declare module BABYLON {
  121401. /**
  121402. * Block used to read a reflection texture from a sampler
  121403. */
  121404. export class ReflectionTextureBlock extends NodeMaterialBlock {
  121405. private _define3DName;
  121406. private _defineCubicName;
  121407. private _defineExplicitName;
  121408. private _defineProjectionName;
  121409. private _defineLocalCubicName;
  121410. private _defineSphericalName;
  121411. private _definePlanarName;
  121412. private _defineEquirectangularName;
  121413. private _defineMirroredEquirectangularFixedName;
  121414. private _defineEquirectangularFixedName;
  121415. private _defineSkyboxName;
  121416. private _cubeSamplerName;
  121417. private _2DSamplerName;
  121418. private _positionUVWName;
  121419. private _directionWName;
  121420. private _reflectionCoordsName;
  121421. private _reflection2DCoordsName;
  121422. private _reflectionColorName;
  121423. private _reflectionMatrixName;
  121424. /**
  121425. * Gets or sets the texture associated with the node
  121426. */
  121427. texture: Nullable<BaseTexture>;
  121428. /**
  121429. * Create a new TextureBlock
  121430. * @param name defines the block name
  121431. */
  121432. constructor(name: string);
  121433. /**
  121434. * Gets the current class name
  121435. * @returns the class name
  121436. */
  121437. getClassName(): string;
  121438. /**
  121439. * Gets the world position input component
  121440. */
  121441. readonly position: NodeMaterialConnectionPoint;
  121442. /**
  121443. * Gets the world position input component
  121444. */
  121445. readonly worldPosition: NodeMaterialConnectionPoint;
  121446. /**
  121447. * Gets the world normal input component
  121448. */
  121449. readonly worldNormal: NodeMaterialConnectionPoint;
  121450. /**
  121451. * Gets the world input component
  121452. */
  121453. readonly world: NodeMaterialConnectionPoint;
  121454. /**
  121455. * Gets the camera (or eye) position component
  121456. */
  121457. readonly cameraPosition: NodeMaterialConnectionPoint;
  121458. /**
  121459. * Gets the view input component
  121460. */
  121461. readonly view: NodeMaterialConnectionPoint;
  121462. /**
  121463. * Gets the rgb output component
  121464. */
  121465. readonly rgb: NodeMaterialConnectionPoint;
  121466. /**
  121467. * Gets the r output component
  121468. */
  121469. readonly r: NodeMaterialConnectionPoint;
  121470. /**
  121471. * Gets the g output component
  121472. */
  121473. readonly g: NodeMaterialConnectionPoint;
  121474. /**
  121475. * Gets the b output component
  121476. */
  121477. readonly b: NodeMaterialConnectionPoint;
  121478. autoConfigure(material: NodeMaterial): void;
  121479. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121480. isReady(): boolean;
  121481. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121482. private _injectVertexCode;
  121483. private _writeOutput;
  121484. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121485. protected _dumpPropertiesCode(): string;
  121486. serialize(): any;
  121487. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121488. }
  121489. }
  121490. declare module BABYLON {
  121491. /**
  121492. * Interface used to configure the node material editor
  121493. */
  121494. export interface INodeMaterialEditorOptions {
  121495. /** Define the URl to load node editor script */
  121496. editorURL?: string;
  121497. }
  121498. /** @hidden */
  121499. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  121500. /** BONES */
  121501. NUM_BONE_INFLUENCERS: number;
  121502. BonesPerMesh: number;
  121503. BONETEXTURE: boolean;
  121504. /** MORPH TARGETS */
  121505. MORPHTARGETS: boolean;
  121506. MORPHTARGETS_NORMAL: boolean;
  121507. MORPHTARGETS_TANGENT: boolean;
  121508. MORPHTARGETS_UV: boolean;
  121509. NUM_MORPH_INFLUENCERS: number;
  121510. /** IMAGE PROCESSING */
  121511. IMAGEPROCESSING: boolean;
  121512. VIGNETTE: boolean;
  121513. VIGNETTEBLENDMODEMULTIPLY: boolean;
  121514. VIGNETTEBLENDMODEOPAQUE: boolean;
  121515. TONEMAPPING: boolean;
  121516. TONEMAPPING_ACES: boolean;
  121517. CONTRAST: boolean;
  121518. EXPOSURE: boolean;
  121519. COLORCURVES: boolean;
  121520. COLORGRADING: boolean;
  121521. COLORGRADING3D: boolean;
  121522. SAMPLER3DGREENDEPTH: boolean;
  121523. SAMPLER3DBGRMAP: boolean;
  121524. IMAGEPROCESSINGPOSTPROCESS: boolean;
  121525. /** MISC. */
  121526. BUMPDIRECTUV: number;
  121527. constructor();
  121528. setValue(name: string, value: boolean): void;
  121529. }
  121530. /**
  121531. * Class used to configure NodeMaterial
  121532. */
  121533. export interface INodeMaterialOptions {
  121534. /**
  121535. * Defines if blocks should emit comments
  121536. */
  121537. emitComments: boolean;
  121538. }
  121539. /**
  121540. * Class used to create a node based material built by assembling shader blocks
  121541. */
  121542. export class NodeMaterial extends PushMaterial {
  121543. private static _BuildIdGenerator;
  121544. private _options;
  121545. private _vertexCompilationState;
  121546. private _fragmentCompilationState;
  121547. private _sharedData;
  121548. private _buildId;
  121549. private _buildWasSuccessful;
  121550. private _cachedWorldViewMatrix;
  121551. private _cachedWorldViewProjectionMatrix;
  121552. private _optimizers;
  121553. private _animationFrame;
  121554. /** Define the URl to load node editor script */
  121555. static EditorURL: string;
  121556. private BJSNODEMATERIALEDITOR;
  121557. /** Get the inspector from bundle or global */
  121558. private _getGlobalNodeMaterialEditor;
  121559. /**
  121560. * 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)
  121561. */
  121562. ignoreAlpha: boolean;
  121563. /**
  121564. * Defines the maximum number of lights that can be used in the material
  121565. */
  121566. maxSimultaneousLights: number;
  121567. /**
  121568. * Observable raised when the material is built
  121569. */
  121570. onBuildObservable: Observable<NodeMaterial>;
  121571. /**
  121572. * Gets or sets the root nodes of the material vertex shader
  121573. */
  121574. _vertexOutputNodes: NodeMaterialBlock[];
  121575. /**
  121576. * Gets or sets the root nodes of the material fragment (pixel) shader
  121577. */
  121578. _fragmentOutputNodes: NodeMaterialBlock[];
  121579. /** Gets or sets options to control the node material overall behavior */
  121580. options: INodeMaterialOptions;
  121581. /**
  121582. * Default configuration related to image processing available in the standard Material.
  121583. */
  121584. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  121585. /**
  121586. * Gets the image processing configuration used either in this material.
  121587. */
  121588. /**
  121589. * Sets the Default image processing configuration used either in the this material.
  121590. *
  121591. * If sets to null, the scene one is in use.
  121592. */
  121593. imageProcessingConfiguration: ImageProcessingConfiguration;
  121594. /**
  121595. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  121596. */
  121597. attachedBlocks: NodeMaterialBlock[];
  121598. /**
  121599. * Create a new node based material
  121600. * @param name defines the material name
  121601. * @param scene defines the hosting scene
  121602. * @param options defines creation option
  121603. */
  121604. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  121605. /**
  121606. * Gets the current class name of the material e.g. "NodeMaterial"
  121607. * @returns the class name
  121608. */
  121609. getClassName(): string;
  121610. /**
  121611. * Keep track of the image processing observer to allow dispose and replace.
  121612. */
  121613. private _imageProcessingObserver;
  121614. /**
  121615. * Attaches a new image processing configuration to the Standard Material.
  121616. * @param configuration
  121617. */
  121618. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  121619. /**
  121620. * Get a block by its name
  121621. * @param name defines the name of the block to retrieve
  121622. * @returns the required block or null if not found
  121623. */
  121624. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  121625. /**
  121626. * Get a block by its name
  121627. * @param predicate defines the predicate used to find the good candidate
  121628. * @returns the required block or null if not found
  121629. */
  121630. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  121631. /**
  121632. * Get an input block by its name
  121633. * @param predicate defines the predicate used to find the good candidate
  121634. * @returns the required input block or null if not found
  121635. */
  121636. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  121637. /**
  121638. * Gets the list of input blocks attached to this material
  121639. * @returns an array of InputBlocks
  121640. */
  121641. getInputBlocks(): InputBlock[];
  121642. /**
  121643. * Adds a new optimizer to the list of optimizers
  121644. * @param optimizer defines the optimizers to add
  121645. * @returns the current material
  121646. */
  121647. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  121648. /**
  121649. * Remove an optimizer from the list of optimizers
  121650. * @param optimizer defines the optimizers to remove
  121651. * @returns the current material
  121652. */
  121653. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  121654. /**
  121655. * Add a new block to the list of output nodes
  121656. * @param node defines the node to add
  121657. * @returns the current material
  121658. */
  121659. addOutputNode(node: NodeMaterialBlock): this;
  121660. /**
  121661. * Remove a block from the list of root nodes
  121662. * @param node defines the node to remove
  121663. * @returns the current material
  121664. */
  121665. removeOutputNode(node: NodeMaterialBlock): this;
  121666. private _addVertexOutputNode;
  121667. private _removeVertexOutputNode;
  121668. private _addFragmentOutputNode;
  121669. private _removeFragmentOutputNode;
  121670. /**
  121671. * Specifies if the material will require alpha blending
  121672. * @returns a boolean specifying if alpha blending is needed
  121673. */
  121674. needAlphaBlending(): boolean;
  121675. /**
  121676. * Specifies if this material should be rendered in alpha test mode
  121677. * @returns a boolean specifying if an alpha test is needed.
  121678. */
  121679. needAlphaTesting(): boolean;
  121680. private _initializeBlock;
  121681. private _resetDualBlocks;
  121682. /**
  121683. * Build the material and generates the inner effect
  121684. * @param verbose defines if the build should log activity
  121685. */
  121686. build(verbose?: boolean): void;
  121687. /**
  121688. * Runs an otpimization phase to try to improve the shader code
  121689. */
  121690. optimize(): void;
  121691. private _prepareDefinesForAttributes;
  121692. /**
  121693. * Get if the submesh is ready to be used and all its information available.
  121694. * Child classes can use it to update shaders
  121695. * @param mesh defines the mesh to check
  121696. * @param subMesh defines which submesh to check
  121697. * @param useInstances specifies that instances should be used
  121698. * @returns a boolean indicating that the submesh is ready or not
  121699. */
  121700. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  121701. /**
  121702. * Get a string representing the shaders built by the current node graph
  121703. */
  121704. readonly compiledShaders: string;
  121705. /**
  121706. * Binds the world matrix to the material
  121707. * @param world defines the world transformation matrix
  121708. */
  121709. bindOnlyWorldMatrix(world: Matrix): void;
  121710. /**
  121711. * Binds the submesh to this material by preparing the effect and shader to draw
  121712. * @param world defines the world transformation matrix
  121713. * @param mesh defines the mesh containing the submesh
  121714. * @param subMesh defines the submesh to bind the material to
  121715. */
  121716. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  121717. /**
  121718. * Gets the active textures from the material
  121719. * @returns an array of textures
  121720. */
  121721. getActiveTextures(): BaseTexture[];
  121722. /**
  121723. * Gets the list of texture blocks
  121724. * @returns an array of texture blocks
  121725. */
  121726. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  121727. /**
  121728. * Specifies if the material uses a texture
  121729. * @param texture defines the texture to check against the material
  121730. * @returns a boolean specifying if the material uses the texture
  121731. */
  121732. hasTexture(texture: BaseTexture): boolean;
  121733. /**
  121734. * Disposes the material
  121735. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  121736. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  121737. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  121738. */
  121739. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  121740. /** Creates the node editor window. */
  121741. private _createNodeEditor;
  121742. /**
  121743. * Launch the node material editor
  121744. * @param config Define the configuration of the editor
  121745. * @return a promise fulfilled when the node editor is visible
  121746. */
  121747. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  121748. /**
  121749. * Clear the current material
  121750. */
  121751. clear(): void;
  121752. /**
  121753. * Clear the current material and set it to a default state
  121754. */
  121755. setToDefault(): void;
  121756. /**
  121757. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  121758. * @param url defines the url to load from
  121759. * @returns a promise that will fullfil when the material is fully loaded
  121760. */
  121761. loadAsync(url: string): Promise<void>;
  121762. private _gatherBlocks;
  121763. /**
  121764. * Generate a string containing the code declaration required to create an equivalent of this material
  121765. * @returns a string
  121766. */
  121767. generateCode(): string;
  121768. /**
  121769. * Serializes this material in a JSON representation
  121770. * @returns the serialized material object
  121771. */
  121772. serialize(): any;
  121773. private _restoreConnections;
  121774. /**
  121775. * Clear the current graph and load a new one from a serialization object
  121776. * @param source defines the JSON representation of the material
  121777. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121778. */
  121779. loadFromSerialization(source: any, rootUrl?: string): void;
  121780. /**
  121781. * Creates a node material from parsed material data
  121782. * @param source defines the JSON representation of the material
  121783. * @param scene defines the hosting scene
  121784. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121785. * @returns a new node material
  121786. */
  121787. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  121788. /**
  121789. * Creates a new node material set to default basic configuration
  121790. * @param name defines the name of the material
  121791. * @param scene defines the hosting scene
  121792. * @returns a new NodeMaterial
  121793. */
  121794. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  121795. }
  121796. }
  121797. declare module BABYLON {
  121798. /**
  121799. * Block used to read a texture from a sampler
  121800. */
  121801. export class TextureBlock extends NodeMaterialBlock {
  121802. private _defineName;
  121803. private _linearDefineName;
  121804. private _samplerName;
  121805. private _transformedUVName;
  121806. private _textureTransformName;
  121807. private _textureInfoName;
  121808. private _mainUVName;
  121809. private _mainUVDefineName;
  121810. /**
  121811. * Gets or sets the texture associated with the node
  121812. */
  121813. texture: Nullable<Texture>;
  121814. /**
  121815. * Create a new TextureBlock
  121816. * @param name defines the block name
  121817. */
  121818. constructor(name: string);
  121819. /**
  121820. * Gets the current class name
  121821. * @returns the class name
  121822. */
  121823. getClassName(): string;
  121824. /**
  121825. * Gets the uv input component
  121826. */
  121827. readonly uv: NodeMaterialConnectionPoint;
  121828. /**
  121829. * Gets the rgba output component
  121830. */
  121831. readonly rgba: NodeMaterialConnectionPoint;
  121832. /**
  121833. * Gets the rgb output component
  121834. */
  121835. readonly rgb: NodeMaterialConnectionPoint;
  121836. /**
  121837. * Gets the r output component
  121838. */
  121839. readonly r: NodeMaterialConnectionPoint;
  121840. /**
  121841. * Gets the g output component
  121842. */
  121843. readonly g: NodeMaterialConnectionPoint;
  121844. /**
  121845. * Gets the b output component
  121846. */
  121847. readonly b: NodeMaterialConnectionPoint;
  121848. /**
  121849. * Gets the a output component
  121850. */
  121851. readonly a: NodeMaterialConnectionPoint;
  121852. readonly target: NodeMaterialBlockTargets;
  121853. autoConfigure(material: NodeMaterial): void;
  121854. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121855. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121856. isReady(): boolean;
  121857. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121858. private readonly _isMixed;
  121859. private _injectVertexCode;
  121860. private _writeOutput;
  121861. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121862. protected _dumpPropertiesCode(): string;
  121863. serialize(): any;
  121864. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121865. }
  121866. }
  121867. declare module BABYLON {
  121868. /**
  121869. * Class used to store shared data between 2 NodeMaterialBuildState
  121870. */
  121871. export class NodeMaterialBuildStateSharedData {
  121872. /**
  121873. * Gets the list of emitted varyings
  121874. */
  121875. temps: string[];
  121876. /**
  121877. * Gets the list of emitted varyings
  121878. */
  121879. varyings: string[];
  121880. /**
  121881. * Gets the varying declaration string
  121882. */
  121883. varyingDeclaration: string;
  121884. /**
  121885. * Input blocks
  121886. */
  121887. inputBlocks: InputBlock[];
  121888. /**
  121889. * Input blocks
  121890. */
  121891. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  121892. /**
  121893. * Bindable blocks (Blocks that need to set data to the effect)
  121894. */
  121895. bindableBlocks: NodeMaterialBlock[];
  121896. /**
  121897. * List of blocks that can provide a compilation fallback
  121898. */
  121899. blocksWithFallbacks: NodeMaterialBlock[];
  121900. /**
  121901. * List of blocks that can provide a define update
  121902. */
  121903. blocksWithDefines: NodeMaterialBlock[];
  121904. /**
  121905. * List of blocks that can provide a repeatable content
  121906. */
  121907. repeatableContentBlocks: NodeMaterialBlock[];
  121908. /**
  121909. * List of blocks that can provide a dynamic list of uniforms
  121910. */
  121911. dynamicUniformBlocks: NodeMaterialBlock[];
  121912. /**
  121913. * List of blocks that can block the isReady function for the material
  121914. */
  121915. blockingBlocks: NodeMaterialBlock[];
  121916. /**
  121917. * Gets the list of animated inputs
  121918. */
  121919. animatedInputs: InputBlock[];
  121920. /**
  121921. * Build Id used to avoid multiple recompilations
  121922. */
  121923. buildId: number;
  121924. /** List of emitted variables */
  121925. variableNames: {
  121926. [key: string]: number;
  121927. };
  121928. /** List of emitted defines */
  121929. defineNames: {
  121930. [key: string]: number;
  121931. };
  121932. /** Should emit comments? */
  121933. emitComments: boolean;
  121934. /** Emit build activity */
  121935. verbose: boolean;
  121936. /** Gets or sets the hosting scene */
  121937. scene: Scene;
  121938. /**
  121939. * Gets the compilation hints emitted at compilation time
  121940. */
  121941. hints: {
  121942. needWorldViewMatrix: boolean;
  121943. needWorldViewProjectionMatrix: boolean;
  121944. needAlphaBlending: boolean;
  121945. needAlphaTesting: boolean;
  121946. };
  121947. /**
  121948. * List of compilation checks
  121949. */
  121950. checks: {
  121951. emitVertex: boolean;
  121952. emitFragment: boolean;
  121953. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  121954. };
  121955. /** Creates a new shared data */
  121956. constructor();
  121957. /**
  121958. * Emits console errors and exceptions if there is a failing check
  121959. */
  121960. emitErrors(): void;
  121961. }
  121962. }
  121963. declare module BABYLON {
  121964. /**
  121965. * Class used to store node based material build state
  121966. */
  121967. export class NodeMaterialBuildState {
  121968. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  121969. supportUniformBuffers: boolean;
  121970. /**
  121971. * Gets the list of emitted attributes
  121972. */
  121973. attributes: string[];
  121974. /**
  121975. * Gets the list of emitted uniforms
  121976. */
  121977. uniforms: string[];
  121978. /**
  121979. * Gets the list of emitted constants
  121980. */
  121981. constants: string[];
  121982. /**
  121983. * Gets the list of emitted samplers
  121984. */
  121985. samplers: string[];
  121986. /**
  121987. * Gets the list of emitted functions
  121988. */
  121989. functions: {
  121990. [key: string]: string;
  121991. };
  121992. /**
  121993. * Gets the list of emitted extensions
  121994. */
  121995. extensions: {
  121996. [key: string]: string;
  121997. };
  121998. /**
  121999. * Gets the target of the compilation state
  122000. */
  122001. target: NodeMaterialBlockTargets;
  122002. /**
  122003. * Gets the list of emitted counters
  122004. */
  122005. counters: {
  122006. [key: string]: number;
  122007. };
  122008. /**
  122009. * Shared data between multiple NodeMaterialBuildState instances
  122010. */
  122011. sharedData: NodeMaterialBuildStateSharedData;
  122012. /** @hidden */
  122013. _vertexState: NodeMaterialBuildState;
  122014. /** @hidden */
  122015. _attributeDeclaration: string;
  122016. /** @hidden */
  122017. _uniformDeclaration: string;
  122018. /** @hidden */
  122019. _constantDeclaration: string;
  122020. /** @hidden */
  122021. _samplerDeclaration: string;
  122022. /** @hidden */
  122023. _varyingTransfer: string;
  122024. private _repeatableContentAnchorIndex;
  122025. /** @hidden */
  122026. _builtCompilationString: string;
  122027. /**
  122028. * Gets the emitted compilation strings
  122029. */
  122030. compilationString: string;
  122031. /**
  122032. * Finalize the compilation strings
  122033. * @param state defines the current compilation state
  122034. */
  122035. finalize(state: NodeMaterialBuildState): void;
  122036. /** @hidden */
  122037. readonly _repeatableContentAnchor: string;
  122038. /** @hidden */
  122039. _getFreeVariableName(prefix: string): string;
  122040. /** @hidden */
  122041. _getFreeDefineName(prefix: string): string;
  122042. /** @hidden */
  122043. _excludeVariableName(name: string): void;
  122044. /** @hidden */
  122045. _emit2DSampler(name: string): void;
  122046. /** @hidden */
  122047. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  122048. /** @hidden */
  122049. _emitExtension(name: string, extension: string): void;
  122050. /** @hidden */
  122051. _emitFunction(name: string, code: string, comments: string): void;
  122052. /** @hidden */
  122053. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  122054. replaceStrings?: {
  122055. search: RegExp;
  122056. replace: string;
  122057. }[];
  122058. repeatKey?: string;
  122059. }): string;
  122060. /** @hidden */
  122061. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  122062. repeatKey?: string;
  122063. removeAttributes?: boolean;
  122064. removeUniforms?: boolean;
  122065. removeVaryings?: boolean;
  122066. removeIfDef?: boolean;
  122067. replaceStrings?: {
  122068. search: RegExp;
  122069. replace: string;
  122070. }[];
  122071. }, storeKey?: string): void;
  122072. /** @hidden */
  122073. _registerTempVariable(name: string): boolean;
  122074. /** @hidden */
  122075. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  122076. /** @hidden */
  122077. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  122078. /** @hidden */
  122079. _emitFloat(value: number): string;
  122080. }
  122081. }
  122082. declare module BABYLON {
  122083. /**
  122084. * Defines a block that can be used inside a node based material
  122085. */
  122086. export class NodeMaterialBlock {
  122087. private _buildId;
  122088. private _buildTarget;
  122089. private _target;
  122090. private _isFinalMerger;
  122091. private _isInput;
  122092. protected _isUnique: boolean;
  122093. /** @hidden */
  122094. _codeVariableName: string;
  122095. /** @hidden */
  122096. _inputs: NodeMaterialConnectionPoint[];
  122097. /** @hidden */
  122098. _outputs: NodeMaterialConnectionPoint[];
  122099. /** @hidden */
  122100. _preparationId: number;
  122101. /**
  122102. * Gets or sets the name of the block
  122103. */
  122104. name: string;
  122105. /**
  122106. * Gets or sets the unique id of the node
  122107. */
  122108. uniqueId: number;
  122109. /**
  122110. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  122111. */
  122112. readonly isUnique: boolean;
  122113. /**
  122114. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  122115. */
  122116. readonly isFinalMerger: boolean;
  122117. /**
  122118. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  122119. */
  122120. readonly isInput: boolean;
  122121. /**
  122122. * Gets or sets the build Id
  122123. */
  122124. buildId: number;
  122125. /**
  122126. * Gets or sets the target of the block
  122127. */
  122128. target: NodeMaterialBlockTargets;
  122129. /**
  122130. * Gets the list of input points
  122131. */
  122132. readonly inputs: NodeMaterialConnectionPoint[];
  122133. /** Gets the list of output points */
  122134. readonly outputs: NodeMaterialConnectionPoint[];
  122135. /**
  122136. * Find an input by its name
  122137. * @param name defines the name of the input to look for
  122138. * @returns the input or null if not found
  122139. */
  122140. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  122141. /**
  122142. * Find an output by its name
  122143. * @param name defines the name of the outputto look for
  122144. * @returns the output or null if not found
  122145. */
  122146. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  122147. /**
  122148. * Creates a new NodeMaterialBlock
  122149. * @param name defines the block name
  122150. * @param target defines the target of that block (Vertex by default)
  122151. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  122152. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  122153. */
  122154. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  122155. /**
  122156. * Initialize the block and prepare the context for build
  122157. * @param state defines the state that will be used for the build
  122158. */
  122159. initialize(state: NodeMaterialBuildState): void;
  122160. /**
  122161. * Bind data to effect. Will only be called for blocks with isBindable === true
  122162. * @param effect defines the effect to bind data to
  122163. * @param nodeMaterial defines the hosting NodeMaterial
  122164. * @param mesh defines the mesh that will be rendered
  122165. */
  122166. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122167. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  122168. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  122169. protected _writeFloat(value: number): string;
  122170. /**
  122171. * Gets the current class name e.g. "NodeMaterialBlock"
  122172. * @returns the class name
  122173. */
  122174. getClassName(): string;
  122175. /**
  122176. * Register a new input. Must be called inside a block constructor
  122177. * @param name defines the connection point name
  122178. * @param type defines the connection point type
  122179. * @param isOptional defines a boolean indicating that this input can be omitted
  122180. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  122181. * @returns the current block
  122182. */
  122183. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  122184. /**
  122185. * Register a new output. Must be called inside a block constructor
  122186. * @param name defines the connection point name
  122187. * @param type defines the connection point type
  122188. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  122189. * @returns the current block
  122190. */
  122191. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  122192. /**
  122193. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  122194. * @param forOutput defines an optional connection point to check compatibility with
  122195. * @returns the first available input or null
  122196. */
  122197. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  122198. /**
  122199. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  122200. * @param forBlock defines an optional block to check compatibility with
  122201. * @returns the first available input or null
  122202. */
  122203. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  122204. /**
  122205. * Gets the sibling of the given output
  122206. * @param current defines the current output
  122207. * @returns the next output in the list or null
  122208. */
  122209. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  122210. /**
  122211. * Connect current block with another block
  122212. * @param other defines the block to connect with
  122213. * @param options define the various options to help pick the right connections
  122214. * @returns the current block
  122215. */
  122216. connectTo(other: NodeMaterialBlock, options?: {
  122217. input?: string;
  122218. output?: string;
  122219. outputSwizzle?: string;
  122220. }): this | undefined;
  122221. protected _buildBlock(state: NodeMaterialBuildState): void;
  122222. /**
  122223. * Add uniforms, samplers and uniform buffers at compilation time
  122224. * @param state defines the state to update
  122225. * @param nodeMaterial defines the node material requesting the update
  122226. * @param defines defines the material defines to update
  122227. * @param uniformBuffers defines the list of uniform buffer names
  122228. */
  122229. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  122230. /**
  122231. * Add potential fallbacks if shader compilation fails
  122232. * @param mesh defines the mesh to be rendered
  122233. * @param fallbacks defines the current prioritized list of fallbacks
  122234. */
  122235. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  122236. /**
  122237. * Initialize defines for shader compilation
  122238. * @param mesh defines the mesh to be rendered
  122239. * @param nodeMaterial defines the node material requesting the update
  122240. * @param defines defines the material defines to update
  122241. * @param useInstances specifies that instances should be used
  122242. */
  122243. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122244. /**
  122245. * Update defines for shader compilation
  122246. * @param mesh defines the mesh to be rendered
  122247. * @param nodeMaterial defines the node material requesting the update
  122248. * @param defines defines the material defines to update
  122249. * @param useInstances specifies that instances should be used
  122250. */
  122251. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122252. /**
  122253. * Lets the block try to connect some inputs automatically
  122254. * @param material defines the hosting NodeMaterial
  122255. */
  122256. autoConfigure(material: NodeMaterial): void;
  122257. /**
  122258. * Function called when a block is declared as repeatable content generator
  122259. * @param vertexShaderState defines the current compilation state for the vertex shader
  122260. * @param fragmentShaderState defines the current compilation state for the fragment shader
  122261. * @param mesh defines the mesh to be rendered
  122262. * @param defines defines the material defines to update
  122263. */
  122264. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  122265. /**
  122266. * Checks if the block is ready
  122267. * @param mesh defines the mesh to be rendered
  122268. * @param nodeMaterial defines the node material requesting the update
  122269. * @param defines defines the material defines to update
  122270. * @param useInstances specifies that instances should be used
  122271. * @returns true if the block is ready
  122272. */
  122273. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  122274. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  122275. private _processBuild;
  122276. /**
  122277. * Compile the current node and generate the shader code
  122278. * @param state defines the current compilation state (uniforms, samplers, current string)
  122279. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  122280. * @returns true if already built
  122281. */
  122282. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  122283. protected _inputRename(name: string): string;
  122284. protected _outputRename(name: string): string;
  122285. protected _dumpPropertiesCode(): string;
  122286. /** @hidden */
  122287. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  122288. /** @hidden */
  122289. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  122290. /**
  122291. * Clone the current block to a new identical block
  122292. * @param scene defines the hosting scene
  122293. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  122294. * @returns a copy of the current block
  122295. */
  122296. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  122297. /**
  122298. * Serializes this block in a JSON representation
  122299. * @returns the serialized block object
  122300. */
  122301. serialize(): any;
  122302. /** @hidden */
  122303. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122304. /**
  122305. * Release resources
  122306. */
  122307. dispose(): void;
  122308. }
  122309. }
  122310. declare module BABYLON {
  122311. /**
  122312. * Enum defining the type of animations supported by InputBlock
  122313. */
  122314. export enum AnimatedInputBlockTypes {
  122315. /** No animation */
  122316. None = 0,
  122317. /** Time based animation. Will only work for floats */
  122318. Time = 1
  122319. }
  122320. }
  122321. declare module BABYLON {
  122322. /**
  122323. * Block used to expose an input value
  122324. */
  122325. export class InputBlock extends NodeMaterialBlock {
  122326. private _mode;
  122327. private _associatedVariableName;
  122328. private _storedValue;
  122329. private _valueCallback;
  122330. private _type;
  122331. private _animationType;
  122332. /** Gets or set a value used to limit the range of float values */
  122333. min: number;
  122334. /** Gets or set a value used to limit the range of float values */
  122335. max: number;
  122336. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  122337. matrixMode: number;
  122338. /** @hidden */
  122339. _systemValue: Nullable<NodeMaterialSystemValues>;
  122340. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  122341. visibleInInspector: boolean;
  122342. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  122343. isConstant: boolean;
  122344. /**
  122345. * Gets or sets the connection point type (default is float)
  122346. */
  122347. readonly type: NodeMaterialBlockConnectionPointTypes;
  122348. /**
  122349. * Creates a new InputBlock
  122350. * @param name defines the block name
  122351. * @param target defines the target of that block (Vertex by default)
  122352. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  122353. */
  122354. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  122355. /**
  122356. * Gets the output component
  122357. */
  122358. readonly output: NodeMaterialConnectionPoint;
  122359. /**
  122360. * Set the source of this connection point to a vertex attribute
  122361. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  122362. * @returns the current connection point
  122363. */
  122364. setAsAttribute(attributeName?: string): InputBlock;
  122365. /**
  122366. * Set the source of this connection point to a system value
  122367. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  122368. * @returns the current connection point
  122369. */
  122370. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  122371. /**
  122372. * Gets or sets the value of that point.
  122373. * Please note that this value will be ignored if valueCallback is defined
  122374. */
  122375. value: any;
  122376. /**
  122377. * Gets or sets a callback used to get the value of that point.
  122378. * Please note that setting this value will force the connection point to ignore the value property
  122379. */
  122380. valueCallback: () => any;
  122381. /**
  122382. * Gets or sets the associated variable name in the shader
  122383. */
  122384. associatedVariableName: string;
  122385. /** Gets or sets the type of animation applied to the input */
  122386. animationType: AnimatedInputBlockTypes;
  122387. /**
  122388. * Gets a boolean indicating that this connection point not defined yet
  122389. */
  122390. readonly isUndefined: boolean;
  122391. /**
  122392. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  122393. * In this case the connection point name must be the name of the uniform to use.
  122394. * Can only be set on inputs
  122395. */
  122396. isUniform: boolean;
  122397. /**
  122398. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  122399. * In this case the connection point name must be the name of the attribute to use
  122400. * Can only be set on inputs
  122401. */
  122402. isAttribute: boolean;
  122403. /**
  122404. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  122405. * Can only be set on exit points
  122406. */
  122407. isVarying: boolean;
  122408. /**
  122409. * Gets a boolean indicating that the current connection point is a system value
  122410. */
  122411. readonly isSystemValue: boolean;
  122412. /**
  122413. * Gets or sets the current well known value or null if not defined as a system value
  122414. */
  122415. systemValue: Nullable<NodeMaterialSystemValues>;
  122416. /**
  122417. * Gets the current class name
  122418. * @returns the class name
  122419. */
  122420. getClassName(): string;
  122421. /**
  122422. * Animate the input if animationType !== None
  122423. * @param scene defines the rendering scene
  122424. */
  122425. animate(scene: Scene): void;
  122426. private _emitDefine;
  122427. initialize(state: NodeMaterialBuildState): void;
  122428. /**
  122429. * Set the input block to its default value (based on its type)
  122430. */
  122431. setDefaultValue(): void;
  122432. private _emitConstant;
  122433. private _emit;
  122434. /** @hidden */
  122435. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  122436. /** @hidden */
  122437. _transmit(effect: Effect, scene: Scene): void;
  122438. protected _buildBlock(state: NodeMaterialBuildState): void;
  122439. protected _dumpPropertiesCode(): string;
  122440. serialize(): any;
  122441. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122442. }
  122443. }
  122444. declare module BABYLON {
  122445. /**
  122446. * Enum used to define the compatibility state between two connection points
  122447. */
  122448. export enum NodeMaterialConnectionPointCompatibilityStates {
  122449. /** Points are compatibles */
  122450. Compatible = 0,
  122451. /** Points are incompatible because of their types */
  122452. TypeIncompatible = 1,
  122453. /** Points are incompatible because of their targets (vertex vs fragment) */
  122454. TargetIncompatible = 2
  122455. }
  122456. /**
  122457. * Defines a connection point for a block
  122458. */
  122459. export class NodeMaterialConnectionPoint {
  122460. /** @hidden */
  122461. _ownerBlock: NodeMaterialBlock;
  122462. /** @hidden */
  122463. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  122464. private _endpoints;
  122465. private _associatedVariableName;
  122466. /** @hidden */
  122467. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  122468. /** @hidden */
  122469. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  122470. private _type;
  122471. /** @hidden */
  122472. _enforceAssociatedVariableName: boolean;
  122473. /**
  122474. * Gets or sets the additional types supported by this connection point
  122475. */
  122476. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  122477. /**
  122478. * Gets or sets the additional types excluded by this connection point
  122479. */
  122480. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  122481. /**
  122482. * Observable triggered when this point is connected
  122483. */
  122484. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  122485. /**
  122486. * Gets or sets the associated variable name in the shader
  122487. */
  122488. associatedVariableName: string;
  122489. /**
  122490. * Gets or sets the connection point type (default is float)
  122491. */
  122492. type: NodeMaterialBlockConnectionPointTypes;
  122493. /**
  122494. * Gets or sets the connection point name
  122495. */
  122496. name: string;
  122497. /**
  122498. * Gets or sets a boolean indicating that this connection point can be omitted
  122499. */
  122500. isOptional: boolean;
  122501. /**
  122502. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  122503. */
  122504. define: string;
  122505. /** @hidden */
  122506. _prioritizeVertex: boolean;
  122507. private _target;
  122508. /** Gets or sets the target of that connection point */
  122509. target: NodeMaterialBlockTargets;
  122510. /**
  122511. * Gets a boolean indicating that the current point is connected
  122512. */
  122513. readonly isConnected: boolean;
  122514. /**
  122515. * Gets a boolean indicating that the current point is connected to an input block
  122516. */
  122517. readonly isConnectedToInputBlock: boolean;
  122518. /**
  122519. * Gets a the connected input block (if any)
  122520. */
  122521. readonly connectInputBlock: Nullable<InputBlock>;
  122522. /** Get the other side of the connection (if any) */
  122523. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  122524. /** Get the block that owns this connection point */
  122525. readonly ownerBlock: NodeMaterialBlock;
  122526. /** Get the block connected on the other side of this connection (if any) */
  122527. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  122528. /** Get the block connected on the endpoints of this connection (if any) */
  122529. readonly connectedBlocks: Array<NodeMaterialBlock>;
  122530. /** Gets the list of connected endpoints */
  122531. readonly endpoints: NodeMaterialConnectionPoint[];
  122532. /** Gets a boolean indicating if that output point is connected to at least one input */
  122533. readonly hasEndpoints: boolean;
  122534. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  122535. readonly isConnectedInVertexShader: boolean;
  122536. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  122537. readonly isConnectedInFragmentShader: boolean;
  122538. /**
  122539. * Creates a new connection point
  122540. * @param name defines the connection point name
  122541. * @param ownerBlock defines the block hosting this connection point
  122542. */
  122543. constructor(name: string, ownerBlock: NodeMaterialBlock);
  122544. /**
  122545. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  122546. * @returns the class name
  122547. */
  122548. getClassName(): string;
  122549. /**
  122550. * Gets a boolean indicating if the current point can be connected to another point
  122551. * @param connectionPoint defines the other connection point
  122552. * @returns a boolean
  122553. */
  122554. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  122555. /**
  122556. * Gets a number indicating if the current point can be connected to another point
  122557. * @param connectionPoint defines the other connection point
  122558. * @returns a number defining the compatibility state
  122559. */
  122560. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  122561. /**
  122562. * Connect this point to another connection point
  122563. * @param connectionPoint defines the other connection point
  122564. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  122565. * @returns the current connection point
  122566. */
  122567. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  122568. /**
  122569. * Disconnect this point from one of his endpoint
  122570. * @param endpoint defines the other connection point
  122571. * @returns the current connection point
  122572. */
  122573. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  122574. /**
  122575. * Serializes this point in a JSON representation
  122576. * @returns the serialized point object
  122577. */
  122578. serialize(): any;
  122579. /**
  122580. * Release resources
  122581. */
  122582. dispose(): void;
  122583. }
  122584. }
  122585. declare module BABYLON {
  122586. /**
  122587. * Block used to add support for vertex skinning (bones)
  122588. */
  122589. export class BonesBlock extends NodeMaterialBlock {
  122590. /**
  122591. * Creates a new BonesBlock
  122592. * @param name defines the block name
  122593. */
  122594. constructor(name: string);
  122595. /**
  122596. * Initialize the block and prepare the context for build
  122597. * @param state defines the state that will be used for the build
  122598. */
  122599. initialize(state: NodeMaterialBuildState): void;
  122600. /**
  122601. * Gets the current class name
  122602. * @returns the class name
  122603. */
  122604. getClassName(): string;
  122605. /**
  122606. * Gets the matrix indices input component
  122607. */
  122608. readonly matricesIndices: NodeMaterialConnectionPoint;
  122609. /**
  122610. * Gets the matrix weights input component
  122611. */
  122612. readonly matricesWeights: NodeMaterialConnectionPoint;
  122613. /**
  122614. * Gets the extra matrix indices input component
  122615. */
  122616. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  122617. /**
  122618. * Gets the extra matrix weights input component
  122619. */
  122620. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  122621. /**
  122622. * Gets the world input component
  122623. */
  122624. readonly world: NodeMaterialConnectionPoint;
  122625. /**
  122626. * Gets the output component
  122627. */
  122628. readonly output: NodeMaterialConnectionPoint;
  122629. autoConfigure(material: NodeMaterial): void;
  122630. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  122631. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122632. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122633. protected _buildBlock(state: NodeMaterialBuildState): this;
  122634. }
  122635. }
  122636. declare module BABYLON {
  122637. /**
  122638. * Block used to add support for instances
  122639. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  122640. */
  122641. export class InstancesBlock extends NodeMaterialBlock {
  122642. /**
  122643. * Creates a new InstancesBlock
  122644. * @param name defines the block name
  122645. */
  122646. constructor(name: string);
  122647. /**
  122648. * Gets the current class name
  122649. * @returns the class name
  122650. */
  122651. getClassName(): string;
  122652. /**
  122653. * Gets the first world row input component
  122654. */
  122655. readonly world0: NodeMaterialConnectionPoint;
  122656. /**
  122657. * Gets the second world row input component
  122658. */
  122659. readonly world1: NodeMaterialConnectionPoint;
  122660. /**
  122661. * Gets the third world row input component
  122662. */
  122663. readonly world2: NodeMaterialConnectionPoint;
  122664. /**
  122665. * Gets the forth world row input component
  122666. */
  122667. readonly world3: NodeMaterialConnectionPoint;
  122668. /**
  122669. * Gets the world input component
  122670. */
  122671. readonly world: NodeMaterialConnectionPoint;
  122672. /**
  122673. * Gets the output component
  122674. */
  122675. readonly output: NodeMaterialConnectionPoint;
  122676. autoConfigure(material: NodeMaterial): void;
  122677. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122678. protected _buildBlock(state: NodeMaterialBuildState): this;
  122679. }
  122680. }
  122681. declare module BABYLON {
  122682. /**
  122683. * Block used to add morph targets support to vertex shader
  122684. */
  122685. export class MorphTargetsBlock extends NodeMaterialBlock {
  122686. private _repeatableContentAnchor;
  122687. private _repeatebleContentGenerated;
  122688. /**
  122689. * Create a new MorphTargetsBlock
  122690. * @param name defines the block name
  122691. */
  122692. constructor(name: string);
  122693. /**
  122694. * Gets the current class name
  122695. * @returns the class name
  122696. */
  122697. getClassName(): string;
  122698. /**
  122699. * Gets the position input component
  122700. */
  122701. readonly position: NodeMaterialConnectionPoint;
  122702. /**
  122703. * Gets the normal input component
  122704. */
  122705. readonly normal: NodeMaterialConnectionPoint;
  122706. /**
  122707. * Gets the tangent input component
  122708. */
  122709. readonly tangent: NodeMaterialConnectionPoint;
  122710. /**
  122711. * Gets the tangent input component
  122712. */
  122713. readonly uv: NodeMaterialConnectionPoint;
  122714. /**
  122715. * Gets the position output component
  122716. */
  122717. readonly positionOutput: NodeMaterialConnectionPoint;
  122718. /**
  122719. * Gets the normal output component
  122720. */
  122721. readonly normalOutput: NodeMaterialConnectionPoint;
  122722. /**
  122723. * Gets the tangent output component
  122724. */
  122725. readonly tangentOutput: NodeMaterialConnectionPoint;
  122726. /**
  122727. * Gets the tangent output component
  122728. */
  122729. readonly uvOutput: NodeMaterialConnectionPoint;
  122730. initialize(state: NodeMaterialBuildState): void;
  122731. autoConfigure(material: NodeMaterial): void;
  122732. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122733. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122734. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  122735. protected _buildBlock(state: NodeMaterialBuildState): this;
  122736. }
  122737. }
  122738. declare module BABYLON {
  122739. /**
  122740. * Block used to get data information from a light
  122741. */
  122742. export class LightInformationBlock extends NodeMaterialBlock {
  122743. private _lightDataUniformName;
  122744. private _lightColorUniformName;
  122745. private _lightTypeDefineName;
  122746. /**
  122747. * Gets or sets the light associated with this block
  122748. */
  122749. light: Nullable<Light>;
  122750. /**
  122751. * Creates a new LightInformationBlock
  122752. * @param name defines the block name
  122753. */
  122754. constructor(name: string);
  122755. /**
  122756. * Gets the current class name
  122757. * @returns the class name
  122758. */
  122759. getClassName(): string;
  122760. /**
  122761. * Gets the world position input component
  122762. */
  122763. readonly worldPosition: NodeMaterialConnectionPoint;
  122764. /**
  122765. * Gets the direction output component
  122766. */
  122767. readonly direction: NodeMaterialConnectionPoint;
  122768. /**
  122769. * Gets the direction output component
  122770. */
  122771. readonly color: NodeMaterialConnectionPoint;
  122772. /**
  122773. * Gets the direction output component
  122774. */
  122775. readonly intensity: NodeMaterialConnectionPoint;
  122776. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122777. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122778. protected _buildBlock(state: NodeMaterialBuildState): this;
  122779. serialize(): any;
  122780. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122781. }
  122782. }
  122783. declare module BABYLON {
  122784. /**
  122785. * Block used to add image processing support to fragment shader
  122786. */
  122787. export class ImageProcessingBlock extends NodeMaterialBlock {
  122788. /**
  122789. * Create a new ImageProcessingBlock
  122790. * @param name defines the block name
  122791. */
  122792. constructor(name: string);
  122793. /**
  122794. * Gets the current class name
  122795. * @returns the class name
  122796. */
  122797. getClassName(): string;
  122798. /**
  122799. * Gets the color input component
  122800. */
  122801. readonly color: NodeMaterialConnectionPoint;
  122802. /**
  122803. * Gets the output component
  122804. */
  122805. readonly output: NodeMaterialConnectionPoint;
  122806. /**
  122807. * Initialize the block and prepare the context for build
  122808. * @param state defines the state that will be used for the build
  122809. */
  122810. initialize(state: NodeMaterialBuildState): void;
  122811. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  122812. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122813. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122814. protected _buildBlock(state: NodeMaterialBuildState): this;
  122815. }
  122816. }
  122817. declare module BABYLON {
  122818. /**
  122819. * Block used to pertub normals based on a normal map
  122820. */
  122821. export class PerturbNormalBlock extends NodeMaterialBlock {
  122822. private _tangentSpaceParameterName;
  122823. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  122824. invertX: boolean;
  122825. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  122826. invertY: boolean;
  122827. /**
  122828. * Create a new PerturbNormalBlock
  122829. * @param name defines the block name
  122830. */
  122831. constructor(name: string);
  122832. /**
  122833. * Gets the current class name
  122834. * @returns the class name
  122835. */
  122836. getClassName(): string;
  122837. /**
  122838. * Gets the world position input component
  122839. */
  122840. readonly worldPosition: NodeMaterialConnectionPoint;
  122841. /**
  122842. * Gets the world normal input component
  122843. */
  122844. readonly worldNormal: NodeMaterialConnectionPoint;
  122845. /**
  122846. * Gets the uv input component
  122847. */
  122848. readonly uv: NodeMaterialConnectionPoint;
  122849. /**
  122850. * Gets the normal map color input component
  122851. */
  122852. readonly normalMapColor: NodeMaterialConnectionPoint;
  122853. /**
  122854. * Gets the strength input component
  122855. */
  122856. readonly strength: NodeMaterialConnectionPoint;
  122857. /**
  122858. * Gets the output component
  122859. */
  122860. readonly output: NodeMaterialConnectionPoint;
  122861. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122862. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122863. autoConfigure(material: NodeMaterial): void;
  122864. protected _buildBlock(state: NodeMaterialBuildState): this;
  122865. protected _dumpPropertiesCode(): string;
  122866. serialize(): any;
  122867. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122868. }
  122869. }
  122870. declare module BABYLON {
  122871. /**
  122872. * Block used to discard a pixel if a value is smaller than a cutoff
  122873. */
  122874. export class DiscardBlock extends NodeMaterialBlock {
  122875. /**
  122876. * Create a new DiscardBlock
  122877. * @param name defines the block name
  122878. */
  122879. constructor(name: string);
  122880. /**
  122881. * Gets the current class name
  122882. * @returns the class name
  122883. */
  122884. getClassName(): string;
  122885. /**
  122886. * Gets the color input component
  122887. */
  122888. readonly value: NodeMaterialConnectionPoint;
  122889. /**
  122890. * Gets the cutoff input component
  122891. */
  122892. readonly cutoff: NodeMaterialConnectionPoint;
  122893. protected _buildBlock(state: NodeMaterialBuildState): this;
  122894. }
  122895. }
  122896. declare module BABYLON {
  122897. /**
  122898. * Block used to test if the fragment shader is front facing
  122899. */
  122900. export class FrontFacingBlock extends NodeMaterialBlock {
  122901. /**
  122902. * Creates a new FrontFacingBlock
  122903. * @param name defines the block name
  122904. */
  122905. constructor(name: string);
  122906. /**
  122907. * Gets the current class name
  122908. * @returns the class name
  122909. */
  122910. getClassName(): string;
  122911. /**
  122912. * Gets the output component
  122913. */
  122914. readonly output: NodeMaterialConnectionPoint;
  122915. protected _buildBlock(state: NodeMaterialBuildState): this;
  122916. }
  122917. }
  122918. declare module BABYLON {
  122919. /**
  122920. * Block used to add support for scene fog
  122921. */
  122922. export class FogBlock extends NodeMaterialBlock {
  122923. private _fogDistanceName;
  122924. private _fogParameters;
  122925. /**
  122926. * Create a new FogBlock
  122927. * @param name defines the block name
  122928. */
  122929. constructor(name: string);
  122930. /**
  122931. * Gets the current class name
  122932. * @returns the class name
  122933. */
  122934. getClassName(): string;
  122935. /**
  122936. * Gets the world position input component
  122937. */
  122938. readonly worldPosition: NodeMaterialConnectionPoint;
  122939. /**
  122940. * Gets the view input component
  122941. */
  122942. readonly view: NodeMaterialConnectionPoint;
  122943. /**
  122944. * Gets the color input component
  122945. */
  122946. readonly input: NodeMaterialConnectionPoint;
  122947. /**
  122948. * Gets the fog color input component
  122949. */
  122950. readonly fogColor: NodeMaterialConnectionPoint;
  122951. /**
  122952. * Gets the output component
  122953. */
  122954. readonly output: NodeMaterialConnectionPoint;
  122955. autoConfigure(material: NodeMaterial): void;
  122956. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122957. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122958. protected _buildBlock(state: NodeMaterialBuildState): this;
  122959. }
  122960. }
  122961. declare module BABYLON {
  122962. /**
  122963. * Block used to add light in the fragment shader
  122964. */
  122965. export class LightBlock extends NodeMaterialBlock {
  122966. private _lightId;
  122967. /**
  122968. * Gets or sets the light associated with this block
  122969. */
  122970. light: Nullable<Light>;
  122971. /**
  122972. * Create a new LightBlock
  122973. * @param name defines the block name
  122974. */
  122975. constructor(name: string);
  122976. /**
  122977. * Gets the current class name
  122978. * @returns the class name
  122979. */
  122980. getClassName(): string;
  122981. /**
  122982. * Gets the world position input component
  122983. */
  122984. readonly worldPosition: NodeMaterialConnectionPoint;
  122985. /**
  122986. * Gets the world normal input component
  122987. */
  122988. readonly worldNormal: NodeMaterialConnectionPoint;
  122989. /**
  122990. * Gets the camera (or eye) position component
  122991. */
  122992. readonly cameraPosition: NodeMaterialConnectionPoint;
  122993. /**
  122994. * Gets the glossiness component
  122995. */
  122996. readonly glossiness: NodeMaterialConnectionPoint;
  122997. /**
  122998. * Gets the glossinness power component
  122999. */
  123000. readonly glossPower: NodeMaterialConnectionPoint;
  123001. /**
  123002. * Gets the diffuse color component
  123003. */
  123004. readonly diffuseColor: NodeMaterialConnectionPoint;
  123005. /**
  123006. * Gets the specular color component
  123007. */
  123008. readonly specularColor: NodeMaterialConnectionPoint;
  123009. /**
  123010. * Gets the diffuse output component
  123011. */
  123012. readonly diffuseOutput: NodeMaterialConnectionPoint;
  123013. /**
  123014. * Gets the specular output component
  123015. */
  123016. readonly specularOutput: NodeMaterialConnectionPoint;
  123017. autoConfigure(material: NodeMaterial): void;
  123018. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123019. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  123020. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123021. private _injectVertexCode;
  123022. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123023. serialize(): any;
  123024. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123025. }
  123026. }
  123027. declare module BABYLON {
  123028. /**
  123029. * Block used to multiply 2 values
  123030. */
  123031. export class MultiplyBlock extends NodeMaterialBlock {
  123032. /**
  123033. * Creates a new MultiplyBlock
  123034. * @param name defines the block name
  123035. */
  123036. constructor(name: string);
  123037. /**
  123038. * Gets the current class name
  123039. * @returns the class name
  123040. */
  123041. getClassName(): string;
  123042. /**
  123043. * Gets the left operand input component
  123044. */
  123045. readonly left: NodeMaterialConnectionPoint;
  123046. /**
  123047. * Gets the right operand input component
  123048. */
  123049. readonly right: NodeMaterialConnectionPoint;
  123050. /**
  123051. * Gets the output component
  123052. */
  123053. readonly output: NodeMaterialConnectionPoint;
  123054. protected _buildBlock(state: NodeMaterialBuildState): this;
  123055. }
  123056. }
  123057. declare module BABYLON {
  123058. /**
  123059. * Block used to add 2 vectors
  123060. */
  123061. export class AddBlock extends NodeMaterialBlock {
  123062. /**
  123063. * Creates a new AddBlock
  123064. * @param name defines the block name
  123065. */
  123066. constructor(name: string);
  123067. /**
  123068. * Gets the current class name
  123069. * @returns the class name
  123070. */
  123071. getClassName(): string;
  123072. /**
  123073. * Gets the left operand input component
  123074. */
  123075. readonly left: NodeMaterialConnectionPoint;
  123076. /**
  123077. * Gets the right operand input component
  123078. */
  123079. readonly right: NodeMaterialConnectionPoint;
  123080. /**
  123081. * Gets the output component
  123082. */
  123083. readonly output: NodeMaterialConnectionPoint;
  123084. protected _buildBlock(state: NodeMaterialBuildState): this;
  123085. }
  123086. }
  123087. declare module BABYLON {
  123088. /**
  123089. * Block used to scale a vector by a float
  123090. */
  123091. export class ScaleBlock extends NodeMaterialBlock {
  123092. /**
  123093. * Creates a new ScaleBlock
  123094. * @param name defines the block name
  123095. */
  123096. constructor(name: string);
  123097. /**
  123098. * Gets the current class name
  123099. * @returns the class name
  123100. */
  123101. getClassName(): string;
  123102. /**
  123103. * Gets the input component
  123104. */
  123105. readonly input: NodeMaterialConnectionPoint;
  123106. /**
  123107. * Gets the factor input component
  123108. */
  123109. readonly factor: NodeMaterialConnectionPoint;
  123110. /**
  123111. * Gets the output component
  123112. */
  123113. readonly output: NodeMaterialConnectionPoint;
  123114. protected _buildBlock(state: NodeMaterialBuildState): this;
  123115. }
  123116. }
  123117. declare module BABYLON {
  123118. /**
  123119. * Block used to clamp a float
  123120. */
  123121. export class ClampBlock extends NodeMaterialBlock {
  123122. /** Gets or sets the minimum range */
  123123. minimum: number;
  123124. /** Gets or sets the maximum range */
  123125. maximum: number;
  123126. /**
  123127. * Creates a new ClampBlock
  123128. * @param name defines the block name
  123129. */
  123130. constructor(name: string);
  123131. /**
  123132. * Gets the current class name
  123133. * @returns the class name
  123134. */
  123135. getClassName(): string;
  123136. /**
  123137. * Gets the value input component
  123138. */
  123139. readonly value: NodeMaterialConnectionPoint;
  123140. /**
  123141. * Gets the output component
  123142. */
  123143. readonly output: NodeMaterialConnectionPoint;
  123144. protected _buildBlock(state: NodeMaterialBuildState): this;
  123145. protected _dumpPropertiesCode(): string;
  123146. serialize(): any;
  123147. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123148. }
  123149. }
  123150. declare module BABYLON {
  123151. /**
  123152. * Block used to apply a cross product between 2 vectors
  123153. */
  123154. export class CrossBlock extends NodeMaterialBlock {
  123155. /**
  123156. * Creates a new CrossBlock
  123157. * @param name defines the block name
  123158. */
  123159. constructor(name: string);
  123160. /**
  123161. * Gets the current class name
  123162. * @returns the class name
  123163. */
  123164. getClassName(): string;
  123165. /**
  123166. * Gets the left operand input component
  123167. */
  123168. readonly left: NodeMaterialConnectionPoint;
  123169. /**
  123170. * Gets the right operand input component
  123171. */
  123172. readonly right: NodeMaterialConnectionPoint;
  123173. /**
  123174. * Gets the output component
  123175. */
  123176. readonly output: NodeMaterialConnectionPoint;
  123177. protected _buildBlock(state: NodeMaterialBuildState): this;
  123178. }
  123179. }
  123180. declare module BABYLON {
  123181. /**
  123182. * Block used to apply a dot product between 2 vectors
  123183. */
  123184. export class DotBlock extends NodeMaterialBlock {
  123185. /**
  123186. * Creates a new DotBlock
  123187. * @param name defines the block name
  123188. */
  123189. constructor(name: string);
  123190. /**
  123191. * Gets the current class name
  123192. * @returns the class name
  123193. */
  123194. getClassName(): string;
  123195. /**
  123196. * Gets the left operand input component
  123197. */
  123198. readonly left: NodeMaterialConnectionPoint;
  123199. /**
  123200. * Gets the right operand input component
  123201. */
  123202. readonly right: NodeMaterialConnectionPoint;
  123203. /**
  123204. * Gets the output component
  123205. */
  123206. readonly output: NodeMaterialConnectionPoint;
  123207. protected _buildBlock(state: NodeMaterialBuildState): this;
  123208. }
  123209. }
  123210. declare module BABYLON {
  123211. /**
  123212. * Block used to remap a float from a range to a new one
  123213. */
  123214. export class RemapBlock extends NodeMaterialBlock {
  123215. /**
  123216. * Gets or sets the source range
  123217. */
  123218. sourceRange: Vector2;
  123219. /**
  123220. * Gets or sets the target range
  123221. */
  123222. targetRange: Vector2;
  123223. /**
  123224. * Creates a new RemapBlock
  123225. * @param name defines the block name
  123226. */
  123227. constructor(name: string);
  123228. /**
  123229. * Gets the current class name
  123230. * @returns the class name
  123231. */
  123232. getClassName(): string;
  123233. /**
  123234. * Gets the input component
  123235. */
  123236. readonly input: NodeMaterialConnectionPoint;
  123237. /**
  123238. * Gets the source min input component
  123239. */
  123240. readonly sourceMin: NodeMaterialConnectionPoint;
  123241. /**
  123242. * Gets the source max input component
  123243. */
  123244. readonly sourceMax: NodeMaterialConnectionPoint;
  123245. /**
  123246. * Gets the target min input component
  123247. */
  123248. readonly targetMin: NodeMaterialConnectionPoint;
  123249. /**
  123250. * Gets the target max input component
  123251. */
  123252. readonly targetMax: NodeMaterialConnectionPoint;
  123253. /**
  123254. * Gets the output component
  123255. */
  123256. readonly output: NodeMaterialConnectionPoint;
  123257. protected _buildBlock(state: NodeMaterialBuildState): this;
  123258. protected _dumpPropertiesCode(): string;
  123259. serialize(): any;
  123260. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123261. }
  123262. }
  123263. declare module BABYLON {
  123264. /**
  123265. * Block used to normalize a vector
  123266. */
  123267. export class NormalizeBlock extends NodeMaterialBlock {
  123268. /**
  123269. * Creates a new NormalizeBlock
  123270. * @param name defines the block name
  123271. */
  123272. constructor(name: string);
  123273. /**
  123274. * Gets the current class name
  123275. * @returns the class name
  123276. */
  123277. getClassName(): string;
  123278. /**
  123279. * Gets the input component
  123280. */
  123281. readonly input: NodeMaterialConnectionPoint;
  123282. /**
  123283. * Gets the output component
  123284. */
  123285. readonly output: NodeMaterialConnectionPoint;
  123286. protected _buildBlock(state: NodeMaterialBuildState): this;
  123287. }
  123288. }
  123289. declare module BABYLON {
  123290. /**
  123291. * Operations supported by the Trigonometry block
  123292. */
  123293. export enum TrigonometryBlockOperations {
  123294. /** Cos */
  123295. Cos = 0,
  123296. /** Sin */
  123297. Sin = 1,
  123298. /** Abs */
  123299. Abs = 2,
  123300. /** Exp */
  123301. Exp = 3,
  123302. /** Exp2 */
  123303. Exp2 = 4,
  123304. /** Round */
  123305. Round = 5,
  123306. /** Floor */
  123307. Floor = 6,
  123308. /** Ceiling */
  123309. Ceiling = 7,
  123310. /** Square root */
  123311. Sqrt = 8,
  123312. /** Log */
  123313. Log = 9,
  123314. /** Tangent */
  123315. Tan = 10,
  123316. /** Arc tangent */
  123317. ArcTan = 11,
  123318. /** Arc cosinus */
  123319. ArcCos = 12,
  123320. /** Arc sinus */
  123321. ArcSin = 13,
  123322. /** Fraction */
  123323. Fract = 14,
  123324. /** Sign */
  123325. Sign = 15,
  123326. /** To radians (from degrees) */
  123327. Radians = 16,
  123328. /** To degrees (from radians) */
  123329. Degrees = 17
  123330. }
  123331. /**
  123332. * Block used to apply trigonometry operation to floats
  123333. */
  123334. export class TrigonometryBlock extends NodeMaterialBlock {
  123335. /**
  123336. * Gets or sets the operation applied by the block
  123337. */
  123338. operation: TrigonometryBlockOperations;
  123339. /**
  123340. * Creates a new TrigonometryBlock
  123341. * @param name defines the block name
  123342. */
  123343. constructor(name: string);
  123344. /**
  123345. * Gets the current class name
  123346. * @returns the class name
  123347. */
  123348. getClassName(): string;
  123349. /**
  123350. * Gets the input component
  123351. */
  123352. readonly input: NodeMaterialConnectionPoint;
  123353. /**
  123354. * Gets the output component
  123355. */
  123356. readonly output: NodeMaterialConnectionPoint;
  123357. protected _buildBlock(state: NodeMaterialBuildState): this;
  123358. serialize(): any;
  123359. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123360. }
  123361. }
  123362. declare module BABYLON {
  123363. /**
  123364. * Block used to create a Color3/4 out of individual inputs (one for each component)
  123365. */
  123366. export class ColorMergerBlock extends NodeMaterialBlock {
  123367. /**
  123368. * Create a new ColorMergerBlock
  123369. * @param name defines the block name
  123370. */
  123371. constructor(name: string);
  123372. /**
  123373. * Gets the current class name
  123374. * @returns the class name
  123375. */
  123376. getClassName(): string;
  123377. /**
  123378. * Gets the r component (input)
  123379. */
  123380. readonly r: NodeMaterialConnectionPoint;
  123381. /**
  123382. * Gets the g component (input)
  123383. */
  123384. readonly g: NodeMaterialConnectionPoint;
  123385. /**
  123386. * Gets the b component (input)
  123387. */
  123388. readonly b: NodeMaterialConnectionPoint;
  123389. /**
  123390. * Gets the a component (input)
  123391. */
  123392. readonly a: NodeMaterialConnectionPoint;
  123393. /**
  123394. * Gets the rgba component (output)
  123395. */
  123396. readonly rgba: NodeMaterialConnectionPoint;
  123397. /**
  123398. * Gets the rgb component (output)
  123399. */
  123400. readonly rgb: NodeMaterialConnectionPoint;
  123401. protected _buildBlock(state: NodeMaterialBuildState): this;
  123402. }
  123403. }
  123404. declare module BABYLON {
  123405. /**
  123406. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  123407. */
  123408. export class VectorMergerBlock extends NodeMaterialBlock {
  123409. /**
  123410. * Create a new VectorMergerBlock
  123411. * @param name defines the block name
  123412. */
  123413. constructor(name: string);
  123414. /**
  123415. * Gets the current class name
  123416. * @returns the class name
  123417. */
  123418. getClassName(): string;
  123419. /**
  123420. * Gets the x component (input)
  123421. */
  123422. readonly x: NodeMaterialConnectionPoint;
  123423. /**
  123424. * Gets the y component (input)
  123425. */
  123426. readonly y: NodeMaterialConnectionPoint;
  123427. /**
  123428. * Gets the z component (input)
  123429. */
  123430. readonly z: NodeMaterialConnectionPoint;
  123431. /**
  123432. * Gets the w component (input)
  123433. */
  123434. readonly w: NodeMaterialConnectionPoint;
  123435. /**
  123436. * Gets the xyzw component (output)
  123437. */
  123438. readonly xyzw: NodeMaterialConnectionPoint;
  123439. /**
  123440. * Gets the xyz component (output)
  123441. */
  123442. readonly xyz: NodeMaterialConnectionPoint;
  123443. /**
  123444. * Gets the xy component (output)
  123445. */
  123446. readonly xy: NodeMaterialConnectionPoint;
  123447. protected _buildBlock(state: NodeMaterialBuildState): this;
  123448. }
  123449. }
  123450. declare module BABYLON {
  123451. /**
  123452. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  123453. */
  123454. export class ColorSplitterBlock extends NodeMaterialBlock {
  123455. /**
  123456. * Create a new ColorSplitterBlock
  123457. * @param name defines the block name
  123458. */
  123459. constructor(name: string);
  123460. /**
  123461. * Gets the current class name
  123462. * @returns the class name
  123463. */
  123464. getClassName(): string;
  123465. /**
  123466. * Gets the rgba component (input)
  123467. */
  123468. readonly rgba: NodeMaterialConnectionPoint;
  123469. /**
  123470. * Gets the rgb component (input)
  123471. */
  123472. readonly rgbIn: NodeMaterialConnectionPoint;
  123473. /**
  123474. * Gets the rgb component (output)
  123475. */
  123476. readonly rgbOut: NodeMaterialConnectionPoint;
  123477. /**
  123478. * Gets the r component (output)
  123479. */
  123480. readonly r: NodeMaterialConnectionPoint;
  123481. /**
  123482. * Gets the g component (output)
  123483. */
  123484. readonly g: NodeMaterialConnectionPoint;
  123485. /**
  123486. * Gets the b component (output)
  123487. */
  123488. readonly b: NodeMaterialConnectionPoint;
  123489. /**
  123490. * Gets the a component (output)
  123491. */
  123492. readonly a: NodeMaterialConnectionPoint;
  123493. protected _inputRename(name: string): string;
  123494. protected _outputRename(name: string): string;
  123495. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123496. }
  123497. }
  123498. declare module BABYLON {
  123499. /**
  123500. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  123501. */
  123502. export class VectorSplitterBlock extends NodeMaterialBlock {
  123503. /**
  123504. * Create a new VectorSplitterBlock
  123505. * @param name defines the block name
  123506. */
  123507. constructor(name: string);
  123508. /**
  123509. * Gets the current class name
  123510. * @returns the class name
  123511. */
  123512. getClassName(): string;
  123513. /**
  123514. * Gets the xyzw component (input)
  123515. */
  123516. readonly xyzw: NodeMaterialConnectionPoint;
  123517. /**
  123518. * Gets the xyz component (input)
  123519. */
  123520. readonly xyzIn: NodeMaterialConnectionPoint;
  123521. /**
  123522. * Gets the xy component (input)
  123523. */
  123524. readonly xyIn: NodeMaterialConnectionPoint;
  123525. /**
  123526. * Gets the xyz component (output)
  123527. */
  123528. readonly xyzOut: NodeMaterialConnectionPoint;
  123529. /**
  123530. * Gets the xy component (output)
  123531. */
  123532. readonly xyOut: NodeMaterialConnectionPoint;
  123533. /**
  123534. * Gets the x component (output)
  123535. */
  123536. readonly x: NodeMaterialConnectionPoint;
  123537. /**
  123538. * Gets the y component (output)
  123539. */
  123540. readonly y: NodeMaterialConnectionPoint;
  123541. /**
  123542. * Gets the z component (output)
  123543. */
  123544. readonly z: NodeMaterialConnectionPoint;
  123545. /**
  123546. * Gets the w component (output)
  123547. */
  123548. readonly w: NodeMaterialConnectionPoint;
  123549. protected _inputRename(name: string): string;
  123550. protected _outputRename(name: string): string;
  123551. protected _buildBlock(state: NodeMaterialBuildState): this;
  123552. }
  123553. }
  123554. declare module BABYLON {
  123555. /**
  123556. * Block used to lerp between 2 values
  123557. */
  123558. export class LerpBlock extends NodeMaterialBlock {
  123559. /**
  123560. * Creates a new LerpBlock
  123561. * @param name defines the block name
  123562. */
  123563. constructor(name: string);
  123564. /**
  123565. * Gets the current class name
  123566. * @returns the class name
  123567. */
  123568. getClassName(): string;
  123569. /**
  123570. * Gets the left operand input component
  123571. */
  123572. readonly left: NodeMaterialConnectionPoint;
  123573. /**
  123574. * Gets the right operand input component
  123575. */
  123576. readonly right: NodeMaterialConnectionPoint;
  123577. /**
  123578. * Gets the gradient operand input component
  123579. */
  123580. readonly gradient: NodeMaterialConnectionPoint;
  123581. /**
  123582. * Gets the output component
  123583. */
  123584. readonly output: NodeMaterialConnectionPoint;
  123585. protected _buildBlock(state: NodeMaterialBuildState): this;
  123586. }
  123587. }
  123588. declare module BABYLON {
  123589. /**
  123590. * Block used to divide 2 vectors
  123591. */
  123592. export class DivideBlock extends NodeMaterialBlock {
  123593. /**
  123594. * Creates a new DivideBlock
  123595. * @param name defines the block name
  123596. */
  123597. constructor(name: string);
  123598. /**
  123599. * Gets the current class name
  123600. * @returns the class name
  123601. */
  123602. getClassName(): string;
  123603. /**
  123604. * Gets the left operand input component
  123605. */
  123606. readonly left: NodeMaterialConnectionPoint;
  123607. /**
  123608. * Gets the right operand input component
  123609. */
  123610. readonly right: NodeMaterialConnectionPoint;
  123611. /**
  123612. * Gets the output component
  123613. */
  123614. readonly output: NodeMaterialConnectionPoint;
  123615. protected _buildBlock(state: NodeMaterialBuildState): this;
  123616. }
  123617. }
  123618. declare module BABYLON {
  123619. /**
  123620. * Block used to subtract 2 vectors
  123621. */
  123622. export class SubtractBlock extends NodeMaterialBlock {
  123623. /**
  123624. * Creates a new SubtractBlock
  123625. * @param name defines the block name
  123626. */
  123627. constructor(name: string);
  123628. /**
  123629. * Gets the current class name
  123630. * @returns the class name
  123631. */
  123632. getClassName(): string;
  123633. /**
  123634. * Gets the left operand input component
  123635. */
  123636. readonly left: NodeMaterialConnectionPoint;
  123637. /**
  123638. * Gets the right operand input component
  123639. */
  123640. readonly right: NodeMaterialConnectionPoint;
  123641. /**
  123642. * Gets the output component
  123643. */
  123644. readonly output: NodeMaterialConnectionPoint;
  123645. protected _buildBlock(state: NodeMaterialBuildState): this;
  123646. }
  123647. }
  123648. declare module BABYLON {
  123649. /**
  123650. * Block used to step a value
  123651. */
  123652. export class StepBlock extends NodeMaterialBlock {
  123653. /**
  123654. * Creates a new StepBlock
  123655. * @param name defines the block name
  123656. */
  123657. constructor(name: string);
  123658. /**
  123659. * Gets the current class name
  123660. * @returns the class name
  123661. */
  123662. getClassName(): string;
  123663. /**
  123664. * Gets the value operand input component
  123665. */
  123666. readonly value: NodeMaterialConnectionPoint;
  123667. /**
  123668. * Gets the edge operand input component
  123669. */
  123670. readonly edge: NodeMaterialConnectionPoint;
  123671. /**
  123672. * Gets the output component
  123673. */
  123674. readonly output: NodeMaterialConnectionPoint;
  123675. protected _buildBlock(state: NodeMaterialBuildState): this;
  123676. }
  123677. }
  123678. declare module BABYLON {
  123679. /**
  123680. * Block used to get the opposite (1 - x) of a value
  123681. */
  123682. export class OneMinusBlock extends NodeMaterialBlock {
  123683. /**
  123684. * Creates a new OneMinusBlock
  123685. * @param name defines the block name
  123686. */
  123687. constructor(name: string);
  123688. /**
  123689. * Gets the current class name
  123690. * @returns the class name
  123691. */
  123692. getClassName(): string;
  123693. /**
  123694. * Gets the input component
  123695. */
  123696. readonly input: NodeMaterialConnectionPoint;
  123697. /**
  123698. * Gets the output component
  123699. */
  123700. readonly output: NodeMaterialConnectionPoint;
  123701. protected _buildBlock(state: NodeMaterialBuildState): this;
  123702. }
  123703. }
  123704. declare module BABYLON {
  123705. /**
  123706. * Block used to get the view direction
  123707. */
  123708. export class ViewDirectionBlock extends NodeMaterialBlock {
  123709. /**
  123710. * Creates a new ViewDirectionBlock
  123711. * @param name defines the block name
  123712. */
  123713. constructor(name: string);
  123714. /**
  123715. * Gets the current class name
  123716. * @returns the class name
  123717. */
  123718. getClassName(): string;
  123719. /**
  123720. * Gets the world position component
  123721. */
  123722. readonly worldPosition: NodeMaterialConnectionPoint;
  123723. /**
  123724. * Gets the camera position component
  123725. */
  123726. readonly cameraPosition: NodeMaterialConnectionPoint;
  123727. /**
  123728. * Gets the output component
  123729. */
  123730. readonly output: NodeMaterialConnectionPoint;
  123731. autoConfigure(material: NodeMaterial): void;
  123732. protected _buildBlock(state: NodeMaterialBuildState): this;
  123733. }
  123734. }
  123735. declare module BABYLON {
  123736. /**
  123737. * Block used to compute fresnel value
  123738. */
  123739. export class FresnelBlock extends NodeMaterialBlock {
  123740. /**
  123741. * Create a new FresnelBlock
  123742. * @param name defines the block name
  123743. */
  123744. constructor(name: string);
  123745. /**
  123746. * Gets the current class name
  123747. * @returns the class name
  123748. */
  123749. getClassName(): string;
  123750. /**
  123751. * Gets the world normal input component
  123752. */
  123753. readonly worldNormal: NodeMaterialConnectionPoint;
  123754. /**
  123755. * Gets the view direction input component
  123756. */
  123757. readonly viewDirection: NodeMaterialConnectionPoint;
  123758. /**
  123759. * Gets the bias input component
  123760. */
  123761. readonly bias: NodeMaterialConnectionPoint;
  123762. /**
  123763. * Gets the camera (or eye) position component
  123764. */
  123765. readonly power: NodeMaterialConnectionPoint;
  123766. /**
  123767. * Gets the fresnel output component
  123768. */
  123769. readonly fresnel: NodeMaterialConnectionPoint;
  123770. autoConfigure(material: NodeMaterial): void;
  123771. protected _buildBlock(state: NodeMaterialBuildState): this;
  123772. }
  123773. }
  123774. declare module BABYLON {
  123775. /**
  123776. * Block used to get the max of 2 values
  123777. */
  123778. export class MaxBlock extends NodeMaterialBlock {
  123779. /**
  123780. * Creates a new MaxBlock
  123781. * @param name defines the block name
  123782. */
  123783. constructor(name: string);
  123784. /**
  123785. * Gets the current class name
  123786. * @returns the class name
  123787. */
  123788. getClassName(): string;
  123789. /**
  123790. * Gets the left operand input component
  123791. */
  123792. readonly left: NodeMaterialConnectionPoint;
  123793. /**
  123794. * Gets the right operand input component
  123795. */
  123796. readonly right: NodeMaterialConnectionPoint;
  123797. /**
  123798. * Gets the output component
  123799. */
  123800. readonly output: NodeMaterialConnectionPoint;
  123801. protected _buildBlock(state: NodeMaterialBuildState): this;
  123802. }
  123803. }
  123804. declare module BABYLON {
  123805. /**
  123806. * Block used to get the min of 2 values
  123807. */
  123808. export class MinBlock extends NodeMaterialBlock {
  123809. /**
  123810. * Creates a new MinBlock
  123811. * @param name defines the block name
  123812. */
  123813. constructor(name: string);
  123814. /**
  123815. * Gets the current class name
  123816. * @returns the class name
  123817. */
  123818. getClassName(): string;
  123819. /**
  123820. * Gets the left operand input component
  123821. */
  123822. readonly left: NodeMaterialConnectionPoint;
  123823. /**
  123824. * Gets the right operand input component
  123825. */
  123826. readonly right: NodeMaterialConnectionPoint;
  123827. /**
  123828. * Gets the output component
  123829. */
  123830. readonly output: NodeMaterialConnectionPoint;
  123831. protected _buildBlock(state: NodeMaterialBuildState): this;
  123832. }
  123833. }
  123834. declare module BABYLON {
  123835. /**
  123836. * Block used to get the distance between 2 values
  123837. */
  123838. export class DistanceBlock extends NodeMaterialBlock {
  123839. /**
  123840. * Creates a new DistanceBlock
  123841. * @param name defines the block name
  123842. */
  123843. constructor(name: string);
  123844. /**
  123845. * Gets the current class name
  123846. * @returns the class name
  123847. */
  123848. getClassName(): string;
  123849. /**
  123850. * Gets the left operand input component
  123851. */
  123852. readonly left: NodeMaterialConnectionPoint;
  123853. /**
  123854. * Gets the right operand input component
  123855. */
  123856. readonly right: NodeMaterialConnectionPoint;
  123857. /**
  123858. * Gets the output component
  123859. */
  123860. readonly output: NodeMaterialConnectionPoint;
  123861. protected _buildBlock(state: NodeMaterialBuildState): this;
  123862. }
  123863. }
  123864. declare module BABYLON {
  123865. /**
  123866. * Block used to get the length of a vector
  123867. */
  123868. export class LengthBlock extends NodeMaterialBlock {
  123869. /**
  123870. * Creates a new LengthBlock
  123871. * @param name defines the block name
  123872. */
  123873. constructor(name: string);
  123874. /**
  123875. * Gets the current class name
  123876. * @returns the class name
  123877. */
  123878. getClassName(): string;
  123879. /**
  123880. * Gets the value input component
  123881. */
  123882. readonly value: NodeMaterialConnectionPoint;
  123883. /**
  123884. * Gets the output component
  123885. */
  123886. readonly output: NodeMaterialConnectionPoint;
  123887. protected _buildBlock(state: NodeMaterialBuildState): this;
  123888. }
  123889. }
  123890. declare module BABYLON {
  123891. /**
  123892. * Block used to get negative version of a value (i.e. x * -1)
  123893. */
  123894. export class NegateBlock extends NodeMaterialBlock {
  123895. /**
  123896. * Creates a new NegateBlock
  123897. * @param name defines the block name
  123898. */
  123899. constructor(name: string);
  123900. /**
  123901. * Gets the current class name
  123902. * @returns the class name
  123903. */
  123904. getClassName(): string;
  123905. /**
  123906. * Gets the value input component
  123907. */
  123908. readonly value: NodeMaterialConnectionPoint;
  123909. /**
  123910. * Gets the output component
  123911. */
  123912. readonly output: NodeMaterialConnectionPoint;
  123913. protected _buildBlock(state: NodeMaterialBuildState): this;
  123914. }
  123915. }
  123916. declare module BABYLON {
  123917. /**
  123918. * Block used to get the value of the first parameter raised to the power of the second
  123919. */
  123920. export class PowBlock extends NodeMaterialBlock {
  123921. /**
  123922. * Creates a new PowBlock
  123923. * @param name defines the block name
  123924. */
  123925. constructor(name: string);
  123926. /**
  123927. * Gets the current class name
  123928. * @returns the class name
  123929. */
  123930. getClassName(): string;
  123931. /**
  123932. * Gets the value operand input component
  123933. */
  123934. readonly value: NodeMaterialConnectionPoint;
  123935. /**
  123936. * Gets the power operand input component
  123937. */
  123938. readonly power: NodeMaterialConnectionPoint;
  123939. /**
  123940. * Gets the output component
  123941. */
  123942. readonly output: NodeMaterialConnectionPoint;
  123943. protected _buildBlock(state: NodeMaterialBuildState): this;
  123944. }
  123945. }
  123946. declare module BABYLON {
  123947. /**
  123948. * Block used to get a random number
  123949. */
  123950. export class RandomNumberBlock extends NodeMaterialBlock {
  123951. /**
  123952. * Creates a new RandomNumberBlock
  123953. * @param name defines the block name
  123954. */
  123955. constructor(name: string);
  123956. /**
  123957. * Gets the current class name
  123958. * @returns the class name
  123959. */
  123960. getClassName(): string;
  123961. /**
  123962. * Gets the seed input component
  123963. */
  123964. readonly seed: NodeMaterialConnectionPoint;
  123965. /**
  123966. * Gets the output component
  123967. */
  123968. readonly output: NodeMaterialConnectionPoint;
  123969. protected _buildBlock(state: NodeMaterialBuildState): this;
  123970. }
  123971. }
  123972. declare module BABYLON {
  123973. /**
  123974. * Block used to compute arc tangent of 2 values
  123975. */
  123976. export class ArcTan2Block extends NodeMaterialBlock {
  123977. /**
  123978. * Creates a new ArcTan2Block
  123979. * @param name defines the block name
  123980. */
  123981. constructor(name: string);
  123982. /**
  123983. * Gets the current class name
  123984. * @returns the class name
  123985. */
  123986. getClassName(): string;
  123987. /**
  123988. * Gets the x operand input component
  123989. */
  123990. readonly x: NodeMaterialConnectionPoint;
  123991. /**
  123992. * Gets the y operand input component
  123993. */
  123994. readonly y: NodeMaterialConnectionPoint;
  123995. /**
  123996. * Gets the output component
  123997. */
  123998. readonly output: NodeMaterialConnectionPoint;
  123999. protected _buildBlock(state: NodeMaterialBuildState): this;
  124000. }
  124001. }
  124002. declare module BABYLON {
  124003. /**
  124004. * Block used to smooth step a value
  124005. */
  124006. export class SmoothStepBlock extends NodeMaterialBlock {
  124007. /**
  124008. * Creates a new SmoothStepBlock
  124009. * @param name defines the block name
  124010. */
  124011. constructor(name: string);
  124012. /**
  124013. * Gets the current class name
  124014. * @returns the class name
  124015. */
  124016. getClassName(): string;
  124017. /**
  124018. * Gets the value operand input component
  124019. */
  124020. readonly value: NodeMaterialConnectionPoint;
  124021. /**
  124022. * Gets the first edge operand input component
  124023. */
  124024. readonly edge0: NodeMaterialConnectionPoint;
  124025. /**
  124026. * Gets the second edge operand input component
  124027. */
  124028. readonly edge1: NodeMaterialConnectionPoint;
  124029. /**
  124030. * Gets the output component
  124031. */
  124032. readonly output: NodeMaterialConnectionPoint;
  124033. protected _buildBlock(state: NodeMaterialBuildState): this;
  124034. }
  124035. }
  124036. declare module BABYLON {
  124037. /**
  124038. * Block used to get the reciprocal (1 / x) of a value
  124039. */
  124040. export class ReciprocalBlock extends NodeMaterialBlock {
  124041. /**
  124042. * Creates a new ReciprocalBlock
  124043. * @param name defines the block name
  124044. */
  124045. constructor(name: string);
  124046. /**
  124047. * Gets the current class name
  124048. * @returns the class name
  124049. */
  124050. getClassName(): string;
  124051. /**
  124052. * Gets the input component
  124053. */
  124054. readonly input: NodeMaterialConnectionPoint;
  124055. /**
  124056. * Gets the output component
  124057. */
  124058. readonly output: NodeMaterialConnectionPoint;
  124059. protected _buildBlock(state: NodeMaterialBuildState): this;
  124060. }
  124061. }
  124062. declare module BABYLON {
  124063. /**
  124064. * Block used to replace a color by another one
  124065. */
  124066. export class ReplaceColorBlock extends NodeMaterialBlock {
  124067. /**
  124068. * Creates a new ReplaceColorBlock
  124069. * @param name defines the block name
  124070. */
  124071. constructor(name: string);
  124072. /**
  124073. * Gets the current class name
  124074. * @returns the class name
  124075. */
  124076. getClassName(): string;
  124077. /**
  124078. * Gets the value input component
  124079. */
  124080. readonly value: NodeMaterialConnectionPoint;
  124081. /**
  124082. * Gets the reference input component
  124083. */
  124084. readonly reference: NodeMaterialConnectionPoint;
  124085. /**
  124086. * Gets the distance input component
  124087. */
  124088. readonly distance: NodeMaterialConnectionPoint;
  124089. /**
  124090. * Gets the replacement input component
  124091. */
  124092. readonly replacement: NodeMaterialConnectionPoint;
  124093. /**
  124094. * Gets the output component
  124095. */
  124096. readonly output: NodeMaterialConnectionPoint;
  124097. protected _buildBlock(state: NodeMaterialBuildState): this;
  124098. }
  124099. }
  124100. declare module BABYLON {
  124101. /**
  124102. * Block used to posterize a value
  124103. * @see https://en.wikipedia.org/wiki/Posterization
  124104. */
  124105. export class PosterizeBlock extends NodeMaterialBlock {
  124106. /**
  124107. * Creates a new PosterizeBlock
  124108. * @param name defines the block name
  124109. */
  124110. constructor(name: string);
  124111. /**
  124112. * Gets the current class name
  124113. * @returns the class name
  124114. */
  124115. getClassName(): string;
  124116. /**
  124117. * Gets the value input component
  124118. */
  124119. readonly value: NodeMaterialConnectionPoint;
  124120. /**
  124121. * Gets the steps input component
  124122. */
  124123. readonly steps: NodeMaterialConnectionPoint;
  124124. /**
  124125. * Gets the output component
  124126. */
  124127. readonly output: NodeMaterialConnectionPoint;
  124128. protected _buildBlock(state: NodeMaterialBuildState): this;
  124129. }
  124130. }
  124131. declare module BABYLON {
  124132. /**
  124133. * Operations supported by the Wave block
  124134. */
  124135. export enum WaveBlockKind {
  124136. /** SawTooth */
  124137. SawTooth = 0,
  124138. /** Square */
  124139. Square = 1,
  124140. /** Triangle */
  124141. Triangle = 2
  124142. }
  124143. /**
  124144. * Block used to apply wave operation to floats
  124145. */
  124146. export class WaveBlock extends NodeMaterialBlock {
  124147. /**
  124148. * Gets or sets the kibnd of wave to be applied by the block
  124149. */
  124150. kind: WaveBlockKind;
  124151. /**
  124152. * Creates a new WaveBlock
  124153. * @param name defines the block name
  124154. */
  124155. constructor(name: string);
  124156. /**
  124157. * Gets the current class name
  124158. * @returns the class name
  124159. */
  124160. getClassName(): string;
  124161. /**
  124162. * Gets the input component
  124163. */
  124164. readonly input: NodeMaterialConnectionPoint;
  124165. /**
  124166. * Gets the output component
  124167. */
  124168. readonly output: NodeMaterialConnectionPoint;
  124169. protected _buildBlock(state: NodeMaterialBuildState): this;
  124170. serialize(): any;
  124171. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124172. }
  124173. }
  124174. declare module BABYLON {
  124175. /**
  124176. * Class used to store a color step for the GradientBlock
  124177. */
  124178. export class GradientBlockColorStep {
  124179. /**
  124180. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  124181. */
  124182. step: number;
  124183. /**
  124184. * Gets or sets the color associated with this step
  124185. */
  124186. color: Color3;
  124187. /**
  124188. * Creates a new GradientBlockColorStep
  124189. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  124190. * @param color defines the color associated with this step
  124191. */
  124192. constructor(
  124193. /**
  124194. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  124195. */
  124196. step: number,
  124197. /**
  124198. * Gets or sets the color associated with this step
  124199. */
  124200. color: Color3);
  124201. }
  124202. /**
  124203. * Block used to return a color from a gradient based on an input value between 0 and 1
  124204. */
  124205. export class GradientBlock extends NodeMaterialBlock {
  124206. /**
  124207. * Gets or sets the list of color steps
  124208. */
  124209. colorSteps: GradientBlockColorStep[];
  124210. /**
  124211. * Creates a new GradientBlock
  124212. * @param name defines the block name
  124213. */
  124214. constructor(name: string);
  124215. /**
  124216. * Gets the current class name
  124217. * @returns the class name
  124218. */
  124219. getClassName(): string;
  124220. /**
  124221. * Gets the gradient input component
  124222. */
  124223. readonly gradient: NodeMaterialConnectionPoint;
  124224. /**
  124225. * Gets the output component
  124226. */
  124227. readonly output: NodeMaterialConnectionPoint;
  124228. private _writeColorConstant;
  124229. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124230. serialize(): any;
  124231. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124232. protected _dumpPropertiesCode(): string;
  124233. }
  124234. }
  124235. declare module BABYLON {
  124236. /**
  124237. * Block used to normalize lerp between 2 values
  124238. */
  124239. export class NLerpBlock extends NodeMaterialBlock {
  124240. /**
  124241. * Creates a new NLerpBlock
  124242. * @param name defines the block name
  124243. */
  124244. constructor(name: string);
  124245. /**
  124246. * Gets the current class name
  124247. * @returns the class name
  124248. */
  124249. getClassName(): string;
  124250. /**
  124251. * Gets the left operand input component
  124252. */
  124253. readonly left: NodeMaterialConnectionPoint;
  124254. /**
  124255. * Gets the right operand input component
  124256. */
  124257. readonly right: NodeMaterialConnectionPoint;
  124258. /**
  124259. * Gets the gradient operand input component
  124260. */
  124261. readonly gradient: NodeMaterialConnectionPoint;
  124262. /**
  124263. * Gets the output component
  124264. */
  124265. readonly output: NodeMaterialConnectionPoint;
  124266. protected _buildBlock(state: NodeMaterialBuildState): this;
  124267. }
  124268. }
  124269. declare module BABYLON {
  124270. /**
  124271. * Effect Render Options
  124272. */
  124273. export interface IEffectRendererOptions {
  124274. /**
  124275. * Defines the vertices positions.
  124276. */
  124277. positions?: number[];
  124278. /**
  124279. * Defines the indices.
  124280. */
  124281. indices?: number[];
  124282. }
  124283. /**
  124284. * Helper class to render one or more effects
  124285. */
  124286. export class EffectRenderer {
  124287. private engine;
  124288. private static _DefaultOptions;
  124289. private _vertexBuffers;
  124290. private _indexBuffer;
  124291. private _ringBufferIndex;
  124292. private _ringScreenBuffer;
  124293. private _fullscreenViewport;
  124294. private _getNextFrameBuffer;
  124295. /**
  124296. * Creates an effect renderer
  124297. * @param engine the engine to use for rendering
  124298. * @param options defines the options of the effect renderer
  124299. */
  124300. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  124301. /**
  124302. * Sets the current viewport in normalized coordinates 0-1
  124303. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  124304. */
  124305. setViewport(viewport?: Viewport): void;
  124306. /**
  124307. * Binds the embedded attributes buffer to the effect.
  124308. * @param effect Defines the effect to bind the attributes for
  124309. */
  124310. bindBuffers(effect: Effect): void;
  124311. /**
  124312. * Sets the current effect wrapper to use during draw.
  124313. * The effect needs to be ready before calling this api.
  124314. * This also sets the default full screen position attribute.
  124315. * @param effectWrapper Defines the effect to draw with
  124316. */
  124317. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  124318. /**
  124319. * Draws a full screen quad.
  124320. */
  124321. draw(): void;
  124322. /**
  124323. * renders one or more effects to a specified texture
  124324. * @param effectWrappers list of effects to renderer
  124325. * @param outputTexture texture to draw to, if null it will render to the screen
  124326. */
  124327. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  124328. /**
  124329. * Disposes of the effect renderer
  124330. */
  124331. dispose(): void;
  124332. }
  124333. /**
  124334. * Options to create an EffectWrapper
  124335. */
  124336. interface EffectWrapperCreationOptions {
  124337. /**
  124338. * Engine to use to create the effect
  124339. */
  124340. engine: ThinEngine;
  124341. /**
  124342. * Fragment shader for the effect
  124343. */
  124344. fragmentShader: string;
  124345. /**
  124346. * Vertex shader for the effect
  124347. */
  124348. vertexShader?: string;
  124349. /**
  124350. * Attributes to use in the shader
  124351. */
  124352. attributeNames?: Array<string>;
  124353. /**
  124354. * Uniforms to use in the shader
  124355. */
  124356. uniformNames?: Array<string>;
  124357. /**
  124358. * Texture sampler names to use in the shader
  124359. */
  124360. samplerNames?: Array<string>;
  124361. /**
  124362. * The friendly name of the effect displayed in Spector.
  124363. */
  124364. name?: string;
  124365. }
  124366. /**
  124367. * Wraps an effect to be used for rendering
  124368. */
  124369. export class EffectWrapper {
  124370. /**
  124371. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  124372. */
  124373. onApplyObservable: Observable<{}>;
  124374. /**
  124375. * The underlying effect
  124376. */
  124377. effect: Effect;
  124378. /**
  124379. * Creates an effect to be renderer
  124380. * @param creationOptions options to create the effect
  124381. */
  124382. constructor(creationOptions: EffectWrapperCreationOptions);
  124383. /**
  124384. * Disposes of the effect wrapper
  124385. */
  124386. dispose(): void;
  124387. }
  124388. }
  124389. declare module BABYLON {
  124390. /**
  124391. * Helper class to push actions to a pool of workers.
  124392. */
  124393. export class WorkerPool implements IDisposable {
  124394. private _workerInfos;
  124395. private _pendingActions;
  124396. /**
  124397. * Constructor
  124398. * @param workers Array of workers to use for actions
  124399. */
  124400. constructor(workers: Array<Worker>);
  124401. /**
  124402. * Terminates all workers and clears any pending actions.
  124403. */
  124404. dispose(): void;
  124405. /**
  124406. * Pushes an action to the worker pool. If all the workers are active, the action will be
  124407. * pended until a worker has completed its action.
  124408. * @param action The action to perform. Call onComplete when the action is complete.
  124409. */
  124410. push(action: (worker: Worker, onComplete: () => void) => void): void;
  124411. private _execute;
  124412. }
  124413. }
  124414. declare module BABYLON {
  124415. /**
  124416. * Configuration for Draco compression
  124417. */
  124418. export interface IDracoCompressionConfiguration {
  124419. /**
  124420. * Configuration for the decoder.
  124421. */
  124422. decoder: {
  124423. /**
  124424. * The url to the WebAssembly module.
  124425. */
  124426. wasmUrl?: string;
  124427. /**
  124428. * The url to the WebAssembly binary.
  124429. */
  124430. wasmBinaryUrl?: string;
  124431. /**
  124432. * The url to the fallback JavaScript module.
  124433. */
  124434. fallbackUrl?: string;
  124435. };
  124436. }
  124437. /**
  124438. * Draco compression (https://google.github.io/draco/)
  124439. *
  124440. * This class wraps the Draco module.
  124441. *
  124442. * **Encoder**
  124443. *
  124444. * The encoder is not currently implemented.
  124445. *
  124446. * **Decoder**
  124447. *
  124448. * 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.
  124449. *
  124450. * To update the configuration, use the following code:
  124451. * ```javascript
  124452. * DracoCompression.Configuration = {
  124453. * decoder: {
  124454. * wasmUrl: "<url to the WebAssembly library>",
  124455. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  124456. * fallbackUrl: "<url to the fallback JavaScript library>",
  124457. * }
  124458. * };
  124459. * ```
  124460. *
  124461. * 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.
  124462. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  124463. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  124464. *
  124465. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  124466. * ```javascript
  124467. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  124468. * ```
  124469. *
  124470. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  124471. */
  124472. export class DracoCompression implements IDisposable {
  124473. private _workerPoolPromise?;
  124474. private _decoderModulePromise?;
  124475. /**
  124476. * The configuration. Defaults to the following urls:
  124477. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  124478. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  124479. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  124480. */
  124481. static Configuration: IDracoCompressionConfiguration;
  124482. /**
  124483. * Returns true if the decoder configuration is available.
  124484. */
  124485. static readonly DecoderAvailable: boolean;
  124486. /**
  124487. * Default number of workers to create when creating the draco compression object.
  124488. */
  124489. static DefaultNumWorkers: number;
  124490. private static GetDefaultNumWorkers;
  124491. private static _Default;
  124492. /**
  124493. * Default instance for the draco compression object.
  124494. */
  124495. static readonly Default: DracoCompression;
  124496. /**
  124497. * Constructor
  124498. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  124499. */
  124500. constructor(numWorkers?: number);
  124501. /**
  124502. * Stop all async operations and release resources.
  124503. */
  124504. dispose(): void;
  124505. /**
  124506. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  124507. * @returns a promise that resolves when ready
  124508. */
  124509. whenReadyAsync(): Promise<void>;
  124510. /**
  124511. * Decode Draco compressed mesh data to vertex data.
  124512. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  124513. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  124514. * @returns A promise that resolves with the decoded vertex data
  124515. */
  124516. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  124517. [kind: string]: number;
  124518. }): Promise<VertexData>;
  124519. }
  124520. }
  124521. declare module BABYLON {
  124522. /**
  124523. * Class for building Constructive Solid Geometry
  124524. */
  124525. export class CSG {
  124526. private polygons;
  124527. /**
  124528. * The world matrix
  124529. */
  124530. matrix: Matrix;
  124531. /**
  124532. * Stores the position
  124533. */
  124534. position: Vector3;
  124535. /**
  124536. * Stores the rotation
  124537. */
  124538. rotation: Vector3;
  124539. /**
  124540. * Stores the rotation quaternion
  124541. */
  124542. rotationQuaternion: Nullable<Quaternion>;
  124543. /**
  124544. * Stores the scaling vector
  124545. */
  124546. scaling: Vector3;
  124547. /**
  124548. * Convert the Mesh to CSG
  124549. * @param mesh The Mesh to convert to CSG
  124550. * @returns A new CSG from the Mesh
  124551. */
  124552. static FromMesh(mesh: Mesh): CSG;
  124553. /**
  124554. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  124555. * @param polygons Polygons used to construct a CSG solid
  124556. */
  124557. private static FromPolygons;
  124558. /**
  124559. * Clones, or makes a deep copy, of the CSG
  124560. * @returns A new CSG
  124561. */
  124562. clone(): CSG;
  124563. /**
  124564. * Unions this CSG with another CSG
  124565. * @param csg The CSG to union against this CSG
  124566. * @returns The unioned CSG
  124567. */
  124568. union(csg: CSG): CSG;
  124569. /**
  124570. * Unions this CSG with another CSG in place
  124571. * @param csg The CSG to union against this CSG
  124572. */
  124573. unionInPlace(csg: CSG): void;
  124574. /**
  124575. * Subtracts this CSG with another CSG
  124576. * @param csg The CSG to subtract against this CSG
  124577. * @returns A new CSG
  124578. */
  124579. subtract(csg: CSG): CSG;
  124580. /**
  124581. * Subtracts this CSG with another CSG in place
  124582. * @param csg The CSG to subtact against this CSG
  124583. */
  124584. subtractInPlace(csg: CSG): void;
  124585. /**
  124586. * Intersect this CSG with another CSG
  124587. * @param csg The CSG to intersect against this CSG
  124588. * @returns A new CSG
  124589. */
  124590. intersect(csg: CSG): CSG;
  124591. /**
  124592. * Intersects this CSG with another CSG in place
  124593. * @param csg The CSG to intersect against this CSG
  124594. */
  124595. intersectInPlace(csg: CSG): void;
  124596. /**
  124597. * Return a new CSG solid with solid and empty space switched. This solid is
  124598. * not modified.
  124599. * @returns A new CSG solid with solid and empty space switched
  124600. */
  124601. inverse(): CSG;
  124602. /**
  124603. * Inverses the CSG in place
  124604. */
  124605. inverseInPlace(): void;
  124606. /**
  124607. * This is used to keep meshes transformations so they can be restored
  124608. * when we build back a Babylon Mesh
  124609. * NB : All CSG operations are performed in world coordinates
  124610. * @param csg The CSG to copy the transform attributes from
  124611. * @returns This CSG
  124612. */
  124613. copyTransformAttributes(csg: CSG): CSG;
  124614. /**
  124615. * Build Raw mesh from CSG
  124616. * Coordinates here are in world space
  124617. * @param name The name of the mesh geometry
  124618. * @param scene The Scene
  124619. * @param keepSubMeshes Specifies if the submeshes should be kept
  124620. * @returns A new Mesh
  124621. */
  124622. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  124623. /**
  124624. * Build Mesh from CSG taking material and transforms into account
  124625. * @param name The name of the Mesh
  124626. * @param material The material of the Mesh
  124627. * @param scene The Scene
  124628. * @param keepSubMeshes Specifies if submeshes should be kept
  124629. * @returns The new Mesh
  124630. */
  124631. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  124632. }
  124633. }
  124634. declare module BABYLON {
  124635. /**
  124636. * Class used to create a trail following a mesh
  124637. */
  124638. export class TrailMesh extends Mesh {
  124639. private _generator;
  124640. private _autoStart;
  124641. private _running;
  124642. private _diameter;
  124643. private _length;
  124644. private _sectionPolygonPointsCount;
  124645. private _sectionVectors;
  124646. private _sectionNormalVectors;
  124647. private _beforeRenderObserver;
  124648. /**
  124649. * @constructor
  124650. * @param name The value used by scene.getMeshByName() to do a lookup.
  124651. * @param generator The mesh to generate a trail.
  124652. * @param scene The scene to add this mesh to.
  124653. * @param diameter Diameter of trailing mesh. Default is 1.
  124654. * @param length Length of trailing mesh. Default is 60.
  124655. * @param autoStart Automatically start trailing mesh. Default true.
  124656. */
  124657. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  124658. /**
  124659. * "TrailMesh"
  124660. * @returns "TrailMesh"
  124661. */
  124662. getClassName(): string;
  124663. private _createMesh;
  124664. /**
  124665. * Start trailing mesh.
  124666. */
  124667. start(): void;
  124668. /**
  124669. * Stop trailing mesh.
  124670. */
  124671. stop(): void;
  124672. /**
  124673. * Update trailing mesh geometry.
  124674. */
  124675. update(): void;
  124676. /**
  124677. * Returns a new TrailMesh object.
  124678. * @param name is a string, the name given to the new mesh
  124679. * @param newGenerator use new generator object for cloned trail mesh
  124680. * @returns a new mesh
  124681. */
  124682. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  124683. /**
  124684. * Serializes this trail mesh
  124685. * @param serializationObject object to write serialization to
  124686. */
  124687. serialize(serializationObject: any): void;
  124688. /**
  124689. * Parses a serialized trail mesh
  124690. * @param parsedMesh the serialized mesh
  124691. * @param scene the scene to create the trail mesh in
  124692. * @returns the created trail mesh
  124693. */
  124694. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  124695. }
  124696. }
  124697. declare module BABYLON {
  124698. /**
  124699. * Class containing static functions to help procedurally build meshes
  124700. */
  124701. export class TiledBoxBuilder {
  124702. /**
  124703. * Creates a box mesh
  124704. * 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)
  124705. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124707. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124709. * @param name defines the name of the mesh
  124710. * @param options defines the options used to create the mesh
  124711. * @param scene defines the hosting scene
  124712. * @returns the box mesh
  124713. */
  124714. static CreateTiledBox(name: string, options: {
  124715. pattern?: number;
  124716. width?: number;
  124717. height?: number;
  124718. depth?: number;
  124719. tileSize?: number;
  124720. tileWidth?: number;
  124721. tileHeight?: number;
  124722. alignHorizontal?: number;
  124723. alignVertical?: number;
  124724. faceUV?: Vector4[];
  124725. faceColors?: Color4[];
  124726. sideOrientation?: number;
  124727. updatable?: boolean;
  124728. }, scene?: Nullable<Scene>): Mesh;
  124729. }
  124730. }
  124731. declare module BABYLON {
  124732. /**
  124733. * Class containing static functions to help procedurally build meshes
  124734. */
  124735. export class TorusKnotBuilder {
  124736. /**
  124737. * Creates a torus knot mesh
  124738. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  124739. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  124740. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  124741. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  124742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124743. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124745. * @param name defines the name of the mesh
  124746. * @param options defines the options used to create the mesh
  124747. * @param scene defines the hosting scene
  124748. * @returns the torus knot mesh
  124749. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  124750. */
  124751. static CreateTorusKnot(name: string, options: {
  124752. radius?: number;
  124753. tube?: number;
  124754. radialSegments?: number;
  124755. tubularSegments?: number;
  124756. p?: number;
  124757. q?: number;
  124758. updatable?: boolean;
  124759. sideOrientation?: number;
  124760. frontUVs?: Vector4;
  124761. backUVs?: Vector4;
  124762. }, scene: any): Mesh;
  124763. }
  124764. }
  124765. declare module BABYLON {
  124766. /**
  124767. * Polygon
  124768. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  124769. */
  124770. export class Polygon {
  124771. /**
  124772. * Creates a rectangle
  124773. * @param xmin bottom X coord
  124774. * @param ymin bottom Y coord
  124775. * @param xmax top X coord
  124776. * @param ymax top Y coord
  124777. * @returns points that make the resulting rectation
  124778. */
  124779. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  124780. /**
  124781. * Creates a circle
  124782. * @param radius radius of circle
  124783. * @param cx scale in x
  124784. * @param cy scale in y
  124785. * @param numberOfSides number of sides that make up the circle
  124786. * @returns points that make the resulting circle
  124787. */
  124788. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  124789. /**
  124790. * Creates a polygon from input string
  124791. * @param input Input polygon data
  124792. * @returns the parsed points
  124793. */
  124794. static Parse(input: string): Vector2[];
  124795. /**
  124796. * Starts building a polygon from x and y coordinates
  124797. * @param x x coordinate
  124798. * @param y y coordinate
  124799. * @returns the started path2
  124800. */
  124801. static StartingAt(x: number, y: number): Path2;
  124802. }
  124803. /**
  124804. * Builds a polygon
  124805. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  124806. */
  124807. export class PolygonMeshBuilder {
  124808. private _points;
  124809. private _outlinepoints;
  124810. private _holes;
  124811. private _name;
  124812. private _scene;
  124813. private _epoints;
  124814. private _eholes;
  124815. private _addToepoint;
  124816. /**
  124817. * Babylon reference to the earcut plugin.
  124818. */
  124819. bjsEarcut: any;
  124820. /**
  124821. * Creates a PolygonMeshBuilder
  124822. * @param name name of the builder
  124823. * @param contours Path of the polygon
  124824. * @param scene scene to add to when creating the mesh
  124825. * @param earcutInjection can be used to inject your own earcut reference
  124826. */
  124827. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  124828. /**
  124829. * Adds a whole within the polygon
  124830. * @param hole Array of points defining the hole
  124831. * @returns this
  124832. */
  124833. addHole(hole: Vector2[]): PolygonMeshBuilder;
  124834. /**
  124835. * Creates the polygon
  124836. * @param updatable If the mesh should be updatable
  124837. * @param depth The depth of the mesh created
  124838. * @returns the created mesh
  124839. */
  124840. build(updatable?: boolean, depth?: number): Mesh;
  124841. /**
  124842. * Creates the polygon
  124843. * @param depth The depth of the mesh created
  124844. * @returns the created VertexData
  124845. */
  124846. buildVertexData(depth?: number): VertexData;
  124847. /**
  124848. * Adds a side to the polygon
  124849. * @param positions points that make the polygon
  124850. * @param normals normals of the polygon
  124851. * @param uvs uvs of the polygon
  124852. * @param indices indices of the polygon
  124853. * @param bounds bounds of the polygon
  124854. * @param points points of the polygon
  124855. * @param depth depth of the polygon
  124856. * @param flip flip of the polygon
  124857. */
  124858. private addSide;
  124859. }
  124860. }
  124861. declare module BABYLON {
  124862. /**
  124863. * Class containing static functions to help procedurally build meshes
  124864. */
  124865. export class PolygonBuilder {
  124866. /**
  124867. * Creates a polygon mesh
  124868. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  124869. * * 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
  124870. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  124871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124872. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  124873. * * Remember you can only change the shape positions, not their number when updating a polygon
  124874. * @param name defines the name of the mesh
  124875. * @param options defines the options used to create the mesh
  124876. * @param scene defines the hosting scene
  124877. * @param earcutInjection can be used to inject your own earcut reference
  124878. * @returns the polygon mesh
  124879. */
  124880. static CreatePolygon(name: string, options: {
  124881. shape: Vector3[];
  124882. holes?: Vector3[][];
  124883. depth?: number;
  124884. faceUV?: Vector4[];
  124885. faceColors?: Color4[];
  124886. updatable?: boolean;
  124887. sideOrientation?: number;
  124888. frontUVs?: Vector4;
  124889. backUVs?: Vector4;
  124890. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124891. /**
  124892. * Creates an extruded polygon mesh, with depth in the Y direction.
  124893. * * 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)
  124894. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124895. * @param name defines the name of the mesh
  124896. * @param options defines the options used to create the mesh
  124897. * @param scene defines the hosting scene
  124898. * @param earcutInjection can be used to inject your own earcut reference
  124899. * @returns the polygon mesh
  124900. */
  124901. static ExtrudePolygon(name: string, options: {
  124902. shape: Vector3[];
  124903. holes?: Vector3[][];
  124904. depth?: number;
  124905. faceUV?: Vector4[];
  124906. faceColors?: Color4[];
  124907. updatable?: boolean;
  124908. sideOrientation?: number;
  124909. frontUVs?: Vector4;
  124910. backUVs?: Vector4;
  124911. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124912. }
  124913. }
  124914. declare module BABYLON {
  124915. /**
  124916. * Class containing static functions to help procedurally build meshes
  124917. */
  124918. export class LatheBuilder {
  124919. /**
  124920. * Creates lathe mesh.
  124921. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  124922. * * 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
  124923. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  124924. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  124925. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  124926. * * 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
  124927. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  124928. * * 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
  124929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124930. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124931. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124933. * @param name defines the name of the mesh
  124934. * @param options defines the options used to create the mesh
  124935. * @param scene defines the hosting scene
  124936. * @returns the lathe mesh
  124937. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  124938. */
  124939. static CreateLathe(name: string, options: {
  124940. shape: Vector3[];
  124941. radius?: number;
  124942. tessellation?: number;
  124943. clip?: number;
  124944. arc?: number;
  124945. closed?: boolean;
  124946. updatable?: boolean;
  124947. sideOrientation?: number;
  124948. frontUVs?: Vector4;
  124949. backUVs?: Vector4;
  124950. cap?: number;
  124951. invertUV?: boolean;
  124952. }, scene?: Nullable<Scene>): Mesh;
  124953. }
  124954. }
  124955. declare module BABYLON {
  124956. /**
  124957. * Class containing static functions to help procedurally build meshes
  124958. */
  124959. export class TiledPlaneBuilder {
  124960. /**
  124961. * Creates a tiled plane mesh
  124962. * * The parameter `pattern` will, depending on value, do nothing or
  124963. * * * flip (reflect about central vertical) alternate tiles across and up
  124964. * * * flip every tile on alternate rows
  124965. * * * rotate (180 degs) alternate tiles across and up
  124966. * * * rotate every tile on alternate rows
  124967. * * * flip and rotate alternate tiles across and up
  124968. * * * flip and rotate every tile on alternate rows
  124969. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  124970. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  124971. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124972. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  124973. * * 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)
  124974. * * 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)
  124975. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  124976. * @param name defines the name of the mesh
  124977. * @param options defines the options used to create the mesh
  124978. * @param scene defines the hosting scene
  124979. * @returns the box mesh
  124980. */
  124981. static CreateTiledPlane(name: string, options: {
  124982. pattern?: number;
  124983. tileSize?: number;
  124984. tileWidth?: number;
  124985. tileHeight?: number;
  124986. size?: number;
  124987. width?: number;
  124988. height?: number;
  124989. alignHorizontal?: number;
  124990. alignVertical?: number;
  124991. sideOrientation?: number;
  124992. frontUVs?: Vector4;
  124993. backUVs?: Vector4;
  124994. updatable?: boolean;
  124995. }, scene?: Nullable<Scene>): Mesh;
  124996. }
  124997. }
  124998. declare module BABYLON {
  124999. /**
  125000. * Class containing static functions to help procedurally build meshes
  125001. */
  125002. export class TubeBuilder {
  125003. /**
  125004. * Creates a tube mesh.
  125005. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125006. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  125007. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  125008. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  125009. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  125010. * * 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)
  125011. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  125012. * * 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
  125013. * * 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
  125014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125015. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125016. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125018. * @param name defines the name of the mesh
  125019. * @param options defines the options used to create the mesh
  125020. * @param scene defines the hosting scene
  125021. * @returns the tube mesh
  125022. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125023. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  125024. */
  125025. static CreateTube(name: string, options: {
  125026. path: Vector3[];
  125027. radius?: number;
  125028. tessellation?: number;
  125029. radiusFunction?: {
  125030. (i: number, distance: number): number;
  125031. };
  125032. cap?: number;
  125033. arc?: number;
  125034. updatable?: boolean;
  125035. sideOrientation?: number;
  125036. frontUVs?: Vector4;
  125037. backUVs?: Vector4;
  125038. instance?: Mesh;
  125039. invertUV?: boolean;
  125040. }, scene?: Nullable<Scene>): Mesh;
  125041. }
  125042. }
  125043. declare module BABYLON {
  125044. /**
  125045. * Class containing static functions to help procedurally build meshes
  125046. */
  125047. export class IcoSphereBuilder {
  125048. /**
  125049. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  125050. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  125051. * * 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`)
  125052. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  125053. * * 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
  125054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125057. * @param name defines the name of the mesh
  125058. * @param options defines the options used to create the mesh
  125059. * @param scene defines the hosting scene
  125060. * @returns the icosahedron mesh
  125061. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  125062. */
  125063. static CreateIcoSphere(name: string, options: {
  125064. radius?: number;
  125065. radiusX?: number;
  125066. radiusY?: number;
  125067. radiusZ?: number;
  125068. flat?: boolean;
  125069. subdivisions?: number;
  125070. sideOrientation?: number;
  125071. frontUVs?: Vector4;
  125072. backUVs?: Vector4;
  125073. updatable?: boolean;
  125074. }, scene?: Nullable<Scene>): Mesh;
  125075. }
  125076. }
  125077. declare module BABYLON {
  125078. /**
  125079. * Class containing static functions to help procedurally build meshes
  125080. */
  125081. export class DecalBuilder {
  125082. /**
  125083. * Creates a decal mesh.
  125084. * 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
  125085. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  125086. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  125087. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  125088. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  125089. * @param name defines the name of the mesh
  125090. * @param sourceMesh defines the mesh where the decal must be applied
  125091. * @param options defines the options used to create the mesh
  125092. * @param scene defines the hosting scene
  125093. * @returns the decal mesh
  125094. * @see https://doc.babylonjs.com/how_to/decals
  125095. */
  125096. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  125097. position?: Vector3;
  125098. normal?: Vector3;
  125099. size?: Vector3;
  125100. angle?: number;
  125101. }): Mesh;
  125102. }
  125103. }
  125104. declare module BABYLON {
  125105. /**
  125106. * Class containing static functions to help procedurally build meshes
  125107. */
  125108. export class MeshBuilder {
  125109. /**
  125110. * Creates a box mesh
  125111. * * The parameter `size` sets the size (float) of each box side (default 1)
  125112. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  125113. * * 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)
  125114. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125116. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125118. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  125119. * @param name defines the name of the mesh
  125120. * @param options defines the options used to create the mesh
  125121. * @param scene defines the hosting scene
  125122. * @returns the box mesh
  125123. */
  125124. static CreateBox(name: string, options: {
  125125. size?: number;
  125126. width?: number;
  125127. height?: number;
  125128. depth?: number;
  125129. faceUV?: Vector4[];
  125130. faceColors?: Color4[];
  125131. sideOrientation?: number;
  125132. frontUVs?: Vector4;
  125133. backUVs?: Vector4;
  125134. updatable?: boolean;
  125135. }, scene?: Nullable<Scene>): Mesh;
  125136. /**
  125137. * Creates a tiled box mesh
  125138. * * faceTiles sets the pattern, tile size and number of tiles for a face
  125139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125140. * @param name defines the name of the mesh
  125141. * @param options defines the options used to create the mesh
  125142. * @param scene defines the hosting scene
  125143. * @returns the tiled box mesh
  125144. */
  125145. static CreateTiledBox(name: string, options: {
  125146. pattern?: number;
  125147. size?: number;
  125148. width?: number;
  125149. height?: number;
  125150. depth: number;
  125151. tileSize?: number;
  125152. tileWidth?: number;
  125153. tileHeight?: number;
  125154. faceUV?: Vector4[];
  125155. faceColors?: Color4[];
  125156. alignHorizontal?: number;
  125157. alignVertical?: number;
  125158. sideOrientation?: number;
  125159. updatable?: boolean;
  125160. }, scene?: Nullable<Scene>): Mesh;
  125161. /**
  125162. * Creates a sphere mesh
  125163. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  125164. * * 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`)
  125165. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  125166. * * 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
  125167. * * 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)
  125168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125169. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125171. * @param name defines the name of the mesh
  125172. * @param options defines the options used to create the mesh
  125173. * @param scene defines the hosting scene
  125174. * @returns the sphere mesh
  125175. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  125176. */
  125177. static CreateSphere(name: string, options: {
  125178. segments?: number;
  125179. diameter?: number;
  125180. diameterX?: number;
  125181. diameterY?: number;
  125182. diameterZ?: number;
  125183. arc?: number;
  125184. slice?: number;
  125185. sideOrientation?: number;
  125186. frontUVs?: Vector4;
  125187. backUVs?: Vector4;
  125188. updatable?: boolean;
  125189. }, scene?: Nullable<Scene>): Mesh;
  125190. /**
  125191. * Creates a plane polygonal mesh. By default, this is a disc
  125192. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  125193. * * 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
  125194. * * 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
  125195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125196. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125198. * @param name defines the name of the mesh
  125199. * @param options defines the options used to create the mesh
  125200. * @param scene defines the hosting scene
  125201. * @returns the plane polygonal mesh
  125202. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  125203. */
  125204. static CreateDisc(name: string, options: {
  125205. radius?: number;
  125206. tessellation?: number;
  125207. arc?: number;
  125208. updatable?: boolean;
  125209. sideOrientation?: number;
  125210. frontUVs?: Vector4;
  125211. backUVs?: Vector4;
  125212. }, scene?: Nullable<Scene>): Mesh;
  125213. /**
  125214. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  125215. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  125216. * * 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`)
  125217. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  125218. * * 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
  125219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125220. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125222. * @param name defines the name of the mesh
  125223. * @param options defines the options used to create the mesh
  125224. * @param scene defines the hosting scene
  125225. * @returns the icosahedron mesh
  125226. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  125227. */
  125228. static CreateIcoSphere(name: string, options: {
  125229. radius?: number;
  125230. radiusX?: number;
  125231. radiusY?: number;
  125232. radiusZ?: number;
  125233. flat?: boolean;
  125234. subdivisions?: number;
  125235. sideOrientation?: number;
  125236. frontUVs?: Vector4;
  125237. backUVs?: Vector4;
  125238. updatable?: boolean;
  125239. }, scene?: Nullable<Scene>): Mesh;
  125240. /**
  125241. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125242. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  125243. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  125244. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  125245. * * 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
  125246. * * 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
  125247. * * 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
  125248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125249. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125250. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125251. * * 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
  125252. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  125253. * * 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
  125254. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  125255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125256. * @param name defines the name of the mesh
  125257. * @param options defines the options used to create the mesh
  125258. * @param scene defines the hosting scene
  125259. * @returns the ribbon mesh
  125260. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  125261. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125262. */
  125263. static CreateRibbon(name: string, options: {
  125264. pathArray: Vector3[][];
  125265. closeArray?: boolean;
  125266. closePath?: boolean;
  125267. offset?: number;
  125268. updatable?: boolean;
  125269. sideOrientation?: number;
  125270. frontUVs?: Vector4;
  125271. backUVs?: Vector4;
  125272. instance?: Mesh;
  125273. invertUV?: boolean;
  125274. uvs?: Vector2[];
  125275. colors?: Color4[];
  125276. }, scene?: Nullable<Scene>): Mesh;
  125277. /**
  125278. * Creates a cylinder or a cone mesh
  125279. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  125280. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  125281. * * 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.
  125282. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  125283. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  125284. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  125285. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  125286. * * 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).
  125287. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  125288. * * 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).
  125289. * * 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
  125290. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  125291. * * 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
  125292. * * 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.
  125293. * * If `enclose` is false, a ring surface is one element.
  125294. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  125295. * * 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
  125296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125297. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125299. * @param name defines the name of the mesh
  125300. * @param options defines the options used to create the mesh
  125301. * @param scene defines the hosting scene
  125302. * @returns the cylinder mesh
  125303. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  125304. */
  125305. static CreateCylinder(name: string, options: {
  125306. height?: number;
  125307. diameterTop?: number;
  125308. diameterBottom?: number;
  125309. diameter?: number;
  125310. tessellation?: number;
  125311. subdivisions?: number;
  125312. arc?: number;
  125313. faceColors?: Color4[];
  125314. faceUV?: Vector4[];
  125315. updatable?: boolean;
  125316. hasRings?: boolean;
  125317. enclose?: boolean;
  125318. cap?: number;
  125319. sideOrientation?: number;
  125320. frontUVs?: Vector4;
  125321. backUVs?: Vector4;
  125322. }, scene?: Nullable<Scene>): Mesh;
  125323. /**
  125324. * Creates a torus mesh
  125325. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  125326. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  125327. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  125328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125329. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125331. * @param name defines the name of the mesh
  125332. * @param options defines the options used to create the mesh
  125333. * @param scene defines the hosting scene
  125334. * @returns the torus mesh
  125335. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  125336. */
  125337. static CreateTorus(name: string, options: {
  125338. diameter?: number;
  125339. thickness?: number;
  125340. tessellation?: number;
  125341. updatable?: boolean;
  125342. sideOrientation?: number;
  125343. frontUVs?: Vector4;
  125344. backUVs?: Vector4;
  125345. }, scene?: Nullable<Scene>): Mesh;
  125346. /**
  125347. * Creates a torus knot mesh
  125348. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  125349. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  125350. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  125351. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  125352. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125353. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125355. * @param name defines the name of the mesh
  125356. * @param options defines the options used to create the mesh
  125357. * @param scene defines the hosting scene
  125358. * @returns the torus knot mesh
  125359. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  125360. */
  125361. static CreateTorusKnot(name: string, options: {
  125362. radius?: number;
  125363. tube?: number;
  125364. radialSegments?: number;
  125365. tubularSegments?: number;
  125366. p?: number;
  125367. q?: number;
  125368. updatable?: boolean;
  125369. sideOrientation?: number;
  125370. frontUVs?: Vector4;
  125371. backUVs?: Vector4;
  125372. }, scene?: Nullable<Scene>): Mesh;
  125373. /**
  125374. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  125375. * * 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
  125376. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  125377. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  125378. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  125379. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  125380. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125381. * * 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
  125382. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  125383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125384. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  125385. * @param name defines the name of the new line system
  125386. * @param options defines the options used to create the line system
  125387. * @param scene defines the hosting scene
  125388. * @returns a new line system mesh
  125389. */
  125390. static CreateLineSystem(name: string, options: {
  125391. lines: Vector3[][];
  125392. updatable?: boolean;
  125393. instance?: Nullable<LinesMesh>;
  125394. colors?: Nullable<Color4[][]>;
  125395. useVertexAlpha?: boolean;
  125396. }, scene: Nullable<Scene>): LinesMesh;
  125397. /**
  125398. * Creates a line mesh
  125399. * 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
  125400. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125401. * * The parameter `points` is an array successive Vector3
  125402. * * 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
  125403. * * The optional parameter `colors` is an array of successive Color4, one per line point
  125404. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  125405. * * When updating an instance, remember that only point positions can change, not the number of points
  125406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125407. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  125408. * @param name defines the name of the new line system
  125409. * @param options defines the options used to create the line system
  125410. * @param scene defines the hosting scene
  125411. * @returns a new line mesh
  125412. */
  125413. static CreateLines(name: string, options: {
  125414. points: Vector3[];
  125415. updatable?: boolean;
  125416. instance?: Nullable<LinesMesh>;
  125417. colors?: Color4[];
  125418. useVertexAlpha?: boolean;
  125419. }, scene?: Nullable<Scene>): LinesMesh;
  125420. /**
  125421. * Creates a dashed line mesh
  125422. * * 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
  125423. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125424. * * The parameter `points` is an array successive Vector3
  125425. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  125426. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  125427. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  125428. * * 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
  125429. * * When updating an instance, remember that only point positions can change, not the number of points
  125430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125431. * @param name defines the name of the mesh
  125432. * @param options defines the options used to create the mesh
  125433. * @param scene defines the hosting scene
  125434. * @returns the dashed line mesh
  125435. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  125436. */
  125437. static CreateDashedLines(name: string, options: {
  125438. points: Vector3[];
  125439. dashSize?: number;
  125440. gapSize?: number;
  125441. dashNb?: number;
  125442. updatable?: boolean;
  125443. instance?: LinesMesh;
  125444. }, scene?: Nullable<Scene>): LinesMesh;
  125445. /**
  125446. * 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.
  125447. * * 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.
  125448. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125449. * * 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.
  125450. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  125451. * * 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
  125452. * * 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
  125453. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  125454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125456. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  125457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125458. * @param name defines the name of the mesh
  125459. * @param options defines the options used to create the mesh
  125460. * @param scene defines the hosting scene
  125461. * @returns the extruded shape mesh
  125462. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125463. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125464. */
  125465. static ExtrudeShape(name: string, options: {
  125466. shape: Vector3[];
  125467. path: Vector3[];
  125468. scale?: number;
  125469. rotation?: number;
  125470. cap?: number;
  125471. updatable?: boolean;
  125472. sideOrientation?: number;
  125473. frontUVs?: Vector4;
  125474. backUVs?: Vector4;
  125475. instance?: Mesh;
  125476. invertUV?: boolean;
  125477. }, scene?: Nullable<Scene>): Mesh;
  125478. /**
  125479. * Creates an custom extruded shape mesh.
  125480. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  125481. * * 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.
  125482. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125483. * * 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
  125484. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  125485. * * 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
  125486. * * It must returns a float value that will be the scale value applied to the shape on each path point
  125487. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  125488. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  125489. * * 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
  125490. * * 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
  125491. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  125492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125493. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125494. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125496. * @param name defines the name of the mesh
  125497. * @param options defines the options used to create the mesh
  125498. * @param scene defines the hosting scene
  125499. * @returns the custom extruded shape mesh
  125500. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  125501. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125502. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125503. */
  125504. static ExtrudeShapeCustom(name: string, options: {
  125505. shape: Vector3[];
  125506. path: Vector3[];
  125507. scaleFunction?: any;
  125508. rotationFunction?: any;
  125509. ribbonCloseArray?: boolean;
  125510. ribbonClosePath?: boolean;
  125511. cap?: number;
  125512. updatable?: boolean;
  125513. sideOrientation?: number;
  125514. frontUVs?: Vector4;
  125515. backUVs?: Vector4;
  125516. instance?: Mesh;
  125517. invertUV?: boolean;
  125518. }, scene?: Nullable<Scene>): Mesh;
  125519. /**
  125520. * Creates lathe mesh.
  125521. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  125522. * * 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
  125523. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  125524. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  125525. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  125526. * * 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
  125527. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  125528. * * 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
  125529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125530. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125531. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125533. * @param name defines the name of the mesh
  125534. * @param options defines the options used to create the mesh
  125535. * @param scene defines the hosting scene
  125536. * @returns the lathe mesh
  125537. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  125538. */
  125539. static CreateLathe(name: string, options: {
  125540. shape: Vector3[];
  125541. radius?: number;
  125542. tessellation?: number;
  125543. clip?: number;
  125544. arc?: number;
  125545. closed?: boolean;
  125546. updatable?: boolean;
  125547. sideOrientation?: number;
  125548. frontUVs?: Vector4;
  125549. backUVs?: Vector4;
  125550. cap?: number;
  125551. invertUV?: boolean;
  125552. }, scene?: Nullable<Scene>): Mesh;
  125553. /**
  125554. * Creates a tiled plane mesh
  125555. * * You can set a limited pattern arrangement with the tiles
  125556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125557. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125559. * @param name defines the name of the mesh
  125560. * @param options defines the options used to create the mesh
  125561. * @param scene defines the hosting scene
  125562. * @returns the plane mesh
  125563. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  125564. */
  125565. static CreateTiledPlane(name: string, options: {
  125566. pattern?: number;
  125567. tileSize?: number;
  125568. tileWidth?: number;
  125569. tileHeight?: number;
  125570. size?: number;
  125571. width?: number;
  125572. height?: number;
  125573. alignHorizontal?: number;
  125574. alignVertical?: number;
  125575. sideOrientation?: number;
  125576. frontUVs?: Vector4;
  125577. backUVs?: Vector4;
  125578. updatable?: boolean;
  125579. }, scene?: Nullable<Scene>): Mesh;
  125580. /**
  125581. * Creates a plane mesh
  125582. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  125583. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  125584. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  125585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125586. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125588. * @param name defines the name of the mesh
  125589. * @param options defines the options used to create the mesh
  125590. * @param scene defines the hosting scene
  125591. * @returns the plane mesh
  125592. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  125593. */
  125594. static CreatePlane(name: string, options: {
  125595. size?: number;
  125596. width?: number;
  125597. height?: number;
  125598. sideOrientation?: number;
  125599. frontUVs?: Vector4;
  125600. backUVs?: Vector4;
  125601. updatable?: boolean;
  125602. sourcePlane?: Plane;
  125603. }, scene?: Nullable<Scene>): Mesh;
  125604. /**
  125605. * Creates a ground mesh
  125606. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  125607. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  125608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125609. * @param name defines the name of the mesh
  125610. * @param options defines the options used to create the mesh
  125611. * @param scene defines the hosting scene
  125612. * @returns the ground mesh
  125613. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  125614. */
  125615. static CreateGround(name: string, options: {
  125616. width?: number;
  125617. height?: number;
  125618. subdivisions?: number;
  125619. subdivisionsX?: number;
  125620. subdivisionsY?: number;
  125621. updatable?: boolean;
  125622. }, scene?: Nullable<Scene>): Mesh;
  125623. /**
  125624. * Creates a tiled ground mesh
  125625. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  125626. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  125627. * * 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
  125628. * * 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
  125629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125630. * @param name defines the name of the mesh
  125631. * @param options defines the options used to create the mesh
  125632. * @param scene defines the hosting scene
  125633. * @returns the tiled ground mesh
  125634. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  125635. */
  125636. static CreateTiledGround(name: string, options: {
  125637. xmin: number;
  125638. zmin: number;
  125639. xmax: number;
  125640. zmax: number;
  125641. subdivisions?: {
  125642. w: number;
  125643. h: number;
  125644. };
  125645. precision?: {
  125646. w: number;
  125647. h: number;
  125648. };
  125649. updatable?: boolean;
  125650. }, scene?: Nullable<Scene>): Mesh;
  125651. /**
  125652. * Creates a ground mesh from a height map
  125653. * * The parameter `url` sets the URL of the height map image resource.
  125654. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  125655. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  125656. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  125657. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  125658. * * 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.
  125659. * * 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).
  125660. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  125661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125662. * @param name defines the name of the mesh
  125663. * @param url defines the url to the height map
  125664. * @param options defines the options used to create the mesh
  125665. * @param scene defines the hosting scene
  125666. * @returns the ground mesh
  125667. * @see https://doc.babylonjs.com/babylon101/height_map
  125668. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  125669. */
  125670. static CreateGroundFromHeightMap(name: string, url: string, options: {
  125671. width?: number;
  125672. height?: number;
  125673. subdivisions?: number;
  125674. minHeight?: number;
  125675. maxHeight?: number;
  125676. colorFilter?: Color3;
  125677. alphaFilter?: number;
  125678. updatable?: boolean;
  125679. onReady?: (mesh: GroundMesh) => void;
  125680. }, scene?: Nullable<Scene>): GroundMesh;
  125681. /**
  125682. * Creates a polygon mesh
  125683. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  125684. * * 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
  125685. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125687. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  125688. * * Remember you can only change the shape positions, not their number when updating a polygon
  125689. * @param name defines the name of the mesh
  125690. * @param options defines the options used to create the mesh
  125691. * @param scene defines the hosting scene
  125692. * @param earcutInjection can be used to inject your own earcut reference
  125693. * @returns the polygon mesh
  125694. */
  125695. static CreatePolygon(name: string, options: {
  125696. shape: Vector3[];
  125697. holes?: Vector3[][];
  125698. depth?: number;
  125699. faceUV?: Vector4[];
  125700. faceColors?: Color4[];
  125701. updatable?: boolean;
  125702. sideOrientation?: number;
  125703. frontUVs?: Vector4;
  125704. backUVs?: Vector4;
  125705. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125706. /**
  125707. * Creates an extruded polygon mesh, with depth in the Y direction.
  125708. * * 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)
  125709. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  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. * @param earcutInjection can be used to inject your own earcut reference
  125714. * @returns the polygon mesh
  125715. */
  125716. static ExtrudePolygon(name: string, options: {
  125717. shape: Vector3[];
  125718. holes?: Vector3[][];
  125719. depth?: number;
  125720. faceUV?: Vector4[];
  125721. faceColors?: Color4[];
  125722. updatable?: boolean;
  125723. sideOrientation?: number;
  125724. frontUVs?: Vector4;
  125725. backUVs?: Vector4;
  125726. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125727. /**
  125728. * Creates a tube mesh.
  125729. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125730. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  125731. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  125732. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  125733. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  125734. * * 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)
  125735. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  125736. * * 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
  125737. * * 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
  125738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125739. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125740. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125742. * @param name defines the name of the mesh
  125743. * @param options defines the options used to create the mesh
  125744. * @param scene defines the hosting scene
  125745. * @returns the tube mesh
  125746. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125747. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  125748. */
  125749. static CreateTube(name: string, options: {
  125750. path: Vector3[];
  125751. radius?: number;
  125752. tessellation?: number;
  125753. radiusFunction?: {
  125754. (i: number, distance: number): number;
  125755. };
  125756. cap?: number;
  125757. arc?: number;
  125758. updatable?: boolean;
  125759. sideOrientation?: number;
  125760. frontUVs?: Vector4;
  125761. backUVs?: Vector4;
  125762. instance?: Mesh;
  125763. invertUV?: boolean;
  125764. }, scene?: Nullable<Scene>): Mesh;
  125765. /**
  125766. * Creates a polyhedron mesh
  125767. * * 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
  125768. * * The parameter `size` (positive float, default 1) sets the polygon size
  125769. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  125770. * * 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`
  125771. * * 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
  125772. * * 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)`)
  125773. * * 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
  125774. * * 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
  125775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125776. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125778. * @param name defines the name of the mesh
  125779. * @param options defines the options used to create the mesh
  125780. * @param scene defines the hosting scene
  125781. * @returns the polyhedron mesh
  125782. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  125783. */
  125784. static CreatePolyhedron(name: string, options: {
  125785. type?: number;
  125786. size?: number;
  125787. sizeX?: number;
  125788. sizeY?: number;
  125789. sizeZ?: number;
  125790. custom?: any;
  125791. faceUV?: Vector4[];
  125792. faceColors?: Color4[];
  125793. flat?: boolean;
  125794. updatable?: boolean;
  125795. sideOrientation?: number;
  125796. frontUVs?: Vector4;
  125797. backUVs?: Vector4;
  125798. }, scene?: Nullable<Scene>): Mesh;
  125799. /**
  125800. * Creates a decal mesh.
  125801. * 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
  125802. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  125803. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  125804. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  125805. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  125806. * @param name defines the name of the mesh
  125807. * @param sourceMesh defines the mesh where the decal must be applied
  125808. * @param options defines the options used to create the mesh
  125809. * @param scene defines the hosting scene
  125810. * @returns the decal mesh
  125811. * @see https://doc.babylonjs.com/how_to/decals
  125812. */
  125813. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  125814. position?: Vector3;
  125815. normal?: Vector3;
  125816. size?: Vector3;
  125817. angle?: number;
  125818. }): Mesh;
  125819. }
  125820. }
  125821. declare module BABYLON {
  125822. /**
  125823. * A simplifier interface for future simplification implementations
  125824. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125825. */
  125826. export interface ISimplifier {
  125827. /**
  125828. * Simplification of a given mesh according to the given settings.
  125829. * Since this requires computation, it is assumed that the function runs async.
  125830. * @param settings The settings of the simplification, including quality and distance
  125831. * @param successCallback A callback that will be called after the mesh was simplified.
  125832. * @param errorCallback in case of an error, this callback will be called. optional.
  125833. */
  125834. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  125835. }
  125836. /**
  125837. * Expected simplification settings.
  125838. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  125839. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125840. */
  125841. export interface ISimplificationSettings {
  125842. /**
  125843. * Gets or sets the expected quality
  125844. */
  125845. quality: number;
  125846. /**
  125847. * Gets or sets the distance when this optimized version should be used
  125848. */
  125849. distance: number;
  125850. /**
  125851. * Gets an already optimized mesh
  125852. */
  125853. optimizeMesh?: boolean;
  125854. }
  125855. /**
  125856. * Class used to specify simplification options
  125857. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125858. */
  125859. export class SimplificationSettings implements ISimplificationSettings {
  125860. /** expected quality */
  125861. quality: number;
  125862. /** distance when this optimized version should be used */
  125863. distance: number;
  125864. /** already optimized mesh */
  125865. optimizeMesh?: boolean | undefined;
  125866. /**
  125867. * Creates a SimplificationSettings
  125868. * @param quality expected quality
  125869. * @param distance distance when this optimized version should be used
  125870. * @param optimizeMesh already optimized mesh
  125871. */
  125872. constructor(
  125873. /** expected quality */
  125874. quality: number,
  125875. /** distance when this optimized version should be used */
  125876. distance: number,
  125877. /** already optimized mesh */
  125878. optimizeMesh?: boolean | undefined);
  125879. }
  125880. /**
  125881. * Interface used to define a simplification task
  125882. */
  125883. export interface ISimplificationTask {
  125884. /**
  125885. * Array of settings
  125886. */
  125887. settings: Array<ISimplificationSettings>;
  125888. /**
  125889. * Simplification type
  125890. */
  125891. simplificationType: SimplificationType;
  125892. /**
  125893. * Mesh to simplify
  125894. */
  125895. mesh: Mesh;
  125896. /**
  125897. * Callback called on success
  125898. */
  125899. successCallback?: () => void;
  125900. /**
  125901. * Defines if parallel processing can be used
  125902. */
  125903. parallelProcessing: boolean;
  125904. }
  125905. /**
  125906. * Queue used to order the simplification tasks
  125907. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125908. */
  125909. export class SimplificationQueue {
  125910. private _simplificationArray;
  125911. /**
  125912. * Gets a boolean indicating that the process is still running
  125913. */
  125914. running: boolean;
  125915. /**
  125916. * Creates a new queue
  125917. */
  125918. constructor();
  125919. /**
  125920. * Adds a new simplification task
  125921. * @param task defines a task to add
  125922. */
  125923. addTask(task: ISimplificationTask): void;
  125924. /**
  125925. * Execute next task
  125926. */
  125927. executeNext(): void;
  125928. /**
  125929. * Execute a simplification task
  125930. * @param task defines the task to run
  125931. */
  125932. runSimplification(task: ISimplificationTask): void;
  125933. private getSimplifier;
  125934. }
  125935. /**
  125936. * The implemented types of simplification
  125937. * At the moment only Quadratic Error Decimation is implemented
  125938. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125939. */
  125940. export enum SimplificationType {
  125941. /** Quadratic error decimation */
  125942. QUADRATIC = 0
  125943. }
  125944. }
  125945. declare module BABYLON {
  125946. interface Scene {
  125947. /** @hidden (Backing field) */
  125948. _simplificationQueue: SimplificationQueue;
  125949. /**
  125950. * Gets or sets the simplification queue attached to the scene
  125951. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125952. */
  125953. simplificationQueue: SimplificationQueue;
  125954. }
  125955. interface Mesh {
  125956. /**
  125957. * Simplify the mesh according to the given array of settings.
  125958. * Function will return immediately and will simplify async
  125959. * @param settings a collection of simplification settings
  125960. * @param parallelProcessing should all levels calculate parallel or one after the other
  125961. * @param simplificationType the type of simplification to run
  125962. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  125963. * @returns the current mesh
  125964. */
  125965. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  125966. }
  125967. /**
  125968. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  125969. * created in a scene
  125970. */
  125971. export class SimplicationQueueSceneComponent implements ISceneComponent {
  125972. /**
  125973. * The component name helpfull to identify the component in the list of scene components.
  125974. */
  125975. readonly name: string;
  125976. /**
  125977. * The scene the component belongs to.
  125978. */
  125979. scene: Scene;
  125980. /**
  125981. * Creates a new instance of the component for the given scene
  125982. * @param scene Defines the scene to register the component in
  125983. */
  125984. constructor(scene: Scene);
  125985. /**
  125986. * Registers the component in a given scene
  125987. */
  125988. register(): void;
  125989. /**
  125990. * Rebuilds the elements related to this component in case of
  125991. * context lost for instance.
  125992. */
  125993. rebuild(): void;
  125994. /**
  125995. * Disposes the component and the associated ressources
  125996. */
  125997. dispose(): void;
  125998. private _beforeCameraUpdate;
  125999. }
  126000. }
  126001. declare module BABYLON {
  126002. /**
  126003. * Navigation plugin interface to add navigation constrained by a navigation mesh
  126004. */
  126005. export interface INavigationEnginePlugin {
  126006. /**
  126007. * plugin name
  126008. */
  126009. name: string;
  126010. /**
  126011. * Creates a navigation mesh
  126012. * @param meshes array of all the geometry used to compute the navigatio mesh
  126013. * @param parameters bunch of parameters used to filter geometry
  126014. */
  126015. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  126016. /**
  126017. * Create a navigation mesh debug mesh
  126018. * @param scene is where the mesh will be added
  126019. * @returns debug display mesh
  126020. */
  126021. createDebugNavMesh(scene: Scene): Mesh;
  126022. /**
  126023. * Get a navigation mesh constrained position, closest to the parameter position
  126024. * @param position world position
  126025. * @returns the closest point to position constrained by the navigation mesh
  126026. */
  126027. getClosestPoint(position: Vector3): Vector3;
  126028. /**
  126029. * Get a navigation mesh constrained position, within a particular radius
  126030. * @param position world position
  126031. * @param maxRadius the maximum distance to the constrained world position
  126032. * @returns the closest point to position constrained by the navigation mesh
  126033. */
  126034. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  126035. /**
  126036. * Compute the final position from a segment made of destination-position
  126037. * @param position world position
  126038. * @param destination world position
  126039. * @returns the resulting point along the navmesh
  126040. */
  126041. moveAlong(position: Vector3, destination: Vector3): Vector3;
  126042. /**
  126043. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  126044. * @param start world position
  126045. * @param end world position
  126046. * @returns array containing world position composing the path
  126047. */
  126048. computePath(start: Vector3, end: Vector3): Vector3[];
  126049. /**
  126050. * If this plugin is supported
  126051. * @returns true if plugin is supported
  126052. */
  126053. isSupported(): boolean;
  126054. /**
  126055. * Create a new Crowd so you can add agents
  126056. * @param maxAgents the maximum agent count in the crowd
  126057. * @param maxAgentRadius the maximum radius an agent can have
  126058. * @param scene to attach the crowd to
  126059. * @returns the crowd you can add agents to
  126060. */
  126061. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  126062. /**
  126063. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126064. * The queries will try to find a solution within those bounds
  126065. * default is (1,1,1)
  126066. * @param extent x,y,z value that define the extent around the queries point of reference
  126067. */
  126068. setDefaultQueryExtent(extent: Vector3): void;
  126069. /**
  126070. * Get the Bounding box extent specified by setDefaultQueryExtent
  126071. * @returns the box extent values
  126072. */
  126073. getDefaultQueryExtent(): Vector3;
  126074. /**
  126075. * Release all resources
  126076. */
  126077. dispose(): void;
  126078. }
  126079. /**
  126080. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  126081. */
  126082. export interface ICrowd {
  126083. /**
  126084. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  126085. * You can attach anything to that node. The node position is updated in the scene update tick.
  126086. * @param pos world position that will be constrained by the navigation mesh
  126087. * @param parameters agent parameters
  126088. * @param transform hooked to the agent that will be update by the scene
  126089. * @returns agent index
  126090. */
  126091. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  126092. /**
  126093. * Returns the agent position in world space
  126094. * @param index agent index returned by addAgent
  126095. * @returns world space position
  126096. */
  126097. getAgentPosition(index: number): Vector3;
  126098. /**
  126099. * Gets the agent velocity in world space
  126100. * @param index agent index returned by addAgent
  126101. * @returns world space velocity
  126102. */
  126103. getAgentVelocity(index: number): Vector3;
  126104. /**
  126105. * remove a particular agent previously created
  126106. * @param index agent index returned by addAgent
  126107. */
  126108. removeAgent(index: number): void;
  126109. /**
  126110. * get the list of all agents attached to this crowd
  126111. * @returns list of agent indices
  126112. */
  126113. getAgents(): number[];
  126114. /**
  126115. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  126116. * @param deltaTime in seconds
  126117. */
  126118. update(deltaTime: number): void;
  126119. /**
  126120. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  126121. * @param index agent index returned by addAgent
  126122. * @param destination targeted world position
  126123. */
  126124. agentGoto(index: number, destination: Vector3): void;
  126125. /**
  126126. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126127. * The queries will try to find a solution within those bounds
  126128. * default is (1,1,1)
  126129. * @param extent x,y,z value that define the extent around the queries point of reference
  126130. */
  126131. setDefaultQueryExtent(extent: Vector3): void;
  126132. /**
  126133. * Get the Bounding box extent specified by setDefaultQueryExtent
  126134. * @returns the box extent values
  126135. */
  126136. getDefaultQueryExtent(): Vector3;
  126137. /**
  126138. * Release all resources
  126139. */
  126140. dispose(): void;
  126141. }
  126142. /**
  126143. * Configures an agent
  126144. */
  126145. export interface IAgentParameters {
  126146. /**
  126147. * Agent radius. [Limit: >= 0]
  126148. */
  126149. radius: number;
  126150. /**
  126151. * Agent height. [Limit: > 0]
  126152. */
  126153. height: number;
  126154. /**
  126155. * Maximum allowed acceleration. [Limit: >= 0]
  126156. */
  126157. maxAcceleration: number;
  126158. /**
  126159. * Maximum allowed speed. [Limit: >= 0]
  126160. */
  126161. maxSpeed: number;
  126162. /**
  126163. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  126164. */
  126165. collisionQueryRange: number;
  126166. /**
  126167. * The path visibility optimization range. [Limit: > 0]
  126168. */
  126169. pathOptimizationRange: number;
  126170. /**
  126171. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  126172. */
  126173. separationWeight: number;
  126174. }
  126175. /**
  126176. * Configures the navigation mesh creation
  126177. */
  126178. export interface INavMeshParameters {
  126179. /**
  126180. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  126181. */
  126182. cs: number;
  126183. /**
  126184. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  126185. */
  126186. ch: number;
  126187. /**
  126188. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  126189. */
  126190. walkableSlopeAngle: number;
  126191. /**
  126192. * Minimum floor to 'ceiling' height that will still allow the floor area to
  126193. * be considered walkable. [Limit: >= 3] [Units: vx]
  126194. */
  126195. walkableHeight: number;
  126196. /**
  126197. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  126198. */
  126199. walkableClimb: number;
  126200. /**
  126201. * The distance to erode/shrink the walkable area of the heightfield away from
  126202. * obstructions. [Limit: >=0] [Units: vx]
  126203. */
  126204. walkableRadius: number;
  126205. /**
  126206. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  126207. */
  126208. maxEdgeLen: number;
  126209. /**
  126210. * The maximum distance a simplfied contour's border edges should deviate
  126211. * the original raw contour. [Limit: >=0] [Units: vx]
  126212. */
  126213. maxSimplificationError: number;
  126214. /**
  126215. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  126216. */
  126217. minRegionArea: number;
  126218. /**
  126219. * Any regions with a span count smaller than this value will, if possible,
  126220. * be merged with larger regions. [Limit: >=0] [Units: vx]
  126221. */
  126222. mergeRegionArea: number;
  126223. /**
  126224. * The maximum number of vertices allowed for polygons generated during the
  126225. * contour to polygon conversion process. [Limit: >= 3]
  126226. */
  126227. maxVertsPerPoly: number;
  126228. /**
  126229. * Sets the sampling distance to use when generating the detail mesh.
  126230. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  126231. */
  126232. detailSampleDist: number;
  126233. /**
  126234. * The maximum distance the detail mesh surface should deviate from heightfield
  126235. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  126236. */
  126237. detailSampleMaxError: number;
  126238. }
  126239. }
  126240. declare module BABYLON {
  126241. /**
  126242. * RecastJS navigation plugin
  126243. */
  126244. export class RecastJSPlugin implements INavigationEnginePlugin {
  126245. /**
  126246. * Reference to the Recast library
  126247. */
  126248. bjsRECAST: any;
  126249. /**
  126250. * plugin name
  126251. */
  126252. name: string;
  126253. /**
  126254. * the first navmesh created. We might extend this to support multiple navmeshes
  126255. */
  126256. navMesh: any;
  126257. /**
  126258. * Initializes the recastJS plugin
  126259. * @param recastInjection can be used to inject your own recast reference
  126260. */
  126261. constructor(recastInjection?: any);
  126262. /**
  126263. * Creates a navigation mesh
  126264. * @param meshes array of all the geometry used to compute the navigatio mesh
  126265. * @param parameters bunch of parameters used to filter geometry
  126266. */
  126267. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  126268. /**
  126269. * Create a navigation mesh debug mesh
  126270. * @param scene is where the mesh will be added
  126271. * @returns debug display mesh
  126272. */
  126273. createDebugNavMesh(scene: Scene): Mesh;
  126274. /**
  126275. * Get a navigation mesh constrained position, closest to the parameter position
  126276. * @param position world position
  126277. * @returns the closest point to position constrained by the navigation mesh
  126278. */
  126279. getClosestPoint(position: Vector3): Vector3;
  126280. /**
  126281. * Get a navigation mesh constrained position, within a particular radius
  126282. * @param position world position
  126283. * @param maxRadius the maximum distance to the constrained world position
  126284. * @returns the closest point to position constrained by the navigation mesh
  126285. */
  126286. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  126287. /**
  126288. * Compute the final position from a segment made of destination-position
  126289. * @param position world position
  126290. * @param destination world position
  126291. * @returns the resulting point along the navmesh
  126292. */
  126293. moveAlong(position: Vector3, destination: Vector3): Vector3;
  126294. /**
  126295. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  126296. * @param start world position
  126297. * @param end world position
  126298. * @returns array containing world position composing the path
  126299. */
  126300. computePath(start: Vector3, end: Vector3): Vector3[];
  126301. /**
  126302. * Create a new Crowd so you can add agents
  126303. * @param maxAgents the maximum agent count in the crowd
  126304. * @param maxAgentRadius the maximum radius an agent can have
  126305. * @param scene to attach the crowd to
  126306. * @returns the crowd you can add agents to
  126307. */
  126308. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  126309. /**
  126310. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126311. * The queries will try to find a solution within those bounds
  126312. * default is (1,1,1)
  126313. * @param extent x,y,z value that define the extent around the queries point of reference
  126314. */
  126315. setDefaultQueryExtent(extent: Vector3): void;
  126316. /**
  126317. * Get the Bounding box extent specified by setDefaultQueryExtent
  126318. * @returns the box extent values
  126319. */
  126320. getDefaultQueryExtent(): Vector3;
  126321. /**
  126322. * Disposes
  126323. */
  126324. dispose(): void;
  126325. /**
  126326. * If this plugin is supported
  126327. * @returns true if plugin is supported
  126328. */
  126329. isSupported(): boolean;
  126330. }
  126331. /**
  126332. * Recast detour crowd implementation
  126333. */
  126334. export class RecastJSCrowd implements ICrowd {
  126335. /**
  126336. * Recast/detour plugin
  126337. */
  126338. bjsRECASTPlugin: RecastJSPlugin;
  126339. /**
  126340. * Link to the detour crowd
  126341. */
  126342. recastCrowd: any;
  126343. /**
  126344. * One transform per agent
  126345. */
  126346. transforms: TransformNode[];
  126347. /**
  126348. * All agents created
  126349. */
  126350. agents: number[];
  126351. /**
  126352. * Link to the scene is kept to unregister the crowd from the scene
  126353. */
  126354. private _scene;
  126355. /**
  126356. * Observer for crowd updates
  126357. */
  126358. private _onBeforeAnimationsObserver;
  126359. /**
  126360. * Constructor
  126361. * @param plugin recastJS plugin
  126362. * @param maxAgents the maximum agent count in the crowd
  126363. * @param maxAgentRadius the maximum radius an agent can have
  126364. * @param scene to attach the crowd to
  126365. * @returns the crowd you can add agents to
  126366. */
  126367. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  126368. /**
  126369. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  126370. * You can attach anything to that node. The node position is updated in the scene update tick.
  126371. * @param pos world position that will be constrained by the navigation mesh
  126372. * @param parameters agent parameters
  126373. * @param transform hooked to the agent that will be update by the scene
  126374. * @returns agent index
  126375. */
  126376. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  126377. /**
  126378. * Returns the agent position in world space
  126379. * @param index agent index returned by addAgent
  126380. * @returns world space position
  126381. */
  126382. getAgentPosition(index: number): Vector3;
  126383. /**
  126384. * Returns the agent velocity in world space
  126385. * @param index agent index returned by addAgent
  126386. * @returns world space velocity
  126387. */
  126388. getAgentVelocity(index: number): Vector3;
  126389. /**
  126390. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  126391. * @param index agent index returned by addAgent
  126392. * @param destination targeted world position
  126393. */
  126394. agentGoto(index: number, destination: Vector3): void;
  126395. /**
  126396. * remove a particular agent previously created
  126397. * @param index agent index returned by addAgent
  126398. */
  126399. removeAgent(index: number): void;
  126400. /**
  126401. * get the list of all agents attached to this crowd
  126402. * @returns list of agent indices
  126403. */
  126404. getAgents(): number[];
  126405. /**
  126406. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  126407. * @param deltaTime in seconds
  126408. */
  126409. update(deltaTime: number): void;
  126410. /**
  126411. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126412. * The queries will try to find a solution within those bounds
  126413. * default is (1,1,1)
  126414. * @param extent x,y,z value that define the extent around the queries point of reference
  126415. */
  126416. setDefaultQueryExtent(extent: Vector3): void;
  126417. /**
  126418. * Get the Bounding box extent specified by setDefaultQueryExtent
  126419. * @returns the box extent values
  126420. */
  126421. getDefaultQueryExtent(): Vector3;
  126422. /**
  126423. * Release all resources
  126424. */
  126425. dispose(): void;
  126426. }
  126427. }
  126428. declare module BABYLON {
  126429. /**
  126430. * Class used to enable access to IndexedDB
  126431. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  126432. */
  126433. export class Database implements IOfflineProvider {
  126434. private _callbackManifestChecked;
  126435. private _currentSceneUrl;
  126436. private _db;
  126437. private _enableSceneOffline;
  126438. private _enableTexturesOffline;
  126439. private _manifestVersionFound;
  126440. private _mustUpdateRessources;
  126441. private _hasReachedQuota;
  126442. private _isSupported;
  126443. private _idbFactory;
  126444. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  126445. private static IsUASupportingBlobStorage;
  126446. /**
  126447. * Gets a boolean indicating if Database storate is enabled (off by default)
  126448. */
  126449. static IDBStorageEnabled: boolean;
  126450. /**
  126451. * Gets a boolean indicating if scene must be saved in the database
  126452. */
  126453. readonly enableSceneOffline: boolean;
  126454. /**
  126455. * Gets a boolean indicating if textures must be saved in the database
  126456. */
  126457. readonly enableTexturesOffline: boolean;
  126458. /**
  126459. * Creates a new Database
  126460. * @param urlToScene defines the url to load the scene
  126461. * @param callbackManifestChecked defines the callback to use when manifest is checked
  126462. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  126463. */
  126464. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  126465. private static _ParseURL;
  126466. private static _ReturnFullUrlLocation;
  126467. private _checkManifestFile;
  126468. /**
  126469. * Open the database and make it available
  126470. * @param successCallback defines the callback to call on success
  126471. * @param errorCallback defines the callback to call on error
  126472. */
  126473. open(successCallback: () => void, errorCallback: () => void): void;
  126474. /**
  126475. * Loads an image from the database
  126476. * @param url defines the url to load from
  126477. * @param image defines the target DOM image
  126478. */
  126479. loadImage(url: string, image: HTMLImageElement): void;
  126480. private _loadImageFromDBAsync;
  126481. private _saveImageIntoDBAsync;
  126482. private _checkVersionFromDB;
  126483. private _loadVersionFromDBAsync;
  126484. private _saveVersionIntoDBAsync;
  126485. /**
  126486. * Loads a file from database
  126487. * @param url defines the URL to load from
  126488. * @param sceneLoaded defines a callback to call on success
  126489. * @param progressCallBack defines a callback to call when progress changed
  126490. * @param errorCallback defines a callback to call on error
  126491. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  126492. */
  126493. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  126494. private _loadFileAsync;
  126495. private _saveFileAsync;
  126496. /**
  126497. * Validates if xhr data is correct
  126498. * @param xhr defines the request to validate
  126499. * @param dataType defines the expected data type
  126500. * @returns true if data is correct
  126501. */
  126502. private static _ValidateXHRData;
  126503. }
  126504. }
  126505. declare module BABYLON {
  126506. /** @hidden */
  126507. export var gpuUpdateParticlesPixelShader: {
  126508. name: string;
  126509. shader: string;
  126510. };
  126511. }
  126512. declare module BABYLON {
  126513. /** @hidden */
  126514. export var gpuUpdateParticlesVertexShader: {
  126515. name: string;
  126516. shader: string;
  126517. };
  126518. }
  126519. declare module BABYLON {
  126520. /** @hidden */
  126521. export var clipPlaneFragmentDeclaration2: {
  126522. name: string;
  126523. shader: string;
  126524. };
  126525. }
  126526. declare module BABYLON {
  126527. /** @hidden */
  126528. export var gpuRenderParticlesPixelShader: {
  126529. name: string;
  126530. shader: string;
  126531. };
  126532. }
  126533. declare module BABYLON {
  126534. /** @hidden */
  126535. export var clipPlaneVertexDeclaration2: {
  126536. name: string;
  126537. shader: string;
  126538. };
  126539. }
  126540. declare module BABYLON {
  126541. /** @hidden */
  126542. export var gpuRenderParticlesVertexShader: {
  126543. name: string;
  126544. shader: string;
  126545. };
  126546. }
  126547. declare module BABYLON {
  126548. /**
  126549. * This represents a GPU particle system in Babylon
  126550. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  126551. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  126552. */
  126553. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  126554. /**
  126555. * The layer mask we are rendering the particles through.
  126556. */
  126557. layerMask: number;
  126558. private _capacity;
  126559. private _activeCount;
  126560. private _currentActiveCount;
  126561. private _accumulatedCount;
  126562. private _renderEffect;
  126563. private _updateEffect;
  126564. private _buffer0;
  126565. private _buffer1;
  126566. private _spriteBuffer;
  126567. private _updateVAO;
  126568. private _renderVAO;
  126569. private _targetIndex;
  126570. private _sourceBuffer;
  126571. private _targetBuffer;
  126572. private _engine;
  126573. private _currentRenderId;
  126574. private _started;
  126575. private _stopped;
  126576. private _timeDelta;
  126577. private _randomTexture;
  126578. private _randomTexture2;
  126579. private _attributesStrideSize;
  126580. private _updateEffectOptions;
  126581. private _randomTextureSize;
  126582. private _actualFrame;
  126583. private readonly _rawTextureWidth;
  126584. /**
  126585. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  126586. */
  126587. static readonly IsSupported: boolean;
  126588. /**
  126589. * An event triggered when the system is disposed.
  126590. */
  126591. onDisposeObservable: Observable<GPUParticleSystem>;
  126592. /**
  126593. * Gets the maximum number of particles active at the same time.
  126594. * @returns The max number of active particles.
  126595. */
  126596. getCapacity(): number;
  126597. /**
  126598. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  126599. * to override the particles.
  126600. */
  126601. forceDepthWrite: boolean;
  126602. /**
  126603. * Gets or set the number of active particles
  126604. */
  126605. activeParticleCount: number;
  126606. private _preWarmDone;
  126607. /**
  126608. * Is this system ready to be used/rendered
  126609. * @return true if the system is ready
  126610. */
  126611. isReady(): boolean;
  126612. /**
  126613. * Gets if the system has been started. (Note: this will still be true after stop is called)
  126614. * @returns True if it has been started, otherwise false.
  126615. */
  126616. isStarted(): boolean;
  126617. /**
  126618. * Starts the particle system and begins to emit
  126619. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  126620. */
  126621. start(delay?: number): void;
  126622. /**
  126623. * Stops the particle system.
  126624. */
  126625. stop(): void;
  126626. /**
  126627. * Remove all active particles
  126628. */
  126629. reset(): void;
  126630. /**
  126631. * Returns the string "GPUParticleSystem"
  126632. * @returns a string containing the class name
  126633. */
  126634. getClassName(): string;
  126635. private _colorGradientsTexture;
  126636. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  126637. /**
  126638. * Adds a new color gradient
  126639. * @param gradient defines the gradient to use (between 0 and 1)
  126640. * @param color1 defines the color to affect to the specified gradient
  126641. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  126642. * @returns the current particle system
  126643. */
  126644. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  126645. /**
  126646. * Remove a specific color gradient
  126647. * @param gradient defines the gradient to remove
  126648. * @returns the current particle system
  126649. */
  126650. removeColorGradient(gradient: number): GPUParticleSystem;
  126651. private _angularSpeedGradientsTexture;
  126652. private _sizeGradientsTexture;
  126653. private _velocityGradientsTexture;
  126654. private _limitVelocityGradientsTexture;
  126655. private _dragGradientsTexture;
  126656. private _addFactorGradient;
  126657. /**
  126658. * Adds a new size gradient
  126659. * @param gradient defines the gradient to use (between 0 and 1)
  126660. * @param factor defines the size factor to affect to the specified gradient
  126661. * @returns the current particle system
  126662. */
  126663. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  126664. /**
  126665. * Remove a specific size gradient
  126666. * @param gradient defines the gradient to remove
  126667. * @returns the current particle system
  126668. */
  126669. removeSizeGradient(gradient: number): GPUParticleSystem;
  126670. /**
  126671. * Adds a new angular speed gradient
  126672. * @param gradient defines the gradient to use (between 0 and 1)
  126673. * @param factor defines the angular speed to affect to the specified gradient
  126674. * @returns the current particle system
  126675. */
  126676. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  126677. /**
  126678. * Remove a specific angular speed gradient
  126679. * @param gradient defines the gradient to remove
  126680. * @returns the current particle system
  126681. */
  126682. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  126683. /**
  126684. * Adds a new velocity gradient
  126685. * @param gradient defines the gradient to use (between 0 and 1)
  126686. * @param factor defines the velocity to affect to the specified gradient
  126687. * @returns the current particle system
  126688. */
  126689. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  126690. /**
  126691. * Remove a specific velocity gradient
  126692. * @param gradient defines the gradient to remove
  126693. * @returns the current particle system
  126694. */
  126695. removeVelocityGradient(gradient: number): GPUParticleSystem;
  126696. /**
  126697. * Adds a new limit velocity gradient
  126698. * @param gradient defines the gradient to use (between 0 and 1)
  126699. * @param factor defines the limit velocity value to affect to the specified gradient
  126700. * @returns the current particle system
  126701. */
  126702. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  126703. /**
  126704. * Remove a specific limit velocity gradient
  126705. * @param gradient defines the gradient to remove
  126706. * @returns the current particle system
  126707. */
  126708. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  126709. /**
  126710. * Adds a new drag gradient
  126711. * @param gradient defines the gradient to use (between 0 and 1)
  126712. * @param factor defines the drag value to affect to the specified gradient
  126713. * @returns the current particle system
  126714. */
  126715. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  126716. /**
  126717. * Remove a specific drag gradient
  126718. * @param gradient defines the gradient to remove
  126719. * @returns the current particle system
  126720. */
  126721. removeDragGradient(gradient: number): GPUParticleSystem;
  126722. /**
  126723. * Not supported by GPUParticleSystem
  126724. * @param gradient defines the gradient to use (between 0 and 1)
  126725. * @param factor defines the emit rate value to affect to the specified gradient
  126726. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126727. * @returns the current particle system
  126728. */
  126729. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126730. /**
  126731. * Not supported by GPUParticleSystem
  126732. * @param gradient defines the gradient to remove
  126733. * @returns the current particle system
  126734. */
  126735. removeEmitRateGradient(gradient: number): IParticleSystem;
  126736. /**
  126737. * Not supported by GPUParticleSystem
  126738. * @param gradient defines the gradient to use (between 0 and 1)
  126739. * @param factor defines the start size value to affect to the specified gradient
  126740. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126741. * @returns the current particle system
  126742. */
  126743. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126744. /**
  126745. * Not supported by GPUParticleSystem
  126746. * @param gradient defines the gradient to remove
  126747. * @returns the current particle system
  126748. */
  126749. removeStartSizeGradient(gradient: number): IParticleSystem;
  126750. /**
  126751. * Not supported by GPUParticleSystem
  126752. * @param gradient defines the gradient to use (between 0 and 1)
  126753. * @param min defines the color remap minimal range
  126754. * @param max defines the color remap maximal range
  126755. * @returns the current particle system
  126756. */
  126757. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  126758. /**
  126759. * Not supported by GPUParticleSystem
  126760. * @param gradient defines the gradient to remove
  126761. * @returns the current particle system
  126762. */
  126763. removeColorRemapGradient(): IParticleSystem;
  126764. /**
  126765. * Not supported by GPUParticleSystem
  126766. * @param gradient defines the gradient to use (between 0 and 1)
  126767. * @param min defines the alpha remap minimal range
  126768. * @param max defines the alpha remap maximal range
  126769. * @returns the current particle system
  126770. */
  126771. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  126772. /**
  126773. * Not supported by GPUParticleSystem
  126774. * @param gradient defines the gradient to remove
  126775. * @returns the current particle system
  126776. */
  126777. removeAlphaRemapGradient(): IParticleSystem;
  126778. /**
  126779. * Not supported by GPUParticleSystem
  126780. * @param gradient defines the gradient to use (between 0 and 1)
  126781. * @param color defines the color to affect to the specified gradient
  126782. * @returns the current particle system
  126783. */
  126784. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  126785. /**
  126786. * Not supported by GPUParticleSystem
  126787. * @param gradient defines the gradient to remove
  126788. * @returns the current particle system
  126789. */
  126790. removeRampGradient(): IParticleSystem;
  126791. /**
  126792. * Not supported by GPUParticleSystem
  126793. * @returns the list of ramp gradients
  126794. */
  126795. getRampGradients(): Nullable<Array<Color3Gradient>>;
  126796. /**
  126797. * Not supported by GPUParticleSystem
  126798. * Gets or sets a boolean indicating that ramp gradients must be used
  126799. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  126800. */
  126801. useRampGradients: boolean;
  126802. /**
  126803. * Not supported by GPUParticleSystem
  126804. * @param gradient defines the gradient to use (between 0 and 1)
  126805. * @param factor defines the life time factor to affect to the specified gradient
  126806. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126807. * @returns the current particle system
  126808. */
  126809. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126810. /**
  126811. * Not supported by GPUParticleSystem
  126812. * @param gradient defines the gradient to remove
  126813. * @returns the current particle system
  126814. */
  126815. removeLifeTimeGradient(gradient: number): IParticleSystem;
  126816. /**
  126817. * Instantiates a GPU particle system.
  126818. * 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.
  126819. * @param name The name of the particle system
  126820. * @param options The options used to create the system
  126821. * @param scene The scene the particle system belongs to
  126822. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  126823. */
  126824. constructor(name: string, options: Partial<{
  126825. capacity: number;
  126826. randomTextureSize: number;
  126827. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  126828. protected _reset(): void;
  126829. private _createUpdateVAO;
  126830. private _createRenderVAO;
  126831. private _initialize;
  126832. /** @hidden */
  126833. _recreateUpdateEffect(): void;
  126834. /** @hidden */
  126835. _recreateRenderEffect(): void;
  126836. /**
  126837. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  126838. * @param preWarm defines if we are in the pre-warmimg phase
  126839. */
  126840. animate(preWarm?: boolean): void;
  126841. private _createFactorGradientTexture;
  126842. private _createSizeGradientTexture;
  126843. private _createAngularSpeedGradientTexture;
  126844. private _createVelocityGradientTexture;
  126845. private _createLimitVelocityGradientTexture;
  126846. private _createDragGradientTexture;
  126847. private _createColorGradientTexture;
  126848. /**
  126849. * Renders the particle system in its current state
  126850. * @param preWarm defines if the system should only update the particles but not render them
  126851. * @returns the current number of particles
  126852. */
  126853. render(preWarm?: boolean): number;
  126854. /**
  126855. * Rebuilds the particle system
  126856. */
  126857. rebuild(): void;
  126858. private _releaseBuffers;
  126859. private _releaseVAOs;
  126860. /**
  126861. * Disposes the particle system and free the associated resources
  126862. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  126863. */
  126864. dispose(disposeTexture?: boolean): void;
  126865. /**
  126866. * Clones the particle system.
  126867. * @param name The name of the cloned object
  126868. * @param newEmitter The new emitter to use
  126869. * @returns the cloned particle system
  126870. */
  126871. clone(name: string, newEmitter: any): GPUParticleSystem;
  126872. /**
  126873. * Serializes the particle system to a JSON object.
  126874. * @returns the JSON object
  126875. */
  126876. serialize(): any;
  126877. /**
  126878. * Parses a JSON object to create a GPU particle system.
  126879. * @param parsedParticleSystem The JSON object to parse
  126880. * @param scene The scene to create the particle system in
  126881. * @param rootUrl The root url to use to load external dependencies like texture
  126882. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  126883. * @returns the parsed GPU particle system
  126884. */
  126885. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  126886. }
  126887. }
  126888. declare module BABYLON {
  126889. /**
  126890. * Represents a set of particle systems working together to create a specific effect
  126891. */
  126892. export class ParticleSystemSet implements IDisposable {
  126893. /**
  126894. * Gets or sets base Assets URL
  126895. */
  126896. static BaseAssetsUrl: string;
  126897. private _emitterCreationOptions;
  126898. private _emitterNode;
  126899. /**
  126900. * Gets the particle system list
  126901. */
  126902. systems: IParticleSystem[];
  126903. /**
  126904. * Gets the emitter node used with this set
  126905. */
  126906. readonly emitterNode: Nullable<TransformNode>;
  126907. /**
  126908. * Creates a new emitter mesh as a sphere
  126909. * @param options defines the options used to create the sphere
  126910. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  126911. * @param scene defines the hosting scene
  126912. */
  126913. setEmitterAsSphere(options: {
  126914. diameter: number;
  126915. segments: number;
  126916. color: Color3;
  126917. }, renderingGroupId: number, scene: Scene): void;
  126918. /**
  126919. * Starts all particle systems of the set
  126920. * @param emitter defines an optional mesh to use as emitter for the particle systems
  126921. */
  126922. start(emitter?: AbstractMesh): void;
  126923. /**
  126924. * Release all associated resources
  126925. */
  126926. dispose(): void;
  126927. /**
  126928. * Serialize the set into a JSON compatible object
  126929. * @returns a JSON compatible representation of the set
  126930. */
  126931. serialize(): any;
  126932. /**
  126933. * Parse a new ParticleSystemSet from a serialized source
  126934. * @param data defines a JSON compatible representation of the set
  126935. * @param scene defines the hosting scene
  126936. * @param gpu defines if we want GPU particles or CPU particles
  126937. * @returns a new ParticleSystemSet
  126938. */
  126939. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  126940. }
  126941. }
  126942. declare module BABYLON {
  126943. /**
  126944. * This class is made for on one-liner static method to help creating particle system set.
  126945. */
  126946. export class ParticleHelper {
  126947. /**
  126948. * Gets or sets base Assets URL
  126949. */
  126950. static BaseAssetsUrl: string;
  126951. /**
  126952. * Create a default particle system that you can tweak
  126953. * @param emitter defines the emitter to use
  126954. * @param capacity defines the system capacity (default is 500 particles)
  126955. * @param scene defines the hosting scene
  126956. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  126957. * @returns the new Particle system
  126958. */
  126959. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  126960. /**
  126961. * This is the main static method (one-liner) of this helper to create different particle systems
  126962. * @param type This string represents the type to the particle system to create
  126963. * @param scene The scene where the particle system should live
  126964. * @param gpu If the system will use gpu
  126965. * @returns the ParticleSystemSet created
  126966. */
  126967. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  126968. /**
  126969. * Static function used to export a particle system to a ParticleSystemSet variable.
  126970. * Please note that the emitter shape is not exported
  126971. * @param systems defines the particle systems to export
  126972. * @returns the created particle system set
  126973. */
  126974. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  126975. }
  126976. }
  126977. declare module BABYLON {
  126978. interface Engine {
  126979. /**
  126980. * Create an effect to use with particle systems.
  126981. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  126982. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  126983. * @param uniformsNames defines a list of attribute names
  126984. * @param samplers defines an array of string used to represent textures
  126985. * @param defines defines the string containing the defines to use to compile the shaders
  126986. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  126987. * @param onCompiled defines a function to call when the effect creation is successful
  126988. * @param onError defines a function to call when the effect creation has failed
  126989. * @returns the new Effect
  126990. */
  126991. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  126992. }
  126993. interface Mesh {
  126994. /**
  126995. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  126996. * @returns an array of IParticleSystem
  126997. */
  126998. getEmittedParticleSystems(): IParticleSystem[];
  126999. /**
  127000. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  127001. * @returns an array of IParticleSystem
  127002. */
  127003. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  127004. }
  127005. /**
  127006. * @hidden
  127007. */
  127008. export var _IDoNeedToBeInTheBuild: number;
  127009. }
  127010. declare module BABYLON {
  127011. /** Defines the 4 color options */
  127012. export enum PointColor {
  127013. /** color value */
  127014. Color = 2,
  127015. /** uv value */
  127016. UV = 1,
  127017. /** random value */
  127018. Random = 0,
  127019. /** stated value */
  127020. Stated = 3
  127021. }
  127022. /**
  127023. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  127024. * 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.
  127025. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  127026. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  127027. *
  127028. * Full documentation here : TO BE ENTERED
  127029. */
  127030. export class PointsCloudSystem implements IDisposable {
  127031. /**
  127032. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  127033. * Example : var p = SPS.particles[i];
  127034. */
  127035. particles: CloudPoint[];
  127036. /**
  127037. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  127038. */
  127039. nbParticles: number;
  127040. /**
  127041. * This a counter for your own usage. It's not set by any SPS functions.
  127042. */
  127043. counter: number;
  127044. /**
  127045. * The PCS name. This name is also given to the underlying mesh.
  127046. */
  127047. name: string;
  127048. /**
  127049. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  127050. */
  127051. mesh: Mesh;
  127052. /**
  127053. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  127054. * Please read :
  127055. */
  127056. vars: any;
  127057. /**
  127058. * @hidden
  127059. */
  127060. _size: number;
  127061. private _scene;
  127062. private _promises;
  127063. private _positions;
  127064. private _indices;
  127065. private _normals;
  127066. private _colors;
  127067. private _uvs;
  127068. private _indices32;
  127069. private _positions32;
  127070. private _colors32;
  127071. private _uvs32;
  127072. private _updatable;
  127073. private _isVisibilityBoxLocked;
  127074. private _alwaysVisible;
  127075. private _groups;
  127076. private _groupCounter;
  127077. private _computeParticleColor;
  127078. private _computeParticleTexture;
  127079. private _computeParticleRotation;
  127080. private _computeBoundingBox;
  127081. private _isReady;
  127082. /**
  127083. * Creates a PCS (Points Cloud System) object
  127084. * @param name (String) is the PCS name, this will be the underlying mesh name
  127085. * @param pointSize (number) is the size for each point
  127086. * @param scene (Scene) is the scene in which the PCS is added
  127087. * @param options defines the options of the PCS e.g.
  127088. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  127089. */
  127090. constructor(name: string, pointSize: number, scene: Scene, options?: {
  127091. updatable?: boolean;
  127092. });
  127093. /**
  127094. * Builds the PCS underlying mesh. Returns a standard Mesh.
  127095. * If no points were added to the PCS, the returned mesh is just a single point.
  127096. * @returns a promise for the created mesh
  127097. */
  127098. buildMeshAsync(): Promise<Mesh>;
  127099. /**
  127100. * @hidden
  127101. */
  127102. private _buildMesh;
  127103. private _addParticle;
  127104. private _randomUnitVector;
  127105. private _getColorIndicesForCoord;
  127106. private _setPointsColorOrUV;
  127107. private _colorFromTexture;
  127108. private _calculateDensity;
  127109. /**
  127110. * Adds points to the PCS in random positions within a unit sphere
  127111. * @param nb (positive integer) the number of particles to be created from this model
  127112. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  127113. * @returns the number of groups in the system
  127114. */
  127115. addPoints(nb: number, pointFunction?: any): number;
  127116. /**
  127117. * Adds points to the PCS from the surface of the model shape
  127118. * @param mesh is any Mesh object that will be used as a surface model for the points
  127119. * @param nb (positive integer) the number of particles to be created from this model
  127120. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  127121. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  127122. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  127123. * @returns the number of groups in the system
  127124. */
  127125. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  127126. /**
  127127. * Adds points to the PCS inside the model shape
  127128. * @param mesh is any Mesh object that will be used as a surface model for the points
  127129. * @param nb (positive integer) the number of particles to be created from this model
  127130. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  127131. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  127132. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  127133. * @returns the number of groups in the system
  127134. */
  127135. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  127136. /**
  127137. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  127138. * This method calls `updateParticle()` for each particle of the SPS.
  127139. * For an animated SPS, it is usually called within the render loop.
  127140. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  127141. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  127142. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  127143. * @returns the PCS.
  127144. */
  127145. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  127146. /**
  127147. * Disposes the PCS.
  127148. */
  127149. dispose(): void;
  127150. /**
  127151. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  127152. * doc :
  127153. * @returns the PCS.
  127154. */
  127155. refreshVisibleSize(): PointsCloudSystem;
  127156. /**
  127157. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  127158. * @param size the size (float) of the visibility box
  127159. * note : this doesn't lock the PCS mesh bounding box.
  127160. * doc :
  127161. */
  127162. setVisibilityBox(size: number): void;
  127163. /**
  127164. * Gets whether the PCS is always visible or not
  127165. * doc :
  127166. */
  127167. /**
  127168. * Sets the PCS as always visible or not
  127169. * doc :
  127170. */
  127171. isAlwaysVisible: boolean;
  127172. /**
  127173. * Tells to `setParticles()` to compute the particle rotations or not
  127174. * Default value : false. The PCS is faster when it's set to false
  127175. * Note : particle rotations are only applied to parent particles
  127176. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  127177. */
  127178. computeParticleRotation: boolean;
  127179. /**
  127180. * Tells to `setParticles()` to compute the particle colors or not.
  127181. * Default value : true. The PCS is faster when it's set to false.
  127182. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  127183. */
  127184. /**
  127185. * Gets if `setParticles()` computes the particle colors or not.
  127186. * Default value : false. The PCS is faster when it's set to false.
  127187. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  127188. */
  127189. computeParticleColor: boolean;
  127190. /**
  127191. * Gets if `setParticles()` computes the particle textures or not.
  127192. * Default value : false. The PCS is faster when it's set to false.
  127193. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  127194. */
  127195. computeParticleTexture: boolean;
  127196. /**
  127197. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  127198. */
  127199. /**
  127200. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  127201. */
  127202. computeBoundingBox: boolean;
  127203. /**
  127204. * This function does nothing. It may be overwritten to set all the particle first values.
  127205. * The PCS doesn't call this function, you may have to call it by your own.
  127206. * doc :
  127207. */
  127208. initParticles(): void;
  127209. /**
  127210. * This function does nothing. It may be overwritten to recycle a particle
  127211. * The PCS doesn't call this function, you can to call it
  127212. * doc :
  127213. * @param particle The particle to recycle
  127214. * @returns the recycled particle
  127215. */
  127216. recycleParticle(particle: CloudPoint): CloudPoint;
  127217. /**
  127218. * Updates a particle : this function should be overwritten by the user.
  127219. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  127220. * doc :
  127221. * @example : just set a particle position or velocity and recycle conditions
  127222. * @param particle The particle to update
  127223. * @returns the updated particle
  127224. */
  127225. updateParticle(particle: CloudPoint): CloudPoint;
  127226. /**
  127227. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  127228. * This does nothing and may be overwritten by the user.
  127229. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  127230. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  127231. * @param update the boolean update value actually passed to setParticles()
  127232. */
  127233. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  127234. /**
  127235. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  127236. * This will be passed three parameters.
  127237. * This does nothing and may be overwritten by the user.
  127238. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  127239. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  127240. * @param update the boolean update value actually passed to setParticles()
  127241. */
  127242. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  127243. }
  127244. }
  127245. declare module BABYLON {
  127246. /**
  127247. * Represents one particle of a points cloud system.
  127248. */
  127249. export class CloudPoint {
  127250. /**
  127251. * particle global index
  127252. */
  127253. idx: number;
  127254. /**
  127255. * The color of the particle
  127256. */
  127257. color: Nullable<Color4>;
  127258. /**
  127259. * The world space position of the particle.
  127260. */
  127261. position: Vector3;
  127262. /**
  127263. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  127264. */
  127265. rotation: Vector3;
  127266. /**
  127267. * The world space rotation quaternion of the particle.
  127268. */
  127269. rotationQuaternion: Nullable<Quaternion>;
  127270. /**
  127271. * The uv of the particle.
  127272. */
  127273. uv: Nullable<Vector2>;
  127274. /**
  127275. * The current speed of the particle.
  127276. */
  127277. velocity: Vector3;
  127278. /**
  127279. * The pivot point in the particle local space.
  127280. */
  127281. pivot: Vector3;
  127282. /**
  127283. * Must the particle be translated from its pivot point in its local space ?
  127284. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  127285. * Default : false
  127286. */
  127287. translateFromPivot: boolean;
  127288. /**
  127289. * Index of this particle in the global "positions" array (Internal use)
  127290. * @hidden
  127291. */
  127292. _pos: number;
  127293. /**
  127294. * @hidden Index of this particle in the global "indices" array (Internal use)
  127295. */
  127296. _ind: number;
  127297. /**
  127298. * Group this particle belongs to
  127299. */
  127300. _group: PointsGroup;
  127301. /**
  127302. * Group id of this particle
  127303. */
  127304. groupId: number;
  127305. /**
  127306. * Index of the particle in its group id (Internal use)
  127307. */
  127308. idxInGroup: number;
  127309. /**
  127310. * @hidden Particle BoundingInfo object (Internal use)
  127311. */
  127312. _boundingInfo: BoundingInfo;
  127313. /**
  127314. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  127315. */
  127316. _pcs: PointsCloudSystem;
  127317. /**
  127318. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  127319. */
  127320. _stillInvisible: boolean;
  127321. /**
  127322. * @hidden Last computed particle rotation matrix
  127323. */
  127324. _rotationMatrix: number[];
  127325. /**
  127326. * Parent particle Id, if any.
  127327. * Default null.
  127328. */
  127329. parentId: Nullable<number>;
  127330. /**
  127331. * @hidden Internal global position in the PCS.
  127332. */
  127333. _globalPosition: Vector3;
  127334. /**
  127335. * Creates a Point Cloud object.
  127336. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  127337. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  127338. * @param group (PointsGroup) is the group the particle belongs to
  127339. * @param groupId (integer) is the group identifier in the PCS.
  127340. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  127341. * @param pcs defines the PCS it is associated to
  127342. */
  127343. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  127344. /**
  127345. * get point size
  127346. */
  127347. /**
  127348. * Set point size
  127349. */
  127350. size: Vector3;
  127351. /**
  127352. * Legacy support, changed quaternion to rotationQuaternion
  127353. */
  127354. /**
  127355. * Legacy support, changed quaternion to rotationQuaternion
  127356. */
  127357. quaternion: Nullable<Quaternion>;
  127358. /**
  127359. * Returns a boolean. True if the particle intersects a mesh, else false
  127360. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  127361. * @param target is the object (point or mesh) what the intersection is computed against
  127362. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  127363. * @returns true if it intersects
  127364. */
  127365. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  127366. /**
  127367. * get the rotation matrix of the particle
  127368. * @hidden
  127369. */
  127370. getRotationMatrix(m: Matrix): void;
  127371. }
  127372. /**
  127373. * Represents a group of points in a points cloud system
  127374. * * PCS internal tool, don't use it manually.
  127375. */
  127376. export class PointsGroup {
  127377. /**
  127378. * The group id
  127379. * @hidden
  127380. */
  127381. groupID: number;
  127382. /**
  127383. * image data for group (internal use)
  127384. * @hidden
  127385. */
  127386. _groupImageData: Nullable<ArrayBufferView>;
  127387. /**
  127388. * Image Width (internal use)
  127389. * @hidden
  127390. */
  127391. _groupImgWidth: number;
  127392. /**
  127393. * Image Height (internal use)
  127394. * @hidden
  127395. */
  127396. _groupImgHeight: number;
  127397. /**
  127398. * Custom position function (internal use)
  127399. * @hidden
  127400. */
  127401. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  127402. /**
  127403. * density per facet for surface points
  127404. * @hidden
  127405. */
  127406. _groupDensity: number[];
  127407. /**
  127408. * Only when points are colored by texture carries pointer to texture list array
  127409. * @hidden
  127410. */
  127411. _textureNb: number;
  127412. /**
  127413. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  127414. * PCS internal tool, don't use it manually.
  127415. * @hidden
  127416. */
  127417. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  127418. }
  127419. }
  127420. declare module BABYLON {
  127421. interface Scene {
  127422. /** @hidden (Backing field) */
  127423. _physicsEngine: Nullable<IPhysicsEngine>;
  127424. /**
  127425. * Gets the current physics engine
  127426. * @returns a IPhysicsEngine or null if none attached
  127427. */
  127428. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  127429. /**
  127430. * Enables physics to the current scene
  127431. * @param gravity defines the scene's gravity for the physics engine
  127432. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  127433. * @return a boolean indicating if the physics engine was initialized
  127434. */
  127435. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  127436. /**
  127437. * Disables and disposes the physics engine associated with the scene
  127438. */
  127439. disablePhysicsEngine(): void;
  127440. /**
  127441. * Gets a boolean indicating if there is an active physics engine
  127442. * @returns a boolean indicating if there is an active physics engine
  127443. */
  127444. isPhysicsEnabled(): boolean;
  127445. /**
  127446. * Deletes a physics compound impostor
  127447. * @param compound defines the compound to delete
  127448. */
  127449. deleteCompoundImpostor(compound: any): void;
  127450. /**
  127451. * An event triggered when physic simulation is about to be run
  127452. */
  127453. onBeforePhysicsObservable: Observable<Scene>;
  127454. /**
  127455. * An event triggered when physic simulation has been done
  127456. */
  127457. onAfterPhysicsObservable: Observable<Scene>;
  127458. }
  127459. interface AbstractMesh {
  127460. /** @hidden */
  127461. _physicsImpostor: Nullable<PhysicsImpostor>;
  127462. /**
  127463. * Gets or sets impostor used for physic simulation
  127464. * @see http://doc.babylonjs.com/features/physics_engine
  127465. */
  127466. physicsImpostor: Nullable<PhysicsImpostor>;
  127467. /**
  127468. * Gets the current physics impostor
  127469. * @see http://doc.babylonjs.com/features/physics_engine
  127470. * @returns a physics impostor or null
  127471. */
  127472. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  127473. /** Apply a physic impulse to the mesh
  127474. * @param force defines the force to apply
  127475. * @param contactPoint defines where to apply the force
  127476. * @returns the current mesh
  127477. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127478. */
  127479. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  127480. /**
  127481. * Creates a physic joint between two meshes
  127482. * @param otherMesh defines the other mesh to use
  127483. * @param pivot1 defines the pivot to use on this mesh
  127484. * @param pivot2 defines the pivot to use on the other mesh
  127485. * @param options defines additional options (can be plugin dependent)
  127486. * @returns the current mesh
  127487. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  127488. */
  127489. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  127490. /** @hidden */
  127491. _disposePhysicsObserver: Nullable<Observer<Node>>;
  127492. }
  127493. /**
  127494. * Defines the physics engine scene component responsible to manage a physics engine
  127495. */
  127496. export class PhysicsEngineSceneComponent implements ISceneComponent {
  127497. /**
  127498. * The component name helpful to identify the component in the list of scene components.
  127499. */
  127500. readonly name: string;
  127501. /**
  127502. * The scene the component belongs to.
  127503. */
  127504. scene: Scene;
  127505. /**
  127506. * Creates a new instance of the component for the given scene
  127507. * @param scene Defines the scene to register the component in
  127508. */
  127509. constructor(scene: Scene);
  127510. /**
  127511. * Registers the component in a given scene
  127512. */
  127513. register(): void;
  127514. /**
  127515. * Rebuilds the elements related to this component in case of
  127516. * context lost for instance.
  127517. */
  127518. rebuild(): void;
  127519. /**
  127520. * Disposes the component and the associated ressources
  127521. */
  127522. dispose(): void;
  127523. }
  127524. }
  127525. declare module BABYLON {
  127526. /**
  127527. * A helper for physics simulations
  127528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127529. */
  127530. export class PhysicsHelper {
  127531. private _scene;
  127532. private _physicsEngine;
  127533. /**
  127534. * Initializes the Physics helper
  127535. * @param scene Babylon.js scene
  127536. */
  127537. constructor(scene: Scene);
  127538. /**
  127539. * Applies a radial explosion impulse
  127540. * @param origin the origin of the explosion
  127541. * @param radiusOrEventOptions the radius or the options of radial explosion
  127542. * @param strength the explosion strength
  127543. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127544. * @returns A physics radial explosion event, or null
  127545. */
  127546. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  127547. /**
  127548. * Applies a radial explosion force
  127549. * @param origin the origin of the explosion
  127550. * @param radiusOrEventOptions the radius or the options of radial explosion
  127551. * @param strength the explosion strength
  127552. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127553. * @returns A physics radial explosion event, or null
  127554. */
  127555. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  127556. /**
  127557. * Creates a gravitational field
  127558. * @param origin the origin of the explosion
  127559. * @param radiusOrEventOptions the radius or the options of radial explosion
  127560. * @param strength the explosion strength
  127561. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127562. * @returns A physics gravitational field event, or null
  127563. */
  127564. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  127565. /**
  127566. * Creates a physics updraft event
  127567. * @param origin the origin of the updraft
  127568. * @param radiusOrEventOptions the radius or the options of the updraft
  127569. * @param strength the strength of the updraft
  127570. * @param height the height of the updraft
  127571. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  127572. * @returns A physics updraft event, or null
  127573. */
  127574. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  127575. /**
  127576. * Creates a physics vortex event
  127577. * @param origin the of the vortex
  127578. * @param radiusOrEventOptions the radius or the options of the vortex
  127579. * @param strength the strength of the vortex
  127580. * @param height the height of the vortex
  127581. * @returns a Physics vortex event, or null
  127582. * A physics vortex event or null
  127583. */
  127584. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  127585. }
  127586. /**
  127587. * Represents a physics radial explosion event
  127588. */
  127589. class PhysicsRadialExplosionEvent {
  127590. private _scene;
  127591. private _options;
  127592. private _sphere;
  127593. private _dataFetched;
  127594. /**
  127595. * Initializes a radial explosioin event
  127596. * @param _scene BabylonJS scene
  127597. * @param _options The options for the vortex event
  127598. */
  127599. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  127600. /**
  127601. * Returns the data related to the radial explosion event (sphere).
  127602. * @returns The radial explosion event data
  127603. */
  127604. getData(): PhysicsRadialExplosionEventData;
  127605. /**
  127606. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  127607. * @param impostor A physics imposter
  127608. * @param origin the origin of the explosion
  127609. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  127610. */
  127611. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  127612. /**
  127613. * Triggers affecterd impostors callbacks
  127614. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  127615. */
  127616. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  127617. /**
  127618. * Disposes the sphere.
  127619. * @param force Specifies if the sphere should be disposed by force
  127620. */
  127621. dispose(force?: boolean): void;
  127622. /*** Helpers ***/
  127623. private _prepareSphere;
  127624. private _intersectsWithSphere;
  127625. }
  127626. /**
  127627. * Represents a gravitational field event
  127628. */
  127629. class PhysicsGravitationalFieldEvent {
  127630. private _physicsHelper;
  127631. private _scene;
  127632. private _origin;
  127633. private _options;
  127634. private _tickCallback;
  127635. private _sphere;
  127636. private _dataFetched;
  127637. /**
  127638. * Initializes the physics gravitational field event
  127639. * @param _physicsHelper A physics helper
  127640. * @param _scene BabylonJS scene
  127641. * @param _origin The origin position of the gravitational field event
  127642. * @param _options The options for the vortex event
  127643. */
  127644. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  127645. /**
  127646. * Returns the data related to the gravitational field event (sphere).
  127647. * @returns A gravitational field event
  127648. */
  127649. getData(): PhysicsGravitationalFieldEventData;
  127650. /**
  127651. * Enables the gravitational field.
  127652. */
  127653. enable(): void;
  127654. /**
  127655. * Disables the gravitational field.
  127656. */
  127657. disable(): void;
  127658. /**
  127659. * Disposes the sphere.
  127660. * @param force The force to dispose from the gravitational field event
  127661. */
  127662. dispose(force?: boolean): void;
  127663. private _tick;
  127664. }
  127665. /**
  127666. * Represents a physics updraft event
  127667. */
  127668. class PhysicsUpdraftEvent {
  127669. private _scene;
  127670. private _origin;
  127671. private _options;
  127672. private _physicsEngine;
  127673. private _originTop;
  127674. private _originDirection;
  127675. private _tickCallback;
  127676. private _cylinder;
  127677. private _cylinderPosition;
  127678. private _dataFetched;
  127679. /**
  127680. * Initializes the physics updraft event
  127681. * @param _scene BabylonJS scene
  127682. * @param _origin The origin position of the updraft
  127683. * @param _options The options for the updraft event
  127684. */
  127685. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  127686. /**
  127687. * Returns the data related to the updraft event (cylinder).
  127688. * @returns A physics updraft event
  127689. */
  127690. getData(): PhysicsUpdraftEventData;
  127691. /**
  127692. * Enables the updraft.
  127693. */
  127694. enable(): void;
  127695. /**
  127696. * Disables the updraft.
  127697. */
  127698. disable(): void;
  127699. /**
  127700. * Disposes the cylinder.
  127701. * @param force Specifies if the updraft should be disposed by force
  127702. */
  127703. dispose(force?: boolean): void;
  127704. private getImpostorHitData;
  127705. private _tick;
  127706. /*** Helpers ***/
  127707. private _prepareCylinder;
  127708. private _intersectsWithCylinder;
  127709. }
  127710. /**
  127711. * Represents a physics vortex event
  127712. */
  127713. class PhysicsVortexEvent {
  127714. private _scene;
  127715. private _origin;
  127716. private _options;
  127717. private _physicsEngine;
  127718. private _originTop;
  127719. private _tickCallback;
  127720. private _cylinder;
  127721. private _cylinderPosition;
  127722. private _dataFetched;
  127723. /**
  127724. * Initializes the physics vortex event
  127725. * @param _scene The BabylonJS scene
  127726. * @param _origin The origin position of the vortex
  127727. * @param _options The options for the vortex event
  127728. */
  127729. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  127730. /**
  127731. * Returns the data related to the vortex event (cylinder).
  127732. * @returns The physics vortex event data
  127733. */
  127734. getData(): PhysicsVortexEventData;
  127735. /**
  127736. * Enables the vortex.
  127737. */
  127738. enable(): void;
  127739. /**
  127740. * Disables the cortex.
  127741. */
  127742. disable(): void;
  127743. /**
  127744. * Disposes the sphere.
  127745. * @param force
  127746. */
  127747. dispose(force?: boolean): void;
  127748. private getImpostorHitData;
  127749. private _tick;
  127750. /*** Helpers ***/
  127751. private _prepareCylinder;
  127752. private _intersectsWithCylinder;
  127753. }
  127754. /**
  127755. * Options fot the radial explosion event
  127756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127757. */
  127758. export class PhysicsRadialExplosionEventOptions {
  127759. /**
  127760. * The radius of the sphere for the radial explosion.
  127761. */
  127762. radius: number;
  127763. /**
  127764. * The strenth of the explosion.
  127765. */
  127766. strength: number;
  127767. /**
  127768. * The strenght of the force in correspondence to the distance of the affected object
  127769. */
  127770. falloff: PhysicsRadialImpulseFalloff;
  127771. /**
  127772. * Sphere options for the radial explosion.
  127773. */
  127774. sphere: {
  127775. segments: number;
  127776. diameter: number;
  127777. };
  127778. /**
  127779. * Sphere options for the radial explosion.
  127780. */
  127781. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  127782. }
  127783. /**
  127784. * Options fot the updraft event
  127785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127786. */
  127787. export class PhysicsUpdraftEventOptions {
  127788. /**
  127789. * The radius of the cylinder for the vortex
  127790. */
  127791. radius: number;
  127792. /**
  127793. * The strenth of the updraft.
  127794. */
  127795. strength: number;
  127796. /**
  127797. * The height of the cylinder for the updraft.
  127798. */
  127799. height: number;
  127800. /**
  127801. * The mode for the the updraft.
  127802. */
  127803. updraftMode: PhysicsUpdraftMode;
  127804. }
  127805. /**
  127806. * Options fot the vortex event
  127807. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127808. */
  127809. export class PhysicsVortexEventOptions {
  127810. /**
  127811. * The radius of the cylinder for the vortex
  127812. */
  127813. radius: number;
  127814. /**
  127815. * The strenth of the vortex.
  127816. */
  127817. strength: number;
  127818. /**
  127819. * The height of the cylinder for the vortex.
  127820. */
  127821. height: number;
  127822. /**
  127823. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  127824. */
  127825. centripetalForceThreshold: number;
  127826. /**
  127827. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  127828. */
  127829. centripetalForceMultiplier: number;
  127830. /**
  127831. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  127832. */
  127833. centrifugalForceMultiplier: number;
  127834. /**
  127835. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  127836. */
  127837. updraftForceMultiplier: number;
  127838. }
  127839. /**
  127840. * The strenght of the force in correspondence to the distance of the affected object
  127841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127842. */
  127843. export enum PhysicsRadialImpulseFalloff {
  127844. /** Defines that impulse is constant in strength across it's whole radius */
  127845. Constant = 0,
  127846. /** Defines that impulse gets weaker if it's further from the origin */
  127847. Linear = 1
  127848. }
  127849. /**
  127850. * The strength of the force in correspondence to the distance of the affected object
  127851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127852. */
  127853. export enum PhysicsUpdraftMode {
  127854. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  127855. Center = 0,
  127856. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  127857. Perpendicular = 1
  127858. }
  127859. /**
  127860. * Interface for a physics hit data
  127861. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127862. */
  127863. export interface PhysicsHitData {
  127864. /**
  127865. * The force applied at the contact point
  127866. */
  127867. force: Vector3;
  127868. /**
  127869. * The contact point
  127870. */
  127871. contactPoint: Vector3;
  127872. /**
  127873. * The distance from the origin to the contact point
  127874. */
  127875. distanceFromOrigin: number;
  127876. }
  127877. /**
  127878. * Interface for radial explosion event data
  127879. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127880. */
  127881. export interface PhysicsRadialExplosionEventData {
  127882. /**
  127883. * A sphere used for the radial explosion event
  127884. */
  127885. sphere: Mesh;
  127886. }
  127887. /**
  127888. * Interface for gravitational field event data
  127889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127890. */
  127891. export interface PhysicsGravitationalFieldEventData {
  127892. /**
  127893. * A sphere mesh used for the gravitational field event
  127894. */
  127895. sphere: Mesh;
  127896. }
  127897. /**
  127898. * Interface for updraft event data
  127899. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127900. */
  127901. export interface PhysicsUpdraftEventData {
  127902. /**
  127903. * A cylinder used for the updraft event
  127904. */
  127905. cylinder: Mesh;
  127906. }
  127907. /**
  127908. * Interface for vortex event data
  127909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127910. */
  127911. export interface PhysicsVortexEventData {
  127912. /**
  127913. * A cylinder used for the vortex event
  127914. */
  127915. cylinder: Mesh;
  127916. }
  127917. /**
  127918. * Interface for an affected physics impostor
  127919. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127920. */
  127921. export interface PhysicsAffectedImpostorWithData {
  127922. /**
  127923. * The impostor affected by the effect
  127924. */
  127925. impostor: PhysicsImpostor;
  127926. /**
  127927. * The data about the hit/horce from the explosion
  127928. */
  127929. hitData: PhysicsHitData;
  127930. }
  127931. }
  127932. declare module BABYLON {
  127933. /** @hidden */
  127934. export var blackAndWhitePixelShader: {
  127935. name: string;
  127936. shader: string;
  127937. };
  127938. }
  127939. declare module BABYLON {
  127940. /**
  127941. * Post process used to render in black and white
  127942. */
  127943. export class BlackAndWhitePostProcess extends PostProcess {
  127944. /**
  127945. * Linear about to convert he result to black and white (default: 1)
  127946. */
  127947. degree: number;
  127948. /**
  127949. * Creates a black and white post process
  127950. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  127951. * @param name The name of the effect.
  127952. * @param options The required width/height ratio to downsize to before computing the render pass.
  127953. * @param camera The camera to apply the render pass to.
  127954. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127955. * @param engine The engine which the post process will be applied. (default: current engine)
  127956. * @param reusable If the post process can be reused on the same frame. (default: false)
  127957. */
  127958. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127959. }
  127960. }
  127961. declare module BABYLON {
  127962. /**
  127963. * This represents a set of one or more post processes in Babylon.
  127964. * A post process can be used to apply a shader to a texture after it is rendered.
  127965. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127966. */
  127967. export class PostProcessRenderEffect {
  127968. private _postProcesses;
  127969. private _getPostProcesses;
  127970. private _singleInstance;
  127971. private _cameras;
  127972. private _indicesForCamera;
  127973. /**
  127974. * Name of the effect
  127975. * @hidden
  127976. */
  127977. _name: string;
  127978. /**
  127979. * Instantiates a post process render effect.
  127980. * A post process can be used to apply a shader to a texture after it is rendered.
  127981. * @param engine The engine the effect is tied to
  127982. * @param name The name of the effect
  127983. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  127984. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  127985. */
  127986. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  127987. /**
  127988. * Checks if all the post processes in the effect are supported.
  127989. */
  127990. readonly isSupported: boolean;
  127991. /**
  127992. * Updates the current state of the effect
  127993. * @hidden
  127994. */
  127995. _update(): void;
  127996. /**
  127997. * Attaches the effect on cameras
  127998. * @param cameras The camera to attach to.
  127999. * @hidden
  128000. */
  128001. _attachCameras(cameras: Camera): void;
  128002. /**
  128003. * Attaches the effect on cameras
  128004. * @param cameras The camera to attach to.
  128005. * @hidden
  128006. */
  128007. _attachCameras(cameras: Camera[]): void;
  128008. /**
  128009. * Detaches the effect on cameras
  128010. * @param cameras The camera to detatch from.
  128011. * @hidden
  128012. */
  128013. _detachCameras(cameras: Camera): void;
  128014. /**
  128015. * Detatches the effect on cameras
  128016. * @param cameras The camera to detatch from.
  128017. * @hidden
  128018. */
  128019. _detachCameras(cameras: Camera[]): void;
  128020. /**
  128021. * Enables the effect on given cameras
  128022. * @param cameras The camera to enable.
  128023. * @hidden
  128024. */
  128025. _enable(cameras: Camera): void;
  128026. /**
  128027. * Enables the effect on given cameras
  128028. * @param cameras The camera to enable.
  128029. * @hidden
  128030. */
  128031. _enable(cameras: Nullable<Camera[]>): void;
  128032. /**
  128033. * Disables the effect on the given cameras
  128034. * @param cameras The camera to disable.
  128035. * @hidden
  128036. */
  128037. _disable(cameras: Camera): void;
  128038. /**
  128039. * Disables the effect on the given cameras
  128040. * @param cameras The camera to disable.
  128041. * @hidden
  128042. */
  128043. _disable(cameras: Nullable<Camera[]>): void;
  128044. /**
  128045. * Gets a list of the post processes contained in the effect.
  128046. * @param camera The camera to get the post processes on.
  128047. * @returns The list of the post processes in the effect.
  128048. */
  128049. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  128050. }
  128051. }
  128052. declare module BABYLON {
  128053. /** @hidden */
  128054. export var extractHighlightsPixelShader: {
  128055. name: string;
  128056. shader: string;
  128057. };
  128058. }
  128059. declare module BABYLON {
  128060. /**
  128061. * 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.
  128062. */
  128063. export class ExtractHighlightsPostProcess extends PostProcess {
  128064. /**
  128065. * The luminance threshold, pixels below this value will be set to black.
  128066. */
  128067. threshold: number;
  128068. /** @hidden */
  128069. _exposure: number;
  128070. /**
  128071. * Post process which has the input texture to be used when performing highlight extraction
  128072. * @hidden
  128073. */
  128074. _inputPostProcess: Nullable<PostProcess>;
  128075. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128076. }
  128077. }
  128078. declare module BABYLON {
  128079. /** @hidden */
  128080. export var bloomMergePixelShader: {
  128081. name: string;
  128082. shader: string;
  128083. };
  128084. }
  128085. declare module BABYLON {
  128086. /**
  128087. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  128088. */
  128089. export class BloomMergePostProcess extends PostProcess {
  128090. /** Weight of the bloom to be added to the original input. */
  128091. weight: number;
  128092. /**
  128093. * Creates a new instance of @see BloomMergePostProcess
  128094. * @param name The name of the effect.
  128095. * @param originalFromInput Post process which's input will be used for the merge.
  128096. * @param blurred Blurred highlights post process which's output will be used.
  128097. * @param weight Weight of the bloom to be added to the original input.
  128098. * @param options The required width/height ratio to downsize to before computing the render pass.
  128099. * @param camera The camera to apply the render pass to.
  128100. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128101. * @param engine The engine which the post process will be applied. (default: current engine)
  128102. * @param reusable If the post process can be reused on the same frame. (default: false)
  128103. * @param textureType Type of textures used when performing the post process. (default: 0)
  128104. * @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)
  128105. */
  128106. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  128107. /** Weight of the bloom to be added to the original input. */
  128108. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128109. }
  128110. }
  128111. declare module BABYLON {
  128112. /**
  128113. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  128114. */
  128115. export class BloomEffect extends PostProcessRenderEffect {
  128116. private bloomScale;
  128117. /**
  128118. * @hidden Internal
  128119. */
  128120. _effects: Array<PostProcess>;
  128121. /**
  128122. * @hidden Internal
  128123. */
  128124. _downscale: ExtractHighlightsPostProcess;
  128125. private _blurX;
  128126. private _blurY;
  128127. private _merge;
  128128. /**
  128129. * The luminance threshold to find bright areas of the image to bloom.
  128130. */
  128131. threshold: number;
  128132. /**
  128133. * The strength of the bloom.
  128134. */
  128135. weight: number;
  128136. /**
  128137. * Specifies the size of the bloom blur kernel, relative to the final output size
  128138. */
  128139. kernel: number;
  128140. /**
  128141. * Creates a new instance of @see BloomEffect
  128142. * @param scene The scene the effect belongs to.
  128143. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  128144. * @param bloomKernel The size of the kernel to be used when applying the blur.
  128145. * @param bloomWeight The the strength of bloom.
  128146. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  128147. * @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)
  128148. */
  128149. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  128150. /**
  128151. * Disposes each of the internal effects for a given camera.
  128152. * @param camera The camera to dispose the effect on.
  128153. */
  128154. disposeEffects(camera: Camera): void;
  128155. /**
  128156. * @hidden Internal
  128157. */
  128158. _updateEffects(): void;
  128159. /**
  128160. * Internal
  128161. * @returns if all the contained post processes are ready.
  128162. * @hidden
  128163. */
  128164. _isReady(): boolean;
  128165. }
  128166. }
  128167. declare module BABYLON {
  128168. /** @hidden */
  128169. export var chromaticAberrationPixelShader: {
  128170. name: string;
  128171. shader: string;
  128172. };
  128173. }
  128174. declare module BABYLON {
  128175. /**
  128176. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  128177. */
  128178. export class ChromaticAberrationPostProcess extends PostProcess {
  128179. /**
  128180. * The amount of seperation of rgb channels (default: 30)
  128181. */
  128182. aberrationAmount: number;
  128183. /**
  128184. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  128185. */
  128186. radialIntensity: number;
  128187. /**
  128188. * 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))
  128189. */
  128190. direction: Vector2;
  128191. /**
  128192. * 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))
  128193. */
  128194. centerPosition: Vector2;
  128195. /**
  128196. * Creates a new instance ChromaticAberrationPostProcess
  128197. * @param name The name of the effect.
  128198. * @param screenWidth The width of the screen to apply the effect on.
  128199. * @param screenHeight The height of the screen to apply the effect on.
  128200. * @param options The required width/height ratio to downsize to before computing the render pass.
  128201. * @param camera The camera to apply the render pass to.
  128202. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128203. * @param engine The engine which the post process will be applied. (default: current engine)
  128204. * @param reusable If the post process can be reused on the same frame. (default: false)
  128205. * @param textureType Type of textures used when performing the post process. (default: 0)
  128206. * @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)
  128207. */
  128208. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128209. }
  128210. }
  128211. declare module BABYLON {
  128212. /** @hidden */
  128213. export var circleOfConfusionPixelShader: {
  128214. name: string;
  128215. shader: string;
  128216. };
  128217. }
  128218. declare module BABYLON {
  128219. /**
  128220. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  128221. */
  128222. export class CircleOfConfusionPostProcess extends PostProcess {
  128223. /**
  128224. * 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.
  128225. */
  128226. lensSize: number;
  128227. /**
  128228. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  128229. */
  128230. fStop: number;
  128231. /**
  128232. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  128233. */
  128234. focusDistance: number;
  128235. /**
  128236. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  128237. */
  128238. focalLength: number;
  128239. private _depthTexture;
  128240. /**
  128241. * Creates a new instance CircleOfConfusionPostProcess
  128242. * @param name The name of the effect.
  128243. * @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.
  128244. * @param options The required width/height ratio to downsize to before computing the render pass.
  128245. * @param camera The camera to apply the render pass to.
  128246. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128247. * @param engine The engine which the post process will be applied. (default: current engine)
  128248. * @param reusable If the post process can be reused on the same frame. (default: false)
  128249. * @param textureType Type of textures used when performing the post process. (default: 0)
  128250. * @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)
  128251. */
  128252. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128253. /**
  128254. * 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.
  128255. */
  128256. depthTexture: RenderTargetTexture;
  128257. }
  128258. }
  128259. declare module BABYLON {
  128260. /** @hidden */
  128261. export var colorCorrectionPixelShader: {
  128262. name: string;
  128263. shader: string;
  128264. };
  128265. }
  128266. declare module BABYLON {
  128267. /**
  128268. *
  128269. * This post-process allows the modification of rendered colors by using
  128270. * a 'look-up table' (LUT). This effect is also called Color Grading.
  128271. *
  128272. * The object needs to be provided an url to a texture containing the color
  128273. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  128274. * Use an image editing software to tweak the LUT to match your needs.
  128275. *
  128276. * For an example of a color LUT, see here:
  128277. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  128278. * For explanations on color grading, see here:
  128279. * @see http://udn.epicgames.com/Three/ColorGrading.html
  128280. *
  128281. */
  128282. export class ColorCorrectionPostProcess extends PostProcess {
  128283. private _colorTableTexture;
  128284. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128285. }
  128286. }
  128287. declare module BABYLON {
  128288. /** @hidden */
  128289. export var convolutionPixelShader: {
  128290. name: string;
  128291. shader: string;
  128292. };
  128293. }
  128294. declare module BABYLON {
  128295. /**
  128296. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  128297. * input texture to perform effects such as edge detection or sharpening
  128298. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  128299. */
  128300. export class ConvolutionPostProcess extends PostProcess {
  128301. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  128302. kernel: number[];
  128303. /**
  128304. * Creates a new instance ConvolutionPostProcess
  128305. * @param name The name of the effect.
  128306. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  128307. * @param options The required width/height ratio to downsize to before computing the render pass.
  128308. * @param camera The camera to apply the render pass to.
  128309. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128310. * @param engine The engine which the post process will be applied. (default: current engine)
  128311. * @param reusable If the post process can be reused on the same frame. (default: false)
  128312. * @param textureType Type of textures used when performing the post process. (default: 0)
  128313. */
  128314. constructor(name: string,
  128315. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  128316. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128317. /**
  128318. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128319. */
  128320. static EdgeDetect0Kernel: number[];
  128321. /**
  128322. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128323. */
  128324. static EdgeDetect1Kernel: number[];
  128325. /**
  128326. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128327. */
  128328. static EdgeDetect2Kernel: number[];
  128329. /**
  128330. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128331. */
  128332. static SharpenKernel: number[];
  128333. /**
  128334. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128335. */
  128336. static EmbossKernel: number[];
  128337. /**
  128338. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128339. */
  128340. static GaussianKernel: number[];
  128341. }
  128342. }
  128343. declare module BABYLON {
  128344. /**
  128345. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  128346. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  128347. * based on samples that have a large difference in distance than the center pixel.
  128348. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  128349. */
  128350. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  128351. direction: Vector2;
  128352. /**
  128353. * Creates a new instance CircleOfConfusionPostProcess
  128354. * @param name The name of the effect.
  128355. * @param scene The scene the effect belongs to.
  128356. * @param direction The direction the blur should be applied.
  128357. * @param kernel The size of the kernel used to blur.
  128358. * @param options The required width/height ratio to downsize to before computing the render pass.
  128359. * @param camera The camera to apply the render pass to.
  128360. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  128361. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  128362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128363. * @param engine The engine which the post process will be applied. (default: current engine)
  128364. * @param reusable If the post process can be reused on the same frame. (default: false)
  128365. * @param textureType Type of textures used when performing the post process. (default: 0)
  128366. * @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)
  128367. */
  128368. 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);
  128369. }
  128370. }
  128371. declare module BABYLON {
  128372. /** @hidden */
  128373. export var depthOfFieldMergePixelShader: {
  128374. name: string;
  128375. shader: string;
  128376. };
  128377. }
  128378. declare module BABYLON {
  128379. /**
  128380. * Options to be set when merging outputs from the default pipeline.
  128381. */
  128382. export class DepthOfFieldMergePostProcessOptions {
  128383. /**
  128384. * The original image to merge on top of
  128385. */
  128386. originalFromInput: PostProcess;
  128387. /**
  128388. * Parameters to perform the merge of the depth of field effect
  128389. */
  128390. depthOfField?: {
  128391. circleOfConfusion: PostProcess;
  128392. blurSteps: Array<PostProcess>;
  128393. };
  128394. /**
  128395. * Parameters to perform the merge of bloom effect
  128396. */
  128397. bloom?: {
  128398. blurred: PostProcess;
  128399. weight: number;
  128400. };
  128401. }
  128402. /**
  128403. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  128404. */
  128405. export class DepthOfFieldMergePostProcess extends PostProcess {
  128406. private blurSteps;
  128407. /**
  128408. * Creates a new instance of DepthOfFieldMergePostProcess
  128409. * @param name The name of the effect.
  128410. * @param originalFromInput Post process which's input will be used for the merge.
  128411. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  128412. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  128413. * @param options The required width/height ratio to downsize to before computing the render pass.
  128414. * @param camera The camera to apply the render pass to.
  128415. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128416. * @param engine The engine which the post process will be applied. (default: current engine)
  128417. * @param reusable If the post process can be reused on the same frame. (default: false)
  128418. * @param textureType Type of textures used when performing the post process. (default: 0)
  128419. * @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)
  128420. */
  128421. 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);
  128422. /**
  128423. * Updates the effect with the current post process compile time values and recompiles the shader.
  128424. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  128425. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  128426. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  128427. * @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
  128428. * @param onCompiled Called when the shader has been compiled.
  128429. * @param onError Called if there is an error when compiling a shader.
  128430. */
  128431. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  128432. }
  128433. }
  128434. declare module BABYLON {
  128435. /**
  128436. * Specifies the level of max blur that should be applied when using the depth of field effect
  128437. */
  128438. export enum DepthOfFieldEffectBlurLevel {
  128439. /**
  128440. * Subtle blur
  128441. */
  128442. Low = 0,
  128443. /**
  128444. * Medium blur
  128445. */
  128446. Medium = 1,
  128447. /**
  128448. * Large blur
  128449. */
  128450. High = 2
  128451. }
  128452. /**
  128453. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  128454. */
  128455. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  128456. private _circleOfConfusion;
  128457. /**
  128458. * @hidden Internal, blurs from high to low
  128459. */
  128460. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  128461. private _depthOfFieldBlurY;
  128462. private _dofMerge;
  128463. /**
  128464. * @hidden Internal post processes in depth of field effect
  128465. */
  128466. _effects: Array<PostProcess>;
  128467. /**
  128468. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  128469. */
  128470. focalLength: number;
  128471. /**
  128472. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  128473. */
  128474. fStop: number;
  128475. /**
  128476. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  128477. */
  128478. focusDistance: number;
  128479. /**
  128480. * 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.
  128481. */
  128482. lensSize: number;
  128483. /**
  128484. * Creates a new instance DepthOfFieldEffect
  128485. * @param scene The scene the effect belongs to.
  128486. * @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.
  128487. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  128488. * @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)
  128489. */
  128490. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  128491. /**
  128492. * Get the current class name of the current effet
  128493. * @returns "DepthOfFieldEffect"
  128494. */
  128495. getClassName(): string;
  128496. /**
  128497. * 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.
  128498. */
  128499. depthTexture: RenderTargetTexture;
  128500. /**
  128501. * Disposes each of the internal effects for a given camera.
  128502. * @param camera The camera to dispose the effect on.
  128503. */
  128504. disposeEffects(camera: Camera): void;
  128505. /**
  128506. * @hidden Internal
  128507. */
  128508. _updateEffects(): void;
  128509. /**
  128510. * Internal
  128511. * @returns if all the contained post processes are ready.
  128512. * @hidden
  128513. */
  128514. _isReady(): boolean;
  128515. }
  128516. }
  128517. declare module BABYLON {
  128518. /** @hidden */
  128519. export var displayPassPixelShader: {
  128520. name: string;
  128521. shader: string;
  128522. };
  128523. }
  128524. declare module BABYLON {
  128525. /**
  128526. * DisplayPassPostProcess which produces an output the same as it's input
  128527. */
  128528. export class DisplayPassPostProcess extends PostProcess {
  128529. /**
  128530. * Creates the DisplayPassPostProcess
  128531. * @param name The name of the effect.
  128532. * @param options The required width/height ratio to downsize to before computing the render pass.
  128533. * @param camera The camera to apply the render pass to.
  128534. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128535. * @param engine The engine which the post process will be applied. (default: current engine)
  128536. * @param reusable If the post process can be reused on the same frame. (default: false)
  128537. */
  128538. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128539. }
  128540. }
  128541. declare module BABYLON {
  128542. /** @hidden */
  128543. export var filterPixelShader: {
  128544. name: string;
  128545. shader: string;
  128546. };
  128547. }
  128548. declare module BABYLON {
  128549. /**
  128550. * Applies a kernel filter to the image
  128551. */
  128552. export class FilterPostProcess extends PostProcess {
  128553. /** The matrix to be applied to the image */
  128554. kernelMatrix: Matrix;
  128555. /**
  128556. *
  128557. * @param name The name of the effect.
  128558. * @param kernelMatrix The matrix to be applied to the image
  128559. * @param options The required width/height ratio to downsize to before computing the render pass.
  128560. * @param camera The camera to apply the render pass to.
  128561. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128562. * @param engine The engine which the post process will be applied. (default: current engine)
  128563. * @param reusable If the post process can be reused on the same frame. (default: false)
  128564. */
  128565. constructor(name: string,
  128566. /** The matrix to be applied to the image */
  128567. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128568. }
  128569. }
  128570. declare module BABYLON {
  128571. /** @hidden */
  128572. export var fxaaPixelShader: {
  128573. name: string;
  128574. shader: string;
  128575. };
  128576. }
  128577. declare module BABYLON {
  128578. /** @hidden */
  128579. export var fxaaVertexShader: {
  128580. name: string;
  128581. shader: string;
  128582. };
  128583. }
  128584. declare module BABYLON {
  128585. /**
  128586. * Fxaa post process
  128587. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  128588. */
  128589. export class FxaaPostProcess extends PostProcess {
  128590. /** @hidden */
  128591. texelWidth: number;
  128592. /** @hidden */
  128593. texelHeight: number;
  128594. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128595. private _getDefines;
  128596. }
  128597. }
  128598. declare module BABYLON {
  128599. /** @hidden */
  128600. export var grainPixelShader: {
  128601. name: string;
  128602. shader: string;
  128603. };
  128604. }
  128605. declare module BABYLON {
  128606. /**
  128607. * The GrainPostProcess adds noise to the image at mid luminance levels
  128608. */
  128609. export class GrainPostProcess extends PostProcess {
  128610. /**
  128611. * The intensity of the grain added (default: 30)
  128612. */
  128613. intensity: number;
  128614. /**
  128615. * If the grain should be randomized on every frame
  128616. */
  128617. animated: boolean;
  128618. /**
  128619. * Creates a new instance of @see GrainPostProcess
  128620. * @param name The name of the effect.
  128621. * @param options The required width/height ratio to downsize to before computing the render pass.
  128622. * @param camera The camera to apply the render pass to.
  128623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128624. * @param engine The engine which the post process will be applied. (default: current engine)
  128625. * @param reusable If the post process can be reused on the same frame. (default: false)
  128626. * @param textureType Type of textures used when performing the post process. (default: 0)
  128627. * @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)
  128628. */
  128629. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128630. }
  128631. }
  128632. declare module BABYLON {
  128633. /** @hidden */
  128634. export var highlightsPixelShader: {
  128635. name: string;
  128636. shader: string;
  128637. };
  128638. }
  128639. declare module BABYLON {
  128640. /**
  128641. * Extracts highlights from the image
  128642. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  128643. */
  128644. export class HighlightsPostProcess extends PostProcess {
  128645. /**
  128646. * Extracts highlights from the image
  128647. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  128648. * @param name The name of the effect.
  128649. * @param options The required width/height ratio to downsize to before computing the render pass.
  128650. * @param camera The camera to apply the render pass to.
  128651. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128652. * @param engine The engine which the post process will be applied. (default: current engine)
  128653. * @param reusable If the post process can be reused on the same frame. (default: false)
  128654. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  128655. */
  128656. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128657. }
  128658. }
  128659. declare module BABYLON {
  128660. /** @hidden */
  128661. export var mrtFragmentDeclaration: {
  128662. name: string;
  128663. shader: string;
  128664. };
  128665. }
  128666. declare module BABYLON {
  128667. /** @hidden */
  128668. export var geometryPixelShader: {
  128669. name: string;
  128670. shader: string;
  128671. };
  128672. }
  128673. declare module BABYLON {
  128674. /** @hidden */
  128675. export var geometryVertexShader: {
  128676. name: string;
  128677. shader: string;
  128678. };
  128679. }
  128680. declare module BABYLON {
  128681. /** @hidden */
  128682. interface ISavedTransformationMatrix {
  128683. world: Matrix;
  128684. viewProjection: Matrix;
  128685. }
  128686. /**
  128687. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  128688. */
  128689. export class GeometryBufferRenderer {
  128690. /**
  128691. * Constant used to retrieve the position texture index in the G-Buffer textures array
  128692. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  128693. */
  128694. static readonly POSITION_TEXTURE_TYPE: number;
  128695. /**
  128696. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  128697. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  128698. */
  128699. static readonly VELOCITY_TEXTURE_TYPE: number;
  128700. /**
  128701. * Dictionary used to store the previous transformation matrices of each rendered mesh
  128702. * in order to compute objects velocities when enableVelocity is set to "true"
  128703. * @hidden
  128704. */
  128705. _previousTransformationMatrices: {
  128706. [index: number]: ISavedTransformationMatrix;
  128707. };
  128708. /**
  128709. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  128710. * in order to compute objects velocities when enableVelocity is set to "true"
  128711. * @hidden
  128712. */
  128713. _previousBonesTransformationMatrices: {
  128714. [index: number]: Float32Array;
  128715. };
  128716. /**
  128717. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  128718. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  128719. */
  128720. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  128721. private _scene;
  128722. private _multiRenderTarget;
  128723. private _ratio;
  128724. private _enablePosition;
  128725. private _enableVelocity;
  128726. private _positionIndex;
  128727. private _velocityIndex;
  128728. protected _effect: Effect;
  128729. protected _cachedDefines: string;
  128730. /**
  128731. * Set the render list (meshes to be rendered) used in the G buffer.
  128732. */
  128733. renderList: Mesh[];
  128734. /**
  128735. * Gets wether or not G buffer are supported by the running hardware.
  128736. * This requires draw buffer supports
  128737. */
  128738. readonly isSupported: boolean;
  128739. /**
  128740. * Returns the index of the given texture type in the G-Buffer textures array
  128741. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  128742. * @returns the index of the given texture type in the G-Buffer textures array
  128743. */
  128744. getTextureIndex(textureType: number): number;
  128745. /**
  128746. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  128747. */
  128748. /**
  128749. * Sets whether or not objects positions are enabled for the G buffer.
  128750. */
  128751. enablePosition: boolean;
  128752. /**
  128753. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  128754. */
  128755. /**
  128756. * Sets wether or not objects velocities are enabled for the G buffer.
  128757. */
  128758. enableVelocity: boolean;
  128759. /**
  128760. * Gets the scene associated with the buffer.
  128761. */
  128762. readonly scene: Scene;
  128763. /**
  128764. * Gets the ratio used by the buffer during its creation.
  128765. * How big is the buffer related to the main canvas.
  128766. */
  128767. readonly ratio: number;
  128768. /** @hidden */
  128769. static _SceneComponentInitialization: (scene: Scene) => void;
  128770. /**
  128771. * Creates a new G Buffer for the scene
  128772. * @param scene The scene the buffer belongs to
  128773. * @param ratio How big is the buffer related to the main canvas.
  128774. */
  128775. constructor(scene: Scene, ratio?: number);
  128776. /**
  128777. * Checks wether everything is ready to render a submesh to the G buffer.
  128778. * @param subMesh the submesh to check readiness for
  128779. * @param useInstances is the mesh drawn using instance or not
  128780. * @returns true if ready otherwise false
  128781. */
  128782. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128783. /**
  128784. * Gets the current underlying G Buffer.
  128785. * @returns the buffer
  128786. */
  128787. getGBuffer(): MultiRenderTarget;
  128788. /**
  128789. * Gets the number of samples used to render the buffer (anti aliasing).
  128790. */
  128791. /**
  128792. * Sets the number of samples used to render the buffer (anti aliasing).
  128793. */
  128794. samples: number;
  128795. /**
  128796. * Disposes the renderer and frees up associated resources.
  128797. */
  128798. dispose(): void;
  128799. protected _createRenderTargets(): void;
  128800. private _copyBonesTransformationMatrices;
  128801. }
  128802. }
  128803. declare module BABYLON {
  128804. interface Scene {
  128805. /** @hidden (Backing field) */
  128806. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  128807. /**
  128808. * Gets or Sets the current geometry buffer associated to the scene.
  128809. */
  128810. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  128811. /**
  128812. * Enables a GeometryBufferRender and associates it with the scene
  128813. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  128814. * @returns the GeometryBufferRenderer
  128815. */
  128816. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  128817. /**
  128818. * Disables the GeometryBufferRender associated with the scene
  128819. */
  128820. disableGeometryBufferRenderer(): void;
  128821. }
  128822. /**
  128823. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  128824. * in several rendering techniques.
  128825. */
  128826. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  128827. /**
  128828. * The component name helpful to identify the component in the list of scene components.
  128829. */
  128830. readonly name: string;
  128831. /**
  128832. * The scene the component belongs to.
  128833. */
  128834. scene: Scene;
  128835. /**
  128836. * Creates a new instance of the component for the given scene
  128837. * @param scene Defines the scene to register the component in
  128838. */
  128839. constructor(scene: Scene);
  128840. /**
  128841. * Registers the component in a given scene
  128842. */
  128843. register(): void;
  128844. /**
  128845. * Rebuilds the elements related to this component in case of
  128846. * context lost for instance.
  128847. */
  128848. rebuild(): void;
  128849. /**
  128850. * Disposes the component and the associated ressources
  128851. */
  128852. dispose(): void;
  128853. private _gatherRenderTargets;
  128854. }
  128855. }
  128856. declare module BABYLON {
  128857. /** @hidden */
  128858. export var motionBlurPixelShader: {
  128859. name: string;
  128860. shader: string;
  128861. };
  128862. }
  128863. declare module BABYLON {
  128864. /**
  128865. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  128866. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  128867. * As an example, all you have to do is to create the post-process:
  128868. * var mb = new BABYLON.MotionBlurPostProcess(
  128869. * 'mb', // The name of the effect.
  128870. * scene, // The scene containing the objects to blur according to their velocity.
  128871. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  128872. * camera // The camera to apply the render pass to.
  128873. * );
  128874. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  128875. */
  128876. export class MotionBlurPostProcess extends PostProcess {
  128877. /**
  128878. * Defines how much the image is blurred by the movement. Default value is equal to 1
  128879. */
  128880. motionStrength: number;
  128881. /**
  128882. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  128883. */
  128884. /**
  128885. * Sets the number of iterations to be used for motion blur quality
  128886. */
  128887. motionBlurSamples: number;
  128888. private _motionBlurSamples;
  128889. private _geometryBufferRenderer;
  128890. /**
  128891. * Creates a new instance MotionBlurPostProcess
  128892. * @param name The name of the effect.
  128893. * @param scene The scene containing the objects to blur according to their velocity.
  128894. * @param options The required width/height ratio to downsize to before computing the render pass.
  128895. * @param camera The camera to apply the render pass to.
  128896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128897. * @param engine The engine which the post process will be applied. (default: current engine)
  128898. * @param reusable If the post process can be reused on the same frame. (default: false)
  128899. * @param textureType Type of textures used when performing the post process. (default: 0)
  128900. * @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)
  128901. */
  128902. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128903. /**
  128904. * Excludes the given skinned mesh from computing bones velocities.
  128905. * 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.
  128906. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  128907. */
  128908. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  128909. /**
  128910. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  128911. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  128912. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  128913. */
  128914. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  128915. /**
  128916. * Disposes the post process.
  128917. * @param camera The camera to dispose the post process on.
  128918. */
  128919. dispose(camera?: Camera): void;
  128920. }
  128921. }
  128922. declare module BABYLON {
  128923. /** @hidden */
  128924. export var refractionPixelShader: {
  128925. name: string;
  128926. shader: string;
  128927. };
  128928. }
  128929. declare module BABYLON {
  128930. /**
  128931. * Post process which applies a refractin texture
  128932. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  128933. */
  128934. export class RefractionPostProcess extends PostProcess {
  128935. /** the base color of the refraction (used to taint the rendering) */
  128936. color: Color3;
  128937. /** simulated refraction depth */
  128938. depth: number;
  128939. /** the coefficient of the base color (0 to remove base color tainting) */
  128940. colorLevel: number;
  128941. private _refTexture;
  128942. private _ownRefractionTexture;
  128943. /**
  128944. * Gets or sets the refraction texture
  128945. * Please note that you are responsible for disposing the texture if you set it manually
  128946. */
  128947. refractionTexture: Texture;
  128948. /**
  128949. * Initializes the RefractionPostProcess
  128950. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  128951. * @param name The name of the effect.
  128952. * @param refractionTextureUrl Url of the refraction texture to use
  128953. * @param color the base color of the refraction (used to taint the rendering)
  128954. * @param depth simulated refraction depth
  128955. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  128956. * @param camera The camera to apply the render pass to.
  128957. * @param options The required width/height ratio to downsize to before computing the render pass.
  128958. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128959. * @param engine The engine which the post process will be applied. (default: current engine)
  128960. * @param reusable If the post process can be reused on the same frame. (default: false)
  128961. */
  128962. constructor(name: string, refractionTextureUrl: string,
  128963. /** the base color of the refraction (used to taint the rendering) */
  128964. color: Color3,
  128965. /** simulated refraction depth */
  128966. depth: number,
  128967. /** the coefficient of the base color (0 to remove base color tainting) */
  128968. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128969. /**
  128970. * Disposes of the post process
  128971. * @param camera Camera to dispose post process on
  128972. */
  128973. dispose(camera: Camera): void;
  128974. }
  128975. }
  128976. declare module BABYLON {
  128977. /** @hidden */
  128978. export var sharpenPixelShader: {
  128979. name: string;
  128980. shader: string;
  128981. };
  128982. }
  128983. declare module BABYLON {
  128984. /**
  128985. * The SharpenPostProcess applies a sharpen kernel to every pixel
  128986. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  128987. */
  128988. export class SharpenPostProcess extends PostProcess {
  128989. /**
  128990. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  128991. */
  128992. colorAmount: number;
  128993. /**
  128994. * How much sharpness should be applied (default: 0.3)
  128995. */
  128996. edgeAmount: number;
  128997. /**
  128998. * Creates a new instance ConvolutionPostProcess
  128999. * @param name The name of the effect.
  129000. * @param options The required width/height ratio to downsize to before computing the render pass.
  129001. * @param camera The camera to apply the render pass to.
  129002. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129003. * @param engine The engine which the post process will be applied. (default: current engine)
  129004. * @param reusable If the post process can be reused on the same frame. (default: false)
  129005. * @param textureType Type of textures used when performing the post process. (default: 0)
  129006. * @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)
  129007. */
  129008. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129009. }
  129010. }
  129011. declare module BABYLON {
  129012. /**
  129013. * PostProcessRenderPipeline
  129014. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129015. */
  129016. export class PostProcessRenderPipeline {
  129017. private engine;
  129018. private _renderEffects;
  129019. private _renderEffectsForIsolatedPass;
  129020. /**
  129021. * List of inspectable custom properties (used by the Inspector)
  129022. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  129023. */
  129024. inspectableCustomProperties: IInspectable[];
  129025. /**
  129026. * @hidden
  129027. */
  129028. protected _cameras: Camera[];
  129029. /** @hidden */
  129030. _name: string;
  129031. /**
  129032. * Gets pipeline name
  129033. */
  129034. readonly name: string;
  129035. /** Gets the list of attached cameras */
  129036. readonly cameras: Camera[];
  129037. /**
  129038. * Initializes a PostProcessRenderPipeline
  129039. * @param engine engine to add the pipeline to
  129040. * @param name name of the pipeline
  129041. */
  129042. constructor(engine: Engine, name: string);
  129043. /**
  129044. * Gets the class name
  129045. * @returns "PostProcessRenderPipeline"
  129046. */
  129047. getClassName(): string;
  129048. /**
  129049. * If all the render effects in the pipeline are supported
  129050. */
  129051. readonly isSupported: boolean;
  129052. /**
  129053. * Adds an effect to the pipeline
  129054. * @param renderEffect the effect to add
  129055. */
  129056. addEffect(renderEffect: PostProcessRenderEffect): void;
  129057. /** @hidden */
  129058. _rebuild(): void;
  129059. /** @hidden */
  129060. _enableEffect(renderEffectName: string, cameras: Camera): void;
  129061. /** @hidden */
  129062. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  129063. /** @hidden */
  129064. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  129065. /** @hidden */
  129066. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  129067. /** @hidden */
  129068. _attachCameras(cameras: Camera, unique: boolean): void;
  129069. /** @hidden */
  129070. _attachCameras(cameras: Camera[], unique: boolean): void;
  129071. /** @hidden */
  129072. _detachCameras(cameras: Camera): void;
  129073. /** @hidden */
  129074. _detachCameras(cameras: Nullable<Camera[]>): void;
  129075. /** @hidden */
  129076. _update(): void;
  129077. /** @hidden */
  129078. _reset(): void;
  129079. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  129080. /**
  129081. * Disposes of the pipeline
  129082. */
  129083. dispose(): void;
  129084. }
  129085. }
  129086. declare module BABYLON {
  129087. /**
  129088. * PostProcessRenderPipelineManager class
  129089. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129090. */
  129091. export class PostProcessRenderPipelineManager {
  129092. private _renderPipelines;
  129093. /**
  129094. * Initializes a PostProcessRenderPipelineManager
  129095. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129096. */
  129097. constructor();
  129098. /**
  129099. * Gets the list of supported render pipelines
  129100. */
  129101. readonly supportedPipelines: PostProcessRenderPipeline[];
  129102. /**
  129103. * Adds a pipeline to the manager
  129104. * @param renderPipeline The pipeline to add
  129105. */
  129106. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  129107. /**
  129108. * Attaches a camera to the pipeline
  129109. * @param renderPipelineName The name of the pipeline to attach to
  129110. * @param cameras the camera to attach
  129111. * @param unique if the camera can be attached multiple times to the pipeline
  129112. */
  129113. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  129114. /**
  129115. * Detaches a camera from the pipeline
  129116. * @param renderPipelineName The name of the pipeline to detach from
  129117. * @param cameras the camera to detach
  129118. */
  129119. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  129120. /**
  129121. * Enables an effect by name on a pipeline
  129122. * @param renderPipelineName the name of the pipeline to enable the effect in
  129123. * @param renderEffectName the name of the effect to enable
  129124. * @param cameras the cameras that the effect should be enabled on
  129125. */
  129126. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  129127. /**
  129128. * Disables an effect by name on a pipeline
  129129. * @param renderPipelineName the name of the pipeline to disable the effect in
  129130. * @param renderEffectName the name of the effect to disable
  129131. * @param cameras the cameras that the effect should be disabled on
  129132. */
  129133. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  129134. /**
  129135. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  129136. */
  129137. update(): void;
  129138. /** @hidden */
  129139. _rebuild(): void;
  129140. /**
  129141. * Disposes of the manager and pipelines
  129142. */
  129143. dispose(): void;
  129144. }
  129145. }
  129146. declare module BABYLON {
  129147. interface Scene {
  129148. /** @hidden (Backing field) */
  129149. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  129150. /**
  129151. * Gets the postprocess render pipeline manager
  129152. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129153. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  129154. */
  129155. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  129156. }
  129157. /**
  129158. * Defines the Render Pipeline scene component responsible to rendering pipelines
  129159. */
  129160. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  129161. /**
  129162. * The component name helpfull to identify the component in the list of scene components.
  129163. */
  129164. readonly name: string;
  129165. /**
  129166. * The scene the component belongs to.
  129167. */
  129168. scene: Scene;
  129169. /**
  129170. * Creates a new instance of the component for the given scene
  129171. * @param scene Defines the scene to register the component in
  129172. */
  129173. constructor(scene: Scene);
  129174. /**
  129175. * Registers the component in a given scene
  129176. */
  129177. register(): void;
  129178. /**
  129179. * Rebuilds the elements related to this component in case of
  129180. * context lost for instance.
  129181. */
  129182. rebuild(): void;
  129183. /**
  129184. * Disposes the component and the associated ressources
  129185. */
  129186. dispose(): void;
  129187. private _gatherRenderTargets;
  129188. }
  129189. }
  129190. declare module BABYLON {
  129191. /**
  129192. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  129193. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  129194. */
  129195. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  129196. private _scene;
  129197. private _camerasToBeAttached;
  129198. /**
  129199. * ID of the sharpen post process,
  129200. */
  129201. private readonly SharpenPostProcessId;
  129202. /**
  129203. * @ignore
  129204. * ID of the image processing post process;
  129205. */
  129206. readonly ImageProcessingPostProcessId: string;
  129207. /**
  129208. * @ignore
  129209. * ID of the Fast Approximate Anti-Aliasing post process;
  129210. */
  129211. readonly FxaaPostProcessId: string;
  129212. /**
  129213. * ID of the chromatic aberration post process,
  129214. */
  129215. private readonly ChromaticAberrationPostProcessId;
  129216. /**
  129217. * ID of the grain post process
  129218. */
  129219. private readonly GrainPostProcessId;
  129220. /**
  129221. * Sharpen post process which will apply a sharpen convolution to enhance edges
  129222. */
  129223. sharpen: SharpenPostProcess;
  129224. private _sharpenEffect;
  129225. private bloom;
  129226. /**
  129227. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  129228. */
  129229. depthOfField: DepthOfFieldEffect;
  129230. /**
  129231. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  129232. */
  129233. fxaa: FxaaPostProcess;
  129234. /**
  129235. * Image post processing pass used to perform operations such as tone mapping or color grading.
  129236. */
  129237. imageProcessing: ImageProcessingPostProcess;
  129238. /**
  129239. * Chromatic aberration post process which will shift rgb colors in the image
  129240. */
  129241. chromaticAberration: ChromaticAberrationPostProcess;
  129242. private _chromaticAberrationEffect;
  129243. /**
  129244. * Grain post process which add noise to the image
  129245. */
  129246. grain: GrainPostProcess;
  129247. private _grainEffect;
  129248. /**
  129249. * Glow post process which adds a glow to emissive areas of the image
  129250. */
  129251. private _glowLayer;
  129252. /**
  129253. * Animations which can be used to tweak settings over a period of time
  129254. */
  129255. animations: Animation[];
  129256. private _imageProcessingConfigurationObserver;
  129257. private _sharpenEnabled;
  129258. private _bloomEnabled;
  129259. private _depthOfFieldEnabled;
  129260. private _depthOfFieldBlurLevel;
  129261. private _fxaaEnabled;
  129262. private _imageProcessingEnabled;
  129263. private _defaultPipelineTextureType;
  129264. private _bloomScale;
  129265. private _chromaticAberrationEnabled;
  129266. private _grainEnabled;
  129267. private _buildAllowed;
  129268. /**
  129269. * Gets active scene
  129270. */
  129271. readonly scene: Scene;
  129272. /**
  129273. * Enable or disable the sharpen process from the pipeline
  129274. */
  129275. sharpenEnabled: boolean;
  129276. private _resizeObserver;
  129277. private _hardwareScaleLevel;
  129278. private _bloomKernel;
  129279. /**
  129280. * Specifies the size of the bloom blur kernel, relative to the final output size
  129281. */
  129282. bloomKernel: number;
  129283. /**
  129284. * Specifies the weight of the bloom in the final rendering
  129285. */
  129286. private _bloomWeight;
  129287. /**
  129288. * Specifies the luma threshold for the area that will be blurred by the bloom
  129289. */
  129290. private _bloomThreshold;
  129291. private _hdr;
  129292. /**
  129293. * The strength of the bloom.
  129294. */
  129295. bloomWeight: number;
  129296. /**
  129297. * The strength of the bloom.
  129298. */
  129299. bloomThreshold: number;
  129300. /**
  129301. * The scale of the bloom, lower value will provide better performance.
  129302. */
  129303. bloomScale: number;
  129304. /**
  129305. * Enable or disable the bloom from the pipeline
  129306. */
  129307. bloomEnabled: boolean;
  129308. private _rebuildBloom;
  129309. /**
  129310. * If the depth of field is enabled.
  129311. */
  129312. depthOfFieldEnabled: boolean;
  129313. /**
  129314. * Blur level of the depth of field effect. (Higher blur will effect performance)
  129315. */
  129316. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  129317. /**
  129318. * If the anti aliasing is enabled.
  129319. */
  129320. fxaaEnabled: boolean;
  129321. private _samples;
  129322. /**
  129323. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  129324. */
  129325. samples: number;
  129326. /**
  129327. * If image processing is enabled.
  129328. */
  129329. imageProcessingEnabled: boolean;
  129330. /**
  129331. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  129332. */
  129333. glowLayerEnabled: boolean;
  129334. /**
  129335. * Gets the glow layer (or null if not defined)
  129336. */
  129337. readonly glowLayer: Nullable<GlowLayer>;
  129338. /**
  129339. * Enable or disable the chromaticAberration process from the pipeline
  129340. */
  129341. chromaticAberrationEnabled: boolean;
  129342. /**
  129343. * Enable or disable the grain process from the pipeline
  129344. */
  129345. grainEnabled: boolean;
  129346. /**
  129347. * @constructor
  129348. * @param name - The rendering pipeline name (default: "")
  129349. * @param hdr - If high dynamic range textures should be used (default: true)
  129350. * @param scene - The scene linked to this pipeline (default: the last created scene)
  129351. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  129352. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  129353. */
  129354. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  129355. /**
  129356. * Get the class name
  129357. * @returns "DefaultRenderingPipeline"
  129358. */
  129359. getClassName(): string;
  129360. /**
  129361. * Force the compilation of the entire pipeline.
  129362. */
  129363. prepare(): void;
  129364. private _hasCleared;
  129365. private _prevPostProcess;
  129366. private _prevPrevPostProcess;
  129367. private _setAutoClearAndTextureSharing;
  129368. private _depthOfFieldSceneObserver;
  129369. private _buildPipeline;
  129370. private _disposePostProcesses;
  129371. /**
  129372. * Adds a camera to the pipeline
  129373. * @param camera the camera to be added
  129374. */
  129375. addCamera(camera: Camera): void;
  129376. /**
  129377. * Removes a camera from the pipeline
  129378. * @param camera the camera to remove
  129379. */
  129380. removeCamera(camera: Camera): void;
  129381. /**
  129382. * Dispose of the pipeline and stop all post processes
  129383. */
  129384. dispose(): void;
  129385. /**
  129386. * Serialize the rendering pipeline (Used when exporting)
  129387. * @returns the serialized object
  129388. */
  129389. serialize(): any;
  129390. /**
  129391. * Parse the serialized pipeline
  129392. * @param source Source pipeline.
  129393. * @param scene The scene to load the pipeline to.
  129394. * @param rootUrl The URL of the serialized pipeline.
  129395. * @returns An instantiated pipeline from the serialized object.
  129396. */
  129397. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  129398. }
  129399. }
  129400. declare module BABYLON {
  129401. /** @hidden */
  129402. export var lensHighlightsPixelShader: {
  129403. name: string;
  129404. shader: string;
  129405. };
  129406. }
  129407. declare module BABYLON {
  129408. /** @hidden */
  129409. export var depthOfFieldPixelShader: {
  129410. name: string;
  129411. shader: string;
  129412. };
  129413. }
  129414. declare module BABYLON {
  129415. /**
  129416. * BABYLON.JS Chromatic Aberration GLSL Shader
  129417. * Author: Olivier Guyot
  129418. * Separates very slightly R, G and B colors on the edges of the screen
  129419. * Inspired by Francois Tarlier & Martins Upitis
  129420. */
  129421. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  129422. /**
  129423. * @ignore
  129424. * The chromatic aberration PostProcess id in the pipeline
  129425. */
  129426. LensChromaticAberrationEffect: string;
  129427. /**
  129428. * @ignore
  129429. * The highlights enhancing PostProcess id in the pipeline
  129430. */
  129431. HighlightsEnhancingEffect: string;
  129432. /**
  129433. * @ignore
  129434. * The depth-of-field PostProcess id in the pipeline
  129435. */
  129436. LensDepthOfFieldEffect: string;
  129437. private _scene;
  129438. private _depthTexture;
  129439. private _grainTexture;
  129440. private _chromaticAberrationPostProcess;
  129441. private _highlightsPostProcess;
  129442. private _depthOfFieldPostProcess;
  129443. private _edgeBlur;
  129444. private _grainAmount;
  129445. private _chromaticAberration;
  129446. private _distortion;
  129447. private _highlightsGain;
  129448. private _highlightsThreshold;
  129449. private _dofDistance;
  129450. private _dofAperture;
  129451. private _dofDarken;
  129452. private _dofPentagon;
  129453. private _blurNoise;
  129454. /**
  129455. * @constructor
  129456. *
  129457. * Effect parameters are as follow:
  129458. * {
  129459. * chromatic_aberration: number; // from 0 to x (1 for realism)
  129460. * edge_blur: number; // from 0 to x (1 for realism)
  129461. * distortion: number; // from 0 to x (1 for realism)
  129462. * grain_amount: number; // from 0 to 1
  129463. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  129464. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  129465. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  129466. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  129467. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  129468. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  129469. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  129470. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  129471. * }
  129472. * Note: if an effect parameter is unset, effect is disabled
  129473. *
  129474. * @param name The rendering pipeline name
  129475. * @param parameters - An object containing all parameters (see above)
  129476. * @param scene The scene linked to this pipeline
  129477. * @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)
  129478. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129479. */
  129480. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  129481. /**
  129482. * Get the class name
  129483. * @returns "LensRenderingPipeline"
  129484. */
  129485. getClassName(): string;
  129486. /**
  129487. * Gets associated scene
  129488. */
  129489. readonly scene: Scene;
  129490. /**
  129491. * Gets or sets the edge blur
  129492. */
  129493. edgeBlur: number;
  129494. /**
  129495. * Gets or sets the grain amount
  129496. */
  129497. grainAmount: number;
  129498. /**
  129499. * Gets or sets the chromatic aberration amount
  129500. */
  129501. chromaticAberration: number;
  129502. /**
  129503. * Gets or sets the depth of field aperture
  129504. */
  129505. dofAperture: number;
  129506. /**
  129507. * Gets or sets the edge distortion
  129508. */
  129509. edgeDistortion: number;
  129510. /**
  129511. * Gets or sets the depth of field distortion
  129512. */
  129513. dofDistortion: number;
  129514. /**
  129515. * Gets or sets the darken out of focus amount
  129516. */
  129517. darkenOutOfFocus: number;
  129518. /**
  129519. * Gets or sets a boolean indicating if blur noise is enabled
  129520. */
  129521. blurNoise: boolean;
  129522. /**
  129523. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  129524. */
  129525. pentagonBokeh: boolean;
  129526. /**
  129527. * Gets or sets the highlight grain amount
  129528. */
  129529. highlightsGain: number;
  129530. /**
  129531. * Gets or sets the highlight threshold
  129532. */
  129533. highlightsThreshold: number;
  129534. /**
  129535. * Sets the amount of blur at the edges
  129536. * @param amount blur amount
  129537. */
  129538. setEdgeBlur(amount: number): void;
  129539. /**
  129540. * Sets edge blur to 0
  129541. */
  129542. disableEdgeBlur(): void;
  129543. /**
  129544. * Sets the amout of grain
  129545. * @param amount Amount of grain
  129546. */
  129547. setGrainAmount(amount: number): void;
  129548. /**
  129549. * Set grain amount to 0
  129550. */
  129551. disableGrain(): void;
  129552. /**
  129553. * Sets the chromatic aberration amount
  129554. * @param amount amount of chromatic aberration
  129555. */
  129556. setChromaticAberration(amount: number): void;
  129557. /**
  129558. * Sets chromatic aberration amount to 0
  129559. */
  129560. disableChromaticAberration(): void;
  129561. /**
  129562. * Sets the EdgeDistortion amount
  129563. * @param amount amount of EdgeDistortion
  129564. */
  129565. setEdgeDistortion(amount: number): void;
  129566. /**
  129567. * Sets edge distortion to 0
  129568. */
  129569. disableEdgeDistortion(): void;
  129570. /**
  129571. * Sets the FocusDistance amount
  129572. * @param amount amount of FocusDistance
  129573. */
  129574. setFocusDistance(amount: number): void;
  129575. /**
  129576. * Disables depth of field
  129577. */
  129578. disableDepthOfField(): void;
  129579. /**
  129580. * Sets the Aperture amount
  129581. * @param amount amount of Aperture
  129582. */
  129583. setAperture(amount: number): void;
  129584. /**
  129585. * Sets the DarkenOutOfFocus amount
  129586. * @param amount amount of DarkenOutOfFocus
  129587. */
  129588. setDarkenOutOfFocus(amount: number): void;
  129589. private _pentagonBokehIsEnabled;
  129590. /**
  129591. * Creates a pentagon bokeh effect
  129592. */
  129593. enablePentagonBokeh(): void;
  129594. /**
  129595. * Disables the pentagon bokeh effect
  129596. */
  129597. disablePentagonBokeh(): void;
  129598. /**
  129599. * Enables noise blur
  129600. */
  129601. enableNoiseBlur(): void;
  129602. /**
  129603. * Disables noise blur
  129604. */
  129605. disableNoiseBlur(): void;
  129606. /**
  129607. * Sets the HighlightsGain amount
  129608. * @param amount amount of HighlightsGain
  129609. */
  129610. setHighlightsGain(amount: number): void;
  129611. /**
  129612. * Sets the HighlightsThreshold amount
  129613. * @param amount amount of HighlightsThreshold
  129614. */
  129615. setHighlightsThreshold(amount: number): void;
  129616. /**
  129617. * Disables highlights
  129618. */
  129619. disableHighlights(): void;
  129620. /**
  129621. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  129622. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  129623. */
  129624. dispose(disableDepthRender?: boolean): void;
  129625. private _createChromaticAberrationPostProcess;
  129626. private _createHighlightsPostProcess;
  129627. private _createDepthOfFieldPostProcess;
  129628. private _createGrainTexture;
  129629. }
  129630. }
  129631. declare module BABYLON {
  129632. /** @hidden */
  129633. export var ssao2PixelShader: {
  129634. name: string;
  129635. shader: string;
  129636. };
  129637. }
  129638. declare module BABYLON {
  129639. /** @hidden */
  129640. export var ssaoCombinePixelShader: {
  129641. name: string;
  129642. shader: string;
  129643. };
  129644. }
  129645. declare module BABYLON {
  129646. /**
  129647. * Render pipeline to produce ssao effect
  129648. */
  129649. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  129650. /**
  129651. * @ignore
  129652. * The PassPostProcess id in the pipeline that contains the original scene color
  129653. */
  129654. SSAOOriginalSceneColorEffect: string;
  129655. /**
  129656. * @ignore
  129657. * The SSAO PostProcess id in the pipeline
  129658. */
  129659. SSAORenderEffect: string;
  129660. /**
  129661. * @ignore
  129662. * The horizontal blur PostProcess id in the pipeline
  129663. */
  129664. SSAOBlurHRenderEffect: string;
  129665. /**
  129666. * @ignore
  129667. * The vertical blur PostProcess id in the pipeline
  129668. */
  129669. SSAOBlurVRenderEffect: string;
  129670. /**
  129671. * @ignore
  129672. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  129673. */
  129674. SSAOCombineRenderEffect: string;
  129675. /**
  129676. * The output strength of the SSAO post-process. Default value is 1.0.
  129677. */
  129678. totalStrength: number;
  129679. /**
  129680. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  129681. */
  129682. maxZ: number;
  129683. /**
  129684. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  129685. */
  129686. minZAspect: number;
  129687. private _samples;
  129688. /**
  129689. * Number of samples used for the SSAO calculations. Default value is 8
  129690. */
  129691. samples: number;
  129692. private _textureSamples;
  129693. /**
  129694. * Number of samples to use for antialiasing
  129695. */
  129696. textureSamples: number;
  129697. /**
  129698. * Ratio object used for SSAO ratio and blur ratio
  129699. */
  129700. private _ratio;
  129701. /**
  129702. * Dynamically generated sphere sampler.
  129703. */
  129704. private _sampleSphere;
  129705. /**
  129706. * Blur filter offsets
  129707. */
  129708. private _samplerOffsets;
  129709. private _expensiveBlur;
  129710. /**
  129711. * If bilateral blur should be used
  129712. */
  129713. expensiveBlur: boolean;
  129714. /**
  129715. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  129716. */
  129717. radius: number;
  129718. /**
  129719. * The base color of the SSAO post-process
  129720. * The final result is "base + ssao" between [0, 1]
  129721. */
  129722. base: number;
  129723. /**
  129724. * Support test.
  129725. */
  129726. static readonly IsSupported: boolean;
  129727. private _scene;
  129728. private _depthTexture;
  129729. private _normalTexture;
  129730. private _randomTexture;
  129731. private _originalColorPostProcess;
  129732. private _ssaoPostProcess;
  129733. private _blurHPostProcess;
  129734. private _blurVPostProcess;
  129735. private _ssaoCombinePostProcess;
  129736. /**
  129737. * Gets active scene
  129738. */
  129739. readonly scene: Scene;
  129740. /**
  129741. * @constructor
  129742. * @param name The rendering pipeline name
  129743. * @param scene The scene linked to this pipeline
  129744. * @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 }
  129745. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129746. */
  129747. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  129748. /**
  129749. * Get the class name
  129750. * @returns "SSAO2RenderingPipeline"
  129751. */
  129752. getClassName(): string;
  129753. /**
  129754. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  129755. */
  129756. dispose(disableGeometryBufferRenderer?: boolean): void;
  129757. private _createBlurPostProcess;
  129758. /** @hidden */
  129759. _rebuild(): void;
  129760. private _bits;
  129761. private _radicalInverse_VdC;
  129762. private _hammersley;
  129763. private _hemisphereSample_uniform;
  129764. private _generateHemisphere;
  129765. private _createSSAOPostProcess;
  129766. private _createSSAOCombinePostProcess;
  129767. private _createRandomTexture;
  129768. /**
  129769. * Serialize the rendering pipeline (Used when exporting)
  129770. * @returns the serialized object
  129771. */
  129772. serialize(): any;
  129773. /**
  129774. * Parse the serialized pipeline
  129775. * @param source Source pipeline.
  129776. * @param scene The scene to load the pipeline to.
  129777. * @param rootUrl The URL of the serialized pipeline.
  129778. * @returns An instantiated pipeline from the serialized object.
  129779. */
  129780. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  129781. }
  129782. }
  129783. declare module BABYLON {
  129784. /** @hidden */
  129785. export var ssaoPixelShader: {
  129786. name: string;
  129787. shader: string;
  129788. };
  129789. }
  129790. declare module BABYLON {
  129791. /**
  129792. * Render pipeline to produce ssao effect
  129793. */
  129794. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  129795. /**
  129796. * @ignore
  129797. * The PassPostProcess id in the pipeline that contains the original scene color
  129798. */
  129799. SSAOOriginalSceneColorEffect: string;
  129800. /**
  129801. * @ignore
  129802. * The SSAO PostProcess id in the pipeline
  129803. */
  129804. SSAORenderEffect: string;
  129805. /**
  129806. * @ignore
  129807. * The horizontal blur PostProcess id in the pipeline
  129808. */
  129809. SSAOBlurHRenderEffect: string;
  129810. /**
  129811. * @ignore
  129812. * The vertical blur PostProcess id in the pipeline
  129813. */
  129814. SSAOBlurVRenderEffect: string;
  129815. /**
  129816. * @ignore
  129817. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  129818. */
  129819. SSAOCombineRenderEffect: string;
  129820. /**
  129821. * The output strength of the SSAO post-process. Default value is 1.0.
  129822. */
  129823. totalStrength: number;
  129824. /**
  129825. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  129826. */
  129827. radius: number;
  129828. /**
  129829. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  129830. * Must not be equal to fallOff and superior to fallOff.
  129831. * Default value is 0.0075
  129832. */
  129833. area: number;
  129834. /**
  129835. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  129836. * Must not be equal to area and inferior to area.
  129837. * Default value is 0.000001
  129838. */
  129839. fallOff: number;
  129840. /**
  129841. * The base color of the SSAO post-process
  129842. * The final result is "base + ssao" between [0, 1]
  129843. */
  129844. base: number;
  129845. private _scene;
  129846. private _depthTexture;
  129847. private _randomTexture;
  129848. private _originalColorPostProcess;
  129849. private _ssaoPostProcess;
  129850. private _blurHPostProcess;
  129851. private _blurVPostProcess;
  129852. private _ssaoCombinePostProcess;
  129853. private _firstUpdate;
  129854. /**
  129855. * Gets active scene
  129856. */
  129857. readonly scene: Scene;
  129858. /**
  129859. * @constructor
  129860. * @param name - The rendering pipeline name
  129861. * @param scene - The scene linked to this pipeline
  129862. * @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 }
  129863. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  129864. */
  129865. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  129866. /**
  129867. * Get the class name
  129868. * @returns "SSAORenderingPipeline"
  129869. */
  129870. getClassName(): string;
  129871. /**
  129872. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  129873. */
  129874. dispose(disableDepthRender?: boolean): void;
  129875. private _createBlurPostProcess;
  129876. /** @hidden */
  129877. _rebuild(): void;
  129878. private _createSSAOPostProcess;
  129879. private _createSSAOCombinePostProcess;
  129880. private _createRandomTexture;
  129881. }
  129882. }
  129883. declare module BABYLON {
  129884. /** @hidden */
  129885. export var standardPixelShader: {
  129886. name: string;
  129887. shader: string;
  129888. };
  129889. }
  129890. declare module BABYLON {
  129891. /**
  129892. * Standard rendering pipeline
  129893. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  129894. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  129895. */
  129896. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  129897. /**
  129898. * Public members
  129899. */
  129900. /**
  129901. * Post-process which contains the original scene color before the pipeline applies all the effects
  129902. */
  129903. originalPostProcess: Nullable<PostProcess>;
  129904. /**
  129905. * Post-process used to down scale an image x4
  129906. */
  129907. downSampleX4PostProcess: Nullable<PostProcess>;
  129908. /**
  129909. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  129910. */
  129911. brightPassPostProcess: Nullable<PostProcess>;
  129912. /**
  129913. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  129914. */
  129915. blurHPostProcesses: PostProcess[];
  129916. /**
  129917. * Post-process array storing all the vertical blur post-processes used by the pipeline
  129918. */
  129919. blurVPostProcesses: PostProcess[];
  129920. /**
  129921. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  129922. */
  129923. textureAdderPostProcess: Nullable<PostProcess>;
  129924. /**
  129925. * Post-process used to create volumetric lighting effect
  129926. */
  129927. volumetricLightPostProcess: Nullable<PostProcess>;
  129928. /**
  129929. * Post-process used to smooth the previous volumetric light post-process on the X axis
  129930. */
  129931. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  129932. /**
  129933. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  129934. */
  129935. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  129936. /**
  129937. * Post-process used to merge the volumetric light effect and the real scene color
  129938. */
  129939. volumetricLightMergePostProces: Nullable<PostProcess>;
  129940. /**
  129941. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  129942. */
  129943. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  129944. /**
  129945. * Base post-process used to calculate the average luminance of the final image for HDR
  129946. */
  129947. luminancePostProcess: Nullable<PostProcess>;
  129948. /**
  129949. * Post-processes used to create down sample post-processes in order to get
  129950. * the average luminance of the final image for HDR
  129951. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  129952. */
  129953. luminanceDownSamplePostProcesses: PostProcess[];
  129954. /**
  129955. * Post-process used to create a HDR effect (light adaptation)
  129956. */
  129957. hdrPostProcess: Nullable<PostProcess>;
  129958. /**
  129959. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  129960. */
  129961. textureAdderFinalPostProcess: Nullable<PostProcess>;
  129962. /**
  129963. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  129964. */
  129965. lensFlareFinalPostProcess: Nullable<PostProcess>;
  129966. /**
  129967. * Post-process used to merge the final HDR post-process and the real scene color
  129968. */
  129969. hdrFinalPostProcess: Nullable<PostProcess>;
  129970. /**
  129971. * Post-process used to create a lens flare effect
  129972. */
  129973. lensFlarePostProcess: Nullable<PostProcess>;
  129974. /**
  129975. * Post-process that merges the result of the lens flare post-process and the real scene color
  129976. */
  129977. lensFlareComposePostProcess: Nullable<PostProcess>;
  129978. /**
  129979. * Post-process used to create a motion blur effect
  129980. */
  129981. motionBlurPostProcess: Nullable<PostProcess>;
  129982. /**
  129983. * Post-process used to create a depth of field effect
  129984. */
  129985. depthOfFieldPostProcess: Nullable<PostProcess>;
  129986. /**
  129987. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  129988. */
  129989. fxaaPostProcess: Nullable<FxaaPostProcess>;
  129990. /**
  129991. * Represents the brightness threshold in order to configure the illuminated surfaces
  129992. */
  129993. brightThreshold: number;
  129994. /**
  129995. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  129996. */
  129997. blurWidth: number;
  129998. /**
  129999. * Sets if the blur for highlighted surfaces must be only horizontal
  130000. */
  130001. horizontalBlur: boolean;
  130002. /**
  130003. * Gets the overall exposure used by the pipeline
  130004. */
  130005. /**
  130006. * Sets the overall exposure used by the pipeline
  130007. */
  130008. exposure: number;
  130009. /**
  130010. * Texture used typically to simulate "dirty" on camera lens
  130011. */
  130012. lensTexture: Nullable<Texture>;
  130013. /**
  130014. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  130015. */
  130016. volumetricLightCoefficient: number;
  130017. /**
  130018. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  130019. */
  130020. volumetricLightPower: number;
  130021. /**
  130022. * Used the set the blur intensity to smooth the volumetric lights
  130023. */
  130024. volumetricLightBlurScale: number;
  130025. /**
  130026. * Light (spot or directional) used to generate the volumetric lights rays
  130027. * The source light must have a shadow generate so the pipeline can get its
  130028. * depth map
  130029. */
  130030. sourceLight: Nullable<SpotLight | DirectionalLight>;
  130031. /**
  130032. * For eye adaptation, represents the minimum luminance the eye can see
  130033. */
  130034. hdrMinimumLuminance: number;
  130035. /**
  130036. * For eye adaptation, represents the decrease luminance speed
  130037. */
  130038. hdrDecreaseRate: number;
  130039. /**
  130040. * For eye adaptation, represents the increase luminance speed
  130041. */
  130042. hdrIncreaseRate: number;
  130043. /**
  130044. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  130045. */
  130046. /**
  130047. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  130048. */
  130049. hdrAutoExposure: boolean;
  130050. /**
  130051. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  130052. */
  130053. lensColorTexture: Nullable<Texture>;
  130054. /**
  130055. * The overall strengh for the lens flare effect
  130056. */
  130057. lensFlareStrength: number;
  130058. /**
  130059. * Dispersion coefficient for lens flare ghosts
  130060. */
  130061. lensFlareGhostDispersal: number;
  130062. /**
  130063. * Main lens flare halo width
  130064. */
  130065. lensFlareHaloWidth: number;
  130066. /**
  130067. * Based on the lens distortion effect, defines how much the lens flare result
  130068. * is distorted
  130069. */
  130070. lensFlareDistortionStrength: number;
  130071. /**
  130072. * Configures the blur intensity used for for lens flare (halo)
  130073. */
  130074. lensFlareBlurWidth: number;
  130075. /**
  130076. * Lens star texture must be used to simulate rays on the flares and is available
  130077. * in the documentation
  130078. */
  130079. lensStarTexture: Nullable<Texture>;
  130080. /**
  130081. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  130082. * flare effect by taking account of the dirt texture
  130083. */
  130084. lensFlareDirtTexture: Nullable<Texture>;
  130085. /**
  130086. * Represents the focal length for the depth of field effect
  130087. */
  130088. depthOfFieldDistance: number;
  130089. /**
  130090. * Represents the blur intensity for the blurred part of the depth of field effect
  130091. */
  130092. depthOfFieldBlurWidth: number;
  130093. /**
  130094. * Gets how much the image is blurred by the movement while using the motion blur post-process
  130095. */
  130096. /**
  130097. * Sets how much the image is blurred by the movement while using the motion blur post-process
  130098. */
  130099. motionStrength: number;
  130100. /**
  130101. * Gets wether or not the motion blur post-process is object based or screen based.
  130102. */
  130103. /**
  130104. * Sets wether or not the motion blur post-process should be object based or screen based
  130105. */
  130106. objectBasedMotionBlur: boolean;
  130107. /**
  130108. * List of animations for the pipeline (IAnimatable implementation)
  130109. */
  130110. animations: Animation[];
  130111. /**
  130112. * Private members
  130113. */
  130114. private _scene;
  130115. private _currentDepthOfFieldSource;
  130116. private _basePostProcess;
  130117. private _fixedExposure;
  130118. private _currentExposure;
  130119. private _hdrAutoExposure;
  130120. private _hdrCurrentLuminance;
  130121. private _motionStrength;
  130122. private _isObjectBasedMotionBlur;
  130123. private _floatTextureType;
  130124. private _camerasToBeAttached;
  130125. private _ratio;
  130126. private _bloomEnabled;
  130127. private _depthOfFieldEnabled;
  130128. private _vlsEnabled;
  130129. private _lensFlareEnabled;
  130130. private _hdrEnabled;
  130131. private _motionBlurEnabled;
  130132. private _fxaaEnabled;
  130133. private _motionBlurSamples;
  130134. private _volumetricLightStepsCount;
  130135. private _samples;
  130136. /**
  130137. * @ignore
  130138. * Specifies if the bloom pipeline is enabled
  130139. */
  130140. BloomEnabled: boolean;
  130141. /**
  130142. * @ignore
  130143. * Specifies if the depth of field pipeline is enabed
  130144. */
  130145. DepthOfFieldEnabled: boolean;
  130146. /**
  130147. * @ignore
  130148. * Specifies if the lens flare pipeline is enabed
  130149. */
  130150. LensFlareEnabled: boolean;
  130151. /**
  130152. * @ignore
  130153. * Specifies if the HDR pipeline is enabled
  130154. */
  130155. HDREnabled: boolean;
  130156. /**
  130157. * @ignore
  130158. * Specifies if the volumetric lights scattering effect is enabled
  130159. */
  130160. VLSEnabled: boolean;
  130161. /**
  130162. * @ignore
  130163. * Specifies if the motion blur effect is enabled
  130164. */
  130165. MotionBlurEnabled: boolean;
  130166. /**
  130167. * Specifies if anti-aliasing is enabled
  130168. */
  130169. fxaaEnabled: boolean;
  130170. /**
  130171. * Specifies the number of steps used to calculate the volumetric lights
  130172. * Typically in interval [50, 200]
  130173. */
  130174. volumetricLightStepsCount: number;
  130175. /**
  130176. * Specifies the number of samples used for the motion blur effect
  130177. * Typically in interval [16, 64]
  130178. */
  130179. motionBlurSamples: number;
  130180. /**
  130181. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  130182. */
  130183. samples: number;
  130184. /**
  130185. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  130186. * @constructor
  130187. * @param name The rendering pipeline name
  130188. * @param scene The scene linked to this pipeline
  130189. * @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)
  130190. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  130191. * @param cameras The array of cameras that the rendering pipeline will be attached to
  130192. */
  130193. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  130194. private _buildPipeline;
  130195. private _createDownSampleX4PostProcess;
  130196. private _createBrightPassPostProcess;
  130197. private _createBlurPostProcesses;
  130198. private _createTextureAdderPostProcess;
  130199. private _createVolumetricLightPostProcess;
  130200. private _createLuminancePostProcesses;
  130201. private _createHdrPostProcess;
  130202. private _createLensFlarePostProcess;
  130203. private _createDepthOfFieldPostProcess;
  130204. private _createMotionBlurPostProcess;
  130205. private _getDepthTexture;
  130206. private _disposePostProcesses;
  130207. /**
  130208. * Dispose of the pipeline and stop all post processes
  130209. */
  130210. dispose(): void;
  130211. /**
  130212. * Serialize the rendering pipeline (Used when exporting)
  130213. * @returns the serialized object
  130214. */
  130215. serialize(): any;
  130216. /**
  130217. * Parse the serialized pipeline
  130218. * @param source Source pipeline.
  130219. * @param scene The scene to load the pipeline to.
  130220. * @param rootUrl The URL of the serialized pipeline.
  130221. * @returns An instantiated pipeline from the serialized object.
  130222. */
  130223. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  130224. /**
  130225. * Luminance steps
  130226. */
  130227. static LuminanceSteps: number;
  130228. }
  130229. }
  130230. declare module BABYLON {
  130231. /** @hidden */
  130232. export var tonemapPixelShader: {
  130233. name: string;
  130234. shader: string;
  130235. };
  130236. }
  130237. declare module BABYLON {
  130238. /** Defines operator used for tonemapping */
  130239. export enum TonemappingOperator {
  130240. /** Hable */
  130241. Hable = 0,
  130242. /** Reinhard */
  130243. Reinhard = 1,
  130244. /** HejiDawson */
  130245. HejiDawson = 2,
  130246. /** Photographic */
  130247. Photographic = 3
  130248. }
  130249. /**
  130250. * Defines a post process to apply tone mapping
  130251. */
  130252. export class TonemapPostProcess extends PostProcess {
  130253. private _operator;
  130254. /** Defines the required exposure adjustement */
  130255. exposureAdjustment: number;
  130256. /**
  130257. * Creates a new TonemapPostProcess
  130258. * @param name defines the name of the postprocess
  130259. * @param _operator defines the operator to use
  130260. * @param exposureAdjustment defines the required exposure adjustement
  130261. * @param camera defines the camera to use (can be null)
  130262. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  130263. * @param engine defines the hosting engine (can be ignore if camera is set)
  130264. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  130265. */
  130266. constructor(name: string, _operator: TonemappingOperator,
  130267. /** Defines the required exposure adjustement */
  130268. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  130269. }
  130270. }
  130271. declare module BABYLON {
  130272. /** @hidden */
  130273. export var depthVertexShader: {
  130274. name: string;
  130275. shader: string;
  130276. };
  130277. }
  130278. declare module BABYLON {
  130279. /** @hidden */
  130280. export var volumetricLightScatteringPixelShader: {
  130281. name: string;
  130282. shader: string;
  130283. };
  130284. }
  130285. declare module BABYLON {
  130286. /** @hidden */
  130287. export var volumetricLightScatteringPassVertexShader: {
  130288. name: string;
  130289. shader: string;
  130290. };
  130291. }
  130292. declare module BABYLON {
  130293. /** @hidden */
  130294. export var volumetricLightScatteringPassPixelShader: {
  130295. name: string;
  130296. shader: string;
  130297. };
  130298. }
  130299. declare module BABYLON {
  130300. /**
  130301. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  130302. */
  130303. export class VolumetricLightScatteringPostProcess extends PostProcess {
  130304. private _volumetricLightScatteringPass;
  130305. private _volumetricLightScatteringRTT;
  130306. private _viewPort;
  130307. private _screenCoordinates;
  130308. private _cachedDefines;
  130309. /**
  130310. * If not undefined, the mesh position is computed from the attached node position
  130311. */
  130312. attachedNode: {
  130313. position: Vector3;
  130314. };
  130315. /**
  130316. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  130317. */
  130318. customMeshPosition: Vector3;
  130319. /**
  130320. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  130321. */
  130322. useCustomMeshPosition: boolean;
  130323. /**
  130324. * If the post-process should inverse the light scattering direction
  130325. */
  130326. invert: boolean;
  130327. /**
  130328. * The internal mesh used by the post-process
  130329. */
  130330. mesh: Mesh;
  130331. /**
  130332. * @hidden
  130333. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  130334. */
  130335. useDiffuseColor: boolean;
  130336. /**
  130337. * Array containing the excluded meshes not rendered in the internal pass
  130338. */
  130339. excludedMeshes: AbstractMesh[];
  130340. /**
  130341. * Controls the overall intensity of the post-process
  130342. */
  130343. exposure: number;
  130344. /**
  130345. * Dissipates each sample's contribution in range [0, 1]
  130346. */
  130347. decay: number;
  130348. /**
  130349. * Controls the overall intensity of each sample
  130350. */
  130351. weight: number;
  130352. /**
  130353. * Controls the density of each sample
  130354. */
  130355. density: number;
  130356. /**
  130357. * @constructor
  130358. * @param name The post-process name
  130359. * @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)
  130360. * @param camera The camera that the post-process will be attached to
  130361. * @param mesh The mesh used to create the light scattering
  130362. * @param samples The post-process quality, default 100
  130363. * @param samplingModeThe post-process filtering mode
  130364. * @param engine The babylon engine
  130365. * @param reusable If the post-process is reusable
  130366. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  130367. */
  130368. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  130369. /**
  130370. * Returns the string "VolumetricLightScatteringPostProcess"
  130371. * @returns "VolumetricLightScatteringPostProcess"
  130372. */
  130373. getClassName(): string;
  130374. private _isReady;
  130375. /**
  130376. * Sets the new light position for light scattering effect
  130377. * @param position The new custom light position
  130378. */
  130379. setCustomMeshPosition(position: Vector3): void;
  130380. /**
  130381. * Returns the light position for light scattering effect
  130382. * @return Vector3 The custom light position
  130383. */
  130384. getCustomMeshPosition(): Vector3;
  130385. /**
  130386. * Disposes the internal assets and detaches the post-process from the camera
  130387. */
  130388. dispose(camera: Camera): void;
  130389. /**
  130390. * Returns the render target texture used by the post-process
  130391. * @return the render target texture used by the post-process
  130392. */
  130393. getPass(): RenderTargetTexture;
  130394. private _meshExcluded;
  130395. private _createPass;
  130396. private _updateMeshScreenCoordinates;
  130397. /**
  130398. * Creates a default mesh for the Volumeric Light Scattering post-process
  130399. * @param name The mesh name
  130400. * @param scene The scene where to create the mesh
  130401. * @return the default mesh
  130402. */
  130403. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  130404. }
  130405. }
  130406. declare module BABYLON {
  130407. interface Scene {
  130408. /** @hidden (Backing field) */
  130409. _boundingBoxRenderer: BoundingBoxRenderer;
  130410. /** @hidden (Backing field) */
  130411. _forceShowBoundingBoxes: boolean;
  130412. /**
  130413. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  130414. */
  130415. forceShowBoundingBoxes: boolean;
  130416. /**
  130417. * Gets the bounding box renderer associated with the scene
  130418. * @returns a BoundingBoxRenderer
  130419. */
  130420. getBoundingBoxRenderer(): BoundingBoxRenderer;
  130421. }
  130422. interface AbstractMesh {
  130423. /** @hidden (Backing field) */
  130424. _showBoundingBox: boolean;
  130425. /**
  130426. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  130427. */
  130428. showBoundingBox: boolean;
  130429. }
  130430. /**
  130431. * Component responsible of rendering the bounding box of the meshes in a scene.
  130432. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  130433. */
  130434. export class BoundingBoxRenderer implements ISceneComponent {
  130435. /**
  130436. * The component name helpfull to identify the component in the list of scene components.
  130437. */
  130438. readonly name: string;
  130439. /**
  130440. * The scene the component belongs to.
  130441. */
  130442. scene: Scene;
  130443. /**
  130444. * Color of the bounding box lines placed in front of an object
  130445. */
  130446. frontColor: Color3;
  130447. /**
  130448. * Color of the bounding box lines placed behind an object
  130449. */
  130450. backColor: Color3;
  130451. /**
  130452. * Defines if the renderer should show the back lines or not
  130453. */
  130454. showBackLines: boolean;
  130455. /**
  130456. * @hidden
  130457. */
  130458. renderList: SmartArray<BoundingBox>;
  130459. private _colorShader;
  130460. private _vertexBuffers;
  130461. private _indexBuffer;
  130462. private _fillIndexBuffer;
  130463. private _fillIndexData;
  130464. /**
  130465. * Instantiates a new bounding box renderer in a scene.
  130466. * @param scene the scene the renderer renders in
  130467. */
  130468. constructor(scene: Scene);
  130469. /**
  130470. * Registers the component in a given scene
  130471. */
  130472. register(): void;
  130473. private _evaluateSubMesh;
  130474. private _activeMesh;
  130475. private _prepareRessources;
  130476. private _createIndexBuffer;
  130477. /**
  130478. * Rebuilds the elements related to this component in case of
  130479. * context lost for instance.
  130480. */
  130481. rebuild(): void;
  130482. /**
  130483. * @hidden
  130484. */
  130485. reset(): void;
  130486. /**
  130487. * Render the bounding boxes of a specific rendering group
  130488. * @param renderingGroupId defines the rendering group to render
  130489. */
  130490. render(renderingGroupId: number): void;
  130491. /**
  130492. * In case of occlusion queries, we can render the occlusion bounding box through this method
  130493. * @param mesh Define the mesh to render the occlusion bounding box for
  130494. */
  130495. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  130496. /**
  130497. * Dispose and release the resources attached to this renderer.
  130498. */
  130499. dispose(): void;
  130500. }
  130501. }
  130502. declare module BABYLON {
  130503. /** @hidden */
  130504. export var depthPixelShader: {
  130505. name: string;
  130506. shader: string;
  130507. };
  130508. }
  130509. declare module BABYLON {
  130510. /**
  130511. * This represents a depth renderer in Babylon.
  130512. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  130513. */
  130514. export class DepthRenderer {
  130515. private _scene;
  130516. private _depthMap;
  130517. private _effect;
  130518. private readonly _storeNonLinearDepth;
  130519. private readonly _clearColor;
  130520. /** Get if the depth renderer is using packed depth or not */
  130521. readonly isPacked: boolean;
  130522. private _cachedDefines;
  130523. private _camera;
  130524. /**
  130525. * Specifiess that the depth renderer will only be used within
  130526. * the camera it is created for.
  130527. * This can help forcing its rendering during the camera processing.
  130528. */
  130529. useOnlyInActiveCamera: boolean;
  130530. /** @hidden */
  130531. static _SceneComponentInitialization: (scene: Scene) => void;
  130532. /**
  130533. * Instantiates a depth renderer
  130534. * @param scene The scene the renderer belongs to
  130535. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  130536. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  130537. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130538. */
  130539. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  130540. /**
  130541. * Creates the depth rendering effect and checks if the effect is ready.
  130542. * @param subMesh The submesh to be used to render the depth map of
  130543. * @param useInstances If multiple world instances should be used
  130544. * @returns if the depth renderer is ready to render the depth map
  130545. */
  130546. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130547. /**
  130548. * Gets the texture which the depth map will be written to.
  130549. * @returns The depth map texture
  130550. */
  130551. getDepthMap(): RenderTargetTexture;
  130552. /**
  130553. * Disposes of the depth renderer.
  130554. */
  130555. dispose(): void;
  130556. }
  130557. }
  130558. declare module BABYLON {
  130559. interface Scene {
  130560. /** @hidden (Backing field) */
  130561. _depthRenderer: {
  130562. [id: string]: DepthRenderer;
  130563. };
  130564. /**
  130565. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  130566. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  130567. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130568. * @returns the created depth renderer
  130569. */
  130570. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  130571. /**
  130572. * Disables a depth renderer for a given camera
  130573. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  130574. */
  130575. disableDepthRenderer(camera?: Nullable<Camera>): void;
  130576. }
  130577. /**
  130578. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  130579. * in several rendering techniques.
  130580. */
  130581. export class DepthRendererSceneComponent implements ISceneComponent {
  130582. /**
  130583. * The component name helpfull to identify the component in the list of scene components.
  130584. */
  130585. readonly name: string;
  130586. /**
  130587. * The scene the component belongs to.
  130588. */
  130589. scene: Scene;
  130590. /**
  130591. * Creates a new instance of the component for the given scene
  130592. * @param scene Defines the scene to register the component in
  130593. */
  130594. constructor(scene: Scene);
  130595. /**
  130596. * Registers the component in a given scene
  130597. */
  130598. register(): void;
  130599. /**
  130600. * Rebuilds the elements related to this component in case of
  130601. * context lost for instance.
  130602. */
  130603. rebuild(): void;
  130604. /**
  130605. * Disposes the component and the associated ressources
  130606. */
  130607. dispose(): void;
  130608. private _gatherRenderTargets;
  130609. private _gatherActiveCameraRenderTargets;
  130610. }
  130611. }
  130612. declare module BABYLON {
  130613. /** @hidden */
  130614. export var outlinePixelShader: {
  130615. name: string;
  130616. shader: string;
  130617. };
  130618. }
  130619. declare module BABYLON {
  130620. /** @hidden */
  130621. export var outlineVertexShader: {
  130622. name: string;
  130623. shader: string;
  130624. };
  130625. }
  130626. declare module BABYLON {
  130627. interface Scene {
  130628. /** @hidden */
  130629. _outlineRenderer: OutlineRenderer;
  130630. /**
  130631. * Gets the outline renderer associated with the scene
  130632. * @returns a OutlineRenderer
  130633. */
  130634. getOutlineRenderer(): OutlineRenderer;
  130635. }
  130636. interface AbstractMesh {
  130637. /** @hidden (Backing field) */
  130638. _renderOutline: boolean;
  130639. /**
  130640. * Gets or sets a boolean indicating if the outline must be rendered as well
  130641. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  130642. */
  130643. renderOutline: boolean;
  130644. /** @hidden (Backing field) */
  130645. _renderOverlay: boolean;
  130646. /**
  130647. * Gets or sets a boolean indicating if the overlay must be rendered as well
  130648. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  130649. */
  130650. renderOverlay: boolean;
  130651. }
  130652. /**
  130653. * This class is responsible to draw bothe outline/overlay of meshes.
  130654. * It should not be used directly but through the available method on mesh.
  130655. */
  130656. export class OutlineRenderer implements ISceneComponent {
  130657. /**
  130658. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  130659. */
  130660. private static _StencilReference;
  130661. /**
  130662. * The name of the component. Each component must have a unique name.
  130663. */
  130664. name: string;
  130665. /**
  130666. * The scene the component belongs to.
  130667. */
  130668. scene: Scene;
  130669. /**
  130670. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  130671. */
  130672. zOffset: number;
  130673. private _engine;
  130674. private _effect;
  130675. private _cachedDefines;
  130676. private _savedDepthWrite;
  130677. /**
  130678. * Instantiates a new outline renderer. (There could be only one per scene).
  130679. * @param scene Defines the scene it belongs to
  130680. */
  130681. constructor(scene: Scene);
  130682. /**
  130683. * Register the component to one instance of a scene.
  130684. */
  130685. register(): void;
  130686. /**
  130687. * Rebuilds the elements related to this component in case of
  130688. * context lost for instance.
  130689. */
  130690. rebuild(): void;
  130691. /**
  130692. * Disposes the component and the associated ressources.
  130693. */
  130694. dispose(): void;
  130695. /**
  130696. * Renders the outline in the canvas.
  130697. * @param subMesh Defines the sumesh to render
  130698. * @param batch Defines the batch of meshes in case of instances
  130699. * @param useOverlay Defines if the rendering is for the overlay or the outline
  130700. */
  130701. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  130702. /**
  130703. * Returns whether or not the outline renderer is ready for a given submesh.
  130704. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  130705. * @param subMesh Defines the submesh to check readyness for
  130706. * @param useInstances Defines wheter wee are trying to render instances or not
  130707. * @returns true if ready otherwise false
  130708. */
  130709. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130710. private _beforeRenderingMesh;
  130711. private _afterRenderingMesh;
  130712. }
  130713. }
  130714. declare module BABYLON {
  130715. /**
  130716. * Class used to manage multiple sprites of different sizes on the same spritesheet
  130717. * @see http://doc.babylonjs.com/babylon101/sprites
  130718. */
  130719. export class SpritePackedManager extends SpriteManager {
  130720. /** defines the packed manager's name */
  130721. name: string;
  130722. /**
  130723. * Creates a new sprite manager from a packed sprite sheet
  130724. * @param name defines the manager's name
  130725. * @param imgUrl defines the sprite sheet url
  130726. * @param capacity defines the maximum allowed number of sprites
  130727. * @param scene defines the hosting scene
  130728. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  130729. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  130730. * @param samplingMode defines the smapling mode to use with spritesheet
  130731. * @param fromPacked set to true; do not alter
  130732. */
  130733. constructor(
  130734. /** defines the packed manager's name */
  130735. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  130736. }
  130737. }
  130738. declare module BABYLON {
  130739. /**
  130740. * Defines the list of states available for a task inside a AssetsManager
  130741. */
  130742. export enum AssetTaskState {
  130743. /**
  130744. * Initialization
  130745. */
  130746. INIT = 0,
  130747. /**
  130748. * Running
  130749. */
  130750. RUNNING = 1,
  130751. /**
  130752. * Done
  130753. */
  130754. DONE = 2,
  130755. /**
  130756. * Error
  130757. */
  130758. ERROR = 3
  130759. }
  130760. /**
  130761. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  130762. */
  130763. export abstract class AbstractAssetTask {
  130764. /**
  130765. * Task name
  130766. */ name: string;
  130767. /**
  130768. * Callback called when the task is successful
  130769. */
  130770. onSuccess: (task: any) => void;
  130771. /**
  130772. * Callback called when the task is not successful
  130773. */
  130774. onError: (task: any, message?: string, exception?: any) => void;
  130775. /**
  130776. * Creates a new AssetsManager
  130777. * @param name defines the name of the task
  130778. */
  130779. constructor(
  130780. /**
  130781. * Task name
  130782. */ name: string);
  130783. private _isCompleted;
  130784. private _taskState;
  130785. private _errorObject;
  130786. /**
  130787. * Get if the task is completed
  130788. */
  130789. readonly isCompleted: boolean;
  130790. /**
  130791. * Gets the current state of the task
  130792. */
  130793. readonly taskState: AssetTaskState;
  130794. /**
  130795. * Gets the current error object (if task is in error)
  130796. */
  130797. readonly errorObject: {
  130798. message?: string;
  130799. exception?: any;
  130800. };
  130801. /**
  130802. * Internal only
  130803. * @hidden
  130804. */
  130805. _setErrorObject(message?: string, exception?: any): void;
  130806. /**
  130807. * Execute the current task
  130808. * @param scene defines the scene where you want your assets to be loaded
  130809. * @param onSuccess is a callback called when the task is successfully executed
  130810. * @param onError is a callback called if an error occurs
  130811. */
  130812. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130813. /**
  130814. * Execute the current task
  130815. * @param scene defines the scene where you want your assets to be loaded
  130816. * @param onSuccess is a callback called when the task is successfully executed
  130817. * @param onError is a callback called if an error occurs
  130818. */
  130819. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130820. /**
  130821. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  130822. * This can be used with failed tasks that have the reason for failure fixed.
  130823. */
  130824. reset(): void;
  130825. private onErrorCallback;
  130826. private onDoneCallback;
  130827. }
  130828. /**
  130829. * Define the interface used by progress events raised during assets loading
  130830. */
  130831. export interface IAssetsProgressEvent {
  130832. /**
  130833. * Defines the number of remaining tasks to process
  130834. */
  130835. remainingCount: number;
  130836. /**
  130837. * Defines the total number of tasks
  130838. */
  130839. totalCount: number;
  130840. /**
  130841. * Defines the task that was just processed
  130842. */
  130843. task: AbstractAssetTask;
  130844. }
  130845. /**
  130846. * Class used to share progress information about assets loading
  130847. */
  130848. export class AssetsProgressEvent implements IAssetsProgressEvent {
  130849. /**
  130850. * Defines the number of remaining tasks to process
  130851. */
  130852. remainingCount: number;
  130853. /**
  130854. * Defines the total number of tasks
  130855. */
  130856. totalCount: number;
  130857. /**
  130858. * Defines the task that was just processed
  130859. */
  130860. task: AbstractAssetTask;
  130861. /**
  130862. * Creates a AssetsProgressEvent
  130863. * @param remainingCount defines the number of remaining tasks to process
  130864. * @param totalCount defines the total number of tasks
  130865. * @param task defines the task that was just processed
  130866. */
  130867. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  130868. }
  130869. /**
  130870. * Define a task used by AssetsManager to load meshes
  130871. */
  130872. export class MeshAssetTask extends AbstractAssetTask {
  130873. /**
  130874. * Defines the name of the task
  130875. */
  130876. name: string;
  130877. /**
  130878. * Defines the list of mesh's names you want to load
  130879. */
  130880. meshesNames: any;
  130881. /**
  130882. * Defines the root url to use as a base to load your meshes and associated resources
  130883. */
  130884. rootUrl: string;
  130885. /**
  130886. * Defines the filename of the scene to load from
  130887. */
  130888. sceneFilename: string;
  130889. /**
  130890. * Gets the list of loaded meshes
  130891. */
  130892. loadedMeshes: Array<AbstractMesh>;
  130893. /**
  130894. * Gets the list of loaded particle systems
  130895. */
  130896. loadedParticleSystems: Array<IParticleSystem>;
  130897. /**
  130898. * Gets the list of loaded skeletons
  130899. */
  130900. loadedSkeletons: Array<Skeleton>;
  130901. /**
  130902. * Gets the list of loaded animation groups
  130903. */
  130904. loadedAnimationGroups: Array<AnimationGroup>;
  130905. /**
  130906. * Callback called when the task is successful
  130907. */
  130908. onSuccess: (task: MeshAssetTask) => void;
  130909. /**
  130910. * Callback called when the task is successful
  130911. */
  130912. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  130913. /**
  130914. * Creates a new MeshAssetTask
  130915. * @param name defines the name of the task
  130916. * @param meshesNames defines the list of mesh's names you want to load
  130917. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  130918. * @param sceneFilename defines the filename of the scene to load from
  130919. */
  130920. constructor(
  130921. /**
  130922. * Defines the name of the task
  130923. */
  130924. name: string,
  130925. /**
  130926. * Defines the list of mesh's names you want to load
  130927. */
  130928. meshesNames: any,
  130929. /**
  130930. * Defines the root url to use as a base to load your meshes and associated resources
  130931. */
  130932. rootUrl: string,
  130933. /**
  130934. * Defines the filename of the scene to load from
  130935. */
  130936. sceneFilename: string);
  130937. /**
  130938. * Execute the current task
  130939. * @param scene defines the scene where you want your assets to be loaded
  130940. * @param onSuccess is a callback called when the task is successfully executed
  130941. * @param onError is a callback called if an error occurs
  130942. */
  130943. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130944. }
  130945. /**
  130946. * Define a task used by AssetsManager to load text content
  130947. */
  130948. export class TextFileAssetTask extends AbstractAssetTask {
  130949. /**
  130950. * Defines the name of the task
  130951. */
  130952. name: string;
  130953. /**
  130954. * Defines the location of the file to load
  130955. */
  130956. url: string;
  130957. /**
  130958. * Gets the loaded text string
  130959. */
  130960. text: string;
  130961. /**
  130962. * Callback called when the task is successful
  130963. */
  130964. onSuccess: (task: TextFileAssetTask) => void;
  130965. /**
  130966. * Callback called when the task is successful
  130967. */
  130968. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  130969. /**
  130970. * Creates a new TextFileAssetTask object
  130971. * @param name defines the name of the task
  130972. * @param url defines the location of the file to load
  130973. */
  130974. constructor(
  130975. /**
  130976. * Defines the name of the task
  130977. */
  130978. name: string,
  130979. /**
  130980. * Defines the location of the file to load
  130981. */
  130982. url: string);
  130983. /**
  130984. * Execute the current task
  130985. * @param scene defines the scene where you want your assets to be loaded
  130986. * @param onSuccess is a callback called when the task is successfully executed
  130987. * @param onError is a callback called if an error occurs
  130988. */
  130989. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130990. }
  130991. /**
  130992. * Define a task used by AssetsManager to load binary data
  130993. */
  130994. export class BinaryFileAssetTask extends AbstractAssetTask {
  130995. /**
  130996. * Defines the name of the task
  130997. */
  130998. name: string;
  130999. /**
  131000. * Defines the location of the file to load
  131001. */
  131002. url: string;
  131003. /**
  131004. * Gets the lodaded data (as an array buffer)
  131005. */
  131006. data: ArrayBuffer;
  131007. /**
  131008. * Callback called when the task is successful
  131009. */
  131010. onSuccess: (task: BinaryFileAssetTask) => void;
  131011. /**
  131012. * Callback called when the task is successful
  131013. */
  131014. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  131015. /**
  131016. * Creates a new BinaryFileAssetTask object
  131017. * @param name defines the name of the new task
  131018. * @param url defines the location of the file to load
  131019. */
  131020. constructor(
  131021. /**
  131022. * Defines the name of the task
  131023. */
  131024. name: string,
  131025. /**
  131026. * Defines the location of the file to load
  131027. */
  131028. url: string);
  131029. /**
  131030. * Execute the current task
  131031. * @param scene defines the scene where you want your assets to be loaded
  131032. * @param onSuccess is a callback called when the task is successfully executed
  131033. * @param onError is a callback called if an error occurs
  131034. */
  131035. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131036. }
  131037. /**
  131038. * Define a task used by AssetsManager to load images
  131039. */
  131040. export class ImageAssetTask extends AbstractAssetTask {
  131041. /**
  131042. * Defines the name of the task
  131043. */
  131044. name: string;
  131045. /**
  131046. * Defines the location of the image to load
  131047. */
  131048. url: string;
  131049. /**
  131050. * Gets the loaded images
  131051. */
  131052. image: HTMLImageElement;
  131053. /**
  131054. * Callback called when the task is successful
  131055. */
  131056. onSuccess: (task: ImageAssetTask) => void;
  131057. /**
  131058. * Callback called when the task is successful
  131059. */
  131060. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  131061. /**
  131062. * Creates a new ImageAssetTask
  131063. * @param name defines the name of the task
  131064. * @param url defines the location of the image to load
  131065. */
  131066. constructor(
  131067. /**
  131068. * Defines the name of the task
  131069. */
  131070. name: string,
  131071. /**
  131072. * Defines the location of the image to load
  131073. */
  131074. url: string);
  131075. /**
  131076. * Execute the current task
  131077. * @param scene defines the scene where you want your assets to be loaded
  131078. * @param onSuccess is a callback called when the task is successfully executed
  131079. * @param onError is a callback called if an error occurs
  131080. */
  131081. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131082. }
  131083. /**
  131084. * Defines the interface used by texture loading tasks
  131085. */
  131086. export interface ITextureAssetTask<TEX extends BaseTexture> {
  131087. /**
  131088. * Gets the loaded texture
  131089. */
  131090. texture: TEX;
  131091. }
  131092. /**
  131093. * Define a task used by AssetsManager to load 2D textures
  131094. */
  131095. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  131096. /**
  131097. * Defines the name of the task
  131098. */
  131099. name: string;
  131100. /**
  131101. * Defines the location of the file to load
  131102. */
  131103. url: string;
  131104. /**
  131105. * Defines if mipmap should not be generated (default is false)
  131106. */
  131107. noMipmap?: boolean | undefined;
  131108. /**
  131109. * Defines if texture must be inverted on Y axis (default is false)
  131110. */
  131111. invertY?: boolean | undefined;
  131112. /**
  131113. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131114. */
  131115. samplingMode: number;
  131116. /**
  131117. * Gets the loaded texture
  131118. */
  131119. texture: Texture;
  131120. /**
  131121. * Callback called when the task is successful
  131122. */
  131123. onSuccess: (task: TextureAssetTask) => void;
  131124. /**
  131125. * Callback called when the task is successful
  131126. */
  131127. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  131128. /**
  131129. * Creates a new TextureAssetTask object
  131130. * @param name defines the name of the task
  131131. * @param url defines the location of the file to load
  131132. * @param noMipmap defines if mipmap should not be generated (default is false)
  131133. * @param invertY defines if texture must be inverted on Y axis (default is false)
  131134. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131135. */
  131136. constructor(
  131137. /**
  131138. * Defines the name of the task
  131139. */
  131140. name: string,
  131141. /**
  131142. * Defines the location of the file to load
  131143. */
  131144. url: string,
  131145. /**
  131146. * Defines if mipmap should not be generated (default is false)
  131147. */
  131148. noMipmap?: boolean | undefined,
  131149. /**
  131150. * Defines if texture must be inverted on Y axis (default is false)
  131151. */
  131152. invertY?: boolean | undefined,
  131153. /**
  131154. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131155. */
  131156. samplingMode?: number);
  131157. /**
  131158. * Execute the current task
  131159. * @param scene defines the scene where you want your assets to be loaded
  131160. * @param onSuccess is a callback called when the task is successfully executed
  131161. * @param onError is a callback called if an error occurs
  131162. */
  131163. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131164. }
  131165. /**
  131166. * Define a task used by AssetsManager to load cube textures
  131167. */
  131168. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  131169. /**
  131170. * Defines the name of the task
  131171. */
  131172. name: string;
  131173. /**
  131174. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131175. */
  131176. url: string;
  131177. /**
  131178. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131179. */
  131180. extensions?: string[] | undefined;
  131181. /**
  131182. * Defines if mipmaps should not be generated (default is false)
  131183. */
  131184. noMipmap?: boolean | undefined;
  131185. /**
  131186. * Defines the explicit list of files (undefined by default)
  131187. */
  131188. files?: string[] | undefined;
  131189. /**
  131190. * Gets the loaded texture
  131191. */
  131192. texture: CubeTexture;
  131193. /**
  131194. * Callback called when the task is successful
  131195. */
  131196. onSuccess: (task: CubeTextureAssetTask) => void;
  131197. /**
  131198. * Callback called when the task is successful
  131199. */
  131200. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  131201. /**
  131202. * Creates a new CubeTextureAssetTask
  131203. * @param name defines the name of the task
  131204. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131205. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131206. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131207. * @param files defines the explicit list of files (undefined by default)
  131208. */
  131209. constructor(
  131210. /**
  131211. * Defines the name of the task
  131212. */
  131213. name: string,
  131214. /**
  131215. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131216. */
  131217. url: string,
  131218. /**
  131219. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131220. */
  131221. extensions?: string[] | undefined,
  131222. /**
  131223. * Defines if mipmaps should not be generated (default is false)
  131224. */
  131225. noMipmap?: boolean | undefined,
  131226. /**
  131227. * Defines the explicit list of files (undefined by default)
  131228. */
  131229. files?: string[] | undefined);
  131230. /**
  131231. * Execute the current task
  131232. * @param scene defines the scene where you want your assets to be loaded
  131233. * @param onSuccess is a callback called when the task is successfully executed
  131234. * @param onError is a callback called if an error occurs
  131235. */
  131236. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131237. }
  131238. /**
  131239. * Define a task used by AssetsManager to load HDR cube textures
  131240. */
  131241. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  131242. /**
  131243. * Defines the name of the task
  131244. */
  131245. name: string;
  131246. /**
  131247. * Defines the location of the file to load
  131248. */
  131249. url: string;
  131250. /**
  131251. * Defines the desired size (the more it increases the longer the generation will be)
  131252. */
  131253. size: number;
  131254. /**
  131255. * Defines if mipmaps should not be generated (default is false)
  131256. */
  131257. noMipmap: boolean;
  131258. /**
  131259. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131260. */
  131261. generateHarmonics: boolean;
  131262. /**
  131263. * 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)
  131264. */
  131265. gammaSpace: boolean;
  131266. /**
  131267. * Internal Use Only
  131268. */
  131269. reserved: boolean;
  131270. /**
  131271. * Gets the loaded texture
  131272. */
  131273. texture: HDRCubeTexture;
  131274. /**
  131275. * Callback called when the task is successful
  131276. */
  131277. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  131278. /**
  131279. * Callback called when the task is successful
  131280. */
  131281. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  131282. /**
  131283. * Creates a new HDRCubeTextureAssetTask object
  131284. * @param name defines the name of the task
  131285. * @param url defines the location of the file to load
  131286. * @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.
  131287. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131288. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131289. * @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)
  131290. * @param reserved Internal use only
  131291. */
  131292. constructor(
  131293. /**
  131294. * Defines the name of the task
  131295. */
  131296. name: string,
  131297. /**
  131298. * Defines the location of the file to load
  131299. */
  131300. url: string,
  131301. /**
  131302. * Defines the desired size (the more it increases the longer the generation will be)
  131303. */
  131304. size: number,
  131305. /**
  131306. * Defines if mipmaps should not be generated (default is false)
  131307. */
  131308. noMipmap?: boolean,
  131309. /**
  131310. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131311. */
  131312. generateHarmonics?: boolean,
  131313. /**
  131314. * 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)
  131315. */
  131316. gammaSpace?: boolean,
  131317. /**
  131318. * Internal Use Only
  131319. */
  131320. reserved?: boolean);
  131321. /**
  131322. * Execute the current task
  131323. * @param scene defines the scene where you want your assets to be loaded
  131324. * @param onSuccess is a callback called when the task is successfully executed
  131325. * @param onError is a callback called if an error occurs
  131326. */
  131327. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131328. }
  131329. /**
  131330. * Define a task used by AssetsManager to load Equirectangular cube textures
  131331. */
  131332. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  131333. /**
  131334. * Defines the name of the task
  131335. */
  131336. name: string;
  131337. /**
  131338. * Defines the location of the file to load
  131339. */
  131340. url: string;
  131341. /**
  131342. * Defines the desired size (the more it increases the longer the generation will be)
  131343. */
  131344. size: number;
  131345. /**
  131346. * Defines if mipmaps should not be generated (default is false)
  131347. */
  131348. noMipmap: boolean;
  131349. /**
  131350. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  131351. * but the standard material would require them in Gamma space) (default is true)
  131352. */
  131353. gammaSpace: boolean;
  131354. /**
  131355. * Gets the loaded texture
  131356. */
  131357. texture: EquiRectangularCubeTexture;
  131358. /**
  131359. * Callback called when the task is successful
  131360. */
  131361. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  131362. /**
  131363. * Callback called when the task is successful
  131364. */
  131365. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  131366. /**
  131367. * Creates a new EquiRectangularCubeTextureAssetTask object
  131368. * @param name defines the name of the task
  131369. * @param url defines the location of the file to load
  131370. * @param size defines the desired size (the more it increases the longer the generation will be)
  131371. * If the size is omitted this implies you are using a preprocessed cubemap.
  131372. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131373. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  131374. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  131375. * (default is true)
  131376. */
  131377. constructor(
  131378. /**
  131379. * Defines the name of the task
  131380. */
  131381. name: string,
  131382. /**
  131383. * Defines the location of the file to load
  131384. */
  131385. url: string,
  131386. /**
  131387. * Defines the desired size (the more it increases the longer the generation will be)
  131388. */
  131389. size: number,
  131390. /**
  131391. * Defines if mipmaps should not be generated (default is false)
  131392. */
  131393. noMipmap?: boolean,
  131394. /**
  131395. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  131396. * but the standard material would require them in Gamma space) (default is true)
  131397. */
  131398. gammaSpace?: boolean);
  131399. /**
  131400. * Execute the current task
  131401. * @param scene defines the scene where you want your assets to be loaded
  131402. * @param onSuccess is a callback called when the task is successfully executed
  131403. * @param onError is a callback called if an error occurs
  131404. */
  131405. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131406. }
  131407. /**
  131408. * This class can be used to easily import assets into a scene
  131409. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  131410. */
  131411. export class AssetsManager {
  131412. private _scene;
  131413. private _isLoading;
  131414. protected _tasks: AbstractAssetTask[];
  131415. protected _waitingTasksCount: number;
  131416. protected _totalTasksCount: number;
  131417. /**
  131418. * Callback called when all tasks are processed
  131419. */
  131420. onFinish: (tasks: AbstractAssetTask[]) => void;
  131421. /**
  131422. * Callback called when a task is successful
  131423. */
  131424. onTaskSuccess: (task: AbstractAssetTask) => void;
  131425. /**
  131426. * Callback called when a task had an error
  131427. */
  131428. onTaskError: (task: AbstractAssetTask) => void;
  131429. /**
  131430. * Callback called when a task is done (whatever the result is)
  131431. */
  131432. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  131433. /**
  131434. * Observable called when all tasks are processed
  131435. */
  131436. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  131437. /**
  131438. * Observable called when a task had an error
  131439. */
  131440. onTaskErrorObservable: Observable<AbstractAssetTask>;
  131441. /**
  131442. * Observable called when all tasks were executed
  131443. */
  131444. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  131445. /**
  131446. * Observable called when a task is done (whatever the result is)
  131447. */
  131448. onProgressObservable: Observable<IAssetsProgressEvent>;
  131449. /**
  131450. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  131451. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  131452. */
  131453. useDefaultLoadingScreen: boolean;
  131454. /**
  131455. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  131456. * when all assets have been downloaded.
  131457. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  131458. */
  131459. autoHideLoadingUI: boolean;
  131460. /**
  131461. * Creates a new AssetsManager
  131462. * @param scene defines the scene to work on
  131463. */
  131464. constructor(scene: Scene);
  131465. /**
  131466. * Add a MeshAssetTask to the list of active tasks
  131467. * @param taskName defines the name of the new task
  131468. * @param meshesNames defines the name of meshes to load
  131469. * @param rootUrl defines the root url to use to locate files
  131470. * @param sceneFilename defines the filename of the scene file
  131471. * @returns a new MeshAssetTask object
  131472. */
  131473. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  131474. /**
  131475. * Add a TextFileAssetTask to the list of active tasks
  131476. * @param taskName defines the name of the new task
  131477. * @param url defines the url of the file to load
  131478. * @returns a new TextFileAssetTask object
  131479. */
  131480. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  131481. /**
  131482. * Add a BinaryFileAssetTask to the list of active tasks
  131483. * @param taskName defines the name of the new task
  131484. * @param url defines the url of the file to load
  131485. * @returns a new BinaryFileAssetTask object
  131486. */
  131487. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  131488. /**
  131489. * Add a ImageAssetTask to the list of active tasks
  131490. * @param taskName defines the name of the new task
  131491. * @param url defines the url of the file to load
  131492. * @returns a new ImageAssetTask object
  131493. */
  131494. addImageTask(taskName: string, url: string): ImageAssetTask;
  131495. /**
  131496. * Add a TextureAssetTask to the list of active tasks
  131497. * @param taskName defines the name of the new task
  131498. * @param url defines the url of the file to load
  131499. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131500. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  131501. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131502. * @returns a new TextureAssetTask object
  131503. */
  131504. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  131505. /**
  131506. * Add a CubeTextureAssetTask to the list of active tasks
  131507. * @param taskName defines the name of the new task
  131508. * @param url defines the url of the file to load
  131509. * @param extensions defines the extension to use to load the cube map (can be null)
  131510. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131511. * @param files defines the list of files to load (can be null)
  131512. * @returns a new CubeTextureAssetTask object
  131513. */
  131514. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  131515. /**
  131516. *
  131517. * Add a HDRCubeTextureAssetTask to the list of active tasks
  131518. * @param taskName defines the name of the new task
  131519. * @param url defines the url of the file to load
  131520. * @param size defines the size you want for the cubemap (can be null)
  131521. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131522. * @param generateHarmonics defines if you want to automatically generate (true by default)
  131523. * @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)
  131524. * @param reserved Internal use only
  131525. * @returns a new HDRCubeTextureAssetTask object
  131526. */
  131527. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  131528. /**
  131529. *
  131530. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  131531. * @param taskName defines the name of the new task
  131532. * @param url defines the url of the file to load
  131533. * @param size defines the size you want for the cubemap (can be null)
  131534. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131535. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  131536. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  131537. * @returns a new EquiRectangularCubeTextureAssetTask object
  131538. */
  131539. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  131540. /**
  131541. * Remove a task from the assets manager.
  131542. * @param task the task to remove
  131543. */
  131544. removeTask(task: AbstractAssetTask): void;
  131545. private _decreaseWaitingTasksCount;
  131546. private _runTask;
  131547. /**
  131548. * Reset the AssetsManager and remove all tasks
  131549. * @return the current instance of the AssetsManager
  131550. */
  131551. reset(): AssetsManager;
  131552. /**
  131553. * Start the loading process
  131554. * @return the current instance of the AssetsManager
  131555. */
  131556. load(): AssetsManager;
  131557. /**
  131558. * Start the loading process as an async operation
  131559. * @return a promise returning the list of failed tasks
  131560. */
  131561. loadAsync(): Promise<void>;
  131562. }
  131563. }
  131564. declare module BABYLON {
  131565. /**
  131566. * Wrapper class for promise with external resolve and reject.
  131567. */
  131568. export class Deferred<T> {
  131569. /**
  131570. * The promise associated with this deferred object.
  131571. */
  131572. readonly promise: Promise<T>;
  131573. private _resolve;
  131574. private _reject;
  131575. /**
  131576. * The resolve method of the promise associated with this deferred object.
  131577. */
  131578. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  131579. /**
  131580. * The reject method of the promise associated with this deferred object.
  131581. */
  131582. readonly reject: (reason?: any) => void;
  131583. /**
  131584. * Constructor for this deferred object.
  131585. */
  131586. constructor();
  131587. }
  131588. }
  131589. declare module BABYLON {
  131590. /**
  131591. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  131592. */
  131593. export class MeshExploder {
  131594. private _centerMesh;
  131595. private _meshes;
  131596. private _meshesOrigins;
  131597. private _toCenterVectors;
  131598. private _scaledDirection;
  131599. private _newPosition;
  131600. private _centerPosition;
  131601. /**
  131602. * Explodes meshes from a center mesh.
  131603. * @param meshes The meshes to explode.
  131604. * @param centerMesh The mesh to be center of explosion.
  131605. */
  131606. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  131607. private _setCenterMesh;
  131608. /**
  131609. * Get class name
  131610. * @returns "MeshExploder"
  131611. */
  131612. getClassName(): string;
  131613. /**
  131614. * "Exploded meshes"
  131615. * @returns Array of meshes with the centerMesh at index 0.
  131616. */
  131617. getMeshes(): Array<Mesh>;
  131618. /**
  131619. * Explodes meshes giving a specific direction
  131620. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  131621. */
  131622. explode(direction?: number): void;
  131623. }
  131624. }
  131625. declare module BABYLON {
  131626. /**
  131627. * Class used to help managing file picking and drag'n'drop
  131628. */
  131629. export class FilesInput {
  131630. /**
  131631. * List of files ready to be loaded
  131632. */
  131633. static readonly FilesToLoad: {
  131634. [key: string]: File;
  131635. };
  131636. /**
  131637. * Callback called when a file is processed
  131638. */
  131639. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  131640. private _engine;
  131641. private _currentScene;
  131642. private _sceneLoadedCallback;
  131643. private _progressCallback;
  131644. private _additionalRenderLoopLogicCallback;
  131645. private _textureLoadingCallback;
  131646. private _startingProcessingFilesCallback;
  131647. private _onReloadCallback;
  131648. private _errorCallback;
  131649. private _elementToMonitor;
  131650. private _sceneFileToLoad;
  131651. private _filesToLoad;
  131652. /**
  131653. * Creates a new FilesInput
  131654. * @param engine defines the rendering engine
  131655. * @param scene defines the hosting scene
  131656. * @param sceneLoadedCallback callback called when scene is loaded
  131657. * @param progressCallback callback called to track progress
  131658. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  131659. * @param textureLoadingCallback callback called when a texture is loading
  131660. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  131661. * @param onReloadCallback callback called when a reload is requested
  131662. * @param errorCallback callback call if an error occurs
  131663. */
  131664. 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);
  131665. private _dragEnterHandler;
  131666. private _dragOverHandler;
  131667. private _dropHandler;
  131668. /**
  131669. * Calls this function to listen to drag'n'drop events on a specific DOM element
  131670. * @param elementToMonitor defines the DOM element to track
  131671. */
  131672. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  131673. /**
  131674. * Release all associated resources
  131675. */
  131676. dispose(): void;
  131677. private renderFunction;
  131678. private drag;
  131679. private drop;
  131680. private _traverseFolder;
  131681. private _processFiles;
  131682. /**
  131683. * Load files from a drop event
  131684. * @param event defines the drop event to use as source
  131685. */
  131686. loadFiles(event: any): void;
  131687. private _processReload;
  131688. /**
  131689. * Reload the current scene from the loaded files
  131690. */
  131691. reload(): void;
  131692. }
  131693. }
  131694. declare module BABYLON {
  131695. /**
  131696. * Defines the root class used to create scene optimization to use with SceneOptimizer
  131697. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131698. */
  131699. export class SceneOptimization {
  131700. /**
  131701. * Defines the priority of this optimization (0 by default which means first in the list)
  131702. */
  131703. priority: number;
  131704. /**
  131705. * Gets a string describing the action executed by the current optimization
  131706. * @returns description string
  131707. */
  131708. getDescription(): string;
  131709. /**
  131710. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131711. * @param scene defines the current scene where to apply this optimization
  131712. * @param optimizer defines the current optimizer
  131713. * @returns true if everything that can be done was applied
  131714. */
  131715. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131716. /**
  131717. * Creates the SceneOptimization object
  131718. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131719. * @param desc defines the description associated with the optimization
  131720. */
  131721. constructor(
  131722. /**
  131723. * Defines the priority of this optimization (0 by default which means first in the list)
  131724. */
  131725. priority?: number);
  131726. }
  131727. /**
  131728. * Defines an optimization used to reduce the size of render target textures
  131729. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131730. */
  131731. export class TextureOptimization extends SceneOptimization {
  131732. /**
  131733. * Defines the priority of this optimization (0 by default which means first in the list)
  131734. */
  131735. priority: number;
  131736. /**
  131737. * 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
  131738. */
  131739. maximumSize: number;
  131740. /**
  131741. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131742. */
  131743. step: number;
  131744. /**
  131745. * Gets a string describing the action executed by the current optimization
  131746. * @returns description string
  131747. */
  131748. getDescription(): string;
  131749. /**
  131750. * Creates the TextureOptimization object
  131751. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131752. * @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
  131753. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131754. */
  131755. constructor(
  131756. /**
  131757. * Defines the priority of this optimization (0 by default which means first in the list)
  131758. */
  131759. priority?: number,
  131760. /**
  131761. * 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
  131762. */
  131763. maximumSize?: number,
  131764. /**
  131765. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131766. */
  131767. step?: number);
  131768. /**
  131769. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131770. * @param scene defines the current scene where to apply this optimization
  131771. * @param optimizer defines the current optimizer
  131772. * @returns true if everything that can be done was applied
  131773. */
  131774. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131775. }
  131776. /**
  131777. * Defines an optimization used to increase or decrease the rendering resolution
  131778. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131779. */
  131780. export class HardwareScalingOptimization extends SceneOptimization {
  131781. /**
  131782. * Defines the priority of this optimization (0 by default which means first in the list)
  131783. */
  131784. priority: number;
  131785. /**
  131786. * Defines the maximum scale to use (2 by default)
  131787. */
  131788. maximumScale: number;
  131789. /**
  131790. * Defines the step to use between two passes (0.5 by default)
  131791. */
  131792. step: number;
  131793. private _currentScale;
  131794. private _directionOffset;
  131795. /**
  131796. * Gets a string describing the action executed by the current optimization
  131797. * @return description string
  131798. */
  131799. getDescription(): string;
  131800. /**
  131801. * Creates the HardwareScalingOptimization object
  131802. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131803. * @param maximumScale defines the maximum scale to use (2 by default)
  131804. * @param step defines the step to use between two passes (0.5 by default)
  131805. */
  131806. constructor(
  131807. /**
  131808. * Defines the priority of this optimization (0 by default which means first in the list)
  131809. */
  131810. priority?: number,
  131811. /**
  131812. * Defines the maximum scale to use (2 by default)
  131813. */
  131814. maximumScale?: number,
  131815. /**
  131816. * Defines the step to use between two passes (0.5 by default)
  131817. */
  131818. step?: number);
  131819. /**
  131820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131821. * @param scene defines the current scene where to apply this optimization
  131822. * @param optimizer defines the current optimizer
  131823. * @returns true if everything that can be done was applied
  131824. */
  131825. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131826. }
  131827. /**
  131828. * Defines an optimization used to remove shadows
  131829. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131830. */
  131831. export class ShadowsOptimization extends SceneOptimization {
  131832. /**
  131833. * Gets a string describing the action executed by the current optimization
  131834. * @return description string
  131835. */
  131836. getDescription(): string;
  131837. /**
  131838. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131839. * @param scene defines the current scene where to apply this optimization
  131840. * @param optimizer defines the current optimizer
  131841. * @returns true if everything that can be done was applied
  131842. */
  131843. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131844. }
  131845. /**
  131846. * Defines an optimization used to turn post-processes off
  131847. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131848. */
  131849. export class PostProcessesOptimization extends SceneOptimization {
  131850. /**
  131851. * Gets a string describing the action executed by the current optimization
  131852. * @return description string
  131853. */
  131854. getDescription(): string;
  131855. /**
  131856. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131857. * @param scene defines the current scene where to apply this optimization
  131858. * @param optimizer defines the current optimizer
  131859. * @returns true if everything that can be done was applied
  131860. */
  131861. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131862. }
  131863. /**
  131864. * Defines an optimization used to turn lens flares off
  131865. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131866. */
  131867. export class LensFlaresOptimization extends SceneOptimization {
  131868. /**
  131869. * Gets a string describing the action executed by the current optimization
  131870. * @return description string
  131871. */
  131872. getDescription(): string;
  131873. /**
  131874. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131875. * @param scene defines the current scene where to apply this optimization
  131876. * @param optimizer defines the current optimizer
  131877. * @returns true if everything that can be done was applied
  131878. */
  131879. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131880. }
  131881. /**
  131882. * Defines an optimization based on user defined callback.
  131883. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131884. */
  131885. export class CustomOptimization extends SceneOptimization {
  131886. /**
  131887. * Callback called to apply the custom optimization.
  131888. */
  131889. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  131890. /**
  131891. * Callback called to get custom description
  131892. */
  131893. onGetDescription: () => string;
  131894. /**
  131895. * Gets a string describing the action executed by the current optimization
  131896. * @returns description string
  131897. */
  131898. getDescription(): string;
  131899. /**
  131900. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131901. * @param scene defines the current scene where to apply this optimization
  131902. * @param optimizer defines the current optimizer
  131903. * @returns true if everything that can be done was applied
  131904. */
  131905. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131906. }
  131907. /**
  131908. * Defines an optimization used to turn particles off
  131909. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131910. */
  131911. export class ParticlesOptimization extends SceneOptimization {
  131912. /**
  131913. * Gets a string describing the action executed by the current optimization
  131914. * @return description string
  131915. */
  131916. getDescription(): string;
  131917. /**
  131918. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131919. * @param scene defines the current scene where to apply this optimization
  131920. * @param optimizer defines the current optimizer
  131921. * @returns true if everything that can be done was applied
  131922. */
  131923. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131924. }
  131925. /**
  131926. * Defines an optimization used to turn render targets off
  131927. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131928. */
  131929. export class RenderTargetsOptimization extends SceneOptimization {
  131930. /**
  131931. * Gets a string describing the action executed by the current optimization
  131932. * @return description string
  131933. */
  131934. getDescription(): string;
  131935. /**
  131936. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131937. * @param scene defines the current scene where to apply this optimization
  131938. * @param optimizer defines the current optimizer
  131939. * @returns true if everything that can be done was applied
  131940. */
  131941. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131942. }
  131943. /**
  131944. * Defines an optimization used to merge meshes with compatible materials
  131945. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131946. */
  131947. export class MergeMeshesOptimization extends SceneOptimization {
  131948. private static _UpdateSelectionTree;
  131949. /**
  131950. * Gets or sets a boolean which defines if optimization octree has to be updated
  131951. */
  131952. /**
  131953. * Gets or sets a boolean which defines if optimization octree has to be updated
  131954. */
  131955. static UpdateSelectionTree: boolean;
  131956. /**
  131957. * Gets a string describing the action executed by the current optimization
  131958. * @return description string
  131959. */
  131960. getDescription(): string;
  131961. private _canBeMerged;
  131962. /**
  131963. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131964. * @param scene defines the current scene where to apply this optimization
  131965. * @param optimizer defines the current optimizer
  131966. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  131967. * @returns true if everything that can be done was applied
  131968. */
  131969. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  131970. }
  131971. /**
  131972. * Defines a list of options used by SceneOptimizer
  131973. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131974. */
  131975. export class SceneOptimizerOptions {
  131976. /**
  131977. * Defines the target frame rate to reach (60 by default)
  131978. */
  131979. targetFrameRate: number;
  131980. /**
  131981. * Defines the interval between two checkes (2000ms by default)
  131982. */
  131983. trackerDuration: number;
  131984. /**
  131985. * Gets the list of optimizations to apply
  131986. */
  131987. optimizations: SceneOptimization[];
  131988. /**
  131989. * Creates a new list of options used by SceneOptimizer
  131990. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  131991. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  131992. */
  131993. constructor(
  131994. /**
  131995. * Defines the target frame rate to reach (60 by default)
  131996. */
  131997. targetFrameRate?: number,
  131998. /**
  131999. * Defines the interval between two checkes (2000ms by default)
  132000. */
  132001. trackerDuration?: number);
  132002. /**
  132003. * Add a new optimization
  132004. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  132005. * @returns the current SceneOptimizerOptions
  132006. */
  132007. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  132008. /**
  132009. * Add a new custom optimization
  132010. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  132011. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  132012. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132013. * @returns the current SceneOptimizerOptions
  132014. */
  132015. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  132016. /**
  132017. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  132018. * @param targetFrameRate defines the target frame rate (60 by default)
  132019. * @returns a SceneOptimizerOptions object
  132020. */
  132021. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132022. /**
  132023. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  132024. * @param targetFrameRate defines the target frame rate (60 by default)
  132025. * @returns a SceneOptimizerOptions object
  132026. */
  132027. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132028. /**
  132029. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  132030. * @param targetFrameRate defines the target frame rate (60 by default)
  132031. * @returns a SceneOptimizerOptions object
  132032. */
  132033. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132034. }
  132035. /**
  132036. * Class used to run optimizations in order to reach a target frame rate
  132037. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132038. */
  132039. export class SceneOptimizer implements IDisposable {
  132040. private _isRunning;
  132041. private _options;
  132042. private _scene;
  132043. private _currentPriorityLevel;
  132044. private _targetFrameRate;
  132045. private _trackerDuration;
  132046. private _currentFrameRate;
  132047. private _sceneDisposeObserver;
  132048. private _improvementMode;
  132049. /**
  132050. * Defines an observable called when the optimizer reaches the target frame rate
  132051. */
  132052. onSuccessObservable: Observable<SceneOptimizer>;
  132053. /**
  132054. * Defines an observable called when the optimizer enables an optimization
  132055. */
  132056. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  132057. /**
  132058. * Defines an observable called when the optimizer is not able to reach the target frame rate
  132059. */
  132060. onFailureObservable: Observable<SceneOptimizer>;
  132061. /**
  132062. * Gets a boolean indicating if the optimizer is in improvement mode
  132063. */
  132064. readonly isInImprovementMode: boolean;
  132065. /**
  132066. * Gets the current priority level (0 at start)
  132067. */
  132068. readonly currentPriorityLevel: number;
  132069. /**
  132070. * Gets the current frame rate checked by the SceneOptimizer
  132071. */
  132072. readonly currentFrameRate: number;
  132073. /**
  132074. * Gets or sets the current target frame rate (60 by default)
  132075. */
  132076. /**
  132077. * Gets or sets the current target frame rate (60 by default)
  132078. */
  132079. targetFrameRate: number;
  132080. /**
  132081. * Gets or sets the current interval between two checks (every 2000ms by default)
  132082. */
  132083. /**
  132084. * Gets or sets the current interval between two checks (every 2000ms by default)
  132085. */
  132086. trackerDuration: number;
  132087. /**
  132088. * Gets the list of active optimizations
  132089. */
  132090. readonly optimizations: SceneOptimization[];
  132091. /**
  132092. * Creates a new SceneOptimizer
  132093. * @param scene defines the scene to work on
  132094. * @param options defines the options to use with the SceneOptimizer
  132095. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  132096. * @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)
  132097. */
  132098. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  132099. /**
  132100. * Stops the current optimizer
  132101. */
  132102. stop(): void;
  132103. /**
  132104. * Reset the optimizer to initial step (current priority level = 0)
  132105. */
  132106. reset(): void;
  132107. /**
  132108. * Start the optimizer. By default it will try to reach a specific framerate
  132109. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  132110. */
  132111. start(): void;
  132112. private _checkCurrentState;
  132113. /**
  132114. * Release all resources
  132115. */
  132116. dispose(): void;
  132117. /**
  132118. * Helper function to create a SceneOptimizer with one single line of code
  132119. * @param scene defines the scene to work on
  132120. * @param options defines the options to use with the SceneOptimizer
  132121. * @param onSuccess defines a callback to call on success
  132122. * @param onFailure defines a callback to call on failure
  132123. * @returns the new SceneOptimizer object
  132124. */
  132125. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  132126. }
  132127. }
  132128. declare module BABYLON {
  132129. /**
  132130. * Class used to serialize a scene into a string
  132131. */
  132132. export class SceneSerializer {
  132133. /**
  132134. * Clear cache used by a previous serialization
  132135. */
  132136. static ClearCache(): void;
  132137. /**
  132138. * Serialize a scene into a JSON compatible object
  132139. * @param scene defines the scene to serialize
  132140. * @returns a JSON compatible object
  132141. */
  132142. static Serialize(scene: Scene): any;
  132143. /**
  132144. * Serialize a mesh into a JSON compatible object
  132145. * @param toSerialize defines the mesh to serialize
  132146. * @param withParents defines if parents must be serialized as well
  132147. * @param withChildren defines if children must be serialized as well
  132148. * @returns a JSON compatible object
  132149. */
  132150. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  132151. }
  132152. }
  132153. declare module BABYLON {
  132154. /**
  132155. * Class used to host texture specific utilities
  132156. */
  132157. export class TextureTools {
  132158. /**
  132159. * Uses the GPU to create a copy texture rescaled at a given size
  132160. * @param texture Texture to copy from
  132161. * @param width defines the desired width
  132162. * @param height defines the desired height
  132163. * @param useBilinearMode defines if bilinear mode has to be used
  132164. * @return the generated texture
  132165. */
  132166. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  132167. }
  132168. }
  132169. declare module BABYLON {
  132170. /**
  132171. * This represents the different options available for the video capture.
  132172. */
  132173. export interface VideoRecorderOptions {
  132174. /** Defines the mime type of the video. */
  132175. mimeType: string;
  132176. /** Defines the FPS the video should be recorded at. */
  132177. fps: number;
  132178. /** Defines the chunk size for the recording data. */
  132179. recordChunckSize: number;
  132180. /** The audio tracks to attach to the recording. */
  132181. audioTracks?: MediaStreamTrack[];
  132182. }
  132183. /**
  132184. * This can help with recording videos from BabylonJS.
  132185. * This is based on the available WebRTC functionalities of the browser.
  132186. *
  132187. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  132188. */
  132189. export class VideoRecorder {
  132190. private static readonly _defaultOptions;
  132191. /**
  132192. * Returns whether or not the VideoRecorder is available in your browser.
  132193. * @param engine Defines the Babylon Engine.
  132194. * @returns true if supported otherwise false.
  132195. */
  132196. static IsSupported(engine: Engine): boolean;
  132197. private readonly _options;
  132198. private _canvas;
  132199. private _mediaRecorder;
  132200. private _recordedChunks;
  132201. private _fileName;
  132202. private _resolve;
  132203. private _reject;
  132204. /**
  132205. * True when a recording is already in progress.
  132206. */
  132207. readonly isRecording: boolean;
  132208. /**
  132209. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  132210. * @param engine Defines the BabylonJS Engine you wish to record.
  132211. * @param options Defines options that can be used to customize the capture.
  132212. */
  132213. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  132214. /**
  132215. * Stops the current recording before the default capture timeout passed in the startRecording function.
  132216. */
  132217. stopRecording(): void;
  132218. /**
  132219. * Starts recording the canvas for a max duration specified in parameters.
  132220. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  132221. * If null no automatic download will start and you can rely on the promise to get the data back.
  132222. * @param maxDuration Defines the maximum recording time in seconds.
  132223. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  132224. * @return A promise callback at the end of the recording with the video data in Blob.
  132225. */
  132226. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  132227. /**
  132228. * Releases internal resources used during the recording.
  132229. */
  132230. dispose(): void;
  132231. private _handleDataAvailable;
  132232. private _handleError;
  132233. private _handleStop;
  132234. }
  132235. }
  132236. declare module BABYLON {
  132237. /**
  132238. * Class containing a set of static utilities functions for screenshots
  132239. */
  132240. export class ScreenshotTools {
  132241. /**
  132242. * Captures a screenshot of the current rendering
  132243. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132244. * @param engine defines the rendering engine
  132245. * @param camera defines the source camera
  132246. * @param size This parameter can be set to a single number or to an object with the
  132247. * following (optional) properties: precision, width, height. If a single number is passed,
  132248. * it will be used for both width and height. If an object is passed, the screenshot size
  132249. * will be derived from the parameters. The precision property is a multiplier allowing
  132250. * rendering at a higher or lower resolution
  132251. * @param successCallback defines the callback receives a single parameter which contains the
  132252. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  132253. * src parameter of an <img> to display it
  132254. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  132255. * Check your browser for supported MIME types
  132256. */
  132257. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  132258. /**
  132259. * Captures a screenshot of the current rendering
  132260. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132261. * @param engine defines the rendering engine
  132262. * @param camera defines the source camera
  132263. * @param size This parameter can be set to a single number or to an object with the
  132264. * following (optional) properties: precision, width, height. If a single number is passed,
  132265. * it will be used for both width and height. If an object is passed, the screenshot size
  132266. * will be derived from the parameters. The precision property is a multiplier allowing
  132267. * rendering at a higher or lower resolution
  132268. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  132269. * Check your browser for supported MIME types
  132270. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  132271. * to the src parameter of an <img> to display it
  132272. */
  132273. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  132274. /**
  132275. * Generates an image screenshot from the specified camera.
  132276. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132277. * @param engine The engine to use for rendering
  132278. * @param camera The camera to use for rendering
  132279. * @param size This parameter can be set to a single number or to an object with the
  132280. * following (optional) properties: precision, width, height. If a single number is passed,
  132281. * it will be used for both width and height. If an object is passed, the screenshot size
  132282. * will be derived from the parameters. The precision property is a multiplier allowing
  132283. * rendering at a higher or lower resolution
  132284. * @param successCallback The callback receives a single parameter which contains the
  132285. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  132286. * src parameter of an <img> to display it
  132287. * @param mimeType The MIME type of the screenshot image (default: image/png).
  132288. * Check your browser for supported MIME types
  132289. * @param samples Texture samples (default: 1)
  132290. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  132291. * @param fileName A name for for the downloaded file.
  132292. */
  132293. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  132294. /**
  132295. * Generates an image screenshot from the specified camera.
  132296. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132297. * @param engine The engine to use for rendering
  132298. * @param camera The camera to use for rendering
  132299. * @param size This parameter can be set to a single number or to an object with the
  132300. * following (optional) properties: precision, width, height. If a single number is passed,
  132301. * it will be used for both width and height. If an object is passed, the screenshot size
  132302. * will be derived from the parameters. The precision property is a multiplier allowing
  132303. * rendering at a higher or lower resolution
  132304. * @param mimeType The MIME type of the screenshot image (default: image/png).
  132305. * Check your browser for supported MIME types
  132306. * @param samples Texture samples (default: 1)
  132307. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  132308. * @param fileName A name for for the downloaded file.
  132309. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  132310. * to the src parameter of an <img> to display it
  132311. */
  132312. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  132313. /**
  132314. * Gets height and width for screenshot size
  132315. * @private
  132316. */
  132317. private static _getScreenshotSize;
  132318. }
  132319. }
  132320. declare module BABYLON {
  132321. /**
  132322. * Interface for a data buffer
  132323. */
  132324. export interface IDataBuffer {
  132325. /**
  132326. * Reads bytes from the data buffer.
  132327. * @param byteOffset The byte offset to read
  132328. * @param byteLength The byte length to read
  132329. * @returns A promise that resolves when the bytes are read
  132330. */
  132331. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  132332. /**
  132333. * The byte length of the buffer.
  132334. */
  132335. readonly byteLength: number;
  132336. }
  132337. /**
  132338. * Utility class for reading from a data buffer
  132339. */
  132340. export class DataReader {
  132341. /**
  132342. * The data buffer associated with this data reader.
  132343. */
  132344. readonly buffer: IDataBuffer;
  132345. /**
  132346. * The current byte offset from the beginning of the data buffer.
  132347. */
  132348. byteOffset: number;
  132349. private _dataView;
  132350. private _dataByteOffset;
  132351. /**
  132352. * Constructor
  132353. * @param buffer The buffer to read
  132354. */
  132355. constructor(buffer: IDataBuffer);
  132356. /**
  132357. * Loads the given byte length.
  132358. * @param byteLength The byte length to load
  132359. * @returns A promise that resolves when the load is complete
  132360. */
  132361. loadAsync(byteLength: number): Promise<void>;
  132362. /**
  132363. * Read a unsigned 32-bit integer from the currently loaded data range.
  132364. * @returns The 32-bit integer read
  132365. */
  132366. readUint32(): number;
  132367. /**
  132368. * Read a byte array from the currently loaded data range.
  132369. * @param byteLength The byte length to read
  132370. * @returns The byte array read
  132371. */
  132372. readUint8Array(byteLength: number): Uint8Array;
  132373. /**
  132374. * Read a string from the currently loaded data range.
  132375. * @param byteLength The byte length to read
  132376. * @returns The string read
  132377. */
  132378. readString(byteLength: number): string;
  132379. /**
  132380. * Skips the given byte length the currently loaded data range.
  132381. * @param byteLength The byte length to skip
  132382. */
  132383. skipBytes(byteLength: number): void;
  132384. }
  132385. }
  132386. declare module BABYLON {
  132387. /**
  132388. * A cursor which tracks a point on a path
  132389. */
  132390. export class PathCursor {
  132391. private path;
  132392. /**
  132393. * Stores path cursor callbacks for when an onchange event is triggered
  132394. */
  132395. private _onchange;
  132396. /**
  132397. * The value of the path cursor
  132398. */
  132399. value: number;
  132400. /**
  132401. * The animation array of the path cursor
  132402. */
  132403. animations: Animation[];
  132404. /**
  132405. * Initializes the path cursor
  132406. * @param path The path to track
  132407. */
  132408. constructor(path: Path2);
  132409. /**
  132410. * Gets the cursor point on the path
  132411. * @returns A point on the path cursor at the cursor location
  132412. */
  132413. getPoint(): Vector3;
  132414. /**
  132415. * Moves the cursor ahead by the step amount
  132416. * @param step The amount to move the cursor forward
  132417. * @returns This path cursor
  132418. */
  132419. moveAhead(step?: number): PathCursor;
  132420. /**
  132421. * Moves the cursor behind by the step amount
  132422. * @param step The amount to move the cursor back
  132423. * @returns This path cursor
  132424. */
  132425. moveBack(step?: number): PathCursor;
  132426. /**
  132427. * Moves the cursor by the step amount
  132428. * If the step amount is greater than one, an exception is thrown
  132429. * @param step The amount to move the cursor
  132430. * @returns This path cursor
  132431. */
  132432. move(step: number): PathCursor;
  132433. /**
  132434. * Ensures that the value is limited between zero and one
  132435. * @returns This path cursor
  132436. */
  132437. private ensureLimits;
  132438. /**
  132439. * Runs onchange callbacks on change (used by the animation engine)
  132440. * @returns This path cursor
  132441. */
  132442. private raiseOnChange;
  132443. /**
  132444. * Executes a function on change
  132445. * @param f A path cursor onchange callback
  132446. * @returns This path cursor
  132447. */
  132448. onchange(f: (cursor: PathCursor) => void): PathCursor;
  132449. }
  132450. }
  132451. declare module BABYLON {
  132452. /** @hidden */
  132453. export var blurPixelShader: {
  132454. name: string;
  132455. shader: string;
  132456. };
  132457. }
  132458. declare module BABYLON {
  132459. /** @hidden */
  132460. export var pointCloudVertexDeclaration: {
  132461. name: string;
  132462. shader: string;
  132463. };
  132464. }
  132465. // Mixins
  132466. interface Window {
  132467. mozIndexedDB: IDBFactory;
  132468. webkitIndexedDB: IDBFactory;
  132469. msIndexedDB: IDBFactory;
  132470. webkitURL: typeof URL;
  132471. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  132472. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  132473. WebGLRenderingContext: WebGLRenderingContext;
  132474. MSGesture: MSGesture;
  132475. CANNON: any;
  132476. AudioContext: AudioContext;
  132477. webkitAudioContext: AudioContext;
  132478. PointerEvent: any;
  132479. Math: Math;
  132480. Uint8Array: Uint8ArrayConstructor;
  132481. Float32Array: Float32ArrayConstructor;
  132482. mozURL: typeof URL;
  132483. msURL: typeof URL;
  132484. VRFrameData: any; // WebVR, from specs 1.1
  132485. DracoDecoderModule: any;
  132486. setImmediate(handler: (...args: any[]) => void): number;
  132487. }
  132488. interface HTMLCanvasElement {
  132489. requestPointerLock(): void;
  132490. msRequestPointerLock?(): void;
  132491. mozRequestPointerLock?(): void;
  132492. webkitRequestPointerLock?(): void;
  132493. /** Track wether a record is in progress */
  132494. isRecording: boolean;
  132495. /** Capture Stream method defined by some browsers */
  132496. captureStream(fps?: number): MediaStream;
  132497. }
  132498. interface CanvasRenderingContext2D {
  132499. msImageSmoothingEnabled: boolean;
  132500. }
  132501. interface MouseEvent {
  132502. mozMovementX: number;
  132503. mozMovementY: number;
  132504. webkitMovementX: number;
  132505. webkitMovementY: number;
  132506. msMovementX: number;
  132507. msMovementY: number;
  132508. }
  132509. interface Navigator {
  132510. mozGetVRDevices: (any: any) => any;
  132511. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132512. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132513. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132514. webkitGetGamepads(): Gamepad[];
  132515. msGetGamepads(): Gamepad[];
  132516. webkitGamepads(): Gamepad[];
  132517. }
  132518. interface HTMLVideoElement {
  132519. mozSrcObject: any;
  132520. }
  132521. interface Math {
  132522. fround(x: number): number;
  132523. imul(a: number, b: number): number;
  132524. }
  132525. interface WebGLRenderingContext {
  132526. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  132527. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  132528. vertexAttribDivisor(index: number, divisor: number): void;
  132529. createVertexArray(): any;
  132530. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  132531. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  132532. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  132533. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  132534. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  132535. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  132536. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  132537. // Queries
  132538. createQuery(): WebGLQuery;
  132539. deleteQuery(query: WebGLQuery): void;
  132540. beginQuery(target: number, query: WebGLQuery): void;
  132541. endQuery(target: number): void;
  132542. getQueryParameter(query: WebGLQuery, pname: number): any;
  132543. getQuery(target: number, pname: number): any;
  132544. MAX_SAMPLES: number;
  132545. RGBA8: number;
  132546. READ_FRAMEBUFFER: number;
  132547. DRAW_FRAMEBUFFER: number;
  132548. UNIFORM_BUFFER: number;
  132549. HALF_FLOAT_OES: number;
  132550. RGBA16F: number;
  132551. RGBA32F: number;
  132552. R32F: number;
  132553. RG32F: number;
  132554. RGB32F: number;
  132555. R16F: number;
  132556. RG16F: number;
  132557. RGB16F: number;
  132558. RED: number;
  132559. RG: number;
  132560. R8: number;
  132561. RG8: number;
  132562. UNSIGNED_INT_24_8: number;
  132563. DEPTH24_STENCIL8: number;
  132564. MIN: number;
  132565. MAX: number;
  132566. /* Multiple Render Targets */
  132567. drawBuffers(buffers: number[]): void;
  132568. readBuffer(src: number): void;
  132569. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  132570. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  132571. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  132572. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  132573. // Occlusion Query
  132574. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  132575. ANY_SAMPLES_PASSED: number;
  132576. QUERY_RESULT_AVAILABLE: number;
  132577. QUERY_RESULT: number;
  132578. }
  132579. interface WebGLProgram {
  132580. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  132581. }
  132582. interface EXT_disjoint_timer_query {
  132583. QUERY_COUNTER_BITS_EXT: number;
  132584. TIME_ELAPSED_EXT: number;
  132585. TIMESTAMP_EXT: number;
  132586. GPU_DISJOINT_EXT: number;
  132587. QUERY_RESULT_EXT: number;
  132588. QUERY_RESULT_AVAILABLE_EXT: number;
  132589. queryCounterEXT(query: WebGLQuery, target: number): void;
  132590. createQueryEXT(): WebGLQuery;
  132591. beginQueryEXT(target: number, query: WebGLQuery): void;
  132592. endQueryEXT(target: number): void;
  132593. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  132594. deleteQueryEXT(query: WebGLQuery): void;
  132595. }
  132596. interface WebGLUniformLocation {
  132597. _currentState: any;
  132598. }
  132599. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  132600. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  132601. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  132602. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  132603. interface WebGLRenderingContext {
  132604. readonly RASTERIZER_DISCARD: number;
  132605. readonly DEPTH_COMPONENT24: number;
  132606. readonly TEXTURE_3D: number;
  132607. readonly TEXTURE_2D_ARRAY: number;
  132608. readonly TEXTURE_COMPARE_FUNC: number;
  132609. readonly TEXTURE_COMPARE_MODE: number;
  132610. readonly COMPARE_REF_TO_TEXTURE: number;
  132611. readonly TEXTURE_WRAP_R: number;
  132612. readonly HALF_FLOAT: number;
  132613. readonly RGB8: number;
  132614. readonly RED_INTEGER: number;
  132615. readonly RG_INTEGER: number;
  132616. readonly RGB_INTEGER: number;
  132617. readonly RGBA_INTEGER: number;
  132618. readonly R8_SNORM: number;
  132619. readonly RG8_SNORM: number;
  132620. readonly RGB8_SNORM: number;
  132621. readonly RGBA8_SNORM: number;
  132622. readonly R8I: number;
  132623. readonly RG8I: number;
  132624. readonly RGB8I: number;
  132625. readonly RGBA8I: number;
  132626. readonly R8UI: number;
  132627. readonly RG8UI: number;
  132628. readonly RGB8UI: number;
  132629. readonly RGBA8UI: number;
  132630. readonly R16I: number;
  132631. readonly RG16I: number;
  132632. readonly RGB16I: number;
  132633. readonly RGBA16I: number;
  132634. readonly R16UI: number;
  132635. readonly RG16UI: number;
  132636. readonly RGB16UI: number;
  132637. readonly RGBA16UI: number;
  132638. readonly R32I: number;
  132639. readonly RG32I: number;
  132640. readonly RGB32I: number;
  132641. readonly RGBA32I: number;
  132642. readonly R32UI: number;
  132643. readonly RG32UI: number;
  132644. readonly RGB32UI: number;
  132645. readonly RGBA32UI: number;
  132646. readonly RGB10_A2UI: number;
  132647. readonly R11F_G11F_B10F: number;
  132648. readonly RGB9_E5: number;
  132649. readonly RGB10_A2: number;
  132650. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  132651. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  132652. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  132653. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  132654. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  132655. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  132656. 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;
  132657. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  132658. readonly TRANSFORM_FEEDBACK: number;
  132659. readonly INTERLEAVED_ATTRIBS: number;
  132660. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  132661. createTransformFeedback(): WebGLTransformFeedback;
  132662. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  132663. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  132664. beginTransformFeedback(primitiveMode: number): void;
  132665. endTransformFeedback(): void;
  132666. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  132667. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132668. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132669. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132670. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  132671. }
  132672. interface ImageBitmap {
  132673. readonly width: number;
  132674. readonly height: number;
  132675. close(): void;
  132676. }
  132677. interface WebGLQuery extends WebGLObject {
  132678. }
  132679. declare var WebGLQuery: {
  132680. prototype: WebGLQuery;
  132681. new(): WebGLQuery;
  132682. };
  132683. interface WebGLSampler extends WebGLObject {
  132684. }
  132685. declare var WebGLSampler: {
  132686. prototype: WebGLSampler;
  132687. new(): WebGLSampler;
  132688. };
  132689. interface WebGLSync extends WebGLObject {
  132690. }
  132691. declare var WebGLSync: {
  132692. prototype: WebGLSync;
  132693. new(): WebGLSync;
  132694. };
  132695. interface WebGLTransformFeedback extends WebGLObject {
  132696. }
  132697. declare var WebGLTransformFeedback: {
  132698. prototype: WebGLTransformFeedback;
  132699. new(): WebGLTransformFeedback;
  132700. };
  132701. interface WebGLVertexArrayObject extends WebGLObject {
  132702. }
  132703. declare var WebGLVertexArrayObject: {
  132704. prototype: WebGLVertexArrayObject;
  132705. new(): WebGLVertexArrayObject;
  132706. };
  132707. // Type definitions for WebVR API
  132708. // Project: https://w3c.github.io/webvr/
  132709. // Definitions by: six a <https://github.com/lostfictions>
  132710. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  132711. interface VRDisplay extends EventTarget {
  132712. /**
  132713. * Dictionary of capabilities describing the VRDisplay.
  132714. */
  132715. readonly capabilities: VRDisplayCapabilities;
  132716. /**
  132717. * z-depth defining the far plane of the eye view frustum
  132718. * enables mapping of values in the render target depth
  132719. * attachment to scene coordinates. Initially set to 10000.0.
  132720. */
  132721. depthFar: number;
  132722. /**
  132723. * z-depth defining the near plane of the eye view frustum
  132724. * enables mapping of values in the render target depth
  132725. * attachment to scene coordinates. Initially set to 0.01.
  132726. */
  132727. depthNear: number;
  132728. /**
  132729. * An identifier for this distinct VRDisplay. Used as an
  132730. * association point in the Gamepad API.
  132731. */
  132732. readonly displayId: number;
  132733. /**
  132734. * A display name, a user-readable name identifying it.
  132735. */
  132736. readonly displayName: string;
  132737. readonly isConnected: boolean;
  132738. readonly isPresenting: boolean;
  132739. /**
  132740. * If this VRDisplay supports room-scale experiences, the optional
  132741. * stage attribute contains details on the room-scale parameters.
  132742. */
  132743. readonly stageParameters: VRStageParameters | null;
  132744. /**
  132745. * Passing the value returned by `requestAnimationFrame` to
  132746. * `cancelAnimationFrame` will unregister the callback.
  132747. * @param handle Define the hanle of the request to cancel
  132748. */
  132749. cancelAnimationFrame(handle: number): void;
  132750. /**
  132751. * Stops presenting to the VRDisplay.
  132752. * @returns a promise to know when it stopped
  132753. */
  132754. exitPresent(): Promise<void>;
  132755. /**
  132756. * Return the current VREyeParameters for the given eye.
  132757. * @param whichEye Define the eye we want the parameter for
  132758. * @returns the eye parameters
  132759. */
  132760. getEyeParameters(whichEye: string): VREyeParameters;
  132761. /**
  132762. * Populates the passed VRFrameData with the information required to render
  132763. * the current frame.
  132764. * @param frameData Define the data structure to populate
  132765. * @returns true if ok otherwise false
  132766. */
  132767. getFrameData(frameData: VRFrameData): boolean;
  132768. /**
  132769. * Get the layers currently being presented.
  132770. * @returns the list of VR layers
  132771. */
  132772. getLayers(): VRLayer[];
  132773. /**
  132774. * Return a VRPose containing the future predicted pose of the VRDisplay
  132775. * when the current frame will be presented. The value returned will not
  132776. * change until JavaScript has returned control to the browser.
  132777. *
  132778. * The VRPose will contain the position, orientation, velocity,
  132779. * and acceleration of each of these properties.
  132780. * @returns the pose object
  132781. */
  132782. getPose(): VRPose;
  132783. /**
  132784. * Return the current instantaneous pose of the VRDisplay, with no
  132785. * prediction applied.
  132786. * @returns the current instantaneous pose
  132787. */
  132788. getImmediatePose(): VRPose;
  132789. /**
  132790. * The callback passed to `requestAnimationFrame` will be called
  132791. * any time a new frame should be rendered. When the VRDisplay is
  132792. * presenting the callback will be called at the native refresh
  132793. * rate of the HMD. When not presenting this function acts
  132794. * identically to how window.requestAnimationFrame acts. Content should
  132795. * make no assumptions of frame rate or vsync behavior as the HMD runs
  132796. * asynchronously from other displays and at differing refresh rates.
  132797. * @param callback Define the eaction to run next frame
  132798. * @returns the request handle it
  132799. */
  132800. requestAnimationFrame(callback: FrameRequestCallback): number;
  132801. /**
  132802. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  132803. * Repeat calls while already presenting will update the VRLayers being displayed.
  132804. * @param layers Define the list of layer to present
  132805. * @returns a promise to know when the request has been fulfilled
  132806. */
  132807. requestPresent(layers: VRLayer[]): Promise<void>;
  132808. /**
  132809. * Reset the pose for this display, treating its current position and
  132810. * orientation as the "origin/zero" values. VRPose.position,
  132811. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  132812. * updated when calling resetPose(). This should be called in only
  132813. * sitting-space experiences.
  132814. */
  132815. resetPose(): void;
  132816. /**
  132817. * The VRLayer provided to the VRDisplay will be captured and presented
  132818. * in the HMD. Calling this function has the same effect on the source
  132819. * canvas as any other operation that uses its source image, and canvases
  132820. * created without preserveDrawingBuffer set to true will be cleared.
  132821. * @param pose Define the pose to submit
  132822. */
  132823. submitFrame(pose?: VRPose): void;
  132824. }
  132825. declare var VRDisplay: {
  132826. prototype: VRDisplay;
  132827. new(): VRDisplay;
  132828. };
  132829. interface VRLayer {
  132830. leftBounds?: number[] | Float32Array | null;
  132831. rightBounds?: number[] | Float32Array | null;
  132832. source?: HTMLCanvasElement | null;
  132833. }
  132834. interface VRDisplayCapabilities {
  132835. readonly canPresent: boolean;
  132836. readonly hasExternalDisplay: boolean;
  132837. readonly hasOrientation: boolean;
  132838. readonly hasPosition: boolean;
  132839. readonly maxLayers: number;
  132840. }
  132841. interface VREyeParameters {
  132842. /** @deprecated */
  132843. readonly fieldOfView: VRFieldOfView;
  132844. readonly offset: Float32Array;
  132845. readonly renderHeight: number;
  132846. readonly renderWidth: number;
  132847. }
  132848. interface VRFieldOfView {
  132849. readonly downDegrees: number;
  132850. readonly leftDegrees: number;
  132851. readonly rightDegrees: number;
  132852. readonly upDegrees: number;
  132853. }
  132854. interface VRFrameData {
  132855. readonly leftProjectionMatrix: Float32Array;
  132856. readonly leftViewMatrix: Float32Array;
  132857. readonly pose: VRPose;
  132858. readonly rightProjectionMatrix: Float32Array;
  132859. readonly rightViewMatrix: Float32Array;
  132860. readonly timestamp: number;
  132861. }
  132862. interface VRPose {
  132863. readonly angularAcceleration: Float32Array | null;
  132864. readonly angularVelocity: Float32Array | null;
  132865. readonly linearAcceleration: Float32Array | null;
  132866. readonly linearVelocity: Float32Array | null;
  132867. readonly orientation: Float32Array | null;
  132868. readonly position: Float32Array | null;
  132869. readonly timestamp: number;
  132870. }
  132871. interface VRStageParameters {
  132872. sittingToStandingTransform?: Float32Array;
  132873. sizeX?: number;
  132874. sizeY?: number;
  132875. }
  132876. interface Navigator {
  132877. getVRDisplays(): Promise<VRDisplay[]>;
  132878. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  132879. }
  132880. interface Window {
  132881. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  132882. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  132883. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  132884. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  132885. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  132886. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  132887. }
  132888. interface Gamepad {
  132889. readonly displayId: number;
  132890. }
  132891. type XRSessionMode =
  132892. | "inline"
  132893. | "immersive-vr"
  132894. | "immersive-ar";
  132895. type XRReferenceSpaceType =
  132896. | "viewer"
  132897. | "local"
  132898. | "local-floor"
  132899. | "bounded-floor"
  132900. | "unbounded";
  132901. type XREnvironmentBlendMode =
  132902. | "opaque"
  132903. | "additive"
  132904. | "alpha-blend";
  132905. type XRVisibilityState =
  132906. | "visible"
  132907. | "visible-blurred"
  132908. | "hidden";
  132909. type XRHandedness =
  132910. | "none"
  132911. | "left"
  132912. | "right";
  132913. type XRTargetRayMode =
  132914. | "gaze"
  132915. | "tracked-pointer"
  132916. | "screen";
  132917. type XREye =
  132918. | "none"
  132919. | "left"
  132920. | "right";
  132921. interface XRSpace extends EventTarget {
  132922. }
  132923. interface XRRenderState {
  132924. depthNear?: number;
  132925. depthFar?: number;
  132926. inlineVerticalFieldOfView?: number;
  132927. baseLayer?: XRWebGLLayer;
  132928. }
  132929. interface XRInputSource {
  132930. handedness: XRHandedness;
  132931. targetRayMode: XRTargetRayMode;
  132932. targetRaySpace: XRSpace;
  132933. gripSpace: XRSpace | undefined;
  132934. gamepad: Gamepad | undefined;
  132935. profiles: Array<string>;
  132936. }
  132937. interface XRSession {
  132938. addEventListener: Function;
  132939. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  132940. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  132941. requestAnimationFrame: Function;
  132942. end(): Promise<void>;
  132943. renderState: XRRenderState;
  132944. inputSources: Array<XRInputSource>;
  132945. }
  132946. interface XRReferenceSpace extends XRSpace {
  132947. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  132948. onreset: any;
  132949. }
  132950. interface XRFrame {
  132951. session: XRSession;
  132952. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  132953. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  132954. }
  132955. interface XRViewerPose extends XRPose {
  132956. views: Array<XRView>;
  132957. }
  132958. interface XRPose {
  132959. transform: XRRigidTransform;
  132960. emulatedPosition: boolean;
  132961. }
  132962. declare var XRWebGLLayer: {
  132963. prototype: XRWebGLLayer;
  132964. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  132965. };
  132966. interface XRWebGLLayer {
  132967. framebuffer: WebGLFramebuffer;
  132968. framebufferWidth: number;
  132969. framebufferHeight: number;
  132970. getViewport: Function;
  132971. }
  132972. interface XRRigidTransform {
  132973. position: DOMPointReadOnly;
  132974. orientation: DOMPointReadOnly;
  132975. matrix: Float32Array;
  132976. inverse: XRRigidTransform;
  132977. }
  132978. interface XRView {
  132979. eye: XREye;
  132980. projectionMatrix: Float32Array;
  132981. transform: XRRigidTransform;
  132982. }
  132983. interface XRInputSourceChangeEvent {
  132984. session: XRSession;
  132985. removed: Array<XRInputSource>;
  132986. added: Array<XRInputSource>;
  132987. }